提交系统配置操作
This commit is contained in:
@@ -0,0 +1,65 @@
|
|||||||
|
package com.njcn.system.pojo.param;
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.constant.PatternRegex;
|
||||||
|
import com.njcn.web.constant.ValidMessage;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @version 1.0.0
|
||||||
|
* @author: chenchao
|
||||||
|
* @date: 2022/08/09 15:23
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ConfigParam {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统类型
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("系统类型:0-省级系统;1-企业系统;2-数据中心")
|
||||||
|
@NotNull(message = "系统类型不可为空")
|
||||||
|
@Max(value = 2)
|
||||||
|
@Min(value = 0)
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据上报
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("数据上报(以逗号分割,比如:冀北,网公司)默认为空")
|
||||||
|
private String dataReport;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审计日志大小
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("审计日志大小(MB)")
|
||||||
|
@NotNull(message = "审计日志大小不可为空")
|
||||||
|
private BigDecimal logSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审计日志大小
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("审计日志存储时间(1-6个月,默认3个月)")
|
||||||
|
private Integer logTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新操作实体
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public static class ConfigUpdateParam extends ConfigParam {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("配置Id")
|
||||||
|
@NotBlank(message = ValidMessage.ID_NOT_BLANK)
|
||||||
|
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = ValidMessage.ID_FORMAT_ERROR)
|
||||||
|
private String id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,25 +1,30 @@
|
|||||||
package com.njcn.system.controller;
|
package com.njcn.system.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
|
import com.njcn.common.pojo.constant.OperateType;
|
||||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.common.pojo.response.HttpResult;
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
import com.njcn.common.utils.HttpResultUtil;
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
import com.njcn.common.utils.LogUtil;
|
import com.njcn.common.utils.LogUtil;
|
||||||
|
import com.njcn.system.pojo.param.ConfigParam;
|
||||||
import com.njcn.system.pojo.po.Config;
|
import com.njcn.system.pojo.po.Config;
|
||||||
import com.njcn.system.service.IConfigService;
|
import com.njcn.system.service.IConfigService;
|
||||||
|
import com.njcn.web.controller.BaseController;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.njcn.web.controller.BaseController;
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,15 +45,29 @@ public class ConfigController extends BaseController {
|
|||||||
private final IConfigService iConfigService;
|
private final IConfigService iConfigService;
|
||||||
|
|
||||||
|
|
||||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@GetMapping("/getSysConfig")
|
@GetMapping("/getSysConfig")
|
||||||
@ApiOperation("获取系统配置")
|
@ApiOperation("获取系统配置列表")
|
||||||
public HttpResult<Config> getSysConfig() {
|
public HttpResult<List<Config>> getSysConfig() {
|
||||||
String methodDescribe = getMethodDescribe("getSysConfig");
|
String methodDescribe = getMethodDescribe("getSysConfig");
|
||||||
LogUtil.njcnDebug(log, "{}", methodDescribe, methodDescribe);
|
LogUtil.njcnDebug(log, "{}", methodDescribe, methodDescribe);
|
||||||
Config config = iConfigService.lambdaQuery()
|
List<Config> res = iConfigService.list(new QueryWrapper<Config>().eq("sys_config.State", DataStateEnum.ENABLE.getCode()));
|
||||||
.eq(Config::getState, DataStateEnum.ENABLE.getCode())
|
if (CollectionUtils.isEmpty(res)) {
|
||||||
.one();
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NO_DATA, null, methodDescribe);
|
||||||
|
} else {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@GetMapping("/getSysConfigById")
|
||||||
|
@ApiOperation("根据配置Id获取系统配置")
|
||||||
|
@ApiImplicitParam(name = "id", value = "参数id", required = true)
|
||||||
|
public HttpResult<Config> getSysConfigById(@RequestParam("id") String id) {
|
||||||
|
String methodDescribe = getMethodDescribe("getSysConfigById");
|
||||||
|
LogUtil.njcnDebug(log, "{}", methodDescribe, methodDescribe);
|
||||||
|
Config config = iConfigService.getById(id);
|
||||||
if (Objects.isNull(config)) {
|
if (Objects.isNull(config)) {
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NO_DATA, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NO_DATA, null, methodDescribe);
|
||||||
} else {
|
} else {
|
||||||
@@ -57,5 +76,53 @@ public class ConfigController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@GetMapping("/removeSysConfigById")
|
||||||
|
@ApiOperation("根据配置Id删除系统配置")
|
||||||
|
@ApiImplicitParam(name = "id", value = "参数id", required = true)
|
||||||
|
public HttpResult<Config> removeSysConfigById(@RequestParam("id") String id) {
|
||||||
|
String methodDescribe = getMethodDescribe("removeSysConfigById");
|
||||||
|
LogUtil.njcnDebug(log, "{}", methodDescribe, methodDescribe);
|
||||||
|
boolean res = iConfigService.removeById(id);
|
||||||
|
if (res) {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
} else {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.ID_NOT_EXIST, null, methodDescribe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||||
|
@PostMapping("/addSysConfig")
|
||||||
|
@ApiOperation("新增系统配置")
|
||||||
|
@ApiImplicitParam(name = "configParam", value = "新增配置实体", required = true)
|
||||||
|
public HttpResult addSysConfig(@RequestBody @Validated ConfigParam configParam) {
|
||||||
|
String methodDescribe = getMethodDescribe("addSysConfig");
|
||||||
|
boolean res = iConfigService.addSysConfig(configParam);
|
||||||
|
if (res) {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
} else {
|
||||||
|
throw new BusinessException(CommonResponseEnum.FAIL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
|
||||||
|
@PostMapping("/updateSysConfig")
|
||||||
|
@ApiOperation("修改系统配置")
|
||||||
|
@ApiImplicitParam(name = "configUpdateParam", value = "更新配置实体", required = true)
|
||||||
|
public HttpResult updateSysConfig(@RequestBody @Validated ConfigParam.ConfigUpdateParam configUpdateParam) {
|
||||||
|
String methodDescribe = getMethodDescribe("updateSysConfig");
|
||||||
|
boolean res = iConfigService.updateSysConfig(configUpdateParam);
|
||||||
|
if (res) {
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
} else {
|
||||||
|
throw new BusinessException(CommonResponseEnum.FAIL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.njcn.system.service;
|
package com.njcn.system.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.system.pojo.param.ConfigParam;
|
||||||
import com.njcn.system.pojo.po.Config;
|
import com.njcn.system.pojo.po.Config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13,4 +14,16 @@ import com.njcn.system.pojo.po.Config;
|
|||||||
*/
|
*/
|
||||||
public interface IConfigService extends IService<Config> {
|
public interface IConfigService extends IService<Config> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增系统配置
|
||||||
|
* @param configParam
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean addSysConfig(ConfigParam configParam);
|
||||||
|
/**
|
||||||
|
* 修改系统配置
|
||||||
|
* @param configUpdateParam
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean updateSysConfig(ConfigParam.ConfigUpdateParam configUpdateParam);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
package com.njcn.system.service.impl;
|
package com.njcn.system.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.njcn.system.mapper.ConfigMapper;
|
import com.njcn.system.mapper.ConfigMapper;
|
||||||
|
import com.njcn.system.pojo.param.ConfigParam;
|
||||||
import com.njcn.system.pojo.po.Config;
|
import com.njcn.system.pojo.po.Config;
|
||||||
import com.njcn.system.service.IConfigService;
|
import com.njcn.system.service.IConfigService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.njcn.web.utils.RequestUtil;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 服务实现类
|
* 服务实现类
|
||||||
@@ -17,4 +23,32 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> implements IConfigService {
|
public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> implements IConfigService {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addSysConfig(ConfigParam configParam) {
|
||||||
|
Config config = new Config();
|
||||||
|
BeanUtils.copyProperties(configParam, config);
|
||||||
|
config.setCreateBy(RequestUtil.getUserIndex());
|
||||||
|
config.setCreateTime(LocalDateTime.now());
|
||||||
|
config.setUpdateBy(RequestUtil.getUserIndex());
|
||||||
|
config.setUpdateTime(LocalDateTime.now());
|
||||||
|
this.baseMapper.insert(config);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateSysConfig(ConfigParam.ConfigUpdateParam configUpdateParam) {
|
||||||
|
Config config = this.baseMapper.selectById(configUpdateParam.getId());
|
||||||
|
if (!Objects.isNull(config)) {
|
||||||
|
BeanUtils.copyProperties(configUpdateParam, config);
|
||||||
|
config.setUpdateBy(RequestUtil.getUserIndex());
|
||||||
|
config.setUpdateTime(LocalDateTime.now());
|
||||||
|
this.baseMapper.updateById(config);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user