新增:getByKey、updateByKey方法
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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<JSONObject> 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')")
|
||||
|
||||
@@ -57,4 +57,6 @@ public interface SettingService extends IService<Setting> {
|
||||
Config getConfig(Integer tenantId);
|
||||
|
||||
JSONObject getUploadConfig(Integer tenantId);
|
||||
|
||||
boolean updateByKey(Setting key);
|
||||
}
|
||||
|
||||
@@ -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<SettingMapper, Setting> 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<SettingMapper, Setting> impl
|
||||
return settingInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateByKey(Setting setting) {
|
||||
return update(setting, new QueryWrapper<Setting>().eq("setting_key", setting.getSettingKey()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user