diff --git a/src/main/java/com/gxwebsoft/common/core/security/SecurityConfig.java b/src/main/java/com/gxwebsoft/common/core/security/SecurityConfig.java index 4df0806..0626cd3 100644 --- a/src/main/java/com/gxwebsoft/common/core/security/SecurityConfig.java +++ b/src/main/java/com/gxwebsoft/common/core/security/SecurityConfig.java @@ -77,6 +77,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { "/api/system/tenant/saveByPhone", "/api/system/user-referee/getRefereeNum", "/api/system/user-referee/getRefereeNumByUidList", + "/api/system/setting/getByKey/**", + "/api/system/setting/updateByKey/**", "/lvQ4EoivKJ.txt" ) .permitAll() diff --git a/src/main/java/com/gxwebsoft/common/system/controller/SettingController.java b/src/main/java/com/gxwebsoft/common/system/controller/SettingController.java index 6084820..bab90dc 100644 --- a/src/main/java/com/gxwebsoft/common/system/controller/SettingController.java +++ b/src/main/java/com/gxwebsoft/common/system/controller/SettingController.java @@ -165,11 +165,28 @@ public class SettingController extends BaseController { return success(settingService.getData("setting")); } - @PreAuthorize("hasAuthority('sys:setting:list')") @ApiOperation("根据key查询系统设置") - @GetMapping("/{key}") + @GetMapping("/getByKey/{key}") public ApiResult getByKey(@PathVariable("key") String key) { - return success(settingService.getBySettingKey(key)); + final User loginUser = getLoginUser(); + if(loginUser != null){ + return success(settingService.getBySettingKey(key)); + } + return fail("请先登录", null); + } + + @ApiOperation("根据key更新系统设置") + @OperationLog + @PutMapping("/updateByKey") + public ApiResult updateByKey(@RequestBody Setting setting) { + final User loginUser = getLoginUser(); + if(loginUser == null){ + return fail("请先登录"); + } + if(!loginUser.getIsSuperAdmin()){ + return fail("权限不足"); + } + return success(settingService.updateByKey(setting)); } @PreAuthorize("hasAuthority('sys:setting:save')") diff --git a/src/main/java/com/gxwebsoft/common/system/service/SettingService.java b/src/main/java/com/gxwebsoft/common/system/service/SettingService.java index d18678f..c95253f 100644 --- a/src/main/java/com/gxwebsoft/common/system/service/SettingService.java +++ b/src/main/java/com/gxwebsoft/common/system/service/SettingService.java @@ -57,4 +57,6 @@ public interface SettingService extends IService { Config getConfig(Integer tenantId); JSONObject getUploadConfig(Integer tenantId); + + boolean updateByKey(Setting key); } diff --git a/src/main/java/com/gxwebsoft/common/system/service/impl/SettingServiceImpl.java b/src/main/java/com/gxwebsoft/common/system/service/impl/SettingServiceImpl.java index a428ec6..38a470e 100644 --- a/src/main/java/com/gxwebsoft/common/system/service/impl/SettingServiceImpl.java +++ b/src/main/java/com/gxwebsoft/common/system/service/impl/SettingServiceImpl.java @@ -4,9 +4,11 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gxwebsoft.common.core.config.ConfigProperties; import com.gxwebsoft.common.core.exception.BusinessException; +import com.gxwebsoft.common.core.utils.JSONUtil; import com.gxwebsoft.common.core.utils.RedisUtil; import com.gxwebsoft.common.core.web.PageParam; import com.gxwebsoft.common.core.web.PageResult; @@ -93,6 +95,7 @@ public class SettingServiceImpl extends ServiceImpl impl if ("printer".equals(key)) { throw new BusinessException("打印机未配置"); } + return new JSONObject(); } return JSON.parseObject(setting.getContent()); } @@ -176,4 +179,9 @@ public class SettingServiceImpl extends ServiceImpl impl return settingInfo; } + @Override + public boolean updateByKey(Setting setting) { + return update(setting, new QueryWrapper().eq("setting_key", setting.getSettingKey())); + } + }