feat: 参数配置修改配置参数
This commit is contained in:
@@ -218,3 +218,38 @@ func (s *SysConfigController) Export(c *gin.Context) {
|
||||
|
||||
c.FileAttachment(saveFilePath, fileName)
|
||||
}
|
||||
|
||||
// 参数配置修改配置参数
|
||||
//
|
||||
// PUT /changeConfigValue
|
||||
func (s *SysConfigController) ConfigValue(c *gin.Context) {
|
||||
var body struct {
|
||||
Key string `json:"key" binding:"required"`
|
||||
Value string `json:"value" binding:"required"`
|
||||
}
|
||||
if err := c.ShouldBindBodyWith(&body, binding.JSON); err != nil {
|
||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否存在
|
||||
info := s.sysConfigService.SelectConfigByKey(body.Key)
|
||||
if info.ConfigKey != body.Key {
|
||||
c.JSON(200, result.ErrMsg("无效 key"))
|
||||
return
|
||||
}
|
||||
|
||||
// 与旧值相等不变更
|
||||
if info.ConfigValue == body.Value {
|
||||
c.JSON(200, result.ErrMsg("变更状态与旧值相等!"))
|
||||
return
|
||||
}
|
||||
info.ConfigValue = body.Value
|
||||
info.UpdateBy = ctx.LoginUserToUserName(c)
|
||||
rows := s.sysConfigService.UpdateConfig(info)
|
||||
if rows > 0 {
|
||||
c.JSON(200, result.Ok(nil))
|
||||
return
|
||||
}
|
||||
c.JSON(200, result.Err(nil))
|
||||
}
|
||||
|
||||
@@ -27,4 +27,7 @@ type ISysConfig interface {
|
||||
|
||||
// ResetConfigCache 重置参数缓存数据
|
||||
ResetConfigCache()
|
||||
|
||||
// SelectConfigByKey 查询配置信息BY键
|
||||
SelectConfigByKey(configKey string) model.SysConfig
|
||||
}
|
||||
|
||||
@@ -155,3 +155,14 @@ func (r *SysConfigImpl) clearConfigCache(configKey string) bool {
|
||||
delOk, _ := redis.DelKeys("", keys)
|
||||
return delOk
|
||||
}
|
||||
|
||||
// SelectConfigByKey 查询配置信息BY键
|
||||
func (r *SysConfigImpl) SelectConfigByKey(configKey string) model.SysConfig {
|
||||
sysConf := r.sysConfigRepository.SelectConfigList(model.SysConfig{
|
||||
ConfigKey: configKey,
|
||||
})
|
||||
if len(sysConf) > 0 {
|
||||
return sysConf[0]
|
||||
}
|
||||
return model.SysConfig{}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,11 @@ func Setup(router *gin.Engine) {
|
||||
collectlogs.OperateLog(collectlogs.OptionNew("参数配置信息", collectlogs.BUSINESS_TYPE_EXPORT)),
|
||||
controller.NewSysConfig.Export,
|
||||
)
|
||||
sysConfigGroup.PUT("/changeValue",
|
||||
middleware.PreAuthorize(map[string][]string{"hasPerms": {"system:config:edit"}}),
|
||||
collectlogs.OperateLog(collectlogs.OptionNew("参数配置信息", collectlogs.BUSINESS_TYPE_UPDATE)),
|
||||
controller.NewSysConfig.ConfigValue,
|
||||
)
|
||||
}
|
||||
|
||||
// 部门信息
|
||||
|
||||
Reference in New Issue
Block a user