mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
systemconfig实体、接口命名修正
This commit is contained in:
+5
-5
@@ -7,8 +7,8 @@ import com.cf.imes.module.system.controller.admin.baseconfig.vo.ConfigPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.baseconfig.vo.ConfigRespVO;
|
||||
import com.cf.imes.module.system.controller.admin.baseconfig.vo.ConfigSaveReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.baseconfig.vo.ConfigUpdateStatusReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.baseconfig.ConfigDO;
|
||||
import com.cf.imes.module.system.service.config.ConfigService;
|
||||
import com.cf.imes.module.system.dal.dataobject.baseconfig.SystemConfigDO;
|
||||
import com.cf.imes.module.system.service.config.SystemConfigService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -37,13 +37,13 @@ import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||
@Validated
|
||||
public class ConfigController {
|
||||
@Resource
|
||||
private ConfigService baseConfigService;
|
||||
private SystemConfigService baseConfigService;
|
||||
|
||||
@GetMapping()
|
||||
@Operation(summary = "获得系统配置的分页列表")
|
||||
@PreAuthorize("@ss.hasPermission('baseconfig:query')")
|
||||
public CommonResult<PageResult<ConfigRespVO>> getBaseConfigPage(@Valid ConfigPageReqVO pageReqVO) {
|
||||
PageResult<ConfigDO> pageResult = baseConfigService.getBaseConfigPage(pageReqVO);
|
||||
PageResult<SystemConfigDO> pageResult = baseConfigService.getBaseConfigPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ConfigRespVO.class));
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ConfigController {
|
||||
@Operation(summary = "根据id查询系统配置")
|
||||
@PreAuthorize("@ss.hasPermission('baseconfig:query')")
|
||||
public CommonResult<ConfigRespVO> getBaseConfig(@PathVariable Long id) {
|
||||
ConfigDO baseConfig = baseConfigService.getBaseConfig(id);
|
||||
SystemConfigDO baseConfig = baseConfigService.getBaseConfig(id);
|
||||
return success(BeanUtils.toBean(baseConfig, ConfigRespVO.class));
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -21,15 +21,15 @@ import lombok.ToString;
|
||||
* @author Gqr
|
||||
* @since 2024/11/7 16:12
|
||||
*/
|
||||
@TableName(value = "config", autoResultMap = true)
|
||||
@KeySequence("config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@TableName(value = "system_config", autoResultMap = true)
|
||||
@KeySequence("system_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ConfigDO extends BaseDO {
|
||||
public class SystemConfigDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
package com.cf.imes.module.system.dal.mysql.config;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.module.system.controller.admin.baseconfig.vo.ConfigPageReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.baseconfig.ConfigDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 系统配置 Mapper
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/11/7 16:25
|
||||
*/
|
||||
@Mapper
|
||||
public interface ConfigMapper extends BaseMapperX<ConfigDO> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
default PageResult<ConfigDO> selectPage(ConfigPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ConfigDO>()
|
||||
.likeIfPresent(ConfigDO::getName, reqVO.getName())
|
||||
.eqIfPresent(ConfigDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(ConfigDO::getOrganId, OrganContextHolder.getOrganId())
|
||||
.select(ConfigDO::getId, ConfigDO::getName, ConfigDO::getStatus, ConfigDO::getType)
|
||||
.orderByAsc(ConfigDO::getId));
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.cf.imes.module.system.dal.mysql.config;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.module.system.controller.admin.baseconfig.vo.ConfigPageReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.baseconfig.SystemConfigDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 系统配置 Mapper
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/11/7 16:25
|
||||
*/
|
||||
@Mapper
|
||||
public interface SystemConfigMapper extends BaseMapperX<SystemConfigDO> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
default PageResult<SystemConfigDO> selectPage(ConfigPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<SystemConfigDO>()
|
||||
.likeIfPresent(SystemConfigDO::getName, reqVO.getName())
|
||||
.eqIfPresent(SystemConfigDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(SystemConfigDO::getOrganId, OrganContextHolder.getOrganId())
|
||||
.select(SystemConfigDO::getId, SystemConfigDO::getName, SystemConfigDO::getStatus, SystemConfigDO::getType)
|
||||
.orderByAsc(SystemConfigDO::getId));
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -4,7 +4,7 @@ import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.module.system.controller.admin.baseconfig.vo.ConfigPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.baseconfig.vo.ConfigSaveReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.baseconfig.vo.ConfigUpdateStatusReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.baseconfig.ConfigDO;
|
||||
import com.cf.imes.module.system.dal.dataobject.baseconfig.SystemConfigDO;
|
||||
|
||||
/**
|
||||
* 系统配置接口
|
||||
@@ -12,14 +12,14 @@ import com.cf.imes.module.system.dal.dataobject.baseconfig.ConfigDO;
|
||||
* @author Gqr
|
||||
* @since 2024/11/7 16:27
|
||||
*/
|
||||
public interface ConfigService {
|
||||
public interface SystemConfigService {
|
||||
/**
|
||||
* 分页查询系统配置管理列表
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
PageResult<ConfigDO> getBaseConfigPage(ConfigPageReqVO reqVO);
|
||||
PageResult<SystemConfigDO> getBaseConfigPage(ConfigPageReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 根据id查询基础配置
|
||||
@@ -27,7 +27,7 @@ public interface ConfigService {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
ConfigDO getBaseConfig(Long id);
|
||||
SystemConfigDO getBaseConfig(Long id);
|
||||
|
||||
/**
|
||||
* 新增/修改基础配置
|
||||
+21
-21
@@ -9,11 +9,11 @@ import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.module.system.controller.admin.baseconfig.vo.ConfigPageReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.baseconfig.vo.ConfigSaveReqVO;
|
||||
import com.cf.imes.module.system.controller.admin.baseconfig.vo.ConfigUpdateStatusReqVO;
|
||||
import com.cf.imes.module.system.dal.dataobject.baseconfig.ConfigDO;
|
||||
import com.cf.imes.module.system.dal.mysql.config.ConfigMapper;
|
||||
import com.cf.imes.module.system.dal.dataobject.baseconfig.SystemConfigDO;
|
||||
import com.cf.imes.module.system.dal.mysql.config.SystemConfigMapper;
|
||||
import com.cf.imes.module.system.enums.config.ConfigTypeEnum;
|
||||
import com.cf.imes.module.system.service.config.factory.ConfigServiceFactory;
|
||||
import com.cf.imes.module.system.service.config.factory.service.AbstractConfigGenerateService;
|
||||
import com.cf.imes.module.system.service.config.factory.SystemConfigServiceFactory;
|
||||
import com.cf.imes.module.system.service.config.factory.service.AbstractSystemConfigGenerateService;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -34,23 +34,23 @@ import static com.cf.imes.module.system.enums.ErrorCodeConstants.SYSTEM_CONFIG_N
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ConfigServiceImpl implements ConfigService {
|
||||
public class SystemConfigServiceImpl implements SystemConfigService {
|
||||
|
||||
@Resource
|
||||
private ConfigMapper baseConfigMapper;
|
||||
private SystemConfigMapper baseConfigMapper;
|
||||
|
||||
@Resource
|
||||
private ConfigServiceFactory configServiceFactory;
|
||||
private SystemConfigServiceFactory configServiceFactory;
|
||||
|
||||
@Override
|
||||
public PageResult<ConfigDO> getBaseConfigPage(ConfigPageReqVO reqVO) {
|
||||
PageResult<ConfigDO> configDOPageResult = baseConfigMapper.selectPage(reqVO);
|
||||
public PageResult<SystemConfigDO> getBaseConfigPage(ConfigPageReqVO reqVO) {
|
||||
PageResult<SystemConfigDO> configDOPageResult = baseConfigMapper.selectPage(reqVO);
|
||||
// todo 后续所有configTypeEnum中的类型需要上到列表补全时通过遍历enum来补充
|
||||
ConfigTypeEnum customBoardNoEnum = ConfigTypeEnum.CUSTOM_BOARD_NO;
|
||||
CopyOnWriteArrayList<ConfigDO> configDOS = Lists.newCopyOnWriteArrayList(configDOPageResult.getList());
|
||||
Optional<ConfigDO> configDOOptional = configDOS.stream().filter(c -> ObjectUtil.equal(customBoardNoEnum.getType(), c.getType())).findAny();
|
||||
CopyOnWriteArrayList<SystemConfigDO> configDOS = Lists.newCopyOnWriteArrayList(configDOPageResult.getList());
|
||||
Optional<SystemConfigDO> configDOOptional = configDOS.stream().filter(c -> ObjectUtil.equal(customBoardNoEnum.getType(), c.getType())).findAny();
|
||||
if (configDOOptional.isEmpty()) {
|
||||
configDOS.add(new ConfigDO().builder().id(null).name(customBoardNoEnum.getName()).type(customBoardNoEnum.getType()).build());
|
||||
configDOS.add(new SystemConfigDO().builder().id(null).name(customBoardNoEnum.getName()).type(customBoardNoEnum.getType()).build());
|
||||
configDOPageResult.setList(configDOS);
|
||||
configDOPageResult.setTotal(configDOPageResult.getTotal() + 1);
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public class ConfigServiceImpl implements ConfigService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigDO getBaseConfig(Long id) {
|
||||
public SystemConfigDO getBaseConfig(Long id) {
|
||||
return validateBaseConfigExists(id);
|
||||
}
|
||||
|
||||
@@ -66,20 +66,20 @@ public class ConfigServiceImpl implements ConfigService {
|
||||
public void modifyBaseConfig(ConfigSaveReqVO reqVO) {
|
||||
Long id = reqVO.getId();
|
||||
// 根据配置类型选择对应的service
|
||||
AbstractConfigGenerateService configService = configServiceFactory.getConfigService(reqVO.getType());
|
||||
AbstractSystemConfigGenerateService configService = configServiceFactory.getConfigService(reqVO.getType());
|
||||
// 校验规则
|
||||
configService.checkValid(reqVO.getSetting());
|
||||
// 系统配置保存前操作
|
||||
configService.beforeSaveConfig(reqVO);
|
||||
if (ObjectUtil.isNotNull(id)) {
|
||||
ConfigDO baseConfigDO = validateBaseConfigExists(id);
|
||||
SystemConfigDO baseConfigDO = validateBaseConfigExists(id);
|
||||
// 覆盖配置
|
||||
baseConfigDO.setSetting(reqVO.getSetting());
|
||||
// 更新
|
||||
baseConfigMapper.updateById(baseConfigDO);
|
||||
} else {
|
||||
// 新增
|
||||
baseConfigMapper.insert(BeanUtils.toBean(reqVO, ConfigDO.class));
|
||||
baseConfigMapper.insert(BeanUtils.toBean(reqVO, SystemConfigDO.class));
|
||||
}
|
||||
// 系统配置保存后操作
|
||||
configService.afterSaveConfig(reqVO);
|
||||
@@ -91,7 +91,7 @@ public class ConfigServiceImpl implements ConfigService {
|
||||
// 校验存在
|
||||
validateBaseConfigExists(id);
|
||||
// 更新状态
|
||||
baseConfigMapper.update(new LambdaUpdateWrapper<ConfigDO>().eq(ConfigDO::getId, id).set(ConfigDO::getStatus, reqVO.getStatus()));
|
||||
baseConfigMapper.update(new LambdaUpdateWrapper<SystemConfigDO>().eq(SystemConfigDO::getId, id).set(SystemConfigDO::getStatus, reqVO.getStatus()));
|
||||
}
|
||||
|
||||
|
||||
@@ -101,10 +101,10 @@ public class ConfigServiceImpl implements ConfigService {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
private ConfigDO validateBaseConfigExists(Long id) {
|
||||
ConfigDO baseConfigDO = baseConfigMapper.selectOne(new LambdaQueryWrapperX<ConfigDO>()
|
||||
.eq(ConfigDO::getId, id)
|
||||
.eq(ConfigDO::getOrganId, OrganContextHolder.getOrganId()));
|
||||
private SystemConfigDO validateBaseConfigExists(Long id) {
|
||||
SystemConfigDO baseConfigDO = baseConfigMapper.selectOne(new LambdaQueryWrapperX<SystemConfigDO>()
|
||||
.eq(SystemConfigDO::getId, id)
|
||||
.eq(SystemConfigDO::getOrganId, OrganContextHolder.getOrganId()));
|
||||
if (ObjectUtil.isNull(baseConfigDO)) {
|
||||
throw exception(SYSTEM_CONFIG_NOT_EXISTS);
|
||||
}
|
||||
+4
-4
@@ -2,7 +2,7 @@ package com.cf.imes.module.system.service.config.factory;
|
||||
|
||||
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
|
||||
import com.cf.imes.module.system.enums.config.ConfigTypeEnum;
|
||||
import com.cf.imes.module.system.service.config.factory.service.AbstractConfigGenerateService;
|
||||
import com.cf.imes.module.system.service.config.factory.service.AbstractSystemConfigGenerateService;
|
||||
import com.cf.imes.module.system.service.config.factory.service.impl.CustomBoardNoGenerateService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -18,11 +18,11 @@ import static com.cf.imes.module.system.enums.ErrorCodeConstants.SYSTEM_CONFIG_T
|
||||
* @since 2024/11/8 16:40
|
||||
*/
|
||||
@Component
|
||||
public class ConfigServiceFactory {
|
||||
public class SystemConfigServiceFactory {
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
@Autowired
|
||||
public ConfigServiceFactory(ApplicationContext applicationContext) {
|
||||
public SystemConfigServiceFactory(ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class ConfigServiceFactory {
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public AbstractConfigGenerateService getConfigService(int type) {
|
||||
public AbstractSystemConfigGenerateService getConfigService(int type) {
|
||||
switch (ConfigTypeEnum.fromType(type)) {
|
||||
case CUSTOM_BOARD_NO:
|
||||
return applicationContext.getBean(CustomBoardNoGenerateService.class);
|
||||
+1
-1
@@ -8,7 +8,7 @@ import com.cf.imes.module.system.controller.admin.baseconfig.vo.ConfigSaveReqVO;
|
||||
* @author Gqr
|
||||
* @since 2024/11/8 16:45
|
||||
*/
|
||||
public abstract class AbstractConfigGenerateService {
|
||||
public abstract class AbstractSystemConfigGenerateService {
|
||||
|
||||
/**
|
||||
* 校验配置的合法性
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.cf.imes.module.system.service.config.factory.service.impl;
|
||||
|
||||
import com.cf.imes.module.system.controller.admin.baseconfig.vo.ConfigSaveReqVO;
|
||||
import com.cf.imes.module.system.service.config.factory.service.AbstractConfigGenerateService;
|
||||
import com.cf.imes.module.system.service.config.factory.service.AbstractSystemConfigGenerateService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
@@ -11,7 +11,7 @@ import org.springframework.stereotype.Service;
|
||||
* @since 2024/11/8 16:48
|
||||
*/
|
||||
@Service("customBoardNoGenerateService")
|
||||
public class CustomBoardNoGenerateService extends AbstractConfigGenerateService {
|
||||
public class CustomBoardNoGenerateService extends AbstractSystemConfigGenerateService {
|
||||
|
||||
@Override
|
||||
public void checkValid(String setting) {
|
||||
|
||||
Reference in New Issue
Block a user