datas = ConfigConvert.INSTANCE.convertList(list);
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/codegen/CodegenColumnDO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/codegen/CodegenColumnDO.java
index f1990f3fc..368162214 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/codegen/CodegenColumnDO.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/codegen/CodegenColumnDO.java
@@ -39,27 +39,38 @@ public class CodegenColumnDO extends BaseDO {
/**
* 字段名
+ *
+ * 关联 {@link TableField#getName()}
*/
private String columnName;
/**
* 数据库字段类型
+ *
* 关联 {@link TableField.MetaInfo#getJdbcType()}
*/
private String dataType;
/**
* 字段描述
+ *
+ * 关联 {@link TableField#getComment()}
*/
private String columnComment;
/**
* 是否允许为空
+ *
+ * 关联 {@link TableField.MetaInfo#isNullable()}
*/
private Boolean nullable;
/**
* 是否主键
+ *
+ * 关联 {@link TableField#isKeyFlag()}
*/
private Boolean primaryKey;
/**
* 是否自增
+ *
+ * 关联 {@link TableField#isKeyIdentityFlag()}
*/
private Boolean autoIncrement;
/**
@@ -71,12 +82,16 @@ public class CodegenColumnDO extends BaseDO {
/**
* Java 属性类型
- *
+ *
* 例如说 String、Boolean 等等
+ *
+ * 关联 {@link TableField#getColumnType()}
*/
private String javaType;
/**
* Java 属性名
+ *
+ * 关联 {@link TableField#getPropertyName()}
*/
private String javaField;
/**
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/codegen/CodegenTableDO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/codegen/CodegenTableDO.java
index b821d210c..4f4a644a7 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/codegen/CodegenTableDO.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/codegen/CodegenTableDO.java
@@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.infra.enums.codegen.CodegenSceneEnum;
import cn.iocoder.yudao.module.infra.enums.codegen.CodegenTemplateTypeEnum;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@@ -44,10 +45,14 @@ public class CodegenTableDO extends BaseDO {
/**
* 表名称
+ *
+ * 关联 {@link TableInfo#getName()}
*/
private String tableName;
/**
* 表描述
+ *
+ * 关联 {@link TableInfo#getComment()}
*/
private String tableComment;
/**
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/job/JobLogMapper.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/job/JobLogMapper.java
index fe196df35..c467498bf 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/job/JobLogMapper.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/job/JobLogMapper.java
@@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.infra.dal.mysql.job;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
-import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogExportReqVO;
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO;
import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobLogDO;
@@ -19,24 +19,24 @@ import java.util.List;
public interface JobLogMapper extends BaseMapperX {
default PageResult selectPage(JobLogPageReqVO reqVO) {
- return selectPage(reqVO, new QueryWrapperX()
- .eqIfPresent("job_id", reqVO.getJobId())
- .likeIfPresent("handler_name", reqVO.getHandlerName())
- .geIfPresent("begin_time", reqVO.getBeginTime())
- .leIfPresent("end_time", reqVO.getEndTime())
- .eqIfPresent("status", reqVO.getStatus())
- .orderByDesc("id") // ID 倒序
+ return selectPage(reqVO, new LambdaQueryWrapperX()
+ .eqIfPresent(JobLogDO::getJobId, reqVO.getJobId())
+ .likeIfPresent(JobLogDO::getHandlerName, reqVO.getHandlerName())
+ .geIfPresent(JobLogDO::getBeginTime, reqVO.getBeginTime())
+ .leIfPresent(JobLogDO::getEndTime, reqVO.getEndTime())
+ .eqIfPresent(JobLogDO::getStatus, reqVO.getStatus())
+ .orderByDesc(JobLogDO::getId) // ID 倒序
);
}
default List selectList(JobLogExportReqVO reqVO) {
- return selectList(new QueryWrapperX()
- .eqIfPresent("job_id", reqVO.getJobId())
- .likeIfPresent("handler_name", reqVO.getHandlerName())
- .geIfPresent("begin_time", reqVO.getBeginTime())
- .leIfPresent("end_time", reqVO.getEndTime())
- .eqIfPresent("status", reqVO.getStatus())
- .orderByDesc("id") // ID 倒序
+ return selectList(new LambdaQueryWrapperX()
+ .eqIfPresent(JobLogDO::getJobId, reqVO.getJobId())
+ .likeIfPresent(JobLogDO::getHandlerName, reqVO.getHandlerName())
+ .geIfPresent(JobLogDO::getBeginTime, reqVO.getBeginTime())
+ .leIfPresent(JobLogDO::getEndTime, reqVO.getEndTime())
+ .eqIfPresent(JobLogDO::getStatus, reqVO.getStatus())
+ .orderByDesc(JobLogDO::getId) // ID 倒序
);
}
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImpl.java
index 3b693eb50..e3a352b8b 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImpl.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImpl.java
@@ -76,7 +76,7 @@ public class CodegenServiceImpl implements CodegenService {
private Long createCodegen0(Long userId, Long dataSourceConfigId, TableInfo tableInfo) {
// 校验导入的表和字段非空
- checkTableInfo(tableInfo);
+ validateTableInfo(tableInfo);
// 校验是否已经存在
if (codegenTableMapper.selectByTableNameAndDataSourceConfigId(tableInfo.getName(),
dataSourceConfigId) != null) {
@@ -100,7 +100,7 @@ public class CodegenServiceImpl implements CodegenService {
return table.getId();
}
- private void checkTableInfo(TableInfo tableInfo) {
+ private void validateTableInfo(TableInfo tableInfo) {
if (tableInfo == null) {
throw exception(CODEGEN_IMPORT_TABLE_NULL);
}
@@ -149,7 +149,7 @@ public class CodegenServiceImpl implements CodegenService {
private void syncCodegen0(Long tableId, TableInfo tableInfo) {
// 校验导入的表和字段非空
- checkTableInfo(tableInfo);
+ validateTableInfo(tableInfo);
List tableFields = tableInfo.getFields();
// 构建 CodegenColumnDO 数组,只同步新增的字段
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/config/ConfigServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/config/ConfigServiceImpl.java
index 5c354c989..51c912be7 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/config/ConfigServiceImpl.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/config/ConfigServiceImpl.java
@@ -9,7 +9,6 @@ import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigUpdateReqV
import cn.iocoder.yudao.module.infra.convert.config.ConfigConvert;
import cn.iocoder.yudao.module.infra.dal.dataobject.config.ConfigDO;
import cn.iocoder.yudao.module.infra.dal.mysql.config.ConfigMapper;
-import cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants;
import cn.iocoder.yudao.module.infra.enums.config.ConfigTypeEnum;
import com.google.common.annotations.VisibleForTesting;
import lombok.extern.slf4j.Slf4j;
@@ -20,6 +19,7 @@ import javax.annotation.Resource;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*;
/**
* 参数配置 Service 实现类
@@ -35,7 +35,7 @@ public class ConfigServiceImpl implements ConfigService {
@Override
public Long createConfig(ConfigCreateReqVO reqVO) {
// 校验正确性
- checkCreateOrUpdate(null, reqVO.getKey());
+ validateConfigForCreateOrUpdate(null, reqVO.getKey());
// 插入参数配置
ConfigDO config = ConfigConvert.INSTANCE.convert(reqVO);
config.setType(ConfigTypeEnum.CUSTOM.getType());
@@ -46,19 +46,19 @@ public class ConfigServiceImpl implements ConfigService {
@Override
public void updateConfig(ConfigUpdateReqVO reqVO) {
// 校验正确性
- checkCreateOrUpdate(reqVO.getId(), null); // 不允许更新 key
+ validateConfigForCreateOrUpdate(reqVO.getId(), null); // 不允许更新 key
// 更新参数配置
ConfigDO updateObj = ConfigConvert.INSTANCE.convert(reqVO);
- configMapper.updateById(updateObj);;
+ configMapper.updateById(updateObj);
}
@Override
public void deleteConfig(Long id) {
// 校验配置存在
- ConfigDO config = checkConfigExists(id);
+ ConfigDO config = validateConfigExists(id);
// 内置配置,不允许删除
if (ConfigTypeEnum.SYSTEM.getType().equals(config.getType())) {
- throw exception(ErrorCodeConstants.CONFIG_CAN_NOT_DELETE_SYSTEM_TYPE);
+ throw exception(CONFIG_CAN_NOT_DELETE_SYSTEM_TYPE);
}
// 删除
configMapper.deleteById(id);
@@ -84,39 +84,39 @@ public class ConfigServiceImpl implements ConfigService {
return configMapper.selectList(reqVO);
}
- private void checkCreateOrUpdate(Long id, String key) {
+ private void validateConfigForCreateOrUpdate(Long id, String key) {
// 校验自己存在
- checkConfigExists(id);
+ validateConfigExists(id);
// 校验参数配置 key 的唯一性
if (StrUtil.isNotEmpty(key)) {
- checkConfigKeyUnique(id, key);
+ validateConfigKeyUnique(id, key);
}
}
@VisibleForTesting
- public ConfigDO checkConfigExists(Long id) {
+ public ConfigDO validateConfigExists(Long id) {
if (id == null) {
return null;
}
ConfigDO config = configMapper.selectById(id);
if (config == null) {
- throw exception(ErrorCodeConstants.CONFIG_NOT_EXISTS);
+ throw exception(CONFIG_NOT_EXISTS);
}
return config;
}
@VisibleForTesting
- public void checkConfigKeyUnique(Long id, String key) {
+ public void validateConfigKeyUnique(Long id, String key) {
ConfigDO config = configMapper.selectByKey(key);
if (config == null) {
return;
}
// 如果 id 为空,说明不用比较是否为相同 id 的参数配置
if (id == null) {
- throw exception(ErrorCodeConstants.CONFIG_KEY_DUPLICATE);
+ throw exception(CONFIG_KEY_DUPLICATE);
}
if (!config.getId().equals(id)) {
- throw exception(ErrorCodeConstants.CONFIG_KEY_DUPLICATE);
+ throw exception(CONFIG_KEY_DUPLICATE);
}
}
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/db/DataSourceConfigServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/db/DataSourceConfigServiceImpl.java
index f2fd0a408..e4365c205 100755
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/db/DataSourceConfigServiceImpl.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/db/DataSourceConfigServiceImpl.java
@@ -37,7 +37,7 @@ public class DataSourceConfigServiceImpl implements DataSourceConfigService {
@Override
public Long createDataSourceConfig(DataSourceConfigCreateReqVO createReqVO) {
DataSourceConfigDO dataSourceConfig = DataSourceConfigConvert.INSTANCE.convert(createReqVO);
- checkConnectionOK(dataSourceConfig);
+ validateConnectionOK(dataSourceConfig);
// 插入
dataSourceConfigMapper.insert(dataSourceConfig);
@@ -50,7 +50,7 @@ public class DataSourceConfigServiceImpl implements DataSourceConfigService {
// 校验存在
validateDataSourceConfigExists(updateReqVO.getId());
DataSourceConfigDO updateObj = DataSourceConfigConvert.INSTANCE.convert(updateReqVO);
- checkConnectionOK(updateObj);
+ validateConnectionOK(updateObj);
// 更新
dataSourceConfigMapper.updateById(updateObj);
@@ -88,7 +88,7 @@ public class DataSourceConfigServiceImpl implements DataSourceConfigService {
return result;
}
- private void checkConnectionOK(DataSourceConfigDO config) {
+ private void validateConnectionOK(DataSourceConfigDO config) {
boolean success = JdbcUtils.isConnectionOK(config.getUrl(), config.getUsername(), config.getPassword());
if (!success) {
throw exception(DATA_SOURCE_CONFIG_NOT_OK);
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/db/DatabaseTableServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/db/DatabaseTableServiceImpl.java
index d0c80ba61..17fb5cea3 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/db/DatabaseTableServiceImpl.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/db/DatabaseTableServiceImpl.java
@@ -41,7 +41,7 @@ public class DatabaseTableServiceImpl implements DatabaseTableService {
return CollUtil.getFirst(getTableList0(dataSourceConfigId, name));
}
- public List getTableList0(Long dataSourceConfigId, String name) {
+ private List getTableList0(Long dataSourceConfigId, String name) {
// 获得数据源配置
DataSourceConfigDO config = dataSourceConfigService.getDataSourceConfig(dataSourceConfigId);
Assert.notNull(config, "数据源({}) 不存在!", dataSourceConfigId);
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileConfigService.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileConfigService.java
index b3fc6bad2..43ab5bc68 100755
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileConfigService.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileConfigService.java
@@ -8,8 +8,6 @@ import cn.iocoder.yudao.module.infra.controller.admin.file.vo.config.FileConfigU
import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileConfigDO;
import javax.validation.Valid;
-import java.util.Collection;
-import java.util.List;
/**
* 文件配置 Service 接口
@@ -60,14 +58,6 @@ public interface FileConfigService {
*/
FileConfigDO getFileConfig(Long id);
- /**
- * 获得文件配置列表
- *
- * @param ids 编号
- * @return 文件配置列表
- */
- List getFileConfigList(Collection ids);
-
/**
* 获得文件配置分页
*
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImpl.java
index 590ff8116..6236df6ff 100755
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImpl.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImpl.java
@@ -27,7 +27,6 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.validation.Validator;
-import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -95,7 +94,7 @@ public class FileConfigServiceImpl implements FileConfigService {
@Override
public void updateFileConfig(FileConfigUpdateReqVO updateReqVO) {
// 校验存在
- FileConfigDO config = this.validateFileConfigExists(updateReqVO.getId());
+ FileConfigDO config = validateFileConfigExists(updateReqVO.getId());
// 更新
FileConfigDO updateObj = FileConfigConvert.INSTANCE.convert(updateReqVO)
.setConfig(parseClientConfig(config.getStorage(), updateReqVO.getConfig()));
@@ -108,7 +107,7 @@ public class FileConfigServiceImpl implements FileConfigService {
@Transactional(rollbackFor = Exception.class)
public void updateFileConfigMaster(Long id) {
// 校验存在
- this.validateFileConfigExists(id);
+ validateFileConfigExists(id);
// 更新其它为非 master
fileConfigMapper.updateBatch(new FileConfigDO().setMaster(false));
// 更新
@@ -138,7 +137,7 @@ public class FileConfigServiceImpl implements FileConfigService {
@Override
public void deleteFileConfig(Long id) {
// 校验存在
- FileConfigDO config = this.validateFileConfigExists(id);
+ FileConfigDO config = validateFileConfigExists(id);
if (Boolean.TRUE.equals(config.getMaster())) {
throw exception(FILE_CONFIG_DELETE_FAIL_MASTER);
}
@@ -161,11 +160,6 @@ public class FileConfigServiceImpl implements FileConfigService {
return fileConfigMapper.selectById(id);
}
- @Override
- public List getFileConfigList(Collection ids) {
- return fileConfigMapper.selectBatchIds(ids);
- }
-
@Override
public PageResult getFileConfigPage(FileConfigPageReqVO pageReqVO) {
return fileConfigMapper.selectPage(pageReqVO);
@@ -174,7 +168,7 @@ public class FileConfigServiceImpl implements FileConfigService {
@Override
public String testFileConfig(Long id) throws Exception {
// 校验存在
- this.validateFileConfigExists(id);
+ validateFileConfigExists(id);
// 上传文件
byte[] content = ResourceUtil.readBytes("file/erweima.jpg");
return fileClientFactory.getFileClient(id).upload(content, IdUtil.fastSimpleUUID() + ".jpg", "image/jpeg");
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java
index 2226e7bae..0732765d8 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java
@@ -69,7 +69,7 @@ public class FileServiceImpl implements FileService {
@Override
public void deleteFile(Long id) throws Exception {
// 校验存在
- FileDO file = this.validateFileExists(id);
+ FileDO file = validateFileExists(id);
// 从文件存储器中删除
FileClient client = fileConfigService.getFileClient(file.getConfigId());
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/job/JobServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/job/JobServiceImpl.java
index e0a245750..498d816b8 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/job/JobServiceImpl.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/job/JobServiceImpl.java
@@ -69,7 +69,7 @@ public class JobServiceImpl implements JobService {
public void updateJob(JobUpdateReqVO updateReqVO) throws SchedulerException {
validateCronExpression(updateReqVO.getCronExpression());
// 校验存在
- JobDO job = this.validateJobExists(updateReqVO.getId());
+ JobDO job = validateJobExists(updateReqVO.getId());
// 只有开启状态,才可以修改.原因是,如果出暂停状态,修改 Quartz Job 时,会导致任务又开始执行
if (!job.getStatus().equals(JobStatusEnum.NORMAL.getStatus())) {
throw exception(JOB_UPDATE_ONLY_NORMAL_STATUS);
@@ -92,7 +92,7 @@ public class JobServiceImpl implements JobService {
throw exception(JOB_CHANGE_STATUS_INVALID);
}
// 校验存在
- JobDO job = this.validateJobExists(id);
+ JobDO job = validateJobExists(id);
// 校验是否已经为当前状态
if (job.getStatus().equals(status)) {
throw exception(JOB_CHANGE_STATUS_EQUALS);
@@ -112,7 +112,7 @@ public class JobServiceImpl implements JobService {
@Override
public void triggerJob(Long id) throws SchedulerException {
// 校验存在
- JobDO job = this.validateJobExists(id);
+ JobDO job = validateJobExists(id);
// 触发 Quartz 中的 Job
schedulerManager.triggerJob(job.getId(), job.getHandlerName(), job.getHandlerParam());
@@ -122,7 +122,7 @@ public class JobServiceImpl implements JobService {
@Transactional(rollbackFor = Exception.class)
public void deleteJob(Long id) throws SchedulerException {
// 校验存在
- JobDO job = this.validateJobExists(id);
+ JobDO job = validateJobExists(id);
// 更新
jobMapper.deleteById(id);
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java
index c1b129322..c0f9252af 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java
@@ -1,6 +1,5 @@
package cn.iocoder.yudao.module.infra.service.logger;
-import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExportReqVO;
@@ -8,7 +7,6 @@ import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiE
import cn.iocoder.yudao.module.infra.convert.logger.ApiErrorLogConvert;
import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO;
import cn.iocoder.yudao.module.infra.dal.mysql.logger.ApiErrorLogMapper;
-import cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants;
import cn.iocoder.yudao.module.infra.enums.logger.ApiErrorLogProcessStatusEnum;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@@ -17,6 +15,10 @@ import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.API_ERROR_LOG_NOT_FOUND;
+import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.API_ERROR_LOG_PROCESSED;
+
/**
* API 错误日志 Service 实现类
*
@@ -31,8 +33,8 @@ public class ApiErrorLogServiceImpl implements ApiErrorLogService {
@Override
public void createApiErrorLog(ApiErrorLogCreateReqDTO createDTO) {
- ApiErrorLogDO apiErrorLog = ApiErrorLogConvert.INSTANCE.convert(createDTO);
- apiErrorLog.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus());
+ ApiErrorLogDO apiErrorLog = ApiErrorLogConvert.INSTANCE.convert(createDTO)
+ .setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus());
apiErrorLogMapper.insert(apiErrorLog);
}
@@ -50,10 +52,10 @@ public class ApiErrorLogServiceImpl implements ApiErrorLogService {
public void updateApiErrorLogProcess(Long id, Integer processStatus, Long processUserId) {
ApiErrorLogDO errorLog = apiErrorLogMapper.selectById(id);
if (errorLog == null) {
- throw ServiceExceptionUtil.exception(ErrorCodeConstants.API_ERROR_LOG_NOT_FOUND);
+ throw exception(API_ERROR_LOG_NOT_FOUND);
}
if (!ApiErrorLogProcessStatusEnum.INIT.getStatus().equals(errorLog.getProcessStatus())) {
- throw ServiceExceptionUtil.exception(ErrorCodeConstants.API_ERROR_LOG_PROCESSED);
+ throw exception(API_ERROR_LOG_PROCESSED);
}
// 标记处理
apiErrorLogMapper.updateById(ApiErrorLogDO.builder().id(id).processStatus(processStatus)
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/test/TestDemoServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/test/TestDemoServiceImpl.java
index 731a29ccc..70f2ebc5d 100755
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/test/TestDemoServiceImpl.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/test/TestDemoServiceImpl.java
@@ -45,7 +45,7 @@ public class TestDemoServiceImpl implements TestDemoService {
@CacheEvict(value = "test", key = "#updateReqVO.id")
public void updateTestDemo(TestDemoUpdateReqVO updateReqVO) {
// 校验存在
- this.validateTestDemoExists(updateReqVO.getId());
+ validateTestDemoExists(updateReqVO.getId());
// 更新
TestDemoDO updateObj = TestDemoConvert.INSTANCE.convert(updateReqVO);
testDemoMapper.updateById(updateObj);
@@ -55,7 +55,7 @@ public class TestDemoServiceImpl implements TestDemoService {
@CacheEvict(value = "test", key = "#id")
public void deleteTestDemo(Long id) {
// 校验存在
- this.validateTestDemoExists(id);
+ validateTestDemoExists(id);
// 删除
testDemoMapper.deleteById(id);
}
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/service/serviceImpl.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/service/serviceImpl.vm
index 85dfa0aab..a732039ce 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/service/serviceImpl.vm
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/service/serviceImpl.vm
@@ -39,7 +39,7 @@ public class ${table.className}ServiceImpl implements ${table.className}Service
@Override
public void update${simpleClassName}(${sceneEnum.prefixClass}${table.className}UpdateReqVO updateReqVO) {
// 校验存在
- this.validate${simpleClassName}Exists(updateReqVO.getId());
+ validate${simpleClassName}Exists(updateReqVO.getId());
// 更新
${table.className}DO updateObj = ${table.className}Convert.INSTANCE.convert(updateReqVO);
${classNameVar}Mapper.updateById(updateObj);
@@ -48,7 +48,7 @@ public class ${table.className}ServiceImpl implements ${table.className}Service
@Override
public void delete${simpleClassName}(${primaryColumn.javaType} id) {
// 校验存在
- this.validate${simpleClassName}Exists(id);
+ validate${simpleClassName}Exists(id);
// 删除
${classNameVar}Mapper.deleteById(id);
}
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/test/serviceTest.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/test/serviceTest.vm
index e97fbb275..67a44e989 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/test/serviceTest.vm
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/test/serviceTest.vm
@@ -52,7 +52,7 @@ import static org.mockito.Mockito.*;
#if (${column.listOperation})
#set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写
#if (${column.listOperationCondition} == "BETWEEN")## BETWEEN 的情况
- reqVO.set${JavaField}((new LocalDateTime[]{}));
+ reqVO.set${JavaField}(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
#else
reqVO.set$JavaField(null);
#end
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/config/ConfigServiceTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/config/ConfigServiceImplTest.java
similarity index 75%
rename from yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/config/ConfigServiceTest.java
rename to yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/config/ConfigServiceImplTest.java
index 5f29e79ec..428b20522 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/config/ConfigServiceTest.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/config/ConfigServiceImplTest.java
@@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.infra.service.config;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils;
-import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.framework.test.core.util.RandomUtils;
import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigCreateReqVO;
@@ -12,17 +11,17 @@ import cn.iocoder.yudao.module.infra.controller.admin.config.vo.ConfigUpdateReqV
import cn.iocoder.yudao.module.infra.dal.dataobject.config.ConfigDO;
import cn.iocoder.yudao.module.infra.dal.mysql.config.ConfigMapper;
import cn.iocoder.yudao.module.infra.enums.config.ConfigTypeEnum;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Import;
import javax.annotation.Resource;
-import java.time.LocalDateTime;
import java.util.List;
import java.util.function.Consumer;
import static cn.hutool.core.util.RandomUtil.randomEle;
+import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime;
+import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
@@ -30,7 +29,7 @@ import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*;
import static org.junit.jupiter.api.Assertions.*;
@Import(ConfigServiceImpl.class)
-public class ConfigServiceTest extends BaseDbUnitTest {
+public class ConfigServiceImplTest extends BaseDbUnitTest {
@Resource
private ConfigServiceImpl configService;
@@ -50,7 +49,7 @@ public class ConfigServiceTest extends BaseDbUnitTest {
// 校验记录的属性是否正确
ConfigDO config = configMapper.selectById(configId);
assertPojoEquals(reqVO, config);
- Assertions.assertEquals(ConfigTypeEnum.CUSTOM.getType(), config.getType());
+ assertEquals(ConfigTypeEnum.CUSTOM.getType(), config.getType());
}
@Test
@@ -101,40 +100,40 @@ public class ConfigServiceTest extends BaseDbUnitTest {
}
@Test
- public void testCheckConfigExists_success() {
+ public void testValidateConfigExists_success() {
// mock 数据
ConfigDO dbConfigDO = randomConfigDO();
configMapper.insert(dbConfigDO);// @Sql: 先插入出一条存在的数据
// 调用成功
- configService.checkConfigExists(dbConfigDO.getId());
+ configService.validateConfigExists(dbConfigDO.getId());
}
@Test
- public void testCheckConfigExist_notExists() {
- assertServiceException(() -> configService.checkConfigExists(randomLongId()), CONFIG_NOT_EXISTS);
+ public void testValidateConfigExist_notExists() {
+ assertServiceException(() -> configService.validateConfigExists(randomLongId()), CONFIG_NOT_EXISTS);
}
@Test
- public void testCheckConfigKeyUnique_success() {
+ public void testValidateConfigKeyUnique_success() {
// 调用,成功
- configService.checkConfigKeyUnique(randomLongId(), randomString());
+ configService.validateConfigKeyUnique(randomLongId(), randomString());
}
@Test
- public void testCheckConfigKeyUnique_keyDuplicateForCreate() {
+ public void testValidateConfigKeyUnique_keyDuplicateForCreate() {
// 准备参数
String key = randomString();
// mock 数据
configMapper.insert(randomConfigDO(o -> o.setConfigKey(key)));
// 调用,校验异常
- assertServiceException(() -> configService.checkConfigKeyUnique(null, key),
+ assertServiceException(() -> configService.validateConfigKeyUnique(null, key),
CONFIG_KEY_DUPLICATE);
}
@Test
- public void testCheckConfigKeyUnique_keyDuplicateForUpdate() {
+ public void testValidateConfigKeyUnique_keyDuplicateForUpdate() {
// 准备参数
Long id = randomLongId();
String key = randomString();
@@ -142,7 +141,7 @@ public class ConfigServiceTest extends BaseDbUnitTest {
configMapper.insert(randomConfigDO(o -> o.setConfigKey(key)));
// 调用,校验异常
- assertServiceException(() -> configService.checkConfigKeyUnique(id, key),
+ assertServiceException(() -> configService.validateConfigKeyUnique(id, key),
CONFIG_KEY_DUPLICATE);
}
@@ -157,19 +156,19 @@ public class ConfigServiceTest extends BaseDbUnitTest {
});
configMapper.insert(dbConfig);
// 测试 name 不匹配
- configMapper.insert(ObjectUtils.cloneIgnoreId(dbConfig, o -> o.setName("土豆")));
+ configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setName("土豆")));
// 测试 key 不匹配
- configMapper.insert(ObjectUtils.cloneIgnoreId(dbConfig, o -> o.setConfigKey("tudou")));
+ configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setConfigKey("tudou")));
// 测试 type 不匹配
- configMapper.insert(ObjectUtils.cloneIgnoreId(dbConfig, o -> o.setType(ConfigTypeEnum.CUSTOM.getType())));
+ configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setType(ConfigTypeEnum.CUSTOM.getType())));
// 测试 createTime 不匹配
- configMapper.insert(ObjectUtils.cloneIgnoreId(dbConfig, o -> o.setCreateTime(buildTime(2021, 1, 1))));
+ configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setCreateTime(buildTime(2021, 1, 1))));
// 准备参数
ConfigPageReqVO reqVO = new ConfigPageReqVO();
reqVO.setName("艿");
reqVO.setKey("nai");
reqVO.setType(ConfigTypeEnum.SYSTEM.getType());
- reqVO.setCreateTime((new LocalDateTime[]{buildTime(2021, 1, 15),buildTime(2021, 2, 15)}));
+ reqVO.setCreateTime(buildBetweenTime(2021, 1, 15, 2021, 2, 15));
// 调用
PageResult pageResult = configService.getConfigPage(reqVO);
@@ -190,19 +189,19 @@ public class ConfigServiceTest extends BaseDbUnitTest {
});
configMapper.insert(dbConfig);
// 测试 name 不匹配
- configMapper.insert(ObjectUtils.cloneIgnoreId(dbConfig, o -> o.setName("土豆")));
+ configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setName("土豆")));
// 测试 key 不匹配
- configMapper.insert(ObjectUtils.cloneIgnoreId(dbConfig, o -> o.setConfigKey("tudou")));
+ configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setConfigKey("tudou")));
// 测试 type 不匹配
- configMapper.insert(ObjectUtils.cloneIgnoreId(dbConfig, o -> o.setType(ConfigTypeEnum.CUSTOM.getType())));
+ configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setType(ConfigTypeEnum.CUSTOM.getType())));
// 测试 createTime 不匹配
- configMapper.insert(ObjectUtils.cloneIgnoreId(dbConfig, o -> o.setCreateTime(buildTime(2021, 1, 1))));
+ configMapper.insert(cloneIgnoreId(dbConfig, o -> o.setCreateTime(buildTime(2021, 1, 1))));
// 准备参数
ConfigExportReqVO reqVO = new ConfigExportReqVO();
reqVO.setName("艿");
reqVO.setKey("nai");
reqVO.setType(ConfigTypeEnum.SYSTEM.getType());
- reqVO.setCreateTime((new LocalDateTime[]{buildTime(2021, 1, 15),buildTime(2021, 2, 15)}));
+ reqVO.setCreateTime(buildBetweenTime(2021, 1, 15, 2021, 2, 15));
// 调用
List list = configService.getConfigList(reqVO);
@@ -211,6 +210,21 @@ public class ConfigServiceTest extends BaseDbUnitTest {
assertPojoEquals(dbConfig, list.get(0));
}
+ @Test
+ public void testGetConfig() {
+ // mock 数据
+ ConfigDO dbConfig = randomConfigDO();
+ configMapper.insert(dbConfig);// @Sql: 先插入出一条存在的数据
+ // 准备参数
+ Long id = dbConfig.getId();
+
+ // 调用
+ ConfigDO config = configService.getConfig(id);
+ // 断言
+ assertNotNull(config);
+ assertPojoEquals(dbConfig, config);
+ }
+
@Test
public void testGetConfigByKey() {
// mock 数据
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DataSourceConfigServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DataSourceConfigServiceImplTest.java
index e1c997f7b..b5ef46c46 100755
--- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DataSourceConfigServiceImplTest.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DataSourceConfigServiceImplTest.java
@@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.infra.service.db;
+import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.crypto.symmetric.AES;
import cn.iocoder.yudao.framework.mybatis.core.type.EncryptTypeHandler;
@@ -9,6 +10,7 @@ import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigCrea
import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigUpdateReqVO;
import cn.iocoder.yudao.module.infra.dal.dataobject.db.DataSourceConfigDO;
import cn.iocoder.yudao.module.infra.dal.mysql.db.DataSourceConfigMapper;
+import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty;
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceProperties;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -18,14 +20,14 @@ import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Import;
import javax.annotation.Resource;
+import java.util.List;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.DATA_SOURCE_CONFIG_NOT_EXISTS;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mockStatic;
@@ -57,6 +59,11 @@ public class DataSourceConfigServiceImplTest extends BaseDbUnitTest {
ReflectUtil.setFieldValue(EncryptTypeHandler.class, "aes", aes);
when(aes.encryptBase64(anyString())).then((Answer) invocation -> invocation.getArgument(0));
when(aes.decryptStr(anyString())).then((Answer) invocation -> invocation.getArgument(0));
+
+ // mock DynamicDataSourceProperties
+ when(dynamicDataSourceProperties.getPrimary()).thenReturn("primary");
+ when(dynamicDataSourceProperties.getDatasource()).thenReturn(MapUtil.of("primary",
+ new DataSourceProperty().setUrl("http://localhost:3306").setUsername("yunai").setPassword("tudou")));
}
@Test
@@ -89,7 +96,6 @@ public class DataSourceConfigServiceImplTest extends BaseDbUnitTest {
o.setId(dbDataSourceConfig.getId()); // 设置更新的 ID
});
// mock 方法
-// when(stringEncryptor.encrypt(eq(reqVO.getPassword()))).thenReturn("123456");
databaseUtilsMock.when(() -> JdbcUtils.isConnectionOK(eq(reqVO.getUrl()),
eq(reqVO.getUsername()), eq(reqVO.getPassword()))).thenReturn(true);
@@ -142,7 +148,58 @@ public class DataSourceConfigServiceImplTest extends BaseDbUnitTest {
// 调用
DataSourceConfigDO result = dataSourceConfigMapper.selectOne(DataSourceConfigDO::getPassword,
EncryptTypeHandler.encrypt(dbDataSourceConfig.getPassword()));
- System.out.println(result);
+ assertPojoEquals(dbDataSourceConfig, result);
+ }
+
+ @Test
+ public void testGetDataSourceConfig_master() {
+ // 准备参数
+ Long id = 0L;
+ // mock 方法
+
+ // 调用
+ DataSourceConfigDO dataSourceConfig = dataSourceConfigService.getDataSourceConfig(id);
+ // 断言
+ assertEquals(id, dataSourceConfig.getId());
+ assertEquals("primary", dataSourceConfig.getName());
+ assertEquals("http://localhost:3306", dataSourceConfig.getUrl());
+ assertEquals("yunai", dataSourceConfig.getUsername());
+ assertEquals("tudou", dataSourceConfig.getPassword());
+ }
+
+ @Test
+ public void testGetDataSourceConfig_normal() {
+ // mock 数据
+ DataSourceConfigDO dbDataSourceConfig = randomPojo(DataSourceConfigDO.class);
+ dataSourceConfigMapper.insert(dbDataSourceConfig);// @Sql: 先插入出一条存在的数据
+ // 准备参数
+ Long id = dbDataSourceConfig.getId();
+
+ // 调用
+ DataSourceConfigDO dataSourceConfig = dataSourceConfigService.getDataSourceConfig(id);
+ // 断言
+ assertPojoEquals(dbDataSourceConfig, dataSourceConfig);
+ }
+
+ @Test
+ public void testGetDataSourceConfigList() {
+ // mock 数据
+ DataSourceConfigDO dbDataSourceConfig = randomPojo(DataSourceConfigDO.class);
+ dataSourceConfigMapper.insert(dbDataSourceConfig);// @Sql: 先插入出一条存在的数据
+ // 准备参数
+
+ // 调用
+ List dataSourceConfigList = dataSourceConfigService.getDataSourceConfigList();
+ // 断言
+ assertEquals(2, dataSourceConfigList.size());
+ // master
+ assertEquals(0L, dataSourceConfigList.get(0).getId());
+ assertEquals("primary", dataSourceConfigList.get(0).getName());
+ assertEquals("http://localhost:3306", dataSourceConfigList.get(0).getUrl());
+ assertEquals("yunai", dataSourceConfigList.get(0).getUsername());
+ assertEquals("tudou", dataSourceConfigList.get(0).getPassword());
+ // normal
+ assertPojoEquals(dbDataSourceConfig, dataSourceConfigList.get(1));
}
}
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DatabaseTableServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DatabaseTableServiceImplTest.java
new file mode 100644
index 000000000..6ce8c7d41
--- /dev/null
+++ b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/db/DatabaseTableServiceImplTest.java
@@ -0,0 +1,89 @@
+package cn.iocoder.yudao.module.infra.service.db;
+
+import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
+import cn.iocoder.yudao.module.infra.dal.dataobject.db.DataSourceConfigDO;
+import com.baomidou.mybatisplus.generator.config.po.TableField;
+import com.baomidou.mybatisplus.generator.config.po.TableInfo;
+import com.baomidou.mybatisplus.generator.config.rules.DbColumnType;
+import org.apache.ibatis.type.JdbcType;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.context.annotation.Import;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+
+@Import(DatabaseTableServiceImpl.class)
+public class DatabaseTableServiceImplTest extends BaseDbUnitTest {
+
+ @Resource
+ private DatabaseTableServiceImpl databaseTableService;
+
+ @MockBean
+ private DataSourceConfigService dataSourceConfigService;
+
+ @Test
+ public void testGetTableList() {
+ // 准备参数
+ Long dataSourceConfigId = randomLongId();
+ // mock 方法
+ DataSourceConfigDO dataSourceConfig = new DataSourceConfigDO().setUsername("sa").setPassword("")
+ .setUrl("jdbc:h2:mem:testdb");
+ when(dataSourceConfigService.getDataSourceConfig(eq(dataSourceConfigId)))
+ .thenReturn(dataSourceConfig);
+
+ // 调用
+ List tables = databaseTableService.getTableList(dataSourceConfigId,
+ "config", "参数");
+ // 断言
+ assertEquals(1, tables.size());
+ assertTableInfo(tables.get(0));
+ }
+
+ @Test
+ public void testGetTable() {
+ // 准备参数
+ Long dataSourceConfigId = randomLongId();
+ // mock 方法
+ DataSourceConfigDO dataSourceConfig = new DataSourceConfigDO().setUsername("sa").setPassword("")
+ .setUrl("jdbc:h2:mem:testdb");
+ when(dataSourceConfigService.getDataSourceConfig(eq(dataSourceConfigId)))
+ .thenReturn(dataSourceConfig);
+
+ // 调用
+ TableInfo tableInfo = databaseTableService.getTable(dataSourceConfigId, "infra_config");
+ // 断言
+ assertTableInfo(tableInfo);
+ }
+
+ private void assertTableInfo(TableInfo tableInfo) {
+ assertEquals("infra_config", tableInfo.getName());
+ assertEquals("参数配置表", tableInfo.getComment());
+ assertEquals(13, tableInfo.getFields().size());
+ // id 字段
+ TableField idField = tableInfo.getFields().get(0);
+ assertEquals("id", idField.getName());
+ assertEquals(JdbcType.BIGINT, idField.getMetaInfo().getJdbcType());
+ assertEquals("编号", idField.getComment());
+ assertFalse(idField.getMetaInfo().isNullable());
+ assertTrue(idField.isKeyFlag());
+ assertTrue(idField.isKeyIdentityFlag());
+ assertEquals(DbColumnType.LONG, idField.getColumnType());
+ assertEquals("id", idField.getPropertyName());
+ // name 字段
+ TableField nameField = tableInfo.getFields().get(3);
+ assertEquals("name", nameField.getName());
+ assertEquals(JdbcType.VARCHAR, nameField.getMetaInfo().getJdbcType());
+ assertEquals("名字", nameField.getComment());
+ assertFalse(nameField.getMetaInfo().isNullable());
+ assertFalse(nameField.isKeyFlag());
+ assertFalse(nameField.isKeyIdentityFlag());
+ assertEquals(DbColumnType.STRING, nameField.getColumnType());
+ assertEquals("name", nameField.getPropertyName());
+ }
+}
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImplTest.java
index 61c9827f6..656955194 100755
--- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImplTest.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImplTest.java
@@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.file.core.client.FileClient;
import cn.iocoder.yudao.framework.file.core.client.FileClientConfig;
import cn.iocoder.yudao.framework.file.core.client.FileClientFactory;
+import cn.iocoder.yudao.framework.file.core.client.local.LocalFileClient;
import cn.iocoder.yudao.framework.file.core.client.local.LocalFileClientConfig;
import cn.iocoder.yudao.framework.file.core.enums.FileStorageEnum;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
@@ -242,6 +243,30 @@ public class FileConfigServiceImplTest extends BaseDbUnitTest {
assertEquals("https://www.iocoder.cn", fileConfigService.testFileConfig(id));
}
+ @Test
+ public void testGetFileConfig() {
+ // mock 数据
+ FileConfigDO dbFileConfig = randomFileConfigDO().setMaster(false);
+ fileConfigMapper.insert(dbFileConfig);// @Sql: 先插入出一条存在的数据
+ // 准备参数
+ Long id = dbFileConfig.getId();
+
+ // 调用,并断言
+ assertPojoEquals(dbFileConfig, fileConfigService.getFileConfig(id));
+ }
+
+ @Test
+ public void testGetFileClient() {
+ // 准备参数
+ Long id = randomLongId();
+ // mock 获得 Client
+ FileClient fileClient = new LocalFileClient(id, new LocalFileClientConfig());
+ when(fileClientFactory.getFileClient(eq(id))).thenReturn(fileClient);
+
+ // 调用,并断言
+ assertSame(fileClient, fileConfigService.getFileClient(id));
+ }
+
private FileConfigDO randomFileConfigDO() {
return randomPojo(FileConfigDO.class).setStorage(randomEle(FileStorageEnum.values()).getStorage())
.setConfig(new EmptyFileClientConfig());
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImplTest.java
similarity index 98%
rename from yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceTest.java
rename to yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImplTest.java
index 90bde8f4e..57cc4c476 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceTest.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImplTest.java
@@ -26,7 +26,7 @@ import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.*;
@Import({FileServiceImpl.class})
-public class FileServiceTest extends BaseDbUnitTest {
+public class FileServiceImplTest extends BaseDbUnitTest {
@Resource
private FileService fileService;
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/job/JobLogServiceTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/job/JobLogServiceImplTest.java
similarity index 52%
rename from yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/job/JobLogServiceTest.java
rename to yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/job/JobLogServiceImplTest.java
index 665e9c509..efba0c0cf 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/job/JobLogServiceTest.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/job/JobLogServiceImplTest.java
@@ -1,7 +1,6 @@
package cn.iocoder.yudao.module.infra.service.job;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogExportReqVO;
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.log.JobLogPageReqVO;
@@ -12,18 +11,20 @@ import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Import;
import javax.annotation.Resource;
-import java.util.ArrayList;
+import java.time.LocalDateTime;
+import java.util.Collection;
import java.util.List;
-import static cn.hutool.core.util.RandomUtil.randomEle;
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime;
+import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
+import static java.util.Collections.singleton;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@Import(JobLogServiceImpl.class)
-public class JobLogServiceTest extends BaseDbUnitTest {
+public class JobLogServiceImplTest extends BaseDbUnitTest {
@Resource
private JobLogServiceImpl jobLogService;
@@ -31,66 +32,103 @@ public class JobLogServiceTest extends BaseDbUnitTest {
private JobLogMapper jobLogMapper;
@Test
- public void testCreateJobLog_success() {
+ public void testCreateJobLog() {
// 准备参数
- JobLogDO reqVO = randomPojo(JobLogDO.class, o -> {
- o.setExecuteIndex(1);
- });
+ JobLogDO reqVO = randomPojo(JobLogDO.class, o -> o.setExecuteIndex(1));
+
// 调用
- Long jobLogId = jobLogService.createJobLog(reqVO.getJobId(), reqVO.getBeginTime(), reqVO.getHandlerName(), reqVO.getHandlerParam(), reqVO.getExecuteIndex());
+ Long id = jobLogService.createJobLog(reqVO.getJobId(), reqVO.getBeginTime(),
+ reqVO.getHandlerName(), reqVO.getHandlerParam(), reqVO.getExecuteIndex());
// 断言
- assertNotNull(jobLogId);
+ assertNotNull(id);
// 校验记录的属性是否正确
- JobLogDO job = jobLogMapper.selectById(jobLogId);
+ JobLogDO job = jobLogMapper.selectById(id);
assertEquals(JobLogStatusEnum.RUNNING.getStatus(), job.getStatus());
}
@Test
public void testUpdateJobLogResultAsync_success() {
- // 准备参数
- JobLogDO reqVO = randomPojo(JobLogDO.class, o -> {
+ // mock 数据
+ JobLogDO log = randomPojo(JobLogDO.class, o -> {
o.setExecuteIndex(1);
+ o.setStatus(JobLogStatusEnum.RUNNING.getStatus());
});
- JobLogDO log = JobLogDO.builder().jobId(reqVO.getJobId()).handlerName(reqVO.getHandlerName()).handlerParam(reqVO.getHandlerParam()).executeIndex(reqVO.getExecuteIndex())
- .beginTime(reqVO.getBeginTime()).status(JobLogStatusEnum.RUNNING.getStatus()).build();
jobLogMapper.insert(log);
- // 调用
- jobLogService.updateJobLogResultAsync(log.getId(), reqVO.getBeginTime(), reqVO.getDuration(), true,reqVO.getResult());
- // 校验记录的属性是否正确
- JobLogDO job = jobLogMapper.selectById(log.getId());
- assertEquals(JobLogStatusEnum.SUCCESS.getStatus(), job.getStatus());
+ // 准备参数
+ Long logId = log.getId();
+ LocalDateTime endTime = randomLocalDateTime();
+ Integer duration = randomInteger();
+ boolean success = true;
+ String result = randomString();
// 调用
- jobLogService.updateJobLogResultAsync(log.getId(), reqVO.getBeginTime(), reqVO.getDuration(), false,reqVO.getResult());
+ jobLogService.updateJobLogResultAsync(logId, endTime, duration, success, result);
// 校验记录的属性是否正确
- JobLogDO job2 = jobLogMapper.selectById(log.getId());
- assertEquals(JobLogStatusEnum.FAILURE.getStatus(), job2.getStatus());
+ JobLogDO dbLog = jobLogMapper.selectById(log.getId());
+ assertEquals(endTime, dbLog.getEndTime());
+ assertEquals(duration, dbLog.getDuration());
+ assertEquals(JobLogStatusEnum.SUCCESS.getStatus(), dbLog.getStatus());
+ assertEquals(result, dbLog.getResult());
}
@Test
- public void testGetJobLogListByIds_success() {
+ public void testUpdateJobLogResultAsync_failure() {
// mock 数据
- JobLogDO dbJobLog = randomPojo(JobLogDO.class, o -> {
+ JobLogDO log = randomPojo(JobLogDO.class, o -> {
o.setExecuteIndex(1);
- o.setStatus(randomEle(JobLogStatusEnum.values()).getStatus()); // 保证 status 的范围
+ o.setStatus(JobLogStatusEnum.RUNNING.getStatus());
});
- JobLogDO cloneJobLog = ObjectUtils.cloneIgnoreId(dbJobLog, o -> o.setHandlerName(randomString()));
+ jobLogMapper.insert(log);
+ // 准备参数
+ Long logId = log.getId();
+ LocalDateTime endTime = randomLocalDateTime();
+ Integer duration = randomInteger();
+ boolean success = false;
+ String result = randomString();
+
+ // 调用
+ jobLogService.updateJobLogResultAsync(logId, endTime, duration, success, result);
+ // 校验记录的属性是否正确
+ JobLogDO dbLog = jobLogMapper.selectById(log.getId());
+ assertEquals(endTime, dbLog.getEndTime());
+ assertEquals(duration, dbLog.getDuration());
+ assertEquals(JobLogStatusEnum.FAILURE.getStatus(), dbLog.getStatus());
+ assertEquals(result, dbLog.getResult());
+ }
+
+ @Test
+ public void testGetJobLog() {
+ // mock 数据
+ JobLogDO dbJobLog = randomPojo(JobLogDO.class, o -> o.setExecuteIndex(1));
+ jobLogMapper.insert(dbJobLog);
+ // 准备参数
+ Long id = dbJobLog.getId();
+
+ // 调用
+ JobLogDO jobLog = jobLogService.getJobLog(id);
+ // 断言
+ assertPojoEquals(dbJobLog, jobLog);
+ }
+
+ @Test
+ public void testGetJobLogList() {
+ // mock 数据
+ JobLogDO dbJobLog = randomPojo(JobLogDO.class, o -> o.setExecuteIndex(1));
jobLogMapper.insert(dbJobLog);
// 测试 handlerName 不匹配
- jobLogMapper.insert(cloneJobLog);
+ jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> {}));
// 准备参数
- ArrayList ids = new ArrayList<>();
- ids.add(dbJobLog.getId());
- ids.add(cloneJobLog.getId());
+ Collection ids = singleton(dbJobLog.getId());
+
// 调用
List list = jobLogService.getJobLogList(ids);
// 断言
- assertEquals(2, list.size());
+ assertEquals(1, list.size());
assertPojoEquals(dbJobLog, list.get(0));
}
@Test
- public void testGetJobPage_success() {
+ public void testGetJobPage() {
// mock 数据
JobLogDO dbJobLog = randomPojo(JobLogDO.class, o -> {
o.setExecuteIndex(1);
@@ -101,15 +139,15 @@ public class JobLogServiceTest extends BaseDbUnitTest {
});
jobLogMapper.insert(dbJobLog);
// 测试 jobId 不匹配
- jobLogMapper.insert(ObjectUtils.cloneIgnoreId(dbJobLog, o -> o.setJobId(randomLongId())));
+ jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setJobId(randomLongId())));
// 测试 handlerName 不匹配
- jobLogMapper.insert(ObjectUtils.cloneIgnoreId(dbJobLog, o -> o.setHandlerName(randomString())));
+ jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setHandlerName(randomString())));
// 测试 beginTime 不匹配
- jobLogMapper.insert(ObjectUtils.cloneIgnoreId(dbJobLog, o -> o.setBeginTime(buildTime(2021, 1, 7))));
+ jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setBeginTime(buildTime(2021, 1, 7))));
// 测试 endTime 不匹配
- jobLogMapper.insert(ObjectUtils.cloneIgnoreId(dbJobLog, o -> o.setEndTime(buildTime(2021, 1, 9))));
+ jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setEndTime(buildTime(2021, 1, 9))));
// 测试 status 不匹配
- jobLogMapper.insert(ObjectUtils.cloneIgnoreId(dbJobLog, o -> o.setStatus(JobLogStatusEnum.FAILURE.getStatus())));
+ jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setStatus(JobLogStatusEnum.FAILURE.getStatus())));
// 准备参数
JobLogPageReqVO reqVo = new JobLogPageReqVO();
reqVo.setJobId(dbJobLog.getJobId());
@@ -117,6 +155,7 @@ public class JobLogServiceTest extends BaseDbUnitTest {
reqVo.setBeginTime(dbJobLog.getBeginTime());
reqVo.setEndTime(dbJobLog.getEndTime());
reqVo.setStatus(JobLogStatusEnum.SUCCESS.getStatus());
+
// 调用
PageResult pageResult = jobLogService.getJobLogPage(reqVo);
// 断言
@@ -126,7 +165,7 @@ public class JobLogServiceTest extends BaseDbUnitTest {
}
@Test
- public void testGetJobListForExport_success() {
+ public void testGetJobList_export() {
// mock 数据
JobLogDO dbJobLog = randomPojo(JobLogDO.class, o -> {
o.setExecuteIndex(1);
@@ -137,15 +176,15 @@ public class JobLogServiceTest extends BaseDbUnitTest {
});
jobLogMapper.insert(dbJobLog);
// 测试 jobId 不匹配
- jobLogMapper.insert(ObjectUtils.cloneIgnoreId(dbJobLog, o -> o.setJobId(randomLongId())));
+ jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setJobId(randomLongId())));
// 测试 handlerName 不匹配
- jobLogMapper.insert(ObjectUtils.cloneIgnoreId(dbJobLog, o -> o.setHandlerName(randomString())));
+ jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setHandlerName(randomString())));
// 测试 beginTime 不匹配
- jobLogMapper.insert(ObjectUtils.cloneIgnoreId(dbJobLog, o -> o.setBeginTime(buildTime(2021, 1, 7))));
+ jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setBeginTime(buildTime(2021, 1, 7))));
// 测试 endTime 不匹配
- jobLogMapper.insert(ObjectUtils.cloneIgnoreId(dbJobLog, o -> o.setEndTime(buildTime(2021, 1, 9))));
+ jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setEndTime(buildTime(2021, 1, 9))));
// 测试 status 不匹配
- jobLogMapper.insert(ObjectUtils.cloneIgnoreId(dbJobLog, o -> o.setStatus(JobLogStatusEnum.FAILURE.getStatus())));
+ jobLogMapper.insert(cloneIgnoreId(dbJobLog, o -> o.setStatus(JobLogStatusEnum.FAILURE.getStatus())));
// 准备参数
JobLogExportReqVO reqVo = new JobLogExportReqVO();
reqVo.setJobId(dbJobLog.getJobId());
@@ -153,6 +192,7 @@ public class JobLogServiceTest extends BaseDbUnitTest {
reqVo.setBeginTime(dbJobLog.getBeginTime());
reqVo.setEndTime(dbJobLog.getEndTime());
reqVo.setStatus(JobLogStatusEnum.SUCCESS.getStatus());
+
// 调用
List list = jobLogService.getJobLogList(reqVo);
// 断言
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/job/JobServiceTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/job/JobServiceImplTest.java
similarity index 60%
rename from yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/job/JobServiceTest.java
rename to yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/job/JobServiceImplTest.java
index 1cfcae998..f10c40365 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/job/JobServiceTest.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/job/JobServiceImplTest.java
@@ -1,14 +1,12 @@
package cn.iocoder.yudao.module.infra.service.job;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
import cn.iocoder.yudao.framework.quartz.core.scheduler.SchedulerManager;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobCreateReqVO;
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobExportReqVO;
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobPageReqVO;
import cn.iocoder.yudao.module.infra.controller.admin.job.vo.job.JobUpdateReqVO;
-import cn.iocoder.yudao.module.infra.convert.job.JobConvert;
import cn.iocoder.yudao.module.infra.dal.dataobject.job.JobDO;
import cn.iocoder.yudao.module.infra.dal.mysql.job.JobMapper;
import cn.iocoder.yudao.module.infra.enums.job.JobStatusEnum;
@@ -18,22 +16,23 @@ import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Import;
import javax.annotation.Resource;
-import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import static cn.hutool.core.util.RandomUtil.randomEle;
+import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomString;
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*;
+import static java.util.Collections.singletonList;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@Import(JobServiceImpl.class)
-public class JobServiceTest extends BaseDbUnitTest {
+public class JobServiceImplTest extends BaseDbUnitTest {
@Resource
private JobServiceImpl jobService;
@@ -46,6 +45,7 @@ public class JobServiceTest extends BaseDbUnitTest {
public void testCreateJob_cronExpressionValid() {
// 准备参数。Cron 表达式为 String 类型,默认随机字符串。
JobCreateReqVO reqVO = randomPojo(JobCreateReqVO.class);
+
// 调用,并断言异常
assertServiceException(() -> jobService.createJob(reqVO), JOB_CRON_EXPRESSION_VALID);
}
@@ -54,6 +54,7 @@ public class JobServiceTest extends BaseDbUnitTest {
public void testCreateJob_jobHandlerExists() throws SchedulerException {
// 准备参数 指定 Cron 表达式
JobCreateReqVO reqVO = randomPojo(JobCreateReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *"));
+
// 调用
jobService.createJob(reqVO);
// 调用,并断言异常
@@ -64,6 +65,7 @@ public class JobServiceTest extends BaseDbUnitTest {
public void testCreateJob_success() throws SchedulerException {
// 准备参数 指定 Cron 表达式
JobCreateReqVO reqVO = randomPojo(JobCreateReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *"));
+
// 调用
Long jobId = jobService.createJob(reqVO);
// 断言
@@ -73,14 +75,15 @@ public class JobServiceTest extends BaseDbUnitTest {
assertPojoEquals(reqVO, job);
assertEquals(JobStatusEnum.NORMAL.getStatus(), job.getStatus());
// 校验调用
- verify(schedulerManager, times(1)).addJob(eq(job.getId()), eq(job.getHandlerName()), eq(job.getHandlerParam()), eq(job.getCronExpression()),
- eq(reqVO.getRetryCount()), eq(reqVO.getRetryInterval()));
+ verify(schedulerManager).addJob(eq(job.getId()), eq(job.getHandlerName()), eq(job.getHandlerParam()),
+ eq(job.getCronExpression()), eq(reqVO.getRetryCount()), eq(reqVO.getRetryInterval()));
}
@Test
public void testUpdateJob_jobNotExists(){
// 准备参数
JobUpdateReqVO reqVO = randomPojo(JobUpdateReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *"));
+
// 调用,并断言异常
assertServiceException(() -> jobService.updateJob(reqVO), JOB_NOT_EXISTS);
}
@@ -88,150 +91,136 @@ public class JobServiceTest extends BaseDbUnitTest {
@Test
public void testUpdateJob_onlyNormalStatus(){
// mock 数据
- JobCreateReqVO createReqVO = randomPojo(JobCreateReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *"));
- JobDO job = JobConvert.INSTANCE.convert(createReqVO);
- job.setStatus(JobStatusEnum.INIT.getStatus());
- fillJobMonitorTimeoutEmpty(job);
+ JobDO job = randomPojo(JobDO.class, o -> o.setStatus(JobStatusEnum.INIT.getStatus()));
jobMapper.insert(job);
// 准备参数
JobUpdateReqVO updateReqVO = randomPojo(JobUpdateReqVO.class, o -> {
o.setId(job.getId());
- o.setName(createReqVO.getName());
- o.setCronExpression(createReqVO.getCronExpression());
+ o.setCronExpression("0 0/1 * * * ? *");
});
+
// 调用,并断言异常
- assertServiceException(() -> jobService.updateJob(updateReqVO), JOB_UPDATE_ONLY_NORMAL_STATUS);
+ assertServiceException(() -> jobService.updateJob(updateReqVO),
+ JOB_UPDATE_ONLY_NORMAL_STATUS);
}
@Test
public void testUpdateJob_success() throws SchedulerException {
// mock 数据
- JobCreateReqVO createReqVO = randomPojo(JobCreateReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *"));
- JobDO job = JobConvert.INSTANCE.convert(createReqVO);
- job.setStatus(JobStatusEnum.NORMAL.getStatus());
- fillJobMonitorTimeoutEmpty(job);
+ JobDO job = randomPojo(JobDO.class, o -> o.setStatus(JobStatusEnum.NORMAL.getStatus()));
jobMapper.insert(job);
// 准备参数
JobUpdateReqVO updateReqVO = randomPojo(JobUpdateReqVO.class, o -> {
o.setId(job.getId());
- o.setName(createReqVO.getName());
- o.setCronExpression(createReqVO.getCronExpression());
+ o.setCronExpression("0 0/1 * * * ? *");
});
+
// 调用
jobService.updateJob(updateReqVO);
// 校验记录的属性是否正确
JobDO updateJob = jobMapper.selectById(updateReqVO.getId());
assertPojoEquals(updateReqVO, updateJob);
// 校验调用
- verify(schedulerManager, times(1)).updateJob(eq(job.getHandlerName()), eq(updateReqVO.getHandlerParam()), eq(updateReqVO.getCronExpression()),
- eq(updateReqVO.getRetryCount()), eq(updateReqVO.getRetryInterval()));
+ verify(schedulerManager).updateJob(eq(job.getHandlerName()), eq(updateReqVO.getHandlerParam()),
+ eq(updateReqVO.getCronExpression()), eq(updateReqVO.getRetryCount()), eq(updateReqVO.getRetryInterval()));
}
@Test
public void testUpdateJobStatus_changeStatusInvalid() {
// 调用,并断言异常
- assertServiceException(() -> jobService.updateJobStatus(1L, JobStatusEnum.INIT.getStatus()), JOB_CHANGE_STATUS_INVALID);
+ assertServiceException(() -> jobService.updateJobStatus(1L, JobStatusEnum.INIT.getStatus()),
+ JOB_CHANGE_STATUS_INVALID);
}
@Test
public void testUpdateJobStatus_changeStatusEquals() {
// mock 数据
- JobCreateReqVO createReqVO = randomPojo(JobCreateReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *"));
- JobDO job = JobConvert.INSTANCE.convert(createReqVO);
- job.setStatus(JobStatusEnum.NORMAL.getStatus());
- fillJobMonitorTimeoutEmpty(job);
+ JobDO job = randomPojo(JobDO.class, o -> o.setStatus(JobStatusEnum.NORMAL.getStatus()));
jobMapper.insert(job);
+
// 调用,并断言异常
- assertServiceException(() -> jobService.updateJobStatus(job.getId(), job.getStatus()), JOB_CHANGE_STATUS_EQUALS);
+ assertServiceException(() -> jobService.updateJobStatus(job.getId(), job.getStatus()),
+ JOB_CHANGE_STATUS_EQUALS);
}
@Test
- public void testUpdateJobStatus_NormalToStop_success() throws SchedulerException {
+ public void testUpdateJobStatus_stopSuccess() throws SchedulerException {
// mock 数据
- JobCreateReqVO createReqVO = randomPojo(JobCreateReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *"));
- JobDO job = JobConvert.INSTANCE.convert(createReqVO);
- job.setStatus(JobStatusEnum.NORMAL.getStatus());
- fillJobMonitorTimeoutEmpty(job);
+ JobDO job = randomPojo(JobDO.class, o -> o.setStatus(JobStatusEnum.NORMAL.getStatus()));
jobMapper.insert(job);
+
// 调用
jobService.updateJobStatus(job.getId(), JobStatusEnum.STOP.getStatus());
// 校验记录的属性是否正确
- JobDO updateJob = jobMapper.selectById(job.getId());
- assertEquals(JobStatusEnum.STOP.getStatus(), updateJob.getStatus());
+ JobDO dbJob = jobMapper.selectById(job.getId());
+ assertEquals(JobStatusEnum.STOP.getStatus(), dbJob.getStatus());
// 校验调用
- verify(schedulerManager, times(1)).pauseJob(eq(job.getHandlerName()));
+ verify(schedulerManager).pauseJob(eq(job.getHandlerName()));
}
@Test
- public void testUpdateJobStatus_StopToNormal_success() throws SchedulerException {
+ public void testUpdateJobStatus_normalSuccess() throws SchedulerException {
// mock 数据
- JobCreateReqVO createReqVO = randomPojo(JobCreateReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *"));
- JobDO job = JobConvert.INSTANCE.convert(createReqVO);
- job.setStatus(JobStatusEnum.STOP.getStatus());
- fillJobMonitorTimeoutEmpty(job);
+ JobDO job = randomPojo(JobDO.class, o -> o.setStatus(JobStatusEnum.STOP.getStatus()));
jobMapper.insert(job);
+
// 调用
jobService.updateJobStatus(job.getId(), JobStatusEnum.NORMAL.getStatus());
// 校验记录的属性是否正确
- JobDO updateJob = jobMapper.selectById(job.getId());
- assertEquals(JobStatusEnum.NORMAL.getStatus(), updateJob.getStatus());
+ JobDO dbJob = jobMapper.selectById(job.getId());
+ assertEquals(JobStatusEnum.NORMAL.getStatus(), dbJob.getStatus());
// 校验调用
- verify(schedulerManager, times(1)).resumeJob(eq(job.getHandlerName()));
+ verify(schedulerManager).resumeJob(eq(job.getHandlerName()));
}
@Test
public void testTriggerJob_success() throws SchedulerException {
// mock 数据
- JobCreateReqVO createReqVO = randomPojo(JobCreateReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *"));
- JobDO job = JobConvert.INSTANCE.convert(createReqVO);
- job.setStatus(JobStatusEnum.NORMAL.getStatus());
- fillJobMonitorTimeoutEmpty(job);
+ JobDO job = randomPojo(JobDO.class);
jobMapper.insert(job);
+
// 调用
jobService.triggerJob(job.getId());
// 校验调用
- verify(schedulerManager, times(1)).triggerJob(eq(job.getId()), eq(job.getHandlerName()), eq(job.getHandlerParam()));
+ verify(schedulerManager).triggerJob(eq(job.getId()),
+ eq(job.getHandlerName()), eq(job.getHandlerParam()));
}
@Test
public void testDeleteJob_success() throws SchedulerException {
// mock 数据
- JobCreateReqVO createReqVO = randomPojo(JobCreateReqVO.class, o -> o.setCronExpression("0 0/1 * * * ? *"));
- JobDO job = JobConvert.INSTANCE.convert(createReqVO);
- job.setStatus(JobStatusEnum.NORMAL.getStatus());
- fillJobMonitorTimeoutEmpty(job);
+ JobDO job = randomPojo(JobDO.class);
jobMapper.insert(job);
- // 调用 UPDATE inf_job SET deleted=1 WHERE id=? AND deleted=0
+
+ // 调用
jobService.deleteJob(job.getId());
- // 校验数据不存在了 WHERE id=? AND deleted=0 查询为空正常
+ // 校验不存在
assertNull(jobMapper.selectById(job.getId()));
// 校验调用
- verify(schedulerManager, times(1)).deleteJob(eq(job.getHandlerName()));
+ verify(schedulerManager).deleteJob(eq(job.getHandlerName()));
}
@Test
- public void testGetJobListByIds_success() {
+ public void testGetJobList() {
// mock 数据
JobDO dbJob = randomPojo(JobDO.class, o -> {
o.setStatus(randomEle(JobStatusEnum.values()).getStatus()); // 保证 status 的范围
});
- JobDO cloneJob = ObjectUtils.cloneIgnoreId(dbJob, o -> o.setHandlerName(randomString()));
jobMapper.insert(dbJob);
- // 测试 handlerName 不匹配
- jobMapper.insert(cloneJob);
+ // 测试 id 不匹配
+ jobMapper.insert(cloneIgnoreId(dbJob, o -> {}));
+
// 准备参数
- ArrayList ids = new ArrayList<>();
- ids.add(dbJob.getId());
- ids.add(cloneJob.getId());
+ Collection ids = singletonList(dbJob.getId());
// 调用
List list = jobService.getJobList(ids);
// 断言
- assertEquals(2, list.size());
+ assertEquals(1, list.size());
assertPojoEquals(dbJob, list.get(0));
}
@Test
- public void testGetJobPage_success() {
+ public void testGetJobPage() {
// mock 数据
JobDO dbJob = randomPojo(JobDO.class, o -> {
o.setName("定时任务测试");
@@ -240,16 +229,17 @@ public class JobServiceTest extends BaseDbUnitTest {
});
jobMapper.insert(dbJob);
// 测试 name 不匹配
- jobMapper.insert(ObjectUtils.cloneIgnoreId(dbJob, o -> o.setName("土豆")));
+ jobMapper.insert(cloneIgnoreId(dbJob, o -> o.setName("土豆")));
// 测试 status 不匹配
- jobMapper.insert(ObjectUtils.cloneIgnoreId(dbJob, o -> o.setStatus(JobStatusEnum.NORMAL.getStatus())));
+ jobMapper.insert(cloneIgnoreId(dbJob, o -> o.setStatus(JobStatusEnum.NORMAL.getStatus())));
// 测试 handlerName 不匹配
- jobMapper.insert(ObjectUtils.cloneIgnoreId(dbJob, o -> o.setHandlerName(randomString())));
+ jobMapper.insert(cloneIgnoreId(dbJob, o -> o.setHandlerName(randomString())));
// 准备参数
JobPageReqVO reqVo = new JobPageReqVO();
reqVo.setName("定时");
reqVo.setStatus(JobStatusEnum.INIT.getStatus());
reqVo.setHandlerName("单元");
+
// 调用
PageResult pageResult = jobService.getJobPage(reqVo);
// 断言
@@ -259,7 +249,7 @@ public class JobServiceTest extends BaseDbUnitTest {
}
@Test
- public void testGetJobListForExport_success() {
+ public void testGetJobList_export() {
// mock 数据
JobDO dbJob = randomPojo(JobDO.class, o -> {
o.setName("定时任务测试");
@@ -268,16 +258,17 @@ public class JobServiceTest extends BaseDbUnitTest {
});
jobMapper.insert(dbJob);
// 测试 name 不匹配
- jobMapper.insert(ObjectUtils.cloneIgnoreId(dbJob, o -> o.setName("土豆")));
+ jobMapper.insert(cloneIgnoreId(dbJob, o -> o.setName("土豆")));
// 测试 status 不匹配
- jobMapper.insert(ObjectUtils.cloneIgnoreId(dbJob, o -> o.setStatus(JobStatusEnum.NORMAL.getStatus())));
+ jobMapper.insert(cloneIgnoreId(dbJob, o -> o.setStatus(JobStatusEnum.NORMAL.getStatus())));
// 测试 handlerName 不匹配
- jobMapper.insert(ObjectUtils.cloneIgnoreId(dbJob, o -> o.setHandlerName(randomString())));
+ jobMapper.insert(cloneIgnoreId(dbJob, o -> o.setHandlerName(randomString())));
// 准备参数
JobExportReqVO reqVo = new JobExportReqVO();
reqVo.setName("定时");
reqVo.setStatus(JobStatusEnum.INIT.getStatus());
reqVo.setHandlerName("单元");
+
// 调用
List list = jobService.getJobList(reqVo);
// 断言
@@ -285,10 +276,15 @@ public class JobServiceTest extends BaseDbUnitTest {
assertPojoEquals(dbJob, list.get(0));
}
- private static void fillJobMonitorTimeoutEmpty(JobDO job) {
- if (job.getMonitorTimeout() == null) {
- job.setMonitorTimeout(0);
- }
+ @Test
+ public void testGetJob() {
+ // mock 数据
+ JobDO dbJob = randomPojo(JobDO.class);
+ jobMapper.insert(dbJob);
+ // 调用
+ JobDO job = jobService.getJob(dbJob.getId());
+ // 断言
+ assertPojoEquals(dbJob, job);
}
}
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java
index b650fb603..8ff2dd9bf 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java
@@ -1,12 +1,9 @@
package cn.iocoder.yudao.module.infra.service.logger;
-import cn.hutool.core.util.RandomUtil;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
-import cn.iocoder.yudao.framework.test.core.util.RandomUtils;
import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExportReqVO;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO;
@@ -16,149 +13,121 @@ import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Import;
import javax.annotation.Resource;
-import java.time.LocalDateTime;
import java.util.List;
+import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime;
+import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
+import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
@Import(ApiAccessLogServiceImpl.class)
public class ApiAccessLogServiceImplTest extends BaseDbUnitTest {
@Resource
- private ApiAccessLogService apiAccessLogService;
+ private ApiAccessLogServiceImpl apiAccessLogService;
@Resource
private ApiAccessLogMapper apiAccessLogMapper;
@Test
public void testGetApiAccessLogPage() {
- // 构造测试数据
- long userId = 2233L;
- int userType = UserTypeEnum.ADMIN.getValue();
- String applicationName = "yudao-test";
- String requestUrl = "foo";
- LocalDateTime beginTime = buildTime(2021, 3, 13);
- int duration = 1000;
- int resultCode = GlobalErrorCodeConstants.SUCCESS.getCode();
-
- ApiAccessLogDO infApiAccessLogDO = RandomUtils.randomPojo(ApiAccessLogDO.class, dto -> {
- dto.setUserId(userId);
- dto.setUserType(userType);
- dto.setApplicationName(applicationName);
- dto.setRequestUrl(requestUrl);
- dto.setBeginTime(beginTime);
- dto.setDuration(duration);
- dto.setResultCode(resultCode);
+ ApiAccessLogDO apiAccessLogDO = randomPojo(ApiAccessLogDO.class, o -> {
+ o.setUserId(2233L);
+ o.setUserType(UserTypeEnum.ADMIN.getValue());
+ o.setApplicationName("yudao-test");
+ o.setRequestUrl("foo");
+ o.setBeginTime(buildTime(2021, 3, 13));
+ o.setDuration(1000);
+ o.setResultCode(GlobalErrorCodeConstants.SUCCESS.getCode());
});
- apiAccessLogMapper.insert(infApiAccessLogDO);
-
- // 下面几个都是不匹配的数据
- // userId 不同的
- apiAccessLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiAccessLogDO, logDO -> logDO.setUserId(3344L)));
- // userType
- apiAccessLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiAccessLogDO, logDO -> logDO.setUserType(UserTypeEnum.MEMBER.getValue())));
- // applicationName 不同的
- apiAccessLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiAccessLogDO, logDO -> logDO.setApplicationName("test")));
- // requestUrl 不同的
- apiAccessLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiAccessLogDO, logDO -> logDO.setRequestUrl("bar")));
- // 构造一个早期时间 2021-02-06 00:00:00
- apiAccessLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiAccessLogDO, logDO -> logDO.setBeginTime(buildTime(2021, 2, 6))));
- // duration 不同的
- apiAccessLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiAccessLogDO, logDO -> logDO.setDuration(100)));
- // resultCode 不同的
- apiAccessLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiAccessLogDO, logDO -> logDO.setResultCode(2)));
-
- // 构造调用参数
+ apiAccessLogMapper.insert(apiAccessLogDO);
+ // 测试 userId 不匹配
+ apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setUserId(3344L)));
+ // 测试 userType 不匹配
+ apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setUserType(UserTypeEnum.MEMBER.getValue())));
+ // 测试 applicationName 不匹配
+ apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setApplicationName("test")));
+ // 测试 requestUrl 不匹配
+ apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setRequestUrl("bar")));
+ // 测试 beginTime 不匹配:构造一个早期时间 2021-02-06 00:00:00
+ apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setBeginTime(buildTime(2021, 2, 6))));
+ // 测试 duration 不匹配
+ apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setDuration(100)));
+ // 测试 resultCode 不匹配
+ apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setResultCode(2)));
+ // 准备参数
ApiAccessLogPageReqVO reqVO = new ApiAccessLogPageReqVO();
- reqVO.setUserId(userId);
- reqVO.setUserType(userType);
- reqVO.setApplicationName(applicationName);
- reqVO.setRequestUrl(requestUrl);
- reqVO.setBeginTime((new LocalDateTime[]{buildTime(2021, 3, 12),buildTime(2021, 3, 14)}));
- reqVO.setDuration(duration);
- reqVO.setResultCode(resultCode);
+ reqVO.setUserId(2233L);
+ reqVO.setUserType(UserTypeEnum.ADMIN.getValue());
+ reqVO.setApplicationName("yudao-test");
+ reqVO.setRequestUrl("foo");
+ reqVO.setBeginTime(buildBetweenTime(2021, 3, 13, 2021, 3, 13));
+ reqVO.setDuration(1000);
+ reqVO.setResultCode(GlobalErrorCodeConstants.SUCCESS.getCode());
- // 调用service方法
+ // 调用
PageResult pageResult = apiAccessLogService.getApiAccessLogPage(reqVO);
-
// 断言,只查到了一条符合条件的
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
- assertPojoEquals(infApiAccessLogDO, pageResult.getList().get(0));
+ assertPojoEquals(apiAccessLogDO, pageResult.getList().get(0));
}
@Test
public void testGetApiAccessLogList() {
- // 构造测试数据
- long userId = 2233L;
- int userType = UserTypeEnum.ADMIN.getValue();
- String applicationName = "yudao-test";
- String requestUrl = "foo";
- LocalDateTime beginTime = buildTime(2021, 3, 13);
- int duration = 1000;
- int resultCode = GlobalErrorCodeConstants.SUCCESS.getCode();
-
- ApiAccessLogDO infApiAccessLogDO = RandomUtils.randomPojo(ApiAccessLogDO.class, dto -> {
- dto.setUserId(userId);
- dto.setUserType(userType);
- dto.setApplicationName(applicationName);
- dto.setRequestUrl(requestUrl);
- dto.setBeginTime(beginTime);
- dto.setDuration(duration);
- dto.setResultCode(resultCode);
+ ApiAccessLogDO apiAccessLogDO = randomPojo(ApiAccessLogDO.class, o -> {
+ o.setUserId(2233L);
+ o.setUserType(UserTypeEnum.ADMIN.getValue());
+ o.setApplicationName("yudao-test");
+ o.setRequestUrl("foo");
+ o.setBeginTime(buildTime(2021, 3, 13));
+ o.setDuration(1000);
+ o.setResultCode(GlobalErrorCodeConstants.SUCCESS.getCode());
});
- apiAccessLogMapper.insert(infApiAccessLogDO);
-
- // 下面几个都是不匹配的数据
- // userId 不同的
- apiAccessLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiAccessLogDO, logDO -> logDO.setUserId(3344L)));
- // userType
- apiAccessLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiAccessLogDO, logDO -> logDO.setUserType(UserTypeEnum.MEMBER.getValue())));
- // applicationName 不同的
- apiAccessLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiAccessLogDO, logDO -> logDO.setApplicationName("test")));
- // requestUrl 不同的
- apiAccessLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiAccessLogDO, logDO -> logDO.setRequestUrl("bar")));
- // 构造一个早期时间 2021-02-06 00:00:00
- apiAccessLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiAccessLogDO, logDO -> logDO.setBeginTime(buildTime(2021, 2, 6))));
- // duration 不同的
- apiAccessLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiAccessLogDO, logDO -> logDO.setDuration(100)));
- // resultCode 不同的
- apiAccessLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiAccessLogDO, logDO -> logDO.setResultCode(2)));
-
- // 构造调用参数
+ apiAccessLogMapper.insert(apiAccessLogDO);
+ // 测试 userId 不匹配
+ apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setUserId(3344L)));
+ // 测试 userType 不匹配
+ apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setUserType(UserTypeEnum.MEMBER.getValue())));
+ // 测试 applicationName 不匹配
+ apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setApplicationName("test")));
+ // 测试 requestUrl 不匹配
+ apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setRequestUrl("bar")));
+ // 测试 beginTime 不匹配:构造一个早期时间 2021-02-06 00:00:00
+ apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setBeginTime(buildTime(2021, 2, 6))));
+ // 测试 duration 不匹配
+ apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setDuration(100)));
+ // 测试 resultCode 不匹配
+ apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setResultCode(2)));
+ // 准备参数
ApiAccessLogExportReqVO reqVO = new ApiAccessLogExportReqVO();
- reqVO.setUserId(userId);
- reqVO.setUserType(userType);
- reqVO.setApplicationName(applicationName);
- reqVO.setRequestUrl(requestUrl);
- reqVO.setBeginTime((new LocalDateTime[]{buildTime(2021, 3, 12),buildTime(2021, 3, 14)}));
- reqVO.setDuration(duration);
- reqVO.setResultCode(resultCode);
+ reqVO.setUserId(2233L);
+ reqVO.setUserType(UserTypeEnum.ADMIN.getValue());
+ reqVO.setApplicationName("yudao-test");
+ reqVO.setRequestUrl("foo");
+ reqVO.setBeginTime(buildBetweenTime(2021, 3, 13, 2021, 3, 13));
+ reqVO.setDuration(1000);
+ reqVO.setResultCode(GlobalErrorCodeConstants.SUCCESS.getCode());
- // 调用service方法
+ // 调用
List list = apiAccessLogService.getApiAccessLogList(reqVO);
-
// 断言,只查到了一条符合条件的
assertEquals(1, list.size());
- assertPojoEquals(infApiAccessLogDO, list.get(0));
+ assertPojoEquals(apiAccessLogDO, list.get(0));
}
@Test
- public void testCreateApiAccessLogAsync() {
+ public void testCreateApiAccessLog() {
// 准备参数
- ApiAccessLogCreateReqDTO createDTO = RandomUtils.randomPojo(ApiAccessLogCreateReqDTO.class,
- dto -> dto.setUserType(RandomUtil.randomEle(UserTypeEnum.values()).getValue()));
+ ApiAccessLogCreateReqDTO createDTO = randomPojo(ApiAccessLogCreateReqDTO.class);
// 调用
apiAccessLogService.createApiAccessLog(createDTO);
// 断言
- ApiAccessLogDO infApiAccessLogDO = apiAccessLogMapper.selectOne(null);
- assertNotNull(infApiAccessLogDO);
- assertPojoEquals(createDTO, infApiAccessLogDO);
+ ApiAccessLogDO apiAccessLogDO = apiAccessLogMapper.selectOne(null);
+ assertPojoEquals(createDTO, apiAccessLogDO);
}
-
}
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java
index 4e35ba7ea..86e55f5d1 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java
@@ -1,28 +1,28 @@
package cn.iocoder.yudao.module.infra.service.logger;
-import cn.hutool.core.util.RandomUtil;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
-import cn.iocoder.yudao.framework.test.core.util.RandomUtils;
import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExportReqVO;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO;
import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO;
import cn.iocoder.yudao.module.infra.dal.mysql.logger.ApiErrorLogMapper;
import cn.iocoder.yudao.module.infra.enums.logger.ApiErrorLogProcessStatusEnum;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Import;
import javax.annotation.Resource;
-import java.time.LocalDateTime;
import java.util.List;
+import static cn.hutool.core.util.RandomUtil.randomEle;
+import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime;
+import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
+import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
+import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.API_ERROR_LOG_NOT_FOUND;
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.API_ERROR_LOG_PROCESSED;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -35,161 +35,150 @@ public class ApiErrorLogServiceImplTest extends BaseDbUnitTest {
private ApiErrorLogServiceImpl apiErrorLogService;
@Resource
- private ApiErrorLogMapper infApiErrorLogMapper;
+ private ApiErrorLogMapper apiErrorLogMapper;
@Test
public void testGetApiErrorLogPage() {
- // 构造测试数据
- long userId = 2233L;
- int userType = UserTypeEnum.ADMIN.getValue();
- String applicationName = "yudao-test";
- String requestUrl = "foo";
- LocalDateTime beginTime = buildTime(2021, 3, 13);
- int progressStatus = ApiErrorLogProcessStatusEnum.INIT.getStatus();
-
- ApiErrorLogDO infApiErrorLogDO = RandomUtils.randomPojo(ApiErrorLogDO.class, logDO -> {
- logDO.setUserId(userId);
- logDO.setUserType(userType);
- logDO.setApplicationName(applicationName);
- logDO.setRequestUrl(requestUrl);
- logDO.setExceptionTime(beginTime);
- logDO.setProcessStatus(progressStatus);
+ // mock 数据
+ ApiErrorLogDO apiErrorLogDO = randomPojo(ApiErrorLogDO.class, o -> {
+ o.setUserId(2233L);
+ o.setUserType(UserTypeEnum.ADMIN.getValue());
+ o.setApplicationName("yudao-test");
+ o.setRequestUrl("foo");
+ o.setExceptionTime(buildTime(2021, 3, 13));
+ o.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus());
});
- infApiErrorLogMapper.insert(infApiErrorLogDO);
-
- // 下面几个都是不匹配的数据
- // userId 不同的
- infApiErrorLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiErrorLogDO, logDO -> logDO.setUserId(3344L)));
- // userType
- infApiErrorLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiErrorLogDO, logDO -> logDO.setUserType(UserTypeEnum.MEMBER.getValue())));
- // applicationName 不同的
- infApiErrorLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiErrorLogDO, logDO -> logDO.setApplicationName("test")));
- // requestUrl 不同的
- infApiErrorLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiErrorLogDO, logDO -> logDO.setRequestUrl("bar")));
- // 构造一个早期时间 2021-02-06 00:00:00
- infApiErrorLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiErrorLogDO, logDO -> logDO.setExceptionTime(buildTime(2021, 2, 6))));
- // progressStatus 不同的
- infApiErrorLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiErrorLogDO, logDO -> logDO.setProcessStatus(ApiErrorLogProcessStatusEnum.DONE.getStatus())));
-
- // 构造调用参数
+ apiErrorLogMapper.insert(apiErrorLogDO);
+ // 测试 userId 不匹配
+ apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, o -> o.setUserId(3344L)));
+ // 测试 userType 不匹配
+ apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setUserType(UserTypeEnum.MEMBER.getValue())));
+ // 测试 applicationName 不匹配
+ apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setApplicationName("test")));
+ // 测试 requestUrl 不匹配
+ apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setRequestUrl("bar")));
+ // 测试 exceptionTime 不匹配:构造一个早期时间 2021-02-06 00:00:00
+ apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setExceptionTime(buildTime(2021, 2, 6))));
+ // 测试 progressStatus 不匹配
+ apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setProcessStatus(ApiErrorLogProcessStatusEnum.DONE.getStatus())));
+ // 准备参数
ApiErrorLogPageReqVO reqVO = new ApiErrorLogPageReqVO();
- reqVO.setUserId(userId);
- reqVO.setUserType(userType);
- reqVO.setApplicationName(applicationName);
- reqVO.setRequestUrl(requestUrl);
- reqVO.setExceptionTime((new LocalDateTime[]{buildTime(2021, 3, 12),buildTime(2021, 3, 14)}));
- reqVO.setProcessStatus(progressStatus);
+ reqVO.setUserId(2233L);
+ reqVO.setUserType(UserTypeEnum.ADMIN.getValue());
+ reqVO.setApplicationName("yudao-test");
+ reqVO.setRequestUrl("foo");
+ reqVO.setExceptionTime(buildBetweenTime(2021, 3, 1, 2021, 3, 31));
+ reqVO.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus());
- // 调用service方法
+ // 调用
PageResult pageResult = apiErrorLogService.getApiErrorLogPage(reqVO);
-
// 断言,只查到了一条符合条件的
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
- assertPojoEquals(infApiErrorLogDO, pageResult.getList().get(0));
+ assertPojoEquals(apiErrorLogDO, pageResult.getList().get(0));
}
@Test
public void testGetApiErrorLogList() {
- // 构造测试数据
- long userId = 2233L;
- int userType = UserTypeEnum.ADMIN.getValue();
- String applicationName = "yudao-test";
- String requestUrl = "foo";
- LocalDateTime beginTime = buildTime(2021, 3, 13);
- int progressStatus = ApiErrorLogProcessStatusEnum.INIT.getStatus();
-
- ApiErrorLogDO infApiErrorLogDO = RandomUtils.randomPojo(ApiErrorLogDO.class, logDO -> {
- logDO.setUserId(userId);
- logDO.setUserType(userType);
- logDO.setApplicationName(applicationName);
- logDO.setRequestUrl(requestUrl);
- logDO.setExceptionTime(beginTime);
- logDO.setProcessStatus(progressStatus);
+ // mock 数据
+ ApiErrorLogDO apiErrorLogDO = randomPojo(ApiErrorLogDO.class, o -> {
+ o.setUserId(2233L);
+ o.setUserType(UserTypeEnum.ADMIN.getValue());
+ o.setApplicationName("yudao-test");
+ o.setRequestUrl("foo");
+ o.setExceptionTime(buildTime(2021, 3, 13));
+ o.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus());
});
- infApiErrorLogMapper.insert(infApiErrorLogDO);
-
- // 下面几个都是不匹配的数据
- // userId 不同的
- infApiErrorLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiErrorLogDO, logDO -> logDO.setUserId(3344L)));
- // userType
- infApiErrorLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiErrorLogDO, logDO -> logDO.setUserType(UserTypeEnum.MEMBER.getValue())));
- // applicationName 不同的
- infApiErrorLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiErrorLogDO, logDO -> logDO.setApplicationName("test")));
- // requestUrl 不同的
- infApiErrorLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiErrorLogDO, logDO -> logDO.setRequestUrl("bar")));
- // 构造一个早期时间 2021-02-06 00:00:00
- infApiErrorLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiErrorLogDO, logDO -> logDO.setExceptionTime(buildTime(2021, 2, 6))));
- // progressStatus 不同的
- infApiErrorLogMapper.insert(ObjectUtils.cloneIgnoreId(infApiErrorLogDO, logDO -> logDO.setProcessStatus(ApiErrorLogProcessStatusEnum.DONE.getStatus())));
-
- // 构造调用参数
+ apiErrorLogMapper.insert(apiErrorLogDO);
+ // 测试 userId 不匹配
+ apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, o -> o.setUserId(3344L)));
+ // 测试 userType 不匹配
+ apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setUserType(UserTypeEnum.MEMBER.getValue())));
+ // 测试 applicationName 不匹配
+ apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setApplicationName("test")));
+ // 测试 requestUrl 不匹配
+ apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setRequestUrl("bar")));
+ // 测试 exceptionTime 不匹配:构造一个早期时间 2021-02-06 00:00:00
+ apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setExceptionTime(buildTime(2021, 2, 6))));
+ // 测试 progressStatus 不匹配
+ apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setProcessStatus(ApiErrorLogProcessStatusEnum.DONE.getStatus())));
+ // 准备参数
ApiErrorLogExportReqVO reqVO = new ApiErrorLogExportReqVO();
- reqVO.setUserId(userId);
- reqVO.setUserType(userType);
- reqVO.setApplicationName(applicationName);
- reqVO.setRequestUrl(requestUrl);
- reqVO.setExceptionTime((new LocalDateTime[]{buildTime(2021, 3, 12),buildTime(2021, 3, 14)}));
- reqVO.setProcessStatus(progressStatus);
+ reqVO.setUserId(2233L);
+ reqVO.setUserType(UserTypeEnum.ADMIN.getValue());
+ reqVO.setApplicationName("yudao-test");
+ reqVO.setRequestUrl("foo");
+ reqVO.setExceptionTime(buildBetweenTime(2021, 3, 1, 2021, 3, 31));
+ reqVO.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus());
- // 调用service方法
+ // 调用
List list = apiErrorLogService.getApiErrorLogList(reqVO);
-
// 断言,只查到了一条符合条件的
assertEquals(1, list.size());
- assertPojoEquals(infApiErrorLogDO, list.get(0));
- }
-
-
- // TODO 芋艿:单元测试,可以拆小一点
- @Test
- public void testUpdateApiErrorLogProcess() {
- // 先构造两条数据,第一条用于抛出异常,第二条用于正常的执行update操作
- Long processUserId = 2233L;
-
- ApiErrorLogDO first = RandomUtils.randomPojo(ApiErrorLogDO.class, logDO -> {
- logDO.setProcessUserId(processUserId);
- logDO.setUserType(UserTypeEnum.ADMIN.getValue());
- logDO.setProcessStatus(ApiErrorLogProcessStatusEnum.DONE.getStatus());
- });
- infApiErrorLogMapper.insert(first);
-
- ApiErrorLogDO second = RandomUtils.randomPojo(ApiErrorLogDO.class, logDO -> {
- logDO.setProcessUserId(1122L);
- logDO.setUserType(UserTypeEnum.ADMIN.getValue());
- logDO.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus());
- });
- infApiErrorLogMapper.insert(second);
-
- Long firstId = first.getId();
- Long secondId = second.getId();
-
- // 执行正常的 update 操作
- apiErrorLogService.updateApiErrorLogProcess(secondId, ApiErrorLogProcessStatusEnum.DONE.getStatus(), processUserId);
- ApiErrorLogDO secondSelect = infApiErrorLogMapper.selectOne("id", secondId);
-
- // id 为 0 查询不到,应该抛出异常 API_ERROR_LOG_NOT_FOUND
- assertServiceException(() -> apiErrorLogService.updateApiErrorLogProcess(0L, ApiErrorLogProcessStatusEnum.DONE.getStatus(), processUserId), API_ERROR_LOG_NOT_FOUND);
- // id 为 first 的 progressStatus 为 DONE ,应该抛出 API_ERROR_LOG_PROCESSED
- assertServiceException(() -> apiErrorLogService.updateApiErrorLogProcess(firstId, ApiErrorLogProcessStatusEnum.DONE.getStatus(), processUserId), API_ERROR_LOG_PROCESSED);
- // 验证 progressStatus 是否修改成功
- Assertions.assertEquals(ApiErrorLogProcessStatusEnum.DONE.getStatus(), secondSelect.getProcessStatus());
- // 验证 progressUserId 是否修改成功
- Assertions.assertEquals(processUserId, secondSelect.getProcessUserId());
+ assertPojoEquals(apiErrorLogDO, list.get(0));
}
@Test
- public void testCreateApiErrorLogAsync() {
+ public void testCreateApiErrorLog() {
// 准备参数
- ApiErrorLogCreateReqDTO createDTO = RandomUtils.randomPojo(ApiErrorLogCreateReqDTO.class,
- dto -> dto.setUserType(RandomUtil.randomEle(UserTypeEnum.values()).getValue()));
+ ApiErrorLogCreateReqDTO createDTO = randomPojo(ApiErrorLogCreateReqDTO.class);
// 调用
apiErrorLogService.createApiErrorLog(createDTO);
// 断言
- ApiErrorLogDO infApiErrorLogDO = infApiErrorLogMapper.selectOne(null);
- assertNotNull(infApiErrorLogDO);
- assertPojoEquals(createDTO, infApiErrorLogDO);
+ ApiErrorLogDO apiErrorLogDO = apiErrorLogMapper.selectOne(null);
+ assertPojoEquals(createDTO, apiErrorLogDO);
+ assertEquals(ApiErrorLogProcessStatusEnum.INIT.getStatus(), apiErrorLogDO.getProcessStatus());
+ }
+
+ @Test
+ public void testUpdateApiErrorLogProcess_success() {
+ // 准备参数
+ ApiErrorLogDO apiErrorLogDO = randomPojo(ApiErrorLogDO.class,
+ o -> o.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus()));
+ apiErrorLogMapper.insert(apiErrorLogDO);
+ // 准备参数
+ Long id = apiErrorLogDO.getId();
+ Integer processStatus = randomEle(ApiErrorLogProcessStatusEnum.values()).getStatus();
+ Long processUserId = randomLongId();
+
+ // 调用
+ apiErrorLogService.updateApiErrorLogProcess(id, processStatus, processUserId);
+ // 断言
+ ApiErrorLogDO dbApiErrorLogDO = apiErrorLogMapper.selectById(apiErrorLogDO.getId());
+ assertEquals(processStatus, dbApiErrorLogDO.getProcessStatus());
+ assertEquals(processUserId, dbApiErrorLogDO.getProcessUserId());
+ assertNotNull(dbApiErrorLogDO.getProcessTime());
+ }
+
+ @Test
+ public void testUpdateApiErrorLogProcess_processed() {
+ // 准备参数
+ ApiErrorLogDO apiErrorLogDO = randomPojo(ApiErrorLogDO.class,
+ o -> o.setProcessStatus(ApiErrorLogProcessStatusEnum.DONE.getStatus()));
+ apiErrorLogMapper.insert(apiErrorLogDO);
+ // 准备参数
+ Long id = apiErrorLogDO.getId();
+ Integer processStatus = randomEle(ApiErrorLogProcessStatusEnum.values()).getStatus();
+ Long processUserId = randomLongId();
+
+ // 调用,并断言异常
+ assertServiceException(() ->
+ apiErrorLogService.updateApiErrorLogProcess(id, processStatus, processUserId),
+ API_ERROR_LOG_PROCESSED);
+ }
+
+ @Test
+ public void testUpdateApiErrorLogProcess_notFound() {
+ // 准备参数
+ Long id = randomLongId();
+ Integer processStatus = randomEle(ApiErrorLogProcessStatusEnum.values()).getStatus();
+ Long processUserId = randomLongId();
+
+ // 调用,并断言异常
+ assertServiceException(() ->
+ apiErrorLogService.updateApiErrorLogProcess(id, processStatus, processUserId),
+ API_ERROR_LOG_NOT_FOUND);
}
}
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/sql/clean.sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/sql/clean.sql
index eb05d3d5a..3dc20f7ba 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/sql/clean.sql
+++ b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/sql/clean.sql
@@ -1,12 +1,10 @@
DELETE FROM "infra_config";
+DELETE FROM "infra_file_config";
DELETE FROM "infra_file";
DELETE FROM "infra_job";
DELETE FROM "infra_job_log";
DELETE FROM "infra_api_access_log";
DELETE FROM "infra_api_error_log";
-DELETE FROM "infra_api_access_log";
-DELETE FROM "infra_file";
-DELETE FROM "infra_api_error_log";
-DELETE FROM "infra_test_demo";
DELETE FROM "infra_file_config";
+DELETE FROM "infra_test_demo";
DELETE FROM "infra_data_source_config";
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/sql/create_tables.sql b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/sql/create_tables.sql
index 5825e0fef..e076ca895 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/test/resources/sql/create_tables.sql
+++ b/yudao-module-infra/yudao-module-infra-biz/src/test/resources/sql/create_tables.sql
@@ -1,9 +1,9 @@
CREATE TABLE IF NOT EXISTS "infra_config" (
- "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY,
+ "id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY COMMENT '编号',
"category" varchar(50) NOT NULL,
"type" tinyint NOT NULL,
- "name" varchar(100) NOT NULL DEFAULT '',
+ "name" varchar(100) NOT NULL DEFAULT '' COMMENT '名字',
"config_key" varchar(100) NOT NULL DEFAULT '',
"value" varchar(500) NOT NULL DEFAULT '',
"visible" bit NOT NULL,
@@ -85,19 +85,6 @@ CREATE TABLE IF NOT EXISTS "infra_job_log" (
PRIMARY KEY ("id")
)COMMENT='定时任务日志表';
-CREATE TABLE IF NOT EXISTS "inf_file" (
- "id" varchar(188) NOT NULL,
- "type" varchar(63) DEFAULT NULL,
- "content" blob NOT NULL,
- "creator" varchar(64) DEFAULT '',
- "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "updater" varchar(64) DEFAULT '',
- "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "deleted" bit NOT NULL DEFAULT FALSE,
- "tenant_id" bigint not null default '0',
- PRIMARY KEY ("id")
- ) COMMENT '文件表';
-
CREATE TABLE IF NOT EXISTS "infra_api_access_log" (
"id" bigint not null GENERATED BY DEFAULT AS IDENTITY,
"trace_id" varchar(64) not null default '',
diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/clean.sql b/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/clean.sql
new file mode 100644
index 000000000..2a45ce1bd
--- /dev/null
+++ b/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/clean.sql
@@ -0,0 +1,7 @@
+DELETE FROM "product_sku";
+DELETE FROM "product_spu";
+DELETE FROM "product_category";
+
+
+
+
diff --git a/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/create_tables.sql b/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/create_tables.sql
new file mode 100644
index 000000000..6b0ffc7c7
--- /dev/null
+++ b/yudao-module-mall/yudao-module-product-biz/src/test/resources/sql/create_tables.sql
@@ -0,0 +1,68 @@
+CREATE TABLE IF NOT EXISTS `product_sku` (
+ `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
+ `spu_id` bigint NOT NULL COMMENT 'spu编号',
+ `spu_name` varchar DEFAULT NULL COMMENT '商品 SPU 名字',
+ `properties` varchar DEFAULT NULL COMMENT '规格值数组-json格式, [{propertId: , valueId: }, {propertId: , valueId: }]',
+ `price` int NOT NULL DEFAULT '-1' COMMENT '销售价格,单位:分',
+ `market_price` int DEFAULT NULL COMMENT '市场价',
+ `cost_price` int NOT NULL DEFAULT '-1' COMMENT '成本价,单位: 分',
+ `pic_url` varchar NOT NULL COMMENT '图片地址',
+ `stock` int DEFAULT NULL COMMENT '库存',
+ `warn_stock` int DEFAULT NULL COMMENT '预警库存',
+ `volume` double DEFAULT NULL COMMENT '商品体积',
+ `weight` double DEFAULT NULL COMMENT '商品重量',
+ `bar_code` varchar DEFAULT NULL COMMENT '条形码',
+ `status` tinyint DEFAULT NULL COMMENT '状态: 0-正常 1-禁用',
+ `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+ `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+ `creator` varchar DEFAULT NULL COMMENT '创建人',
+ `updater` varchar DEFAULT NULL COMMENT '更新人',
+ `deleted` bit(1) NOT NULL DEFAULT 0 COMMENT '是否删除',
+ PRIMARY KEY (`id`)
+) COMMENT '商品sku';
+
+CREATE TABLE IF NOT EXISTS `product_spu` (
+ `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
+ `tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户编号',
+ `brand_id` bigint DEFAULT NULL COMMENT '商品品牌编号',
+ `category_id` bigint NOT NULL COMMENT '分类id',
+ `spec_type` int NOT NULL COMMENT '规格类型:0 单规格 1 多规格',
+ `code` varchar(128) DEFAULT NULL COMMENT '商品编码',
+ `name` varchar(128) NOT NULL COMMENT '商品名称',
+ `sell_point` varchar(128) DEFAULT NULL COMMENT '卖点',
+ `description` text COMMENT '描述',
+ `pic_urls` varchar(1024) DEFAULT '' COMMENT '商品轮播图地址数组,以逗号分隔最多上传15张',
+ `video_url` varchar(128) DEFAULT NULL COMMENT '商品视频',
+ `market_price` int DEFAULT NULL COMMENT '市场价,单位使用:分',
+ `min_price` int DEFAULT NULL COMMENT '最小价格,单位使用:分',
+ `max_price` int DEFAULT NULL COMMENT '最大价格,单位使用:分',
+ `total_stock` int NOT NULL DEFAULT '0' COMMENT '总库存',
+ `show_stock` int DEFAULT '0' COMMENT '是否展示库存',
+ `sales_count` int DEFAULT '0' COMMENT '商品销量',
+ `virtual_sales_count` int DEFAULT '0' COMMENT '虚拟销量',
+ `click_count` int DEFAULT '0' COMMENT '商品点击量',
+ `status` bit(1) DEFAULT NULL COMMENT '上下架状态: 0 上架(开启) 1 下架(禁用)-1 回收',
+ `sort` int NOT NULL DEFAULT '0' COMMENT '排序字段',
+ `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+ `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+ `creator` varchar DEFAULT NULL COMMENT '创建人',
+ `updater` varchar DEFAULT NULL COMMENT '更新人',
+ `deleted` bit(1) NOT NULL DEFAULT 0 COMMENT '是否删除',
+PRIMARY KEY (`id`)
+) COMMENT '商品spu';
+
+CREATE TABLE IF NOT EXISTS `product_category` (
+ `id` bigint NOT NULL AUTO_INCREMENT COMMENT '分类编号',
+ `parent_id` bigint DEFAULT NULL COMMENT '父分类编号',
+ `name` varchar(128) NOT NULL COMMENT '分类名称',
+ `description` varchar(128) NOT NULL COMMENT '分类描述',
+ `pic_url` varchar DEFAULT NULL COMMENT '分类图片',
+ `sort` int NOT NULL DEFAULT '0' COMMENT '排序字段',
+ `status` bit(1) DEFAULT NULL COMMENT '状态',
+ `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+ `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+ `creator` varchar DEFAULT NULL COMMENT '创建人',
+ `updater` varchar DEFAULT NULL COMMENT '更新人',
+ `deleted` bit(1) NOT NULL DEFAULT 0 COMMENT '是否删除',
+ PRIMARY KEY (`id`)
+) COMMENT '商品分类';
diff --git a/yudao-module-member/yudao-module-member-biz/src/test/resources/sql/create_tables.sql b/yudao-module-member/yudao-module-member-biz/src/test/resources/sql/create_tables.sql
index b0347b058..9724c80d6 100644
--- a/yudao-module-member/yudao-module-member-biz/src/test/resources/sql/create_tables.sql
+++ b/yudao-module-member/yudao-module-member-biz/src/test/resources/sql/create_tables.sql
@@ -17,19 +17,6 @@ CREATE TABLE IF NOT EXISTS "member_user" (
PRIMARY KEY ("id")
) COMMENT '会员表';
--- inf 开头的 DB
-CREATE TABLE IF NOT EXISTS "inf_file" (
- "id" varchar(188) NOT NULL,
- "type" varchar(63) DEFAULT NULL,
- "content" blob NOT NULL,
- "creator" varchar(64) DEFAULT '',
- "create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "updater" varchar(64) DEFAULT '',
- "update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
- "deleted" bit NOT NULL DEFAULT FALSE,
- PRIMARY KEY ("id")
-) COMMENT '文件表';
-
CREATE TABLE IF NOT EXISTS "member_address" (
"id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"user_id" bigint(20) NOT NULL,
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java
index c9b456b90..c3d143e46 100644
--- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java
+++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java
@@ -29,7 +29,7 @@ public interface DeptApi {
* @param ids 部门编号数组
* @return 部门信息数组
*/
- List getDepts(Collection ids);
+ List getDeptList(Collection ids);
/**
* 校验部门们是否有效。如下情况,视为无效:
@@ -38,7 +38,7 @@ public interface DeptApi {
*
* @param ids 角色编号数组
*/
- void validDepts(Collection ids);
+ void validateDeptList(Collection ids);
/**
* 获得指定编号的部门 Map
@@ -47,7 +47,7 @@ public interface DeptApi {
* @return 部门 Map
*/
default Map getDeptMap(Set ids) {
- List list = getDepts(ids);
+ List list = getDeptList(ids);
return CollectionUtils.convertMap(list, DeptRespDTO::getId);
}
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/PostApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/PostApi.java
index d1e3d47a1..57db07cc2 100644
--- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/PostApi.java
+++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/PostApi.java
@@ -16,6 +16,6 @@ public interface PostApi {
*
* @param ids 岗位编号数组
*/
- void validPosts(Collection ids);
+ void validPostList(Collection ids);
}
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dict/DictDataApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dict/DictDataApi.java
index 5ba3dfd75..3bc28c89e 100644
--- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dict/DictDataApi.java
+++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dict/DictDataApi.java
@@ -19,7 +19,7 @@ public interface DictDataApi {
* @param dictType 字典类型
* @param values 字典数据值的数组
*/
- void validDictDatas(String dictType, Collection values);
+ void validateDictDataList(String dictType, Collection values);
/**
* 获得指定的字典数据,从缓存中
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/errorcode/ErrorCodeApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/errorcode/ErrorCodeApi.java
index b41728d40..6f6bc24c7 100644
--- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/errorcode/ErrorCodeApi.java
+++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/errorcode/ErrorCodeApi.java
@@ -19,7 +19,7 @@ public interface ErrorCodeApi {
*
* @param autoGenerateDTOs 错误码信息
*/
- void autoGenerateErrorCodes(@Valid List autoGenerateDTOs);
+ void autoGenerateErrorCodeList(@Valid List autoGenerateDTOs);
/**
* 增量获得错误码数组
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/permission/RoleApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/permission/RoleApi.java
index 14133e9d9..309c9ef6e 100644
--- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/permission/RoleApi.java
+++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/permission/RoleApi.java
@@ -16,6 +16,6 @@ public interface RoleApi {
*
* @param ids 角色编号数组
*/
- void validRoles(Collection ids);
+ void validRoleList(Collection ids);
}
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/sms/SmsCodeApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/sms/SmsCodeApi.java
index ffcf46dc0..98d4cdeef 100644
--- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/sms/SmsCodeApi.java
+++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/sms/SmsCodeApi.java
@@ -1,7 +1,7 @@
package cn.iocoder.yudao.module.system.api.sms;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
-import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeCheckReqDTO;
+import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeValidateReqDTO;
import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeSendReqDTO;
import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO;
@@ -35,6 +35,6 @@ public interface SmsCodeApi {
*
* @param reqDTO 校验请求
*/
- void checkSmsCode(@Valid SmsCodeCheckReqDTO reqDTO);
+ void validateSmsCode(@Valid SmsCodeValidateReqDTO reqDTO);
}
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/sms/dto/code/SmsCodeCheckReqDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/sms/dto/code/SmsCodeValidateReqDTO.java
similarity index 95%
rename from yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/sms/dto/code/SmsCodeCheckReqDTO.java
rename to yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/sms/dto/code/SmsCodeValidateReqDTO.java
index 92895bb4d..e7808354c 100644
--- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/sms/dto/code/SmsCodeCheckReqDTO.java
+++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/sms/dto/code/SmsCodeValidateReqDTO.java
@@ -14,7 +14,7 @@ import javax.validation.constraints.NotNull;
* @author 芋道源码
*/
@Data
-public class SmsCodeCheckReqDTO {
+public class SmsCodeValidateReqDTO {
/**
* 手机号
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/tenant/TenantApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/tenant/TenantApi.java
index 3f255d55a..1fad83ed6 100644
--- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/tenant/TenantApi.java
+++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/tenant/TenantApi.java
@@ -14,13 +14,13 @@ public interface TenantApi {
*
* @return 租户编号数组
*/
- List getTenantIds();
+ List getTenantIdList();
/**
* 校验租户是否合法
*
* @param id 租户编号
*/
- void validTenant(Long id);
+ void validateTenant(Long id);
}
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApi.java
index 6c0b7e9d9..35e11f02d 100644
--- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApi.java
+++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApi.java
@@ -6,7 +6,6 @@ import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import java.util.Collection;
import java.util.List;
import java.util.Map;
-import java.util.Set;
/**
* Admin 用户 API 接口
@@ -29,7 +28,7 @@ public interface AdminUserApi {
* @param ids 用户 ID 们
* @return 用户对象信息
*/
- List getUsers(Collection ids);
+ List getUserList(Collection ids);
/**
* 获得指定部门的用户数组
@@ -37,7 +36,7 @@ public interface AdminUserApi {
* @param deptIds 部门数组
* @return 用户数组
*/
- List getUsersByDeptIds(Collection deptIds);
+ List getUserListByDeptIds(Collection deptIds);
/**
* 获得指定岗位的用户数组
@@ -54,7 +53,7 @@ public interface AdminUserApi {
* @return 用户 Map
*/
default Map getUserMap(Collection ids) {
- List users = getUsers(ids);
+ List users = getUserList(ids);
return CollectionUtils.convertMap(users, AdminUserRespDTO::getId);
}
@@ -65,6 +64,6 @@ public interface AdminUserApi {
*
* @param ids 用户编号数组
*/
- void validUsers(Set ids);
+ void validateUserList(Collection ids);
}
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
index b108ca775..8a54ba92e 100644
--- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
+++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
@@ -50,7 +50,7 @@ public interface ErrorCodeConstants {
ErrorCode DEPT_EXITS_CHILDREN = new ErrorCode(1002004003, "存在子部门,无法删除");
ErrorCode DEPT_PARENT_ERROR = new ErrorCode(1002004004, "不能设置自己为父部门");
ErrorCode DEPT_EXISTS_USER = new ErrorCode(1002004005, "部门中存在员工,无法删除");
- ErrorCode DEPT_NOT_ENABLE = new ErrorCode(1002004006, "部门不处于开启状态,不允许选择");
+ ErrorCode DEPT_NOT_ENABLE = new ErrorCode(1002004006, "部门({})不处于开启状态,不允许选择");
ErrorCode DEPT_PARENT_IS_CHILD = new ErrorCode(1002004007, "不能设置自己的子部门为父部门");
// ========== 岗位模块 1002005000 ==========
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/permission/MenuIdEnum.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/permission/MenuIdEnum.java
deleted file mode 100644
index fc2b72ac4..000000000
--- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/permission/MenuIdEnum.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package cn.iocoder.yudao.module.system.enums.permission;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-/**
- * Menu 编号枚举
- */
-@Getter
-@AllArgsConstructor
-public enum MenuIdEnum {
-
- /**
- * 根节点
- */
- ROOT(0L);
-
- private final Long id;
-
-}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java
index 5721030bb..c1676ca53 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java
@@ -28,14 +28,14 @@ public class DeptApiImpl implements DeptApi {
}
@Override
- public List getDepts(Collection ids) {
- List depts = deptService.getDepts(ids);
+ public List getDeptList(Collection ids) {
+ List depts = deptService.getDeptList(ids);
return DeptConvert.INSTANCE.convertList03(depts);
}
@Override
- public void validDepts(Collection ids) {
- deptService.validDepts(ids);
+ public void validateDeptList(Collection ids) {
+ deptService.validateDeptList(ids);
}
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/PostApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/PostApiImpl.java
index 9454193e7..3d8cdf997 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/PostApiImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/PostApiImpl.java
@@ -18,7 +18,8 @@ public class PostApiImpl implements PostApi {
private PostService postService;
@Override
- public void validPosts(Collection ids) {
- postService.validPosts(ids);
+ public void validPostList(Collection ids) {
+ postService.validatePostList(ids);
}
+
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dict/DictDataApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dict/DictDataApiImpl.java
index 7de1a43b3..e88771fa7 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dict/DictDataApiImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dict/DictDataApiImpl.java
@@ -21,8 +21,8 @@ public class DictDataApiImpl implements DictDataApi {
private DictDataService dictDataService;
@Override
- public void validDictDatas(String dictType, Collection values) {
- dictDataService.validDictDatas(dictType, values);
+ public void validateDictDataList(String dictType, Collection values) {
+ dictDataService.validateDictDataList(dictType, values);
}
@Override
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/errorcode/ErrorCodeApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/errorcode/ErrorCodeApiImpl.java
index b68c63215..c9c5f7029 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/errorcode/ErrorCodeApiImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/errorcode/ErrorCodeApiImpl.java
@@ -21,7 +21,7 @@ public class ErrorCodeApiImpl implements ErrorCodeApi {
private ErrorCodeService errorCodeService;
@Override
- public void autoGenerateErrorCodes(List autoGenerateDTOs) {
+ public void autoGenerateErrorCodeList(List autoGenerateDTOs) {
errorCodeService.autoGenerateErrorCodes(autoGenerateDTOs);
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/permission/RoleApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/permission/RoleApiImpl.java
index 2c4f94737..d8622a29a 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/permission/RoleApiImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/permission/RoleApiImpl.java
@@ -18,7 +18,7 @@ public class RoleApiImpl implements RoleApi {
private RoleService roleService;
@Override
- public void validRoles(Collection ids) {
- roleService.validRoles(ids);
+ public void validRoleList(Collection ids) {
+ roleService.validateRoleList(ids);
}
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/sms/SmsCodeApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/sms/SmsCodeApiImpl.java
index 81957e082..23c5e4b3f 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/sms/SmsCodeApiImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/sms/SmsCodeApiImpl.java
@@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.system.api.sms;
-import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeCheckReqDTO;
+import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeValidateReqDTO;
import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeSendReqDTO;
import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO;
import cn.iocoder.yudao.module.system.service.sms.SmsCodeService;
@@ -32,8 +32,8 @@ public class SmsCodeApiImpl implements SmsCodeApi {
}
@Override
- public void checkSmsCode(SmsCodeCheckReqDTO reqDTO) {
- smsCodeService.checkSmsCode(reqDTO);
+ public void validateSmsCode(SmsCodeValidateReqDTO reqDTO) {
+ smsCodeService.validateSmsCode(reqDTO);
}
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/tenant/TenantApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/tenant/TenantApiImpl.java
index 6ea4c795e..25ea260c5 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/tenant/TenantApiImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/tenant/TenantApiImpl.java
@@ -18,12 +18,12 @@ public class TenantApiImpl implements TenantApi {
private TenantService tenantService;
@Override
- public List getTenantIds() {
- return tenantService.getTenantIds();
+ public List getTenantIdList() {
+ return tenantService.getTenantIdList();
}
@Override
- public void validTenant(Long id) {
+ public void validateTenant(Long id) {
tenantService.validTenant(id);
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java
index d493b747a..2271420c4 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java
@@ -9,7 +9,6 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
-import java.util.Set;
/**
* Admin 用户 API 实现类
@@ -29,26 +28,26 @@ public class AdminUserApiImpl implements AdminUserApi {
}
@Override
- public List getUsers(Collection ids) {
- List users = userService.getUsers(ids);
+ public List getUserList(Collection ids) {
+ List users = userService.getUserList(ids);
return UserConvert.INSTANCE.convertList4(users);
}
@Override
- public List getUsersByDeptIds(Collection deptIds) {
- List users = userService.getUsersByDeptIds(deptIds);
+ public List getUserListByDeptIds(Collection deptIds) {
+ List users = userService.getUserListByDeptIds(deptIds);
return UserConvert.INSTANCE.convertList4(users);
}
@Override
public List getUsersByPostIds(Collection postIds) {
- List users = userService.getUsersByPostIds(postIds);
+ List users = userService.getUserListByPostIds(postIds);
return UserConvert.INSTANCE.convertList4(users);
}
@Override
- public void validUsers(Set ids) {
- userService.validUsers(ids);
+ public void validateUserList(Collection ids) {
+ userService.validateUserList(ids);
}
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java
index 6acceae52..7ef7012cc 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java
@@ -97,7 +97,7 @@ public class AuthController {
}
// 获得角色列表
Set roleIds = permissionService.getUserRoleIdsFromCache(getLoginUserId(), singleton(CommonStatusEnum.ENABLE.getStatus()));
- List roleList = roleService.getRolesFromCache(roleIds);
+ List roleList = roleService.getRoleListFromCache(roleIds);
// 获得菜单列表
List menuList = permissionService.getRoleMenuListFromCache(roleIds,
SetUtils.asSet(MenuTypeEnum.DIR.getType(), MenuTypeEnum.MENU.getType(), MenuTypeEnum.BUTTON.getType()),
@@ -108,7 +108,7 @@ public class AuthController {
@GetMapping("/list-menus")
@Operation(summary = "获得登录用户的菜单列表")
- public CommonResult> getMenus() {
+ public CommonResult> getMenuList() {
// 获得角色列表
Set roleIds = permissionService.getUserRoleIdsFromCache(getLoginUserId(), singleton(CommonStatusEnum.ENABLE.getStatus()));
// 获得用户拥有的菜单列表
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/DeptController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/DeptController.java
index 7c9338c40..906ab646a 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/DeptController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/DeptController.java
@@ -57,19 +57,19 @@ public class DeptController {
@GetMapping("/list")
@Operation(summary = "获取部门列表")
@PreAuthorize("@ss.hasPermission('system:dept:query')")
- public CommonResult> listDepts(DeptListReqVO reqVO) {
- List list = deptService.getSimpleDepts(reqVO);
+ public CommonResult> getDeptList(DeptListReqVO reqVO) {
+ List list = deptService.getDeptList(reqVO);
list.sort(Comparator.comparing(DeptDO::getSort));
return success(DeptConvert.INSTANCE.convertList(list));
}
@GetMapping("/list-all-simple")
@Operation(summary = "获取部门精简信息列表", description = "只包含被开启的部门,主要用于前端的下拉选项")
- public CommonResult> getSimpleDepts() {
+ public CommonResult> getSimpleDeptList() {
// 获得部门列表,只要开启状态的
DeptListReqVO reqVO = new DeptListReqVO();
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
- List list = deptService.getSimpleDepts(reqVO);
+ List list = deptService.getDeptList(reqVO);
// 排序后,返回给前端
list.sort(Comparator.comparing(DeptDO::getSort));
return success(DeptConvert.INSTANCE.convertList02(list));
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/PostController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/PostController.java
index 79cd44d3a..70e2d8639 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/PostController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/PostController.java
@@ -70,9 +70,9 @@ public class PostController {
@GetMapping("/list-all-simple")
@Operation(summary = "获取岗位精简信息列表", description = "只包含被开启的岗位,主要用于前端的下拉选项")
- public CommonResult> getSimplePosts() {
+ public CommonResult> getSimplePostList() {
// 获得岗位列表,只要开启状态的
- List list = postService.getPosts(null, Collections.singleton(CommonStatusEnum.ENABLE.getStatus()));
+ List list = postService.getPostList(null, Collections.singleton(CommonStatusEnum.ENABLE.getStatus()));
// 排序后,返回给前端
list.sort(Comparator.comparing(PostDO::getSort));
return success(PostConvert.INSTANCE.convertList02(list));
@@ -90,7 +90,7 @@ public class PostController {
@PreAuthorize("@ss.hasPermission('system:post:export')")
@OperateLog(type = EXPORT)
public void export(HttpServletResponse response, @Validated PostExportReqVO reqVO) throws IOException {
- List posts = postService.getPosts(reqVO);
+ List posts = postService.getPostList(reqVO);
List data = PostConvert.INSTANCE.convertList03(posts);
// 输出
ExcelUtils.write(response, "岗位数据.xls", "岗位列表", PostExcelVO.class, data);
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/DictDataController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/DictDataController.java
index 37793a904..276587472 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/DictDataController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/DictDataController.java
@@ -61,8 +61,8 @@ public class DictDataController {
@GetMapping("/list-all-simple")
@Operation(summary = "获得全部字典数据列表", description = "一般用于管理后台缓存字典数据在本地")
// 无需添加权限认证,因为前端全局都需要
- public CommonResult> getSimpleDictDatas() {
- List list = dictDataService.getDictDatas();
+ public CommonResult> getSimpleDictDataList() {
+ List list = dictDataService.getDictDataList();
return success(DictDataConvert.INSTANCE.convertList(list));
}
@@ -86,7 +86,7 @@ public class DictDataController {
@PreAuthorize("@ss.hasPermission('system:dict:export')")
@OperateLog(type = EXPORT)
public void export(HttpServletResponse response, @Valid DictDataExportReqVO reqVO) throws IOException {
- List list = dictDataService.getDictDatas(reqVO);
+ List list = dictDataService.getDictDataList(reqVO);
List data = DictDataConvert.INSTANCE.convertList02(list);
// 输出
ExcelUtils.write(response, "字典数据.xls", "数据列表", DictDataExcelVO.class, data);
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/DictTypeController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/DictTypeController.java
index d78c62e9a..6fcdcdd9c 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/DictTypeController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/DictTypeController.java
@@ -76,7 +76,7 @@ public class DictTypeController {
@GetMapping("/list-all-simple")
@Operation(summary = "获得全部字典类型列表", description = "包括开启 + 禁用的字典类型,主要用于前端的下拉选项")
// 无需添加权限认证,因为前端全局都需要
- public CommonResult> listSimpleDictTypes() {
+ public CommonResult> getSimpleDictTypeList() {
List list = dictTypeService.getDictTypeList();
return success(DictTypeConvert.INSTANCE.convertList(list));
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/logger/OperateLogController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/logger/OperateLogController.java
index c794f0ca8..fc035f471 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/logger/OperateLogController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/logger/OperateLogController.java
@@ -71,7 +71,7 @@ public class OperateLogController {
@PreAuthorize("@ss.hasPermission('system:operate-log:export')")
@OperateLog(type = EXPORT)
public void exportOperateLog(HttpServletResponse response, @Valid OperateLogExportReqVO reqVO) throws IOException {
- List list = operateLogService.getOperateLogs(reqVO);
+ List list = operateLogService.getOperateLogList(reqVO);
// 获得拼接需要的数据
Collection userIds = CollectionUtils.convertList(list, OperateLogDO::getUserId);
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notice/NoticeController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notice/NoticeController.java
index 39d24bf3e..0e1957785 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notice/NoticeController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notice/NoticeController.java
@@ -57,8 +57,8 @@ public class NoticeController {
@GetMapping("/page")
@Operation(summary = "获取通知公告列表")
@PreAuthorize("@ss.hasPermission('system:notice:query')")
- public CommonResult> pageNotices(@Validated NoticePageReqVO reqVO) {
- return success(NoticeConvert.INSTANCE.convertPage(noticeService.pageNotices(reqVO)));
+ public CommonResult> getNoticePage(@Validated NoticePageReqVO reqVO) {
+ return success(NoticeConvert.INSTANCE.convertPage(noticeService.getNoticePage(reqVO)));
}
@GetMapping("/get")
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2UserController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2UserController.java
index 865646801..b56d71484 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2UserController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2UserController.java
@@ -61,7 +61,7 @@ public class OAuth2UserController {
}
// 获得岗位信息
if (CollUtil.isNotEmpty(user.getPostIds())) {
- List posts = postService.getPosts(user.getPostIds());
+ List posts = postService.getPostList(user.getPostIds());
resp.setPosts(OAuth2UserConvert.INSTANCE.convertList(posts));
}
return success(resp);
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/MenuController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/MenuController.java
index ad7b14c29..4b007ff72 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/MenuController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/MenuController.java
@@ -57,8 +57,8 @@ public class MenuController {
@GetMapping("/list")
@Operation(summary = "获取菜单列表", description = "用于【菜单管理】界面")
@PreAuthorize("@ss.hasPermission('system:menu:query')")
- public CommonResult> getMenus(MenuListReqVO reqVO) {
- List list = menuService.getMenus(reqVO);
+ public CommonResult> getMenuList(MenuListReqVO reqVO) {
+ List list = menuService.getMenuList(reqVO);
list.sort(Comparator.comparing(MenuDO::getSort));
return success(MenuConvert.INSTANCE.convertList(list));
}
@@ -66,11 +66,11 @@ public class MenuController {
@GetMapping("/list-all-simple")
@Operation(summary = "获取菜单精简信息列表", description = "只包含被开启的菜单,用于【角色分配菜单】功能的选项。" +
"在多租户的场景下,会只返回租户所在套餐有的菜单")
- public CommonResult> getSimpleMenus() {
+ public CommonResult> getSimpleMenuList() {
// 获得菜单列表,只要开启状态的
MenuListReqVO reqVO = new MenuListReqVO();
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
- List list = menuService.getTenantMenus(reqVO);
+ List list = menuService.getMenuListByTenant(reqVO);
// 排序后,返回给前端
list.sort(Comparator.comparing(MenuDO::getSort));
return success(MenuConvert.INSTANCE.convertList02(list));
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/RoleController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/RoleController.java
index cde85f9e4..2df1e74b0 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/RoleController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/RoleController.java
@@ -20,12 +20,12 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
-import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
+import static java.util.Collections.singleton;
@Tag(name = "管理后台 - 角色")
@RestController
@@ -85,9 +85,9 @@ public class RoleController {
@GetMapping("/list-all-simple")
@Operation(summary = "获取角色精简信息列表", description = "只包含被开启的角色,主要用于前端的下拉选项")
- public CommonResult> getSimpleRoles() {
+ public CommonResult> getSimpleRoleList() {
// 获得角色列表,只要开启状态的
- List list = roleService.getRoles(Collections.singleton(CommonStatusEnum.ENABLE.getStatus()));
+ List list = roleService.getRoleListByStatus(singleton(CommonStatusEnum.ENABLE.getStatus()));
// 排序后,返回给前端
list.sort(Comparator.comparing(RoleDO::getSort));
return success(RoleConvert.INSTANCE.convertList02(list));
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/sensitiveword/SensitiveWordController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/sensitiveword/SensitiveWordController.java
index 684480be6..ab0a129df 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/sensitiveword/SensitiveWordController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/sensitiveword/SensitiveWordController.java
@@ -90,8 +90,8 @@ public class SensitiveWordController {
@GetMapping("/get-tags")
@Operation(summary = "获取所有敏感词的标签数组")
@PreAuthorize("@ss.hasPermission('system:sensitive-word:query')")
- public CommonResult> getSensitiveWordTags() throws IOException {
- return success(sensitiveWordService.getSensitiveWordTags());
+ public CommonResult> getSensitiveWordTagSet() {
+ return success(sensitiveWordService.getSensitiveWordTagSet());
}
@GetMapping("/validate-text")
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/sms/SmsChannelController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/sms/SmsChannelController.java
index 73057a090..b6512a601 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/sms/SmsChannelController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/sms/SmsChannelController.java
@@ -70,7 +70,7 @@ public class SmsChannelController {
@GetMapping("/list-all-simple")
@Operation(summary = "获得短信渠道精简列表", description = "包含被禁用的短信渠道")
- public CommonResult> getSimpleSmsChannels() {
+ public CommonResult> getSimpleSmsChannelList() {
List list = smsChannelService.getSmsChannelList();
// 排序后,返回给前端
list.sort(Comparator.comparing(SmsChannelDO::getId));
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java
index 2f26b34f4..40efb2d23 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java
@@ -111,9 +111,9 @@ public class UserController {
@GetMapping("/list-all-simple")
@Operation(summary = "获取用户精简信息列表", description = "只包含被开启的用户,主要用于前端的下拉选项")
- public CommonResult> getSimpleUsers() {
+ public CommonResult> getSimpleUserList() {
// 获用户列表,只要开启状态的
- List list = userService.getUsersByStatus(CommonStatusEnum.ENABLE.getStatus());
+ List list = userService.getUserListByStatus(CommonStatusEnum.ENABLE.getStatus());
// 排序后,返回给前端
return success(UserConvert.INSTANCE.convertList04(list));
}
@@ -122,7 +122,7 @@ public class UserController {
@Operation(summary = "获得用户详情")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('system:user:query')")
- public CommonResult getInfo(@RequestParam("id") Long id) {
+ public CommonResult getUser(@RequestParam("id") Long id) {
return success(UserConvert.INSTANCE.convert(userService.getUser(id)));
}
@@ -130,10 +130,10 @@ public class UserController {
@Operation(summary = "导出用户")
@PreAuthorize("@ss.hasPermission('system:user:export')")
@OperateLog(type = EXPORT)
- public void exportUsers(@Validated UserExportReqVO reqVO,
- HttpServletResponse response) throws IOException {
+ public void exportUserList(@Validated UserExportReqVO reqVO,
+ HttpServletResponse response) throws IOException {
// 获得用户列表
- List users = userService.getUsers(reqVO);
+ List users = userService.getUserList(reqVO);
// 获得拼接需要的数据
Collection deptIds = convertList(users, AdminUserDO::getDeptId);
@@ -183,7 +183,7 @@ public class UserController {
public CommonResult importExcel(@RequestParam("file") MultipartFile file,
@RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception {
List list = ExcelUtils.read(file, UserImportExcelVO.class);
- return success(userService.importUsers(list, updateSupport));
+ return success(userService.importUserList(list, updateSupport));
}
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserProfileController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserProfileController.java
index 50e1ef0cd..d9fc4a635 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserProfileController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserProfileController.java
@@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.system.controller.admin.user;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
-import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileRespVO;
@@ -31,6 +30,7 @@ import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_IS_EMPTY;
@@ -63,7 +63,7 @@ public class UserProfileController {
AdminUserDO user = userService.getUser(getLoginUserId());
UserProfileRespVO resp = UserConvert.INSTANCE.convert03(user);
// 获得用户角色
- List userRoles = roleService.getRolesFromCache(permissionService.getUserRoleIdListByUserId(user.getId()));
+ List userRoles = roleService.getRoleListFromCache(permissionService.getUserRoleIdListByUserId(user.getId()));
resp.setRoles(UserConvert.INSTANCE.convertList(userRoles));
// 获得部门信息
if (user.getDeptId() != null) {
@@ -72,7 +72,7 @@ public class UserProfileController {
}
// 获得岗位信息
if (CollUtil.isNotEmpty(user.getPostIds())) {
- List posts = postService.getPosts(user.getPostIds());
+ List posts = postService.getPostList(user.getPostIds());
resp.setPosts(UserConvert.INSTANCE.convertList02(posts));
}
// 获得社交用户信息
@@ -99,7 +99,7 @@ public class UserProfileController {
@Operation(summary = "上传用户个人头像")
public CommonResult updateUserAvatar(@RequestParam("avatarFile") MultipartFile file) throws Exception {
if (file.isEmpty()) {
- throw ServiceExceptionUtil.exception(FILE_IS_EMPTY);
+ throw exception(FILE_IS_EMPTY);
}
String avatar = userService.updateUserAvatar(getLoginUserId(), file.getInputStream());
return success(avatar);
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/auth/AuthConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/auth/AuthConvert.java
index 38e84ea1d..12fd35b1c 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/auth/AuthConvert.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/auth/AuthConvert.java
@@ -9,13 +9,15 @@ import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO;
import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO;
import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
-import cn.iocoder.yudao.module.system.enums.permission.MenuIdEnum;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import org.slf4j.LoggerFactory;
import java.util.*;
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList;
+import static cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO.ID_ROOT;
+
@Mapper
public interface AuthConvert {
@@ -47,7 +49,7 @@ public interface AuthConvert {
Map treeNodeMap = new LinkedHashMap<>();
menuList.forEach(menu -> treeNodeMap.put(menu.getId(), AuthConvert.INSTANCE.convertTreeNode(menu)));
// 处理父子关系
- treeNodeMap.values().stream().filter(node -> !node.getParentId().equals(MenuIdEnum.ROOT.getId())).forEach(childNode -> {
+ treeNodeMap.values().stream().filter(node -> !node.getParentId().equals(ID_ROOT)).forEach(childNode -> {
// 获得父节点
AuthMenuRespVO parentNode = treeNodeMap.get(childNode.getParentId());
if (parentNode == null) {
@@ -62,7 +64,7 @@ public interface AuthConvert {
parentNode.getChildren().add(childNode);
});
// 获得到所有的根节点
- return CollectionUtils.filterList(treeNodeMap.values(), node -> MenuIdEnum.ROOT.getId().equals(node.getParentId()));
+ return filterList(treeNodeMap.values(), node -> ID_ROOT.equals(node.getParentId()));
}
SocialUserBindReqDTO convert(Long userId, Integer userType, AuthSocialLoginReqVO reqVO);
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/permission/MenuDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/permission/MenuDO.java
index 5d77c50da..91e46bbff 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/permission/MenuDO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/permission/MenuDO.java
@@ -21,7 +21,12 @@ import lombok.EqualsAndHashCode;
public class MenuDO extends BaseDO {
/**
- * 菜单ID
+ * 菜单编号 - 根节点
+ */
+ public static final Long ID_ROOT = 0L;
+
+ /**
+ * 菜单编号
*/
@TableId
private Long id;
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/DeptMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/DeptMapper.java
index a7050a182..def79df69 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/DeptMapper.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/DeptMapper.java
@@ -4,7 +4,6 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@@ -19,9 +18,7 @@ public interface DeptMapper extends BaseMapperX {
}
default DeptDO selectByParentIdAndName(Long parentId, String name) {
- return selectOne(new LambdaQueryWrapper()
- .eq(DeptDO::getParentId, parentId)
- .eq(DeptDO::getName, name));
+ return selectOne(DeptDO::getParentId, parentId, DeptDO::getName, name);
}
default Long selectCountByParentId(Long parentId) {
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/PostMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/PostMapper.java
index 6bcb8e2fd..ba062a2c0 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/PostMapper.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/PostMapper.java
@@ -2,11 +2,10 @@ package cn.iocoder.yudao.module.system.dal.mysql.dept;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
-import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.PostDO;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.Collection;
@@ -16,31 +15,32 @@ import java.util.List;
public interface PostMapper extends BaseMapperX {
default List selectList(Collection ids, Collection statuses) {
- return selectList(new QueryWrapperX().inIfPresent("id", ids)
- .inIfPresent("status", statuses));
+ return selectList(new LambdaQueryWrapperX()
+ .inIfPresent(PostDO::getId, ids)
+ .inIfPresent(PostDO::getStatus, statuses));
}
default PageResult selectPage(PostPageReqVO reqVO) {
- return selectPage(reqVO, new QueryWrapperX()
- .likeIfPresent("code", reqVO.getCode())
- .likeIfPresent("name", reqVO.getName())
- .eqIfPresent("status", reqVO.getStatus())
- .orderByDesc("id"));
+ return selectPage(reqVO, new LambdaQueryWrapperX()
+ .likeIfPresent(PostDO::getCode, reqVO.getCode())
+ .likeIfPresent(PostDO::getName, reqVO.getName())
+ .eqIfPresent(PostDO::getStatus, reqVO.getStatus())
+ .orderByDesc(PostDO::getId));
}
default List selectList(PostExportReqVO reqVO) {
- return selectList(new QueryWrapperX()
- .likeIfPresent("code", reqVO.getCode())
- .likeIfPresent("name", reqVO.getName())
- .eqIfPresent("status", reqVO.getStatus()));
+ return selectList(new LambdaQueryWrapperX()
+ .likeIfPresent(PostDO::getCode, reqVO.getCode())
+ .likeIfPresent(PostDO::getName, reqVO.getName())
+ .eqIfPresent(PostDO::getStatus, reqVO.getStatus()));
}
default PostDO selectByName(String name) {
- return selectOne(new QueryWrapper().eq("name", name));
+ return selectOne(PostDO::getName, name);
}
default PostDO selectByCode(String code) {
- return selectOne(new QueryWrapper().eq("code", code));
+ return selectOne(PostDO::getCode, code);
}
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/UserPostMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/UserPostMapper.java
index 9d2601e8f..addc67d43 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/UserPostMapper.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/UserPostMapper.java
@@ -13,8 +13,7 @@ import java.util.List;
public interface UserPostMapper extends BaseMapperX {
default List selectListByUserId(Long userId) {
- return selectList(new LambdaQueryWrapperX()
- .eq(UserPostDO::getUserId, userId));
+ return selectList(UserPostDO::getUserId, userId);
}
default void deleteByUserIdAndPostId(Long userId, Collection postIds) {
@@ -24,11 +23,10 @@ public interface UserPostMapper extends BaseMapperX {
}
default List selectListByPostIds(Collection postIds) {
- return selectList(new LambdaQueryWrapperX()
- .in(UserPostDO::getPostId, postIds));
+ return selectList(UserPostDO::getPostId, postIds);
}
- default void deleteByUserId(Long userId){
+ default void deleteByUserId(Long userId) {
delete(Wrappers.lambdaUpdate(UserPostDO.class).eq(UserPostDO::getUserId, userId));
}
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dict/DictDataMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dict/DictDataMapper.java
index 951ef87af..244825093 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dict/DictDataMapper.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dict/DictDataMapper.java
@@ -17,13 +17,11 @@ import java.util.List;
public interface DictDataMapper extends BaseMapperX {
default DictDataDO selectByDictTypeAndValue(String dictType, String value) {
- return selectOne(new LambdaQueryWrapper().eq(DictDataDO::getDictType, dictType)
- .eq(DictDataDO::getValue, value));
+ return selectOne(DictDataDO::getDictType, dictType, DictDataDO::getValue, value);
}
default DictDataDO selectByDictTypeAndLabel(String dictType, String label) {
- return selectOne(new LambdaQueryWrapper().eq(DictDataDO::getDictType, dictType)
- .eq(DictDataDO::getLabel, label));
+ return selectOne(DictDataDO::getDictType, dictType, DictDataDO::getLabel, label);
}
default List selectByDictTypeAndValues(String dictType, Collection values) {
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/errorcode/ErrorCodeMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/errorcode/ErrorCodeMapper.java
index 3cb6bc8af..93baced06 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/errorcode/ErrorCodeMapper.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/errorcode/ErrorCodeMapper.java
@@ -36,11 +36,11 @@ public interface ErrorCodeMapper extends BaseMapperX {
}
default List selectListByCodes(Collection codes) {
- return selectList(new LambdaQueryWrapperX().in(ErrorCodeDO::getCode, codes));
+ return selectList(ErrorCodeDO::getCode, codes);
}
default ErrorCodeDO selectByCode(Integer code) {
- return selectOne(new LambdaQueryWrapperX().eq(ErrorCodeDO::getCode, code));
+ return selectOne(ErrorCodeDO::getCode, code);
}
default List selectListByApplicationNameAndUpdateTimeGt(String applicationName, LocalDateTime minUpdateTime) {
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/MenuMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/MenuMapper.java
index cdab84b53..3d645bdf2 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/MenuMapper.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/MenuMapper.java
@@ -4,7 +4,6 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.permission.vo.menu.MenuListReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@@ -13,8 +12,7 @@ import java.util.List;
public interface MenuMapper extends BaseMapperX {
default MenuDO selectByParentIdAndName(Long parentId, String name) {
- return selectOne(new LambdaQueryWrapper().eq(MenuDO::getParentId, parentId)
- .eq(MenuDO::getName, name));
+ return selectOne(MenuDO::getParentId, parentId, MenuDO::getName, name);
}
default Long selectCountByParentId(Long parentId) {
@@ -22,7 +20,8 @@ public interface MenuMapper extends BaseMapperX {
}
default List selectList(MenuListReqVO reqVO) {
- return selectList(new LambdaQueryWrapperX().likeIfPresent(MenuDO::getName, reqVO.getName())
+ return selectList(new LambdaQueryWrapperX()
+ .likeIfPresent(MenuDO::getName, reqVO.getName())
.eqIfPresent(MenuDO::getStatus, reqVO.getStatus()));
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/social/SocialUserBindMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/social/SocialUserBindMapper.java
index 88d0c9227..28619ca51 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/social/SocialUserBindMapper.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/social/SocialUserBindMapper.java
@@ -24,9 +24,8 @@ public interface SocialUserBindMapper extends BaseMapperX {
}
default SocialUserBindDO selectByUserTypeAndSocialUserId(Integer userType, Long socialUserId) {
- return selectOne(new LambdaQueryWrapperX()
- .eq(SocialUserBindDO::getUserType, userType)
- .eq(SocialUserBindDO::getSocialUserId, socialUserId));
+ return selectOne(SocialUserBindDO::getUserType, userType,
+ SocialUserBindDO::getSocialUserId, socialUserId);
}
default List selectListByUserIdAndUserType(Long userId, Integer userType) {
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java
index e6713bacb..4e0827210 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java
@@ -6,7 +6,6 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.Collection;
@@ -16,15 +15,15 @@ import java.util.List;
public interface AdminUserMapper extends BaseMapperX {
default AdminUserDO selectByUsername(String username) {
- return selectOne(new LambdaQueryWrapper().eq(AdminUserDO::getUsername, username));
+ return selectOne(AdminUserDO::getUsername, username);
}
default AdminUserDO selectByEmail(String email) {
- return selectOne(new LambdaQueryWrapper().eq(AdminUserDO::getEmail, email));
+ return selectOne(AdminUserDO::getEmail, email);
}
default AdminUserDO selectByMobile(String mobile) {
- return selectOne(new LambdaQueryWrapper().eq(AdminUserDO::getMobile, mobile));
+ return selectOne(AdminUserDO::getMobile, mobile);
}
default PageResult selectPage(UserPageReqVO reqVO, Collection deptIds) {
@@ -50,10 +49,6 @@ public interface AdminUserMapper extends BaseMapperX {
return selectList(new LambdaQueryWrapperX().like(AdminUserDO::getNickname, nickname));
}
- default List selectListByUsername(String username) {
- return selectList(new LambdaQueryWrapperX().like(AdminUserDO::getUsername, username));
- }
-
default List selectListByStatus(Integer status) {
return selectList(AdminUserDO::getStatus, status);
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java
index 490284242..ca34156eb 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java
@@ -94,7 +94,7 @@ public class AdminAuthServiceImpl implements AdminAuthService {
@Override
public AuthLoginRespVO login(AuthLoginReqVO reqVO) {
// 校验验证码
- verifyCaptcha(reqVO);
+ validateCaptcha(reqVO);
// 使用账号密码,进行登录
AdminUserDO user = authenticate(reqVO.getUsername(), reqVO.getPassword());
@@ -171,14 +171,8 @@ public class AdminAuthServiceImpl implements AdminAuthService {
return createTokenAfterLoginSuccess(user.getId(), user.getUsername(), LoginLogTypeEnum.LOGIN_SOCIAL);
}
- @Override
- public AuthLoginRespVO refreshToken(String refreshToken) {
- OAuth2AccessTokenDO accessTokenDO = oauth2TokenService.refreshAccessToken(refreshToken, OAuth2ClientConstants.CLIENT_ID_DEFAULT);
- return AuthConvert.INSTANCE.convert(accessTokenDO);
- }
-
@VisibleForTesting
- void verifyCaptcha(AuthLoginReqVO reqVO) {
+ void validateCaptcha(AuthLoginReqVO reqVO) {
// 如果验证码关闭,则不进行校验
if (!captchaEnable) {
return;
@@ -206,6 +200,12 @@ public class AdminAuthServiceImpl implements AdminAuthService {
return AuthConvert.INSTANCE.convert(accessTokenDO);
}
+ @Override
+ public AuthLoginRespVO refreshToken(String refreshToken) {
+ OAuth2AccessTokenDO accessTokenDO = oauth2TokenService.refreshAccessToken(refreshToken, OAuth2ClientConstants.CLIENT_ID_DEFAULT);
+ return AuthConvert.INSTANCE.convert(accessTokenDO);
+ }
+
@Override
public void logout(String token, Integer logType) {
// 删除访问令牌
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptService.java
index a6c30bc10..87033d4b3 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptService.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptService.java
@@ -52,7 +52,7 @@ public interface DeptService {
* @param reqVO 筛选条件请求 VO
* @return 部门列表
*/
- List getSimpleDepts(DeptListReqVO reqVO);
+ List getDeptList(DeptListReqVO reqVO);
/**
* 获得所有子部门,从缓存中
@@ -61,7 +61,7 @@ public interface DeptService {
* @param recursive 是否递归获取所有
* @return 子部门列表
*/
- List getDeptsByParentIdFromCache(Long parentId, boolean recursive);
+ List getDeptListByParentIdFromCache(Long parentId, boolean recursive);
/**
* 获得部门信息数组
@@ -69,7 +69,21 @@ public interface DeptService {
* @param ids 部门编号数组
* @return 部门信息数组
*/
- List getDepts(Collection ids);
+ List getDeptList(Collection ids);
+
+ /**
+ * 获得指定编号的部门 Map
+ *
+ * @param ids 部门编号数组
+ * @return 部门 Map
+ */
+ default Map