diff --git a/app/hdl/member_center/hdl_tag__management.go b/app/hdl/member_center/hdl_tag__management.go index 89bc7e1..f1d7878 100644 --- a/app/hdl/member_center/hdl_tag__management.go +++ b/app/hdl/member_center/hdl_tag__management.go @@ -7,6 +7,7 @@ import ( "applet/app/utils" "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + "errors" "github.com/gin-gonic/gin" "time" ) @@ -126,7 +127,7 @@ func UpdateTag(c *gin.Context) { Memo: req.Memo, } - forceColumns := []string{"tag_name", "memo", "is_punish"} + forceColumns := []string{"tag_name", "memo"} tagDb := implement.NewUserTagDb(db.Db) affected, err := tagDb.UserTagUpdate(tagID, tag, forceColumns...) @@ -160,7 +161,17 @@ func DeleteTag(c *gin.Context) { session := db.Db.NewSession() defer session.Close() - _, err := tagDb.UserTagDeleteBySession(session, req.TagID) + isUsed, err := recordsDb.UserTagRecordsIsUsedBySession(session, utils.StrToInt(req.TagID)) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + if isUsed { + e.OutErr(c, e.ERR, errors.New("该标签已被使用,无法删除").Error()) + return + } + + _, err = tagDb.UserTagDeleteBySession(session, req.TagID) if err != nil { session.Rollback() e.OutErr(c, e.ERR_DB_ORM, err.Error()) diff --git a/go.mod b/go.mod index 34c8776..94ffe78 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,7 @@ require ( ) require ( - code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241207095049-e0ad89412565 + code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241209061118-ae1be0db6a70 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_mq.git v0.0.5