|
|
@@ -133,16 +133,19 @@ func UserManagementUpdateUserInfo(engine *xorm.Engine, req *md.UserManagementUpd |
|
|
|
if err != nil { |
|
|
|
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{}{ |
|
|
|
"key": "id", |
|
|
|
"value": recordIds, |
|
|
|
"value": delTags, |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
return 0, err |
|
|
@@ -153,8 +156,7 @@ func UserManagementUpdateUserInfo(engine *xorm.Engine, req *md.UserManagementUpd |
|
|
|
if req.Tag != "" { |
|
|
|
newRecords := make([]*model.UserTagRecords, 0) |
|
|
|
now := time.Now() |
|
|
|
tags := strings.Split(req.Tag, ",") |
|
|
|
for _, tag := range tags { |
|
|
|
for _, tag := range addTags { |
|
|
|
newRecord := &model.UserTagRecords{ |
|
|
|
TagId: utils.StrToInt(tag), |
|
|
|
Uid: req.UID, |
|
|
|