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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user