feat 添加修改配置接口

This commit is contained in:
wenjianzhang
2021-05-27 19:33:41 +08:00
parent dc32d92755
commit d69b7807c1
4 changed files with 123 additions and 5 deletions
+67 -1
View File
@@ -87,7 +87,6 @@ func (e SysConfig) GetSysConfigBySysApp(c *gin.Context) {
e.OK(mp, "查询成功")
}
// GetSysConfig 获取配置管理
// @Summary 获取配置管理
// @Description 获取配置管理
@@ -180,6 +179,73 @@ func (e SysConfig) UpdateSysConfig(c *gin.Context) {
e.OK(control.GetId(), "更新成功")
}
// SetSysConfig 设置配置
// @Summary 设置配置
// @Description 界面操作设置配置值
// @Tags 配置管理
// @Accept application/json
// @Product application/json
// @Param data body []dto.SysConfigSetReq true "body"
// @Success 200 {object} response.Response "{"code": 200, "message": "修改成功"}"
// @Router /api/v1/set-config [put]
// @Security Bearer
func (e SysConfig) SetSysConfig(c *gin.Context) {
s := service.SysConfig{}
req := make([]dto.SysConfigSetReq, 0)
err := e.MakeContext(c).
MakeOrm().
Bind(&req).
MakeService(&s.Service).
Errors
if err != nil {
e.Logger.Error(err)
return
}
err = s.SetSysConfig(&req)
if err != nil {
e.Error(http.StatusUnprocessableEntity, err, "更新失败")
e.Logger.Errorf("Orm获取失败, error:%s", err)
return
}
e.OK("", "更新成功")
}
func (e SysConfig) GetSetSysConfig(c *gin.Context) {
s := service.SysConfig{}
err := e.MakeContext(c).
MakeOrm().
MakeService(&s.Service).
Errors
if err != nil {
e.Logger.Error(err)
return
}
d := make([]dto.SysConfigSetReq, 0)
err = s.GetSetSysConfig(&d)
if err != nil {
e.Logger.Errorf("GetSetSysConfig 查询失败, error:%s", err)
e.Error(500, err, "查询失败")
return
}
m := make(map[string]interface{}, 0)
for _, req := range d {
if req.ConfigKey == "sys_app_logo" {
mp := make(map[string]interface{}, 0)
mp["url"] = req.ConfigValue
l := make([]map[string]interface{}, 0)
l = append(l, mp)
m[req.ConfigKey] = l
} else {
m[req.ConfigKey] = req.ConfigValue
}
}
e.OK(m, "查询成功")
}
// DeleteSysConfig 删除配置管理
// @Summary 删除配置管理
// @Description 删除配置管理