@@ -95,7 +95,7 @@ type UserManagementUpdateUserInfoReq struct { | |||||
type TagNode struct { | type TagNode struct { | ||||
TagID int `json:"tag_id"` // 标签 ID | TagID int `json:"tag_id"` // 标签 ID | ||||
TagName string `json:"tag_name"` // 标签 名称 | |||||
TagName string `json:"tag_name"` // 标签名称 | |||||
} | } | ||||
type BasicInfoNode struct { | type BasicInfoNode struct { | ||||
@@ -179,3 +179,14 @@ type UserManagementGetVirtualCoinDetailResp struct { | |||||
List []VirtualCoinDetailNode `json:"list"` | List []VirtualCoinDetailNode `json:"list"` | ||||
Paginate Paginate `json:"paginate"` | Paginate Paginate `json:"paginate"` | ||||
} | } | ||||
type UserManagementAddTagReq struct { | |||||
Uid int64 `json:"uid"` // 用户 ID | |||||
TagId string `json:"tag_id"` // 标签 ID | |||||
Memo string `json:"memo"` // 标签备注 | |||||
} | |||||
type UserManagementDelTagReq struct { | |||||
Uid int64 `json:"uid"` // 用户 ID | |||||
TagId string `json:"tag_id"` // 标签 ID | |||||
} |
@@ -133,16 +133,19 @@ func UserManagementUpdateUserInfo(engine *xorm.Engine, req *md.UserManagementUpd | |||||
if err != nil { | if err != nil { | ||||
return 0, err | return 0, err | ||||
} | } | ||||
if records != nil { | |||||
recordIds := make([]int, 0) | |||||
for _, record := range *records { | |||||
recordIds = append(recordIds, record.Id) | |||||
} | |||||
// 删除所有用户的所有标签记录 | |||||
oldRecordIds := make([]string, 0) | |||||
for _, record := range *records { | |||||
oldRecordIds = append(oldRecordIds, utils.IntToStr(record.Id)) | |||||
} | |||||
newRecordIds := strings.Split(req.Tag, ",") | |||||
// 需要删除的标签 | |||||
delTags := utils.DiffArray(oldRecordIds, newRecordIds) | |||||
addTags := utils.DiffArray(newRecordIds, oldRecordIds) | |||||
if delTags != nil { | |||||
// 删除不需要的标签记录 | |||||
_, err := recordsDb.UserTagRecordsDeleteBySession(session, map[string]interface{}{ | _, err := recordsDb.UserTagRecordsDeleteBySession(session, map[string]interface{}{ | ||||
"key": "id", | "key": "id", | ||||
"value": recordIds, | |||||
"value": delTags, | |||||
}) | }) | ||||
if err != nil { | if err != nil { | ||||
return 0, err | return 0, err | ||||
@@ -153,8 +156,7 @@ func UserManagementUpdateUserInfo(engine *xorm.Engine, req *md.UserManagementUpd | |||||
if req.Tag != "" { | if req.Tag != "" { | ||||
newRecords := make([]*model.UserTagRecords, 0) | newRecords := make([]*model.UserTagRecords, 0) | ||||
now := time.Now() | now := time.Now() | ||||
tags := strings.Split(req.Tag, ",") | |||||
for _, tag := range tags { | |||||
for _, tag := range addTags { | |||||
newRecord := &model.UserTagRecords{ | newRecord := &model.UserTagRecords{ | ||||
TagId: utils.StrToInt(tag), | TagId: utils.StrToInt(tag), | ||||
Uid: req.UID, | Uid: req.UID, | ||||
@@ -33,7 +33,7 @@ require ( | |||||
) | ) | ||||
require ( | require ( | ||||
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241206115326-8cbc93c7c64d | |||||
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241207021144-5eb7d8513c6a | |||||
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241205075006-9c0bf995c788 | code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241205075006-9c0bf995c788 | ||||
code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be | code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be | ||||
code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5 | code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5 | ||||