1
0

feat: 合并代码

This commit is contained in:
TsMask
2023-10-26 09:33:51 +08:00
parent d63db9dd6c
commit 08a908c3f4
38 changed files with 780 additions and 203 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))
}

View File

@@ -132,6 +132,16 @@ func (s *SysUserController) Add(c *gin.Context) {
return
}
// 密码单独取,避免序列化输出
var bodyPassword struct {
Password string `json:"password" binding:"required"`
}
if err := c.ShouldBindBodyWith(&bodyPassword, binding.JSON); err != nil {
c.JSON(400, result.CodeMsg(400, "参数错误"))
return
}
body.Password = bodyPassword.Password
// 检查用户登录账号是否唯一
uniqueUserName := s.sysUserService.CheckUniqueUserName(body.UserName, "")
if !uniqueUserName {
@@ -246,6 +256,8 @@ func (s *SysUserController) Edit(c *gin.Context) {
body.UserName = "" // 忽略修改登录用户名称
body.Password = "" // 忽略修改密码
body.LoginIP = "" // 忽略登录IP
body.LoginDate = 0 // 忽略登录时间
body.UpdateBy = ctx.LoginUserToUserName(c)
rows := s.sysUserService.UpdateUserAndRolePost(body)
if rows > 0 {
@@ -310,12 +322,12 @@ func (s *SysUserController) ResetPwd(c *gin.Context) {
}
userName := ctx.LoginUserToUserName(c)
SysUserController := model.SysUser{
info := model.SysUser{
UserID: body.UserID,
Password: body.Password,
UpdateBy: userName,
}
rows := s.sysUserService.UpdateUser(SysUserController)
rows := s.sysUserService.UpdateUser(info)
if rows > 0 {
c.JSON(200, result.Ok(nil))
return
@@ -350,12 +362,12 @@ func (s *SysUserController) Status(c *gin.Context) {
}
userName := ctx.LoginUserToUserName(c)
SysUserController := model.SysUser{
info := model.SysUser{
UserID: body.UserID,
Status: body.Status,
UpdateBy: userName,
}
rows := s.sysUserService.UpdateUser(SysUserController)
rows := s.sysUserService.UpdateUser(info)
if rows > 0 {
c.JSON(200, result.Ok(nil))
return

View File

@@ -27,4 +27,7 @@ type ISysConfig interface {
// ResetConfigCache 重置参数缓存数据
ResetConfigCache()
// SelectConfigByKey 查询配置信息BY键
SelectConfigByKey(configKey string) model.SysConfig
}

View File

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

View File

@@ -19,6 +19,6 @@ type ISysLogLogin interface {
// CleanSysLogLogin 清空系统登录日志
CleanSysLogLogin() error
// NewSysLogLogin 生成系统登录日志
NewSysLogLogin(userName, status, msg string, ilobArgs ...string) string
// CreateSysLogLogin 创建系统登录日志
CreateSysLogLogin(userName, status, msg string, ilobArgs ...string) string
}

View File

@@ -41,8 +41,8 @@ func (s *SysLogLoginImpl) CleanSysLogLogin() error {
return s.sysLogLoginService.CleanSysLogLogin()
}
// NewSysLogLogin 生成系统登录日志
func (s *SysLogLoginImpl) NewSysLogLogin(userName, status, msg string, ilobArgs ...string) string {
// CreateSysLogLogin 创建系统登录日志
func (s *SysLogLoginImpl) CreateSysLogLogin(userName, status, msg string, ilobArgs ...string) string {
sysSysLogLogin := model.SysLogLogin{
IPAddr: ilobArgs[0],
LoginLocation: ilobArgs[1],

View File

@@ -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,
)
}
// 部门信息