浏览代码

Merge remote-tracking branch 'origin/master'

master
dengbiao 1 个月前
父节点
当前提交
3f592ce576
共有 4 个文件被更改,包括 183 次插入1 次删除
  1. +156
    -0
      app/hdl/institutional_management/module_setting/hdl_basic.go
  2. +20
    -0
      app/md/institutional_management/module_setting/md_basic.go
  3. +6
    -0
      app/router/router.go
  4. +1
    -1
      go.mod

+ 156
- 0
app/hdl/institutional_management/module_setting/hdl_basic.go 查看文件

@@ -0,0 +1,156 @@
package module_setting

import (
"applet/app/db"
"applet/app/e"
"applet/app/md/institutional_management/module_setting"
"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"
)

// ModuleSettingGet
// @Summary 制度中心-模块设置-个性化设置(获取)
// @Tags 模块设置
// @Description 个性化设置(获取)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param mod_name_value query string true "模块类型值"
// @Success 200 {object} md.ModuleSettingGetResp "具体数据"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/institutionalManagement/moduleSetting/getModuleSetting [GET]
func ModuleSettingGet(c *gin.Context) {
modNameValue := c.DefaultQuery("mod_name_value", "1")
modNameList := []map[string]interface{}{
{
"mod_name": "home_page",
"value": "1",
},
{
"mod_name": "member_center",
"value": "2",
},
{
"mod_name": "bottom_bar",
"value": "3",
},
{
"mod_name": "invitation_download_landing_page",
"value": "4",
},
{
"mod_name": "invitation_poster",
"value": "5",
},
}
modNameMap := map[string]string{
"1": "home_page",
"2": "member_center",
"3": "bottom_bar",
"4": "invitation_download_landing_page",
"5": "invitation_poster",
}
moduleStyleDb := implement.NewModuleStyleDb(db.Db)
var moduleStyle *model.ModuleStyle
var err error
moduleStyle, err = moduleStyleDb.ModuleStyleGetOneByParams(map[string]interface{}{
"key": "mod_name",
"value": modNameMap[modNameValue],
})

if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
var dataMap map[string]interface{}
if moduleStyle == nil {
now := time.Now()
m := model.ModuleStyle{
ModName: modNameMap[modNameValue],
Position: modNameMap[modNameValue],
SkipIdentifier: "",
Title: "主标题",
Subtitle: "子标题",
Data: utils.SerializeStr(dataMap),
CreateAt: now.Format("2006-01-02 15:04:05"),
}
_, err = moduleStyleDb.ModuleStyleInsert(&m)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
moduleStyle, err = moduleStyleDb.ModuleStyleGetOneByParams(map[string]interface{}{
"key": "mod_name",
"value": modNameMap[modNameValue],
})
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
}
utils.Unserialize([]byte(moduleStyle.Data), &dataMap)

resp := md.ModuleSettingGetResp{
ModNameList: modNameList,
ModName: moduleStyle.ModName,
Position: moduleStyle.Position,
SkipIdentifier: moduleStyle.SkipIdentifier,
Title: moduleStyle.Title,
Subtitle: moduleStyle.Subtitle,
Data: dataMap,
}

e.OutSuc(c, resp, nil)
}

// ModuleSettingUpdate
// @Summary 制度中心-模块设置-个性化设置(更新)
// @Tags 模块设置
// @Description 个性化设置(更新)
// @Accept json
// @Produce json
// @param Authorization header string true "验证参数Bearer和token空格拼接"
// @Param req body md.ModuleSettingUpdateReq true "模块类型值必填"
// @Success 200 {int} "修改数据条数"
// @Failure 400 {object} md.Response "具体错误"
// @Router /api/institutionalManagement/moduleSetting/updateModuleSetting [POST]
func ModuleSettingUpdate(c *gin.Context) {
var req *md.ModuleSettingUpdateReq
if err1 := c.ShouldBindJSON(&req); err1 != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error())
return
}

modNameMap := map[string]string{
"1": "home_page",
"2": "member_center",
"3": "bottom_bar",
"4": "invitation_download_landing_page",
"5": "invitation_poster",
}
moduleStyleDb := implement.NewModuleStyleDb(db.Db)
moduleStyle, err := moduleStyleDb.ModuleStyleGetOneByParams(map[string]interface{}{
"key": "mod_name",
"value": modNameMap[req.ModNameValue],
})
if moduleStyle == nil {
e.OutErr(c, e.ERR_NO_DATA, errors.New("不存在该页面"))
return
}
forceColumns := []string{"title", "subtitle", "data"}
moduleStyle.Title = req.Title
moduleStyle.Subtitle = req.Subtitle
moduleStyle.Position = req.Position
moduleStyle.Data = utils.SerializeStr(req.Data)

affected, err := moduleStyleDb.ModuleStyleUpdate(moduleStyle.ModId, moduleStyle, forceColumns...)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
e.OutSuc(c, affected, nil)
}

+ 20
- 0
app/md/institutional_management/module_setting/md_basic.go 查看文件

@@ -0,0 +1,20 @@
package md

type ModuleSettingGetResp struct {
ModNameList []map[string]interface{} `json:"mod_name_list"` // 模块名称对照
ModName string `json:"mod_name"` // 模块名称
Position string `json:"position"` // 位置
SkipIdentifier string `json:"skip_identifier"` // 跳转标识
Title string `json:"title"` // 标题
Subtitle string `json:"subtitle"` // 副标题
Data map[string]interface{} `json:"data"` // 内容
}

type ModuleSettingUpdateReq struct {
ModNameValue string `json:"mod_name_value,required"` // 模块类型值
Position string `json:"position"` // 位置
SkipIdentifier string `json:"skip_identifier"` // 跳转标识
Title string `json:"title"` // 标题
Subtitle string `json:"subtitle"` // 副标题
Data map[string]interface{} `json:"data"` // 内容
}

+ 6
- 0
app/router/router.go 查看文件

@@ -9,6 +9,7 @@ import (
"applet/app/hdl/financial_center"
"applet/app/hdl/im"
"applet/app/hdl/institutional_management/egg_energy"
"applet/app/hdl/institutional_management/module_setting"
"applet/app/hdl/institutional_management/public_platoon"
"applet/app/hdl/marketing_applications/new_user_red_package"
"applet/app/hdl/member_center"
@@ -196,6 +197,11 @@ func rInstitutionalManagement(r *gin.RouterGroup) { //制度管理
rContributionValue.POST("/updateBasic", egg_energy.UpdateContributionValueBasicSetting)
}
}
rModuleSetting := r.Group("/moduleSetting")
{
rModuleSetting.GET("/getModuleSetting", module_setting.ModuleSettingGet)
rModuleSetting.POST("/updateModuleSetting", module_setting.ModuleSettingUpdate)
}
}

func rMarketingApplications(r *gin.RouterGroup) { //营销应用


+ 1
- 1
go.mod 查看文件

@@ -33,7 +33,7 @@ require (
)

require (
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241126025500-fff8f11fcef5
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241126070618-9a7e2400a08f
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241125081706-0915be3f4144
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


正在加载...
取消
保存