From 0e8cf7840a071d0a8ad471c0d20f689d5db3f1bf Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Tue, 10 Dec 2024 18:24:55 +0800 Subject: [PATCH] update --- app/hdl/hdl_home_page.go | 12 ++++-- app/hdl/member_center/hdl_tag__management.go | 39 +++++++++++++++++--- app/md/member_center/md_tag_management.go | 7 ++-- docs/docs.go | 4 ++ docs/swagger.json | 4 ++ docs/swagger.yaml | 3 ++ go.mod | 2 +- 7 files changed, 57 insertions(+), 14 deletions(-) diff --git a/app/hdl/hdl_home_page.go b/app/hdl/hdl_home_page.go index 7bb653e..f80313d 100644 --- a/app/hdl/hdl_home_page.go +++ b/app/hdl/hdl_home_page.go @@ -146,7 +146,8 @@ func GetGrowData(c *gin.Context) { return } kind := req.Kind - + var yData []interface{} + var xData []interface{} now := time.Now() dataDb := implement.NewPlatformGrowDataDb(db.Db) m, has, err := dataDb.PlatformGrowDataGetLastOne() @@ -155,11 +156,14 @@ func GetGrowData(c *gin.Context) { return } if !has { - e.OutErr(c, e.ERR_NO_DATA, "未查询到数据") + resp := md.GetPriceCurveResp{ + XData: xData, + YData: yData, + } + e.OutSuc(c, resp, nil) return } - var yData []interface{} - var xData []interface{} + switch kind { case "1": // 日 diff --git a/app/hdl/member_center/hdl_tag__management.go b/app/hdl/member_center/hdl_tag__management.go index d05a0e8..b40b72c 100644 --- a/app/hdl/member_center/hdl_tag__management.go +++ b/app/hdl/member_center/hdl_tag__management.go @@ -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()) diff --git a/app/md/member_center/md_tag_management.go b/app/md/member_center/md_tag_management.go index 8a05c2b..fd6bc13 100644 --- a/app/md/member_center/md_tag_management.go +++ b/app/md/member_center/md_tag_management.go @@ -21,9 +21,10 @@ type AddTagReq struct { } type UpdateTagReq struct { - TagID string `json:"tag_id,required"` // 标签 ID - Name string `json:"name,required"` // 标签名称 - Memo string `json:"memo,required"` // 备注 + TagID string `json:"tag_id,required"` // 标签 ID + Name string `json:"name,required"` // 标签名称 + Memo string `json:"memo,required"` // 备注 + IsPunish string `json:"is_punish"` // 是否是惩罚标签 } type DeleteTagReq struct { diff --git a/docs/docs.go b/docs/docs.go index 791b423..a1f96bf 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -14267,6 +14267,10 @@ const docTemplate = `{ "md.UpdateTagReq": { "type": "object", "properties": { + "is_punish": { + "description": "是否是惩罚标签", + "type": "string" + }, "memo": { "description": "备注", "type": "string" diff --git a/docs/swagger.json b/docs/swagger.json index 0616b50..7a3e0b4 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -14260,6 +14260,10 @@ "md.UpdateTagReq": { "type": "object", "properties": { + "is_punish": { + "description": "是否是惩罚标签", + "type": "string" + }, "memo": { "description": "备注", "type": "string" diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 432ef6b..e56a533 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -3952,6 +3952,9 @@ definitions: type: object md.UpdateTagReq: properties: + is_punish: + description: 是否是惩罚标签 + type: string memo: description: 备注 type: string diff --git a/go.mod b/go.mod index 75c22fc..5cb737f 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,7 @@ require ( ) require ( - code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241209094543-8aafc254a593 + code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241210101917-218ac8890613 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