|
|
@@ -99,16 +99,43 @@ func UpdateTag(c *gin.Context) { |
|
|
|
return |
|
|
|
} |
|
|
|
tagID := utils.StrToInt(req.TagID) |
|
|
|
|
|
|
|
tagDb := implement.NewUserTagDb(db.Db) |
|
|
|
oldTag, err := tagDb.UserTagGetOneByParams(map[string]interface{}{"key": "id", "value": tagID}) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
if oldTag == nil { |
|
|
|
e.OutErr(c, e.ERR_NO_DATA, errors.New("标签不存在").Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
if req.IsPunish != "" && oldTag.IsPunish != utils.StrToInt(req.IsPunish) { |
|
|
|
// 标签在被使用情况下不允许修改是否为处罚标签 |
|
|
|
recordsDb := implement.NewUserTagRecordsDb(db.Db) |
|
|
|
exist, err := recordsDb.UserTagRecordsExist(0, tagID) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
if exist { |
|
|
|
e.OutErr(c, e.ERR, errors.New("该标签已被使用,无法修改是否为处罚标签").Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
tag := &model.UserTag{ |
|
|
|
Id: tagID, |
|
|
|
TagName: req.Name, |
|
|
|
Memo: req.Memo, |
|
|
|
Id: tagID, |
|
|
|
} |
|
|
|
|
|
|
|
forceColumns := []string{"tag_name", "memo"} |
|
|
|
if req.Name != "" { |
|
|
|
tag.TagName = req.Name |
|
|
|
} |
|
|
|
|
|
|
|
if req.Memo != "" { |
|
|
|
tag.Memo = req.Memo |
|
|
|
} |
|
|
|
|
|
|
|
forceColumns := []string{"tag_name", "memo", "is_punish"} |
|
|
|
|
|
|
|
tagDb := implement.NewUserTagDb(db.Db) |
|
|
|
affected, err := tagDb.UserTagUpdate(tagID, tag, forceColumns...) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|