fix(): 修复代码格式
parent
1af2baea05
commit
ad3dec352a
|
@ -31,11 +31,4 @@ public class SuperBasic<OC> implements Serializable {
|
||||||
*/
|
*/
|
||||||
private String serviceId;
|
private String serviceId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建空对象
|
|
||||||
* @return 空类型对象
|
|
||||||
*/
|
|
||||||
public static <OC> OC ofNull(){
|
|
||||||
return (OC) builder().build();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class BaseController {
|
||||||
/**
|
/**
|
||||||
* 返回成功
|
* 返回成功
|
||||||
*/
|
*/
|
||||||
public Result success () {
|
public Result<String> success () {
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.system.controller;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||||
import com.muyu.common.core.web.controller.BaseController;
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
import com.muyu.common.core.web.page.DataPageResp;
|
import com.muyu.common.core.web.page.DataPageResp;
|
||||||
|
@ -12,6 +13,7 @@ import com.muyu.common.security.annotation.RequiresPermissions;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.system.domain.SysConfig;
|
import com.muyu.system.domain.SysConfig;
|
||||||
import com.muyu.system.domain.model.SysConfigPageQueryModel;
|
import com.muyu.system.domain.model.SysConfigPageQueryModel;
|
||||||
|
import com.muyu.system.domain.rep.SysConfigAddReq;
|
||||||
import com.muyu.system.domain.rep.SysConfigListReq;
|
import com.muyu.system.domain.rep.SysConfigListReq;
|
||||||
import com.muyu.system.service.SysConfigService;
|
import com.muyu.system.service.SysConfigService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
@ -78,12 +80,11 @@ public class SysConfigController extends BaseController {
|
||||||
@RequiresPermissions("system:config:add")
|
@RequiresPermissions("system:config:add")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public Result add (@Validated @RequestBody SysConfig config) {
|
public Result add (@Validated @RequestBody SysConfigAddReq sysConfigAddReq) {
|
||||||
if (!configService.checkConfigKeyUnique(config)) {
|
if (!configService.checkConfigKeyUnique(sysConfigAddReq.getConfigKey())) {
|
||||||
return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
return error(StringUtils.format("新增参数「{}」失败,参数键名已存在",sysConfigAddReq.getConfigName()));
|
||||||
}
|
}
|
||||||
config.setCreateBy(SecurityUtils.getUsername());
|
return toAjax(configService.save(SysConfig.addReqBuild(sysConfigAddReq)));
|
||||||
return toAjax(configService.save(config));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,9 +92,9 @@ public class SysConfigController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("system:config:edit")
|
@RequiresPermissions("system:config:edit")
|
||||||
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping("/{sysConfigId}")
|
||||||
public Result edit (@Validated @RequestBody SysConfig config) {
|
public Result edit (@PathVariable("sysConfigId")Long sysConfigId, @Validated @RequestBody SysConfig config) {
|
||||||
if (!configService.checkConfigKeyUnique(config)) {
|
if (!configService.checkConfigKeyUnique(config.getConfigKey())) {
|
||||||
return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||||
}
|
}
|
||||||
config.setUpdateBy(SecurityUtils.getUsername());
|
config.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
|
|
@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.muyu.common.core.annotation.Excel;
|
import com.muyu.common.core.annotation.Excel;
|
||||||
import com.muyu.common.core.annotation.Excel.ColumnType;
|
import com.muyu.common.core.annotation.Excel.ColumnType;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
import com.muyu.system.domain.rep.SysConfigAddReq;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
@ -78,4 +80,19 @@ public class SysConfig extends BaseEntity {
|
||||||
return configValue;
|
return configValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过请求参数直接构建数据库
|
||||||
|
* @param addReq 请求对象
|
||||||
|
* @return 添加对象
|
||||||
|
*/
|
||||||
|
public static SysConfig addReqBuild(SysConfigAddReq addReq) {
|
||||||
|
return builder()
|
||||||
|
.configKey(addReq.getConfigKey())
|
||||||
|
.configName(addReq.getConfigName())
|
||||||
|
.configValue(addReq.getConfigValue())
|
||||||
|
.configType(addReq.getConfigType())
|
||||||
|
.remark(addReq.getRemark())
|
||||||
|
.createBy(SecurityUtils.getUsername())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,4 +56,12 @@ public class SysDeptPageQueryModel extends QueryModel<SysDeptPageQueryModel> {
|
||||||
.deptId(deptId)
|
.deptId(deptId)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建一个空对象
|
||||||
|
* @return 查询模型空对象
|
||||||
|
*/
|
||||||
|
public static SysDeptPageQueryModel ofNull() {
|
||||||
|
return new SysDeptPageQueryModel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.muyu.system.domain.rep;
|
||||||
|
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: 系统配置添加请求
|
||||||
|
* @author dongzeliang
|
||||||
|
* @date 2025/1/10 17:24
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class SysConfigAddReq {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数名称
|
||||||
|
*/
|
||||||
|
private String configName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数键名
|
||||||
|
*/
|
||||||
|
private String configKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数键值
|
||||||
|
*/
|
||||||
|
private String configValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统内置(Y是 N否)
|
||||||
|
*/
|
||||||
|
private String configType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.muyu.system.domain.rep;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author dongzeliang
|
||||||
|
* @version 1.0
|
||||||
|
* @description: 系统配置修改请求
|
||||||
|
* @date 2025/1/14 10:39
|
||||||
|
*/
|
||||||
|
public class SysConfigUpdReq {
|
||||||
|
}
|
|
@ -27,10 +27,10 @@ public interface SysConfigService extends IService<SysConfig> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检测参数是否唯一
|
* 检测参数是否唯一
|
||||||
* @param config
|
* @param configKey 配置唯一Key
|
||||||
* @return
|
* @return 重复:true 不重复:false
|
||||||
*/
|
*/
|
||||||
boolean checkConfigKeyUnique (SysConfig config);
|
boolean checkConfigKeyUnique (String configKey);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 刷新缓存
|
* 刷新缓存
|
||||||
|
|
|
@ -61,10 +61,10 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkConfigKeyUnique (SysConfig config) {
|
public boolean checkConfigKeyUnique (String configKey) {
|
||||||
LambdaQueryWrapper<SysConfig> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SysConfig> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(SysConfig::getConfigKey, config.getConfigKey());
|
queryWrapper.eq(SysConfig::getConfigKey, configKey);
|
||||||
return this.count(queryWrapper) > 0;
|
return this.count(queryWrapper) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue