feat: 参数配置修改配置参数

This commit is contained in:
TsMask
2023-10-25 17:04:40 +08:00
parent 2ac4bea8ba
commit 633878f05a
4 changed files with 54 additions and 0 deletions

View File

@@ -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))
}