|
@@ -7,6 +7,7 @@ import ( |
|
|
"applet/app/utils" |
|
|
"applet/app/utils" |
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement" |
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement" |
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" |
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" |
|
|
|
|
|
"errors" |
|
|
"github.com/gin-gonic/gin" |
|
|
"github.com/gin-gonic/gin" |
|
|
"time" |
|
|
"time" |
|
|
) |
|
|
) |
|
@@ -126,7 +127,7 @@ func UpdateTag(c *gin.Context) { |
|
|
Memo: req.Memo, |
|
|
Memo: req.Memo, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
forceColumns := []string{"tag_name", "memo", "is_punish"} |
|
|
|
|
|
|
|
|
forceColumns := []string{"tag_name", "memo"} |
|
|
|
|
|
|
|
|
tagDb := implement.NewUserTagDb(db.Db) |
|
|
tagDb := implement.NewUserTagDb(db.Db) |
|
|
affected, err := tagDb.UserTagUpdate(tagID, tag, forceColumns...) |
|
|
affected, err := tagDb.UserTagUpdate(tagID, tag, forceColumns...) |
|
@@ -160,7 +161,17 @@ func DeleteTag(c *gin.Context) { |
|
|
session := db.Db.NewSession() |
|
|
session := db.Db.NewSession() |
|
|
defer session.Close() |
|
|
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 { |
|
|
if err != nil { |
|
|
session.Rollback() |
|
|
session.Rollback() |
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|