mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-20 22:15:07 +08:00
1. 优化 config 模板
This commit is contained in:
@ -3,7 +3,6 @@ package cn.iocoder.dashboard.modules.infra.controller.config;
|
||||
import cn.iocoder.dashboard.common.pojo.CommonResult;
|
||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||
import cn.iocoder.dashboard.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.dashboard.framework.idempotent.core.annotation.Idempotent;
|
||||
import cn.iocoder.dashboard.framework.logger.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.dashboard.modules.infra.controller.config.vo.*;
|
||||
import cn.iocoder.dashboard.modules.infra.convert.config.InfConfigConvert;
|
||||
@ -19,7 +18,6 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@ -44,18 +42,17 @@ public class InfConfigController {
|
||||
return success(configService.createConfig(reqVO));
|
||||
}
|
||||
|
||||
@ApiOperation("修改参数配置")
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("修改参数配置")
|
||||
@PreAuthorize("@ss.hasPermission('infra:config:update')")
|
||||
@Idempotent(timeout = 60)
|
||||
public CommonResult<Boolean> updateConfig(@Valid @RequestBody InfConfigUpdateReqVO reqVO) {
|
||||
configService.updateConfig(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@ApiOperation("删除参数配置")
|
||||
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
|
||||
@DeleteMapping("/delete")
|
||||
@PreAuthorize("@ss.hasPermission('infra:config:delete')")
|
||||
public CommonResult<Boolean> deleteConfig(@RequestParam("id") Long id) {
|
||||
configService.deleteConfig(id);
|
||||
@ -70,9 +67,9 @@ public class InfConfigController {
|
||||
return success(InfConfigConvert.INSTANCE.convert(configService.getConfig(id)));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/get-value-by-key")
|
||||
@ApiOperation(value = "根据参数键名查询参数值", notes = "敏感配置,不允许返回给前端")
|
||||
@ApiImplicitParam(name = "key", value = "参数键", required = true, example = "yunai.biz.username", dataTypeClass = String.class)
|
||||
@GetMapping(value = "/get-value-by-key")
|
||||
public CommonResult<String> getConfigKey(@RequestParam("key") String key) {
|
||||
InfConfigDO config = configService.getConfigByKey(key);
|
||||
if (config == null) {
|
||||
|
@ -14,20 +14,21 @@ import java.util.List;
|
||||
@Mapper
|
||||
public interface InfConfigMapper extends BaseMapperX<InfConfigDO> {
|
||||
|
||||
default PageResult<InfConfigDO> selectPage(InfConfigPageReqVO reqVO) {
|
||||
return selectPage(reqVO,
|
||||
new QueryWrapperX<InfConfigDO>().likeIfPresent("name", reqVO.getName())
|
||||
.likeIfPresent("`key`", reqVO.getKey())
|
||||
.eqIfPresent("`type`", reqVO.getType())
|
||||
.betweenIfPresent("create_time", reqVO.getBeginTime(), reqVO.getEndTime()));
|
||||
}
|
||||
|
||||
default InfConfigDO selectByKey(String key) {
|
||||
return selectOne(new QueryWrapper<InfConfigDO>().eq("`key`", key));
|
||||
}
|
||||
|
||||
default PageResult<InfConfigDO> selectPage(InfConfigPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new QueryWrapperX<InfConfigDO>()
|
||||
.likeIfPresent("name", reqVO.getName())
|
||||
.likeIfPresent("`key`", reqVO.getKey())
|
||||
.eqIfPresent("`type`", reqVO.getType())
|
||||
.betweenIfPresent("create_time", reqVO.getBeginTime(), reqVO.getEndTime()));
|
||||
}
|
||||
|
||||
default List<InfConfigDO> selectList(InfConfigExportReqVO reqVO) {
|
||||
return selectList(new QueryWrapperX<InfConfigDO>().likeIfPresent("name", reqVO.getName())
|
||||
return selectList(new QueryWrapperX<InfConfigDO>()
|
||||
.likeIfPresent("name", reqVO.getName())
|
||||
.likeIfPresent("`key`", reqVO.getKey())
|
||||
.eqIfPresent("`type`", reqVO.getType())
|
||||
.betweenIfPresent("create_time", reqVO.getBeginTime(), reqVO.getEndTime()));
|
||||
|
@ -7,6 +7,7 @@ import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigPageReqV
|
||||
import cn.iocoder.dashboard.modules.infra.controller.config.vo.InfConfigUpdateReqVO;
|
||||
import cn.iocoder.dashboard.modules.infra.dal.dataobject.config.InfConfigDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -17,20 +18,26 @@ import java.util.List;
|
||||
public interface InfConfigService {
|
||||
|
||||
/**
|
||||
* 获得参数配置分页列表
|
||||
* 创建参数配置
|
||||
*
|
||||
* @param reqVO 分页条件
|
||||
* @return 分页列表
|
||||
* @param reqVO 创建信息
|
||||
* @return 配置编号
|
||||
*/
|
||||
PageResult<InfConfigDO> getConfigPage(InfConfigPageReqVO reqVO);
|
||||
Long createConfig(@Valid InfConfigCreateReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 获得参数配置列表
|
||||
* 更新参数配置
|
||||
*
|
||||
* @param reqVO 列表
|
||||
* @return 列表
|
||||
* @param reqVO 更新信息
|
||||
*/
|
||||
List<InfConfigDO> getConfigList(InfConfigExportReqVO reqVO);
|
||||
void updateConfig(@Valid InfConfigUpdateReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 删除参数配置
|
||||
*
|
||||
* @param id 配置编号
|
||||
*/
|
||||
void deleteConfig(Long id);
|
||||
|
||||
/**
|
||||
* 获得参数配置
|
||||
@ -49,25 +56,20 @@ public interface InfConfigService {
|
||||
InfConfigDO getConfigByKey(String key);
|
||||
|
||||
/**
|
||||
* 创建参数配置
|
||||
* 获得参数配置分页列表
|
||||
*
|
||||
* @param reqVO 创建信息
|
||||
* @return 配置编号
|
||||
* @param reqVO 分页条件
|
||||
* @return 分页列表
|
||||
*/
|
||||
Long createConfig(InfConfigCreateReqVO reqVO);
|
||||
PageResult<InfConfigDO> getConfigPage(@Valid InfConfigPageReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 更新参数配置
|
||||
* 获得参数配置列表
|
||||
*
|
||||
* @param reqVO 更新信息
|
||||
* @param reqVO 列表
|
||||
* @return 列表
|
||||
*/
|
||||
void updateConfig(InfConfigUpdateReqVO reqVO);
|
||||
List<InfConfigDO> getConfigList(@Valid InfConfigExportReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 删除参数配置
|
||||
*
|
||||
* @param id 配置编号
|
||||
*/
|
||||
void deleteConfig(Long id);
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import cn.iocoder.dashboard.modules.infra.service.config.InfConfigService;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@ -27,6 +28,7 @@ import static cn.iocoder.dashboard.modules.infra.enums.InfErrorCodeConstants.*;
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@Validated
|
||||
public class InfConfigServiceImpl implements InfConfigService {
|
||||
|
||||
@Resource
|
||||
@ -35,26 +37,6 @@ public class InfConfigServiceImpl implements InfConfigService {
|
||||
@Resource
|
||||
private InfConfigProducer configProducer;
|
||||
|
||||
@Override
|
||||
public PageResult<InfConfigDO> getConfigPage(InfConfigPageReqVO reqVO) {
|
||||
return configMapper.selectPage(reqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InfConfigDO> getConfigList(InfConfigExportReqVO reqVO) {
|
||||
return configMapper.selectList(reqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InfConfigDO getConfig(Long id) {
|
||||
return configMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InfConfigDO getConfigByKey(String key) {
|
||||
return configMapper.selectByKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long createConfig(InfConfigCreateReqVO reqVO) {
|
||||
// 校验正确性
|
||||
@ -93,6 +75,26 @@ public class InfConfigServiceImpl implements InfConfigService {
|
||||
configProducer.sendConfigRefreshMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InfConfigDO getConfig(Long id) {
|
||||
return configMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InfConfigDO getConfigByKey(String key) {
|
||||
return configMapper.selectByKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<InfConfigDO> getConfigPage(InfConfigPageReqVO reqVO) {
|
||||
return configMapper.selectPage(reqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<InfConfigDO> getConfigList(InfConfigExportReqVO reqVO) {
|
||||
return configMapper.selectList(reqVO);
|
||||
}
|
||||
|
||||
private void checkCreateOrUpdate(Long id, String key) {
|
||||
// 校验自己存在
|
||||
checkConfigExists(id);
|
||||
|
Reference in New Issue
Block a user