pageResult = testDemoService.getTestDemoPage(pageVO);
return success(TestDemoConvert.INSTANCE.convertPage(pageResult));
}
@GetMapping("/export-excel")
- @ApiOperation("导出字典类型 Excel")
+ @Operation(summary = "导出字典类型 Excel")
@PreAuthorize("@ss.hasPermission('infra:test-demo:export')") @OperateLog(type = EXPORT)
public void exportTestDemoExcel(@Valid TestDemoExportReqVO exportReqVO,
HttpServletResponse response) throws IOException {
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoBaseVO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoBaseVO.java
index 1f657938e..a0216683d 100755
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoBaseVO.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoBaseVO.java
@@ -1,8 +1,6 @@
package cn.iocoder.yudao.module.infra.controller.admin.test.vo;
-
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
-import java.util.*;
-import io.swagger.annotations.*;
import javax.validation.constraints.*;
/**
@@ -12,23 +10,23 @@ import javax.validation.constraints.*;
@Data
public class TestDemoBaseVO {
- @ApiModelProperty(value = "名字", required = true)
+ @Schema(description = "名字", required = true)
@NotNull(message = "名字不能为空")
private String name;
- @ApiModelProperty(value = "状态", required = true)
+ @Schema(description = "状态", required = true)
@NotNull(message = "状态不能为空")
private Integer status;
- @ApiModelProperty(value = "类型", required = true)
+ @Schema(description = "类型", required = true)
@NotNull(message = "类型不能为空")
private Integer type;
- @ApiModelProperty(value = "分类", required = true)
+ @Schema(description = "分类", required = true)
@NotNull(message = "分类不能为空")
private Integer category;
- @ApiModelProperty(value = "备注")
+ @Schema(description = "备注")
private String remark;
}
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoCreateReqVO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoCreateReqVO.java
index d932daac6..3b46fd1cd 100755
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoCreateReqVO.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoCreateReqVO.java
@@ -1,9 +1,8 @@
package cn.iocoder.yudao.module.infra.controller.admin.test.vo;
-
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
-import io.swagger.annotations.*;
-@ApiModel("管理后台 - 字典类型创建 Request VO")
+@Schema(description = "管理后台 - 字典类型创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoExportReqVO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoExportReqVO.java
index 8c386d4c1..8e10484e3 100755
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoExportReqVO.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoExportReqVO.java
@@ -1,34 +1,33 @@
package cn.iocoder.yudao.module.infra.controller.admin.test.vo;
-
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
-import io.swagger.annotations.*;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
-@ApiModel(value = "管理后台 - 字典类型 Excel 导出 Request VO", description = "参数和 TestDemoPageReqVO 是一致的")
+@Schema(description = "管理后台 - 字典类型 Excel 导出 Request VO,参数和 TestDemoPageReqVO 是一致的")
@Data
public class TestDemoExportReqVO {
- @ApiModelProperty(value = "名字")
+ @Schema(description = "名字")
private String name;
- @ApiModelProperty(value = "状态")
+ @Schema(description = "状态")
private Integer status;
- @ApiModelProperty(value = "类型")
+ @Schema(description = "类型")
private Integer type;
- @ApiModelProperty(value = "分类")
+ @Schema(description = "分类")
private Integer category;
- @ApiModelProperty(value = "备注")
+ @Schema(description = "备注")
private String remark;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
- @ApiModelProperty(value = "创建时间")
+ @Schema(description = "创建时间")
private LocalDateTime[] createTime;
}
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoPageReqVO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoPageReqVO.java
index 56b14c3d4..abb5843db 100755
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoPageReqVO.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoPageReqVO.java
@@ -1,37 +1,36 @@
package cn.iocoder.yudao.module.infra.controller.admin.test.vo;
-
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
-import io.swagger.annotations.*;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
-@ApiModel("管理后台 - 字典类型分页 Request VO")
+@Schema(description = "管理后台 - 字典类型分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class TestDemoPageReqVO extends PageParam {
- @ApiModelProperty(value = "名字")
+ @Schema(description = "名字")
private String name;
- @ApiModelProperty(value = "状态")
+ @Schema(description = "状态")
private Integer status;
- @ApiModelProperty(value = "类型")
+ @Schema(description = "类型")
private Integer type;
- @ApiModelProperty(value = "分类")
+ @Schema(description = "分类")
private Integer category;
- @ApiModelProperty(value = "备注")
+ @Schema(description = "备注")
private String remark;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
- @ApiModelProperty(value = "创建时间")
+ @Schema(description = "创建时间")
private LocalDateTime[] createTime;
}
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoRespVO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoRespVO.java
index 4b38ee401..312a5eb98 100755
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoRespVO.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoRespVO.java
@@ -1,20 +1,19 @@
package cn.iocoder.yudao.module.infra.controller.admin.test.vo;
-
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.time.LocalDateTime;
-import io.swagger.annotations.*;
-@ApiModel("管理后台 - 字典类型 Response VO")
+@Schema(description = "管理后台 - 字典类型 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class TestDemoRespVO extends TestDemoBaseVO {
- @ApiModelProperty(value = "编号", required = true)
+ @Schema(description = "编号", required = true)
private Long id;
- @ApiModelProperty(value = "创建时间", required = true)
+ @Schema(description = "创建时间", required = true)
private LocalDateTime createTime;
}
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoUpdateReqVO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoUpdateReqVO.java
index 59d56b4da..6df36addb 100755
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoUpdateReqVO.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/test/vo/TestDemoUpdateReqVO.java
@@ -1,16 +1,15 @@
package cn.iocoder.yudao.module.infra.controller.admin.test.vo;
-
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
-import io.swagger.annotations.*;
import javax.validation.constraints.*;
-@ApiModel("管理后台 - 字典类型更新 Request VO")
+@Schema(description = "管理后台 - 字典类型更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class TestDemoUpdateReqVO extends TestDemoBaseVO {
- @ApiModelProperty(value = "编号", required = true)
+ @Schema(description = "编号", required = true)
@NotNull(message = "编号不能为空")
private Long id;
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/framework/security/config/SecurityConfiguration.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/security/config/SecurityConfiguration.java
index c99cc1a8d..01b5714ba 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/security/config/SecurityConfiguration.java
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/security/config/SecurityConfiguration.java
@@ -23,7 +23,9 @@ public class SecurityConfiguration {
@Override
public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) {
// Swagger 接口文档
- registry.antMatchers("/swagger-ui.html").anonymous()
+ registry.antMatchers("/v3/api-docs/**").permitAll()
+ .antMatchers("/swagger-ui.html").permitAll()
+ .antMatchers("/swagger-ui/**").permitAll()
.antMatchers("/swagger-resources/**").anonymous()
.antMatchers("/webjars/**").anonymous()
.antMatchers("/*/api-docs").anonymous();
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/web/config/InfraWebConfiguration.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/web/config/InfraWebConfiguration.java
new file mode 100644
index 000000000..09f2c2b3f
--- /dev/null
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/web/config/InfraWebConfiguration.java
@@ -0,0 +1,24 @@
+package cn.iocoder.yudao.module.infra.framework.web.config;
+
+import cn.iocoder.yudao.framework.swagger.config.YudaoSwaggerAutoConfiguration;
+import org.springdoc.core.GroupedOpenApi;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * infra 模块的 web 组件的 Configuration
+ *
+ * @author 芋道源码
+ */
+@Configuration(proxyBeanMethods = false)
+public class InfraWebConfiguration {
+
+ /**
+ * infra 模块的 API 分组
+ */
+ @Bean
+ public GroupedOpenApi infraGroupedOpenApi() {
+ return YudaoSwaggerAutoConfiguration.buildGroupedOpenApi("infra");
+ }
+
+}
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/web/package-info.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/web/package-info.java
new file mode 100644
index 000000000..6fb49bfde
--- /dev/null
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/web/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * infra 模块的 web 配置
+ */
+package cn.iocoder.yudao.module.infra.framework.web;
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/controller/controller.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/controller.vm
index 5b0546777..a8c1f62c5 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/controller.vm
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/controller.vm
@@ -5,7 +5,9 @@ import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
#if ($sceneEnum.scene == 1)import org.springframework.security.access.prepost.PreAuthorize;#end
-import io.swagger.annotations.*;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
@@ -27,7 +29,7 @@ import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.business
import ${basePackage}.module.${table.moduleName}.convert.${table.businessName}.${table.className}Convert;
import ${basePackage}.module.${table.moduleName}.service.${table.businessName}.${table.className}Service;
-@Api(tags = "${sceneEnum.name} - ${table.classComment}")
+@Tag(name = "${sceneEnum.name} - ${table.classComment}")
@RestController
##二级的 businessName 暂时不算在 HTTP 路径上,可以根据需要写
@RequestMapping("/${table.moduleName}/${simpleClassName_strikeCase}")
@@ -38,7 +40,7 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
private ${table.className}Service ${classNameVar}Service;
@PostMapping("/create")
- @ApiOperation("创建${table.classComment}")
+ @Operation(summary = "创建${table.classComment}")
#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:create')")#end
public CommonResult<${primaryColumn.javaType}> create${simpleClassName}(@Valid @RequestBody ${sceneEnum.prefixClass}${table.className}CreateReqVO createReqVO) {
@@ -46,7 +48,7 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
}
@PutMapping("/update")
- @ApiOperation("更新${table.classComment}")
+ @Operation(summary = "更新${table.classComment}")
#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:update')")#end
public CommonResult update${simpleClassName}(@Valid @RequestBody ${sceneEnum.prefixClass}${table.className}UpdateReqVO updateReqVO) {
@@ -55,8 +57,8 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
}
@DeleteMapping("/delete")
- @ApiOperation("删除${table.classComment}")
- @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = ${primaryColumn.javaType}.class)
+ @Operation(summary = "删除${table.classComment}")
+ @Parameter(name = "id", description = "编号", required = true)
#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:delete')")#end
public CommonResult delete${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) {
@@ -65,8 +67,8 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
}
@GetMapping("/get")
- @ApiOperation("获得${table.classComment}")
- @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = ${primaryColumn.javaType}.class)
+ @Operation(summary = "获得${table.classComment}")
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")#end
public CommonResult<${sceneEnum.prefixClass}${table.className}RespVO> get${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) {
@@ -75,8 +77,8 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
}
@GetMapping("/list")
- @ApiOperation("获得${table.classComment}列表")
- @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
+ @Operation(summary = "获得${table.classComment}列表")
+ @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")#end
public CommonResult> get${simpleClassName}List(@RequestParam("ids") Collection<${primaryColumn.javaType}> ids) {
@@ -85,7 +87,7 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
}
@GetMapping("/page")
- @ApiOperation("获得${table.classComment}分页")
+ @Operation(summary = "获得${table.classComment}分页")
#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")#end
public CommonResult> get${simpleClassName}Page(@Valid ${sceneEnum.prefixClass}${table.className}PageReqVO pageVO) {
@@ -94,7 +96,7 @@ public class ${sceneEnum.prefixClass}${table.className}Controller {
}
@GetMapping("/export-excel")
- @ApiOperation("导出${table.classComment} Excel")
+ @Operation(summary = "导出${table.classComment} Excel")
#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:export')")#end
@OperateLog(type = EXPORT)
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/_column.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/_column.vm
index 69477d433..89a8e348f 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/_column.vm
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/_column.vm
@@ -1,5 +1,5 @@
## 提供给 baseVO、createVO、updateVO 生成字段
- @ApiModelProperty(value = "${column.columnComment}"#if (!${column.nullable}), required = true#end#if ("$!column.example" != ""), example = "${column.example}"#end)
+ @Schema(description = "${column.columnComment}"#if (!${column.nullable}), required = true#end#if ("$!column.example" != ""), example = "${column.example}"#end)
#if (!${column.nullable})## 判断 @NotEmpty 和 @NotNull 注解
#if (${field.fieldType} == 'String')
@NotEmpty(message = "${column.columnComment}不能为空")
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/baseVO.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/baseVO.vm
index a0ad48d60..e2c1f0b39 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/baseVO.vm
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/baseVO.vm
@@ -1,5 +1,6 @@
package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
#foreach ($column in $columns)
@@ -10,7 +11,6 @@ import java.math.BigDecimal;
import java.time.LocalDateTime;
#end
#end
-import io.swagger.annotations.*;
import javax.validation.constraints.*;
## 处理 Date 字段的引入
#foreach ($column in $columns)
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/createReqVO.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/createReqVO.vm
index bf6408c9c..d4f6f8ea9 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/createReqVO.vm
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/createReqVO.vm
@@ -2,7 +2,7 @@ package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePac
import lombok.*;
import java.util.*;
-import io.swagger.annotations.*;
+import io.swagger.v3.oas.annotations.media.Schema;
import javax.validation.constraints.*;
## 处理 Date 字段的引入
#foreach ($column in $columns)
@@ -15,7 +15,7 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
#end
#end
-@ApiModel("${sceneEnum.name} - ${table.classComment}创建 Request VO")
+@Schema(description = "${sceneEnum.name} - ${table.classComment}创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/excelVO.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/excelVO.vm
index 8bfd92b69..15c6660c8 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/excelVO.vm
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/excelVO.vm
@@ -1,5 +1,6 @@
package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
#foreach ($column in $columns)
@@ -10,7 +11,6 @@ import java.math.BigDecimal;
import java.time.LocalDateTime;
#end
#end
-import io.swagger.annotations.*;
import com.alibaba.excel.annotation.ExcelProperty;
#foreach ($column in $columns)
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/exportReqVO.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/exportReqVO.vm
index cd68dd82e..d3ef4aacd 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/exportReqVO.vm
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/exportReqVO.vm
@@ -2,7 +2,7 @@ package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePac
import lombok.*;
import java.util.*;
-import io.swagger.annotations.*;
+import io.swagger.v3.oas.annotations.media.Schema;
import ${PageParamClassName};
## 处理 Date 字段的引入
#foreach ($column in $columns)
@@ -16,18 +16,18 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
#end
## 字段模板
#macro(columnTpl $prefix $prefixStr)
- @ApiModelProperty(value = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end)
+ @Schema(description = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end)
private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end;
#end
-@ApiModel(value = "${sceneEnum.name} - ${table.classComment} Excel 导出 Request VO", description = "参数和 ${table.className}PageReqVO 是一致的")
+@Schema(description = "${sceneEnum.name} - ${table.classComment} Excel 导出 Request VO,参数和 ${table.className}PageReqVO 是一致的")
@Data
public class ${sceneEnum.prefixClass}${table.className}ExportReqVO {
#foreach ($column in $columns)
#if (${column.listOperation})##查询操作
#if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候
- @ApiModelProperty(value = "${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end)
+ @Schema(description = "${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end)
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private ${column.javaType}[] ${column.javaField};
#else##情况二,非 Between 的时间
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/pageReqVO.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/pageReqVO.vm
index f2664390a..6f9868da3 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/pageReqVO.vm
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/pageReqVO.vm
@@ -2,7 +2,7 @@ package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePac
import lombok.*;
import java.util.*;
-import io.swagger.annotations.*;
+import io.swagger.v3.oas.annotations.media.Schema;
import ${PageParamClassName};
## 处理 Date 字段的引入
#foreach ($column in $columns)
@@ -16,11 +16,11 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
#end
## 字段模板
#macro(columnTpl $prefix $prefixStr)
- @ApiModelProperty(value = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end)
+ @Schema(description = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end)
private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end;
#end
-@ApiModel("${sceneEnum.name} - ${table.classComment}分页 Request VO")
+@Schema(description = "${sceneEnum.name} - ${table.classComment}分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@@ -29,7 +29,7 @@ public class ${sceneEnum.prefixClass}${table.className}PageReqVO extends PagePar
#foreach ($column in $columns)
#if (${column.listOperation})##查询操作
#if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候
- @ApiModelProperty(value = "${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end)
+ @Schema(description = "${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end)
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private ${column.javaType}[] ${column.javaField};
#else##情况二,非 Between 的时间
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/respVO.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/respVO.vm
index 19bc32db6..2288ceee8 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/respVO.vm
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/respVO.vm
@@ -1,5 +1,6 @@
package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
#foreach ($column in $columns)
#if (${column.javaType} == "LocalDateTime")
@@ -7,9 +8,8 @@ import java.time.LocalDateTime;
#break
#end
#end
-import io.swagger.annotations.*;
-@ApiModel("${sceneEnum.name} - ${table.classComment} Response VO")
+@Schema(description = "${sceneEnum.name} - ${table.classComment} Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@@ -17,7 +17,7 @@ public class ${sceneEnum.prefixClass}${table.className}RespVO extends ${sceneEnu
#foreach ($column in $columns)
#if (${column.listOperationResult} && (!${column.createOperation} || !${column.updateOperation}))##不是通用字段
- @ApiModelProperty(value = "${column.columnComment}"#if (!${column.nullable}), required = true#end#if ("$!column.example" != ""), example = "${column.example}"#end)
+ @Schema(description = "${column.columnComment}"#if (!${column.nullable}), required = true#end#if ("$!column.example" != ""), example = "${column.example}"#end)
private ${column.javaType} ${column.javaField};
#end
diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/updateReqVO.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/updateReqVO.vm
index 636991508..48d74321d 100644
--- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/updateReqVO.vm
+++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/updateReqVO.vm
@@ -1,8 +1,8 @@
package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
-import io.swagger.annotations.*;
import javax.validation.constraints.*;
## 处理 Date 字段的引入
#foreach ($column in $columns)
@@ -15,7 +15,7 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
#end
#end
-@ApiModel("${sceneEnum.name} - ${table.classComment}更新 Request VO")
+@Schema(description = "${sceneEnum.name} - ${table.classComment}更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
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/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/ProductBrandController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/ProductBrandController.java
index 2227afeaf..0e6f7f3bc 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/ProductBrandController.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/ProductBrandController.java
@@ -6,9 +6,9 @@ import cn.iocoder.yudao.module.product.controller.admin.brand.vo.*;
import cn.iocoder.yudao.module.product.convert.brand.ProductBrandConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.brand.ProductBrandDO;
import cn.iocoder.yudao.module.product.service.brand.ProductBrandService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiOperation;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -20,7 +20,7 @@ import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
-@Api(tags = "管理后台 - 商品品牌")
+@Tag(name = "管理后台 - 商品品牌")
@RestController
@RequestMapping("/product/brand")
@Validated
@@ -30,14 +30,14 @@ public class ProductBrandController {
private ProductBrandService brandService;
@PostMapping("/create")
- @ApiOperation("创建品牌")
+ @Operation(summary = "创建品牌")
@PreAuthorize("@ss.hasPermission('product:brand:create')")
public CommonResult createBrand(@Valid @RequestBody ProductBrandCreateReqVO createReqVO) {
return success(brandService.createBrand(createReqVO));
}
@PutMapping("/update")
- @ApiOperation("更新品牌")
+ @Operation(summary = "更新品牌")
@PreAuthorize("@ss.hasPermission('product:brand:update')")
public CommonResult updateBrand(@Valid @RequestBody ProductBrandUpdateReqVO updateReqVO) {
brandService.updateBrand(updateReqVO);
@@ -45,8 +45,8 @@ public class ProductBrandController {
}
@DeleteMapping("/delete")
- @ApiOperation("删除品牌")
- @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
+ @Operation(summary = "删除品牌")
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('product:brand:delete')")
public CommonResult deleteBrand(@RequestParam("id") Long id) {
brandService.deleteBrand(id);
@@ -54,8 +54,8 @@ public class ProductBrandController {
}
@GetMapping("/get")
- @ApiOperation("获得品牌")
- @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
+ @Operation(summary = "获得品牌")
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('product:brand:query')")
public CommonResult getBrand(@RequestParam("id") Long id) {
ProductBrandDO brand = brandService.getBrand(id);
@@ -63,7 +63,7 @@ public class ProductBrandController {
}
@GetMapping("/page")
- @ApiOperation("获得品牌分页")
+ @Operation(summary = "获得品牌分页")
@PreAuthorize("@ss.hasPermission('product:brand:query')")
public CommonResult> getBrandPage(@Valid ProductBrandPageReqVO pageVO) {
PageResult pageResult = brandService.getBrandPage(pageVO);
@@ -71,7 +71,7 @@ public class ProductBrandController {
}
@GetMapping("/list")
- @ApiOperation("获得品牌列表")
+ @Operation(summary = "获得品牌列表")
@PreAuthorize("@ss.hasPermission('product:brand:query')")
public CommonResult> getBrandList(@Valid ProductBrandListReqVO listVO) {
List list = brandService.getBrandList(listVO);
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandBaseVO.java
index fa5ecd2d1..e8561fe07 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandBaseVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandBaseVO.java
@@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.product.controller.admin.brand.vo;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
@@ -12,22 +12,22 @@ import javax.validation.constraints.NotNull;
@Data
public class ProductBrandBaseVO {
- @ApiModelProperty(value = "品牌名称", required = true, example = "芋道")
+ @Schema(description = "品牌名称", required = true, example = "芋道")
@NotNull(message = "品牌名称不能为空")
private String name;
- @ApiModelProperty(value = "品牌图片", required = true)
+ @Schema(description = "品牌图片", required = true)
@NotNull(message = "品牌图片不能为空")
private String picUrl;
- @ApiModelProperty(value = "品牌排序", required = true, example = "1")
+ @Schema(description = "品牌排序", required = true, example = "1")
@NotNull(message = "品牌排序不能为空")
private Integer sort;
- @ApiModelProperty(value = "品牌描述", example = "描述")
+ @Schema(description = "品牌描述", example = "描述")
private String description;
- @ApiModelProperty(value = "状态", required = true, example = "0")
+ @Schema(description = "状态", required = true, example = "0")
@NotNull(message = "状态不能为空")
private Integer status;
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandCreateReqVO.java
index 74024929f..dc85a476b 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandCreateReqVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandCreateReqVO.java
@@ -1,9 +1,11 @@
package cn.iocoder.yudao.module.product.controller.admin.brand.vo;
-import lombok.*;
-import io.swagger.annotations.*;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
-@ApiModel("管理后台 - 商品品牌创建 Request VO")
+@Schema(description = "管理后台 - 商品品牌创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandListReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandListReqVO.java
index 5367e2dfe..63305810c 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandListReqVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandListReqVO.java
@@ -1,14 +1,13 @@
package cn.iocoder.yudao.module.product.controller.admin.brand.vo;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
-@ApiModel(value = "管理后台 - 商品品牌分页 Request VO")
+@Schema(description = "管理后台 - 商品品牌分页 Request VO")
@Data
public class ProductBrandListReqVO {
- @ApiModelProperty(value = "品牌名称", example = "芋道")
+ @Schema(description = "品牌名称", example = "芋道")
private String name;
}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandPageReqVO.java
index c5a7b0047..81d470b1b 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandPageReqVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandPageReqVO.java
@@ -1,8 +1,7 @@
package cn.iocoder.yudao.module.product.controller.admin.brand.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@@ -12,20 +11,20 @@ import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
-@ApiModel("管理后台 - 商品品牌分页 Request VO")
+@Schema(description = "管理后台 - 商品品牌分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductBrandPageReqVO extends PageParam {
- @ApiModelProperty(value = "品牌名称", example = "芋道")
+ @Schema(description = "品牌名称", example = "芋道")
private String name;
- @ApiModelProperty(value = "状态", example = "0", notes = "参考 CommonStatusEnum 枚举")
+ @Schema(description = "状态", example = "0")
private Integer status;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
- @ApiModelProperty(value = "创建时间")
+ @Schema(description = "创建时间")
private LocalDateTime[] createTime;
}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandRespVO.java
index fb4ce0954..b68fbc5be 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandRespVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandRespVO.java
@@ -1,23 +1,22 @@
package cn.iocoder.yudao.module.product.controller.admin.brand.vo;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.time.LocalDateTime;
-@ApiModel("管理后台 - 品牌 Response VO")
+@Schema(description = "管理后台 - 品牌 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductBrandRespVO extends ProductBrandBaseVO {
- @ApiModelProperty(value = "品牌编号", required = true, example = "1")
+ @Schema(description = "品牌编号", required = true, example = "1")
private Long id;
- @ApiModelProperty(value = "创建时间", required = true)
+ @Schema(description = "创建时间", required = true)
private LocalDateTime createTime;
}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandUpdateReqVO.java
index 54d610207..c01c3c4b7 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandUpdateReqVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/brand/vo/ProductBrandUpdateReqVO.java
@@ -1,16 +1,19 @@
package cn.iocoder.yudao.module.product.controller.admin.brand.vo;
-import lombok.*;
-import io.swagger.annotations.*;
-import javax.validation.constraints.*;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
-@ApiModel("管理后台 - 商品品牌更新 Request VO")
+import javax.validation.constraints.NotNull;
+
+@Schema(description = "管理后台 - 商品品牌更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductBrandUpdateReqVO extends ProductBrandBaseVO {
- @ApiModelProperty(value = "品牌编号", required = true, example = "1")
+ @Schema(description = "品牌编号", required = true, example = "1")
@NotNull(message = "品牌编号不能为空")
private Long id;
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/ProductCategoryController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/ProductCategoryController.java
index 4144e6a57..dc3a57a38 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/ProductCategoryController.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/ProductCategoryController.java
@@ -1,16 +1,16 @@
package cn.iocoder.yudao.module.product.controller.admin.category;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
-import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryRespVO;
-import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO;
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryCreateReqVO;
+import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO;
+import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryRespVO;
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryUpdateReqVO;
import cn.iocoder.yudao.module.product.convert.category.ProductCategoryConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
import cn.iocoder.yudao.module.product.service.category.ProductCategoryService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiOperation;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -22,7 +22,7 @@ import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
-@Api(tags = "管理后台 - 商品分类")
+@Tag(name = "管理后台 - 商品分类")
@RestController
@RequestMapping("/product/category")
@Validated
@@ -32,14 +32,14 @@ public class ProductCategoryController {
private ProductCategoryService categoryService;
@PostMapping("/create")
- @ApiOperation("创建商品分类")
+ @Operation(summary = "创建商品分类")
@PreAuthorize("@ss.hasPermission('product:category:create')")
public CommonResult createCategory(@Valid @RequestBody ProductCategoryCreateReqVO createReqVO) {
return success(categoryService.createCategory(createReqVO));
}
@PutMapping("/update")
- @ApiOperation("更新商品分类")
+ @Operation(summary = "更新商品分类")
@PreAuthorize("@ss.hasPermission('product:category:update')")
public CommonResult updateCategory(@Valid @RequestBody ProductCategoryUpdateReqVO updateReqVO) {
categoryService.updateCategory(updateReqVO);
@@ -47,8 +47,8 @@ public class ProductCategoryController {
}
@DeleteMapping("/delete")
- @ApiOperation("删除商品分类")
- @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
+ @Operation(summary = "删除商品分类")
+ @Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('product:category:delete')")
public CommonResult deleteCategory(@RequestParam("id") Long id) {
categoryService.deleteCategory(id);
@@ -56,8 +56,8 @@ public class ProductCategoryController {
}
@GetMapping("/get")
- @ApiOperation("获得商品分类")
- @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
+ @Operation(summary = "获得商品分类")
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('product:category:query')")
public CommonResult getCategory(@RequestParam("id") Long id) {
ProductCategoryDO category = categoryService.getCategory(id);
@@ -65,7 +65,7 @@ public class ProductCategoryController {
}
@GetMapping("/list")
- @ApiOperation("获得商品分类列表")
+ @Operation(summary = "获得商品分类列表")
@PreAuthorize("@ss.hasPermission('product:category:query')")
public CommonResult> getCategoryList(@Valid ProductCategoryListReqVO treeListReqVO) {
List list = categoryService.getEnableCategoryList(treeListReqVO);
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryBaseVO.java
index 9b9c77a08..5182bdadd 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryBaseVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryBaseVO.java
@@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.product.controller.admin.category.vo;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@@ -13,25 +13,25 @@ import javax.validation.constraints.NotNull;
@Data
public class ProductCategoryBaseVO {
- @ApiModelProperty(value = "父分类编号", required = true, example = "1")
+ @Schema(description = "父分类编号", required = true, example = "1")
@NotNull(message = "父分类编号不能为空")
private Long parentId;
- @ApiModelProperty(value = "分类名称", required = true, example = "办公文具")
+ @Schema(description = "分类名称", required = true, example = "办公文具")
@NotBlank(message = "分类名称不能为空")
private String name;
- @ApiModelProperty(value = "分类图片", required = true)
+ @Schema(description = "分类图片", required = true)
@NotBlank(message = "分类图片不能为空")
private String picUrl;
- @ApiModelProperty(value = "分类排序", required = true, example = "1")
+ @Schema(description = "分类排序", required = true, example = "1")
private Integer sort;
- @ApiModelProperty(value = "分类描述", required = true, example = "描述")
+ @Schema(description = "分类描述", required = true, example = "描述")
private String description;
- @ApiModelProperty(value = "开启状态", required = true, example = "0")
+ @Schema(description = "开启状态", required = true, example = "0")
@NotNull(message = "开启状态不能为空")
private Integer status;
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryCreateReqVO.java
index d35e1ad3c..f9b559776 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryCreateReqVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryCreateReqVO.java
@@ -1,9 +1,11 @@
package cn.iocoder.yudao.module.product.controller.admin.category.vo;
-import lombok.*;
-import io.swagger.annotations.*;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
-@ApiModel("管理后台 - 商品分类创建 Request VO")
+@Schema(description = "管理后台 - 商品分类创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryListReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryListReqVO.java
index a487c16a4..9c9439d3e 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryListReqVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryListReqVO.java
@@ -1,14 +1,13 @@
package cn.iocoder.yudao.module.product.controller.admin.category.vo;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
-@ApiModel(value = "管理后台 - 商品分类列表查询 Request VO")
+@Schema(description = "管理后台 - 商品分类列表查询 Request VO")
@Data
public class ProductCategoryListReqVO {
- @ApiModelProperty(value = "分类名称", example = "办公文具")
+ @Schema(description = "分类名称", example = "办公文具")
private String name;
}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryRespVO.java
index c6fdfcfe1..484e0e51e 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryRespVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryRespVO.java
@@ -1,20 +1,22 @@
package cn.iocoder.yudao.module.product.controller.admin.category.vo;
-import lombok.*;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
import java.time.LocalDateTime;
-import io.swagger.annotations.*;
-@ApiModel("管理后台 - 商品分类 Response VO")
+@Schema(description = "管理后台 - 商品分类 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductCategoryRespVO extends ProductCategoryBaseVO {
- @ApiModelProperty(value = "分类编号", required = true, example = "2")
+ @Schema(description = "分类编号", required = true, example = "2")
private Long id;
- @ApiModelProperty(value = "创建时间", required = true)
+ @Schema(description = "创建时间", required = true)
private LocalDateTime createTime;
}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryUpdateReqVO.java
index b0c8fe57d..15f663761 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryUpdateReqVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/category/vo/ProductCategoryUpdateReqVO.java
@@ -1,16 +1,19 @@
package cn.iocoder.yudao.module.product.controller.admin.category.vo;
-import lombok.*;
-import io.swagger.annotations.*;
-import javax.validation.constraints.*;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
-@ApiModel("管理后台 - 商品分类更新 Request VO")
+import javax.validation.constraints.NotNull;
+
+@Schema(description = "管理后台 - 商品分类更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductCategoryUpdateReqVO extends ProductCategoryBaseVO {
- @ApiModelProperty(value = "分类编号", required = true, example = "2")
+ @Schema(description = "分类编号", required = true, example = "2")
@NotNull(message = "分类编号不能为空")
private Long id;
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java
index 5efecd0c7..bd063e0ec 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyController.java
@@ -9,9 +9,9 @@ import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO
import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO;
import cn.iocoder.yudao.module.product.service.property.ProductPropertyService;
import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiOperation;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -24,7 +24,7 @@ import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
-@Api(tags = "管理后台 - 商品属性项")
+@Tag(name = "管理后台 - 商品属性项")
@RestController
@RequestMapping("/product/property")
@Validated
@@ -36,14 +36,14 @@ public class ProductPropertyController {
private ProductPropertyValueService productPropertyValueService;
@PostMapping("/create")
- @ApiOperation("创建属性项")
+ @Operation(summary = "创建属性项")
@PreAuthorize("@ss.hasPermission('product:property:create')")
public CommonResult createProperty(@Valid @RequestBody ProductPropertyCreateReqVO createReqVO) {
return success(productPropertyService.createProperty(createReqVO));
}
@PutMapping("/update")
- @ApiOperation("更新属性项")
+ @Operation(summary = "更新属性项")
@PreAuthorize("@ss.hasPermission('product:property:update')")
public CommonResult updateProperty(@Valid @RequestBody ProductPropertyUpdateReqVO updateReqVO) {
productPropertyService.updateProperty(updateReqVO);
@@ -51,8 +51,8 @@ public class ProductPropertyController {
}
@DeleteMapping("/delete")
- @ApiOperation("删除属性项")
- @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
+ @Operation(summary = "删除属性项")
+ @Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('product:property:delete')")
public CommonResult deleteProperty(@RequestParam("id") Long id) {
productPropertyService.deleteProperty(id);
@@ -60,29 +60,29 @@ public class ProductPropertyController {
}
@GetMapping("/get")
- @ApiOperation("获得属性项")
- @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
+ @Operation(summary = "获得属性项")
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('product:property:query')")
public CommonResult getProperty(@RequestParam("id") Long id) {
return success(ProductPropertyConvert.INSTANCE.convert(productPropertyService.getProperty(id)));
}
@GetMapping("/list")
- @ApiOperation("获得属性项列表")
+ @Operation(summary = "获得属性项列表")
@PreAuthorize("@ss.hasPermission('product:property:query')")
public CommonResult> getPropertyList(@Valid ProductPropertyListReqVO listReqVO) {
return success(ProductPropertyConvert.INSTANCE.convertList(productPropertyService.getPropertyList(listReqVO)));
}
@GetMapping("/page")
- @ApiOperation("获得属性项分页")
+ @Operation(summary = "获得属性项分页")
@PreAuthorize("@ss.hasPermission('product:property:query')")
public CommonResult> getPropertyPage(@Valid ProductPropertyPageReqVO pageVO) {
return success(ProductPropertyConvert.INSTANCE.convertPage(productPropertyService.getPropertyPage(pageVO)));
}
@GetMapping("/get-value-list")
- @ApiOperation("获得属性项列表")
+ @Operation(summary = "获得属性项列表")
@PreAuthorize("@ss.hasPermission('product:property:query')")
public CommonResult> getPropertyAndValueList(@Valid ProductPropertyListReqVO listReqVO) {
// 查询属性项
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyValueController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyValueController.java
index fec327946..92ce6bee0 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyValueController.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/ProductPropertyValueController.java
@@ -8,9 +8,9 @@ import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.Produc
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueUpdateReqVO;
import cn.iocoder.yudao.module.product.convert.propertyvalue.ProductPropertyValueConvert;
import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiOperation;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -20,7 +20,7 @@ import javax.validation.Valid;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
-@Api(tags = "管理后台 - 商品属性值")
+@Tag(name = "管理后台 - 商品属性值")
@RestController
@RequestMapping("/product/property/value")
@Validated
@@ -30,14 +30,14 @@ public class ProductPropertyValueController {
private ProductPropertyValueService productPropertyValueService;
@PostMapping("/create")
- @ApiOperation("创建属性值")
+ @Operation(summary = "创建属性值")
@PreAuthorize("@ss.hasPermission('product:property:create')")
public CommonResult createProperty(@Valid @RequestBody ProductPropertyValueCreateReqVO createReqVO) {
return success(productPropertyValueService.createPropertyValue(createReqVO));
}
@PutMapping("/update")
- @ApiOperation("更新属性值")
+ @Operation(summary = "更新属性值")
@PreAuthorize("@ss.hasPermission('product:property:update')")
public CommonResult updateProperty(@Valid @RequestBody ProductPropertyValueUpdateReqVO updateReqVO) {
productPropertyValueService.updatePropertyValue(updateReqVO);
@@ -45,8 +45,8 @@ public class ProductPropertyValueController {
}
@DeleteMapping("/delete")
- @ApiOperation("删除属性值")
- @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
+ @Operation(summary = "删除属性值")
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('product:property:delete')")
public CommonResult deleteProperty(@RequestParam("id") Long id) {
productPropertyValueService.deletePropertyValue(id);
@@ -54,15 +54,15 @@ public class ProductPropertyValueController {
}
@GetMapping("/get")
- @ApiOperation("获得属性值")
- @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
+ @Operation(summary = "获得属性值")
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('product:property:query')")
public CommonResult getProperty(@RequestParam("id") Long id) {
return success(ProductPropertyValueConvert.INSTANCE.convert(productPropertyValueService.getPropertyValue(id)));
}
@GetMapping("/page")
- @ApiOperation("获得属性值分页")
+ @Operation(summary = "获得属性值分页")
@PreAuthorize("@ss.hasPermission('product:property:query')")
public CommonResult> getPropertyValuePage(@Valid ProductPropertyValuePageReqVO pageVO) {
return success(ProductPropertyValueConvert.INSTANCE.convertPage(productPropertyValueService.getPropertyValuePage(pageVO)));
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyAndValueRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyAndValueRespVO.java
index a739bc0f2..4be1bad18 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyAndValueRespVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyAndValueRespVO.java
@@ -1,19 +1,18 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.property;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
-@ApiModel("管理后台 - 商品属性项 + 属性值 Response VO")
+@Schema(description = "管理后台 - 商品属性项 + 属性值 Response VO")
@Data
public class ProductPropertyAndValueRespVO {
- @ApiModelProperty(value = "属性项的编号", required = true, example = "1024")
+ @Schema(description = "属性项的编号", required = true, example = "1024")
private Long id;
- @ApiModelProperty(value = "属性项的名称", required = true, example = "颜色")
+ @Schema(description = "属性项的名称", required = true, example = "颜色")
private String name;
/**
@@ -21,14 +20,14 @@ public class ProductPropertyAndValueRespVO {
*/
private List values;
- @ApiModel("管理后台 - 属性值的简单 Response VO")
+ @Schema(description = "管理后台 - 属性值的简单 Response VO")
@Data
public static class Value {
- @ApiModelProperty(value = "属性值的编号", required = true, example = "2048")
+ @Schema(description = "属性值的编号", required = true, example = "2048")
private Long id;
- @ApiModelProperty(value = "属性值的名称", required = true, example = "红色")
+ @Schema(description = "属性值的名称", required = true, example = "红色")
private String name;
}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyBaseVO.java
index fb089dce1..1f05af4b2 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyBaseVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyBaseVO.java
@@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.property;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@@ -12,11 +12,11 @@ import javax.validation.constraints.NotBlank;
@Data
public class ProductPropertyBaseVO {
- @ApiModelProperty(value = "名称", required = true, example = "颜色")
+ @Schema(description = "名称", required = true, example = "颜色")
@NotBlank(message = "名称不能为空")
private String name;
- @ApiModelProperty(value = "备注", example = "颜色")
+ @Schema(description = "备注", example = "颜色")
private String remark;
}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyCreateReqVO.java
index 2e68f21e3..b854dd73c 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyCreateReqVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyCreateReqVO.java
@@ -1,11 +1,11 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.property;
-import io.swagger.annotations.ApiModel;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
-@ApiModel("管理后台 - 属性项创建 Request VO")
+@Schema(description = "管理后台 - 属性项创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyListReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyListReqVO.java
index 1233480d1..242caff84 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyListReqVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyListReqVO.java
@@ -1,16 +1,15 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.property;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.ToString;
-@ApiModel("管理后台 - 属性项 List Request VO")
+@Schema(description = "管理后台 - 属性项 List Request VO")
@Data
@ToString(callSuper = true)
public class ProductPropertyListReqVO {
- @ApiModelProperty(value = "名称", example = "颜色")
+ @Schema(description = "名称", example = "颜色")
private String name;
}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyPageReqVO.java
index 60bd7db5b..d729880f0 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyPageReqVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyPageReqVO.java
@@ -1,8 +1,7 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.property;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@@ -12,20 +11,20 @@ import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
-@ApiModel("管理后台 - 属性项 Request VO")
+@Schema(description = "管理后台 - 属性项 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductPropertyPageReqVO extends PageParam {
- @ApiModelProperty(value = "名称", example = "颜色")
+ @Schema(description = "名称", example = "颜色")
private String name;
- @ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 CommonStatusEnum 枚举")
+ @Schema(description = "状态", required = true, example = "1")
private Integer status;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
- @ApiModelProperty(value = "创建时间")
+ @Schema(description = "创建时间")
private LocalDateTime[] createTime;
}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyRespVO.java
index 299aa56e4..b33e615fc 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyRespVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyRespVO.java
@@ -1,23 +1,22 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.property;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.time.LocalDateTime;
-@ApiModel("管理后台 - 属性项 Response VO")
+@Schema(description = "管理后台 - 属性项 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductPropertyRespVO extends ProductPropertyBaseVO {
- @ApiModelProperty(value = "编号", required = true, example = "1024")
+ @Schema(description = "编号", required = true, example = "1024")
private Long id;
- @ApiModelProperty(value = "创建时间", required = true)
+ @Schema(description = "创建时间", required = true)
private LocalDateTime createTime;
}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyUpdateReqVO.java
index 4dfa48366..33ba8f2c1 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyUpdateReqVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/property/ProductPropertyUpdateReqVO.java
@@ -1,20 +1,19 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.property;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.NotNull;
-@ApiModel("管理后台 - 属性项更新 Request VO")
+@Schema(description = "管理后台 - 属性项更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductPropertyUpdateReqVO extends ProductPropertyBaseVO {
- @ApiModelProperty(value = "主键", required = true, example = "1")
+ @Schema(description = "主键", required = true, example = "1")
@NotNull(message = "主键不能为空")
private Long id;
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueBaseVO.java
index 76b2f1a8b..da3bf5068 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueBaseVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueBaseVO.java
@@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.value;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
@@ -13,15 +13,15 @@ import javax.validation.constraints.NotNull;
@Data
public class ProductPropertyValueBaseVO {
- @ApiModelProperty(value = "属性项的编号", required = true, example = "1024")
+ @Schema(description = "属性项的编号", required = true, example = "1024")
@NotNull(message = "属性项的编号不能为空")
private Long propertyId;
- @ApiModelProperty(value = "名称", required = true, example = "红色")
+ @Schema(description = "名称", required = true, example = "红色")
@NotEmpty(message = "名称名字不能为空")
private String name;
- @ApiModelProperty(value = "备注", example = "颜色")
+ @Schema(description = "备注", example = "颜色")
private String remark;
}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueCreateReqVO.java
index 8930f6ba3..d3fe4d0f1 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueCreateReqVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueCreateReqVO.java
@@ -1,9 +1,11 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.value;
-import lombok.*;
-import io.swagger.annotations.*;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
-@ApiModel("管理后台 - 商品属性值创建 Request VO")
+@Schema(description = "管理后台 - 商品属性值创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueDetailRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueDetailRespVO.java
index 55bae16df..56801cc7d 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueDetailRespVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueDetailRespVO.java
@@ -1,23 +1,22 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.value;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
-@ApiModel("管理后台 - 商品属性值的明细 Response VO")
+@Schema(description = "管理后台 - 商品属性值的明细 Response VO")
@Data
public class ProductPropertyValueDetailRespVO {
- @ApiModelProperty(value = "属性的编号", required = true, example = "1")
+ @Schema(description = "属性的编号", required = true, example = "1")
private Long propertyId;
- @ApiModelProperty(value = "属性的名称", required = true, example = "颜色")
+ @Schema(description = "属性的名称", required = true, example = "颜色")
private String propertyName;
- @ApiModelProperty(value = "属性值的编号", required = true, example = "1024")
+ @Schema(description = "属性值的编号", required = true, example = "1024")
private Long valueId;
- @ApiModelProperty(value = "属性值的名称", required = true, example = "红色")
+ @Schema(description = "属性值的名称", required = true, example = "红色")
private String valueName;
}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValuePageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValuePageReqVO.java
index 3f5ffee3d..a6088deb9 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValuePageReqVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValuePageReqVO.java
@@ -1,25 +1,24 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.value;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
-@ApiModel("管理后台 - 商品属性值分页 Request VO")
+@Schema(description = "管理后台 - 商品属性值分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductPropertyValuePageReqVO extends PageParam {
- @ApiModelProperty(value = "属性项的编号", example = "1024")
+ @Schema(description = "属性项的编号", example = "1024")
private String propertyId;
- @ApiModelProperty(value = "名称", example = "红色")
+ @Schema(description = "名称", example = "红色")
private String name;
- @ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 CommonStatusEnum 枚举")
+ @Schema(description = "状态", required = true, example = "1")
private Integer status;
}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueRespVO.java
index fb5ecead9..dac075b86 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueRespVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueRespVO.java
@@ -1,23 +1,22 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.value;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.time.LocalDateTime;
-@ApiModel("管理后台 - 商品属性值 Response VO")
+@Schema(description = "管理后台 - 商品属性值 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductPropertyValueRespVO extends ProductPropertyValueBaseVO {
- @ApiModelProperty(value = "编号", required = true, example = "10")
+ @Schema(description = "编号", required = true, example = "10")
private Long id;
- @ApiModelProperty(value = "创建时间")
+ @Schema(description = "创建时间")
private LocalDateTime createTime;
}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueUpdateReqVO.java
index f13d434b3..474a980b8 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueUpdateReqVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/property/vo/value/ProductPropertyValueUpdateReqVO.java
@@ -1,16 +1,19 @@
package cn.iocoder.yudao.module.product.controller.admin.property.vo.value;
-import lombok.*;
-import io.swagger.annotations.*;
-import javax.validation.constraints.*;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
-@ApiModel("管理后台 - 商品属性值更新 Request VO")
+import javax.validation.constraints.NotNull;
+
+@Schema(description = "管理后台 - 商品属性值更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductPropertyValueUpdateReqVO extends ProductPropertyValueBaseVO {
- @ApiModelProperty(value = "主键", required = true, example = "1024")
+ @Schema(description = "主键", required = true, example = "1024")
@NotNull(message = "主键不能为空")
private Long id;
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/ProductSkuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/ProductSkuController.java
index ac9713423..038642db1 100755
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/ProductSkuController.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/ProductSkuController.java
@@ -9,8 +9,8 @@ import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
import cn.iocoder.yudao.module.product.service.spu.ProductSpuService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -24,7 +24,7 @@ import java.util.Map;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
-@Api(tags = "管理后台 - 商品 sku")
+@Tag(name = "管理后台 - 商品 sku")
@RestController
@RequestMapping("/product/sku")
@Validated
@@ -36,7 +36,7 @@ public class ProductSkuController {
private ProductSpuService productSpuService;
@GetMapping("/get-option-list")
- @ApiOperation("获得商品 SKU 选项的列表")
+ @Operation(summary = "获得商品 SKU 选项的列表")
// @PreAuthorize("@ss.hasPermission('product:sku:query')")
public CommonResult> getSkuOptionList() {
// 获得 SKU 列表
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java
index 1bb08ff32..f28220046 100755
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuBaseVO.java
@@ -2,8 +2,7 @@ package cn.iocoder.yudao.module.product.controller.admin.sku.vo;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.validation.InEnum;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -18,56 +17,56 @@ import javax.validation.constraints.NotNull;
@Data
public class ProductSkuBaseVO {
- @ApiModelProperty(value = "商品 SKU 名字", required = true, example = "芋道")
+ @Schema(description = "商品 SKU 名字", required = true, example = "芋道")
@NotEmpty(message = "商品 SKU 名字不能为空")
private String name;
- @ApiModelProperty(value = "销售价格,单位:分", required = true, example = "1024", notes = "单位:分")
+ @Schema(description = "销售价格,单位:分", required = true, example = "1024")
@NotNull(message = "销售价格,单位:分不能为空")
private Integer price;
- @ApiModelProperty(value = "市场价", example = "1024", notes = "单位:分")
+ @Schema(description = "市场价", example = "1024")
private Integer marketPrice;
- @ApiModelProperty(value = "成本价", example = "1024", notes = "单位:分")
+ @Schema(description = "成本价", example = "1024")
private Integer costPrice;
- @ApiModelProperty(value = "条形码", example = "haha")
+ @Schema(description = "条形码", example = "haha")
private String barCode;
- @ApiModelProperty(value = "图片地址", required = true, example = "https://www.iocoder.cn/xx.png")
+ @Schema(description = "图片地址", required = true, example = "https://www.iocoder.cn/xx.png")
@NotNull(message = "图片地址不能为空")
private String picUrl;
- @ApiModelProperty(value = "SKU 状态", required = true, example = "1", notes = "参见 CommonStatusEnum 枚举")
+ @Schema(description = "SKU 状态", required = true, example = "1")
@NotNull(message = "SKU 状态不能为空")
@InEnum(CommonStatusEnum.class)
private Integer status;
- @ApiModelProperty(value = "库存", required = true, example = "1")
+ @Schema(description = "库存", required = true, example = "1")
@NotNull(message = "库存不能为空")
private Integer stock;
- @ApiModelProperty(value = "预警预存", example = "1")
+ @Schema(description = "预警预存", example = "1")
private Integer warnStock;
- @ApiModelProperty(value = "商品重量", example = "1", notes = "单位:kg 千克")
+ @Schema(description = "商品重量", example = "1") // 单位:kg 千克
private Double weight;
- @ApiModelProperty(value = "商品体积", example = "1024", notes = "单位:m^3 平米")
+ @Schema(description = "商品体积", example = "1024") // 单位:m^3 平米
private Double volume;
- @ApiModel("商品属性")
+ @Schema(description = "商品属性")
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class Property {
- @ApiModelProperty(value = "属性编号", required = true, example = "1")
+ @Schema(description = "属性编号", required = true, example = "1")
@NotNull(message = "属性编号不能为空")
private Long propertyId;
- @ApiModelProperty(value = "属性值编号", required = true, example = "1024")
+ @Schema(description = "属性值编号", required = true, example = "1024")
@NotNull(message = "属性值编号不能为空")
private Long valueId;
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateOrUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateOrUpdateReqVO.java
index ab83eeeac..496475f99 100755
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateOrUpdateReqVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuCreateOrUpdateReqVO.java
@@ -1,13 +1,13 @@
package cn.iocoder.yudao.module.product.controller.admin.sku.vo;
-import io.swagger.annotations.ApiModel;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.util.List;
-@ApiModel("管理后台 - 商品 SKU 创建/更新 Request VO")
+@Schema(description = "管理后台 - 商品 SKU 创建/更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuOptionRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuOptionRespVO.java
index 0324bdc8d..861454795 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuOptionRespVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuOptionRespVO.java
@@ -1,31 +1,30 @@
package cn.iocoder.yudao.module.product.controller.admin.sku.vo;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
-@ApiModel(value = "管理后台 - 商品 SKU 选项 Response VO", description = "用于前端 SELECT 选项")
+@Schema(description = "管理后台 - 商品 SKU 选项 Response VO") // 用于前端 SELECT 选项
@Data
public class ProductSkuOptionRespVO {
- @ApiModelProperty(value = "主键", required = true, example = "1024")
+ @Schema(description = "主键", required = true, example = "1024")
private Long id;
- @ApiModelProperty(value = "商品 SKU 名字", example = "红色")
+ @Schema(description = "商品 SKU 名字", example = "红色")
private String name;
- @ApiModelProperty(value = "销售价格", required = true, example = "100", notes = "单位:分")
+ @Schema(description = "销售价格", required = true, example = "100")
private String price;
- @ApiModelProperty(value = "库存", required = true, example = "100")
+ @Schema(description = "库存", required = true, example = "100")
private Integer stock;
// ========== 商品 SPU 信息 ==========
- @ApiModelProperty(value = "商品 SPU 编号", required = true, example = "1")
+ @Schema(description = "商品 SPU 编号", required = true, example = "1")
private Long spuId;
- @ApiModelProperty(value = "商品 SPU 名字", required = true, example = "iPhone 11")
+ @Schema(description = "商品 SPU 名字", required = true, example = "iPhone 11")
private String spuName;
}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java
index 85f5903cc..95e394ada 100755
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuRespVO.java
@@ -1,7 +1,6 @@
package cn.iocoder.yudao.module.product.controller.admin.sku.vo;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@@ -9,16 +8,16 @@ import lombok.ToString;
import java.time.LocalDateTime;
import java.util.List;
-@ApiModel("管理后台 - 商品 SKU Response VO")
+@Schema(description = "管理后台 - 商品 SKU Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductSkuRespVO extends ProductSkuBaseVO {
- @ApiModelProperty(value = "主键", required = true, example = "1024")
+ @Schema(description = "主键", required = true, example = "1024")
private Long id;
- @ApiModelProperty(value = "创建时间")
+ @Schema(description = "创建时间")
private LocalDateTime createTime;
/**
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java
index f19fde594..85fa93f8e 100755
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java
@@ -11,9 +11,9 @@ import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueServ
import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO;
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
import cn.iocoder.yudao.module.product.service.spu.ProductSpuService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiOperation;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -26,7 +26,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS;
-@Api(tags = "管理后台 - 商品 SPU")
+@Tag(name = "管理后台 - 商品 SPU")
@RestController
@RequestMapping("/product/spu")
@Validated
@@ -40,14 +40,14 @@ public class ProductSpuController {
private ProductPropertyValueService productPropertyValueService;
@PostMapping("/create")
- @ApiOperation("创建商品 SPU")
+ @Operation(summary = "创建商品 SPU")
@PreAuthorize("@ss.hasPermission('product:spu:create')")
public CommonResult createProductSpu(@Valid @RequestBody ProductSpuCreateReqVO createReqVO) {
return success(productSpuService.createSpu(createReqVO));
}
@PutMapping("/update")
- @ApiOperation("更新商品 SPU")
+ @Operation(summary = "更新商品 SPU")
@PreAuthorize("@ss.hasPermission('product:spu:update')")
public CommonResult updateSpu(@Valid @RequestBody ProductSpuUpdateReqVO updateReqVO) {
productSpuService.updateSpu(updateReqVO);
@@ -55,8 +55,8 @@ public class ProductSpuController {
}
@DeleteMapping("/delete")
- @ApiOperation("删除商品 SPU")
- @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
+ @Operation(summary = "删除商品 SPU")
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('product:spu:delete')")
public CommonResult deleteSpu(@RequestParam("id") Long id) {
productSpuService.deleteSpu(id);
@@ -64,8 +64,8 @@ public class ProductSpuController {
}
@GetMapping("/get-detail")
- @ApiOperation("获得商品 SPU 明细")
- @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
+ @Operation(summary = "获得商品 SPU 明细")
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('product:spu:query')")
public CommonResult getSpuDetail(@RequestParam("id") Long id) {
// 获得商品 SPU
@@ -84,7 +84,7 @@ public class ProductSpuController {
}
@GetMapping("/get-simple-list")
- @ApiOperation("获得商品 SPU 精简列表")
+ @Operation(summary = "获得商品 SPU 精简列表")
@PreAuthorize("@ss.hasPermission('product:spu:query')")
public CommonResult> getSpuSimpleList() {
List list = productSpuService.getSpuList();
@@ -92,7 +92,7 @@ public class ProductSpuController {
}
@GetMapping("/page")
- @ApiOperation("获得商品 SPU 分页")
+ @Operation(summary = "获得商品 SPU 分页")
@PreAuthorize("@ss.hasPermission('product:spu:query')")
public CommonResult> getSpuPage(@Valid ProductSpuPageReqVO pageVO) {
return success(ProductSpuConvert.INSTANCE.convertPage(productSpuService.getSpuPage(pageVO)));
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java
index 5f9f8a24c..3f0c94a74 100755
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java
@@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuSpecTypeEnum;
import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
@@ -17,59 +17,59 @@ import java.util.List;
@Data
public class ProductSpuBaseVO {
- @ApiModelProperty(value = "商品名称", required = true, example = "芋道")
+ @Schema(description = "商品名称", required = true, example = "芋道")
@NotEmpty(message = "商品名称不能为空")
private String name;
- @ApiModelProperty(value = "商品编码", example = "yudaoyuanma")
+ @Schema(description = "商品编码", example = "yudaoyuanma")
private String code;
- @ApiModelProperty(value = "促销语", example = "好吃!")
+ @Schema(description = "促销语", example = "好吃!")
private String sellPoint;
- @ApiModelProperty(value = "商品详情", required = true, example = "我是商品描述")
+ @Schema(description = "商品详情", required = true, example = "我是商品描述")
@NotNull(message = "商品详情不能为空")
private String description;
- @ApiModelProperty(value = "商品分类编号", required = true, example = "1")
+ @Schema(description = "商品分类编号", required = true, example = "1")
@NotNull(message = "商品分类编号不能为空")
private Long categoryId;
- @ApiModelProperty(value = "商品品牌编号", example = "1")
+ @Schema(description = "商品品牌编号", example = "1")
private Long brandId;
- @ApiModelProperty(value = "商品图片的数组", required = true)
+ @Schema(description = "商品图片的数组", required = true)
@NotNull(message = "商品图片的数组不能为空")
private List picUrls;
- @ApiModelProperty(value = "商品视频", required = true)
+ @Schema(description = "商品视频", required = true)
private String videoUrl;
- @ApiModelProperty(value = "排序字段", required = true, example = "1")
+ @Schema(description = "排序字段", required = true, example = "1")
private Integer sort;
- @ApiModelProperty(value = "商品状态", required = true, example = "1", notes = "参见 ProductSpuStatusEnum 枚举类")
+ @Schema(description = "商品状态", required = true, example = "1")
@NotNull(message = "商品状态不能为空")
@InEnum(ProductSpuStatusEnum.class)
private Integer status;
// ========== SKU 相关字段 =========
- @ApiModelProperty(value = "规格类型", required = true, example = "1", notes = "参见 ProductSpuSpecTypeEnum 枚举类")
+ @Schema(description = "规格类型", required = true, example = "1")
@NotNull(message = "规格类型不能为空")
@InEnum(ProductSpuSpecTypeEnum.class)
private Integer specType;
- @ApiModelProperty(value = "是否展示库存", required = true, example = "true")
+ @Schema(description = "是否展示库存", required = true, example = "true")
@NotNull(message = "是否展示库存不能为空")
private Boolean showStock;
- @ApiModelProperty(value = "市场价", example = "1024")
+ @Schema(description = "市场价", example = "1024")
private Integer marketPrice;
// ========== 统计相关字段 =========
- @ApiModelProperty(value = "虚拟销量", required = true, example = "1024")
+ @Schema(description = "虚拟销量", required = true, example = "1024")
@NotNull(message = "虚拟销量不能为空")
private Integer virtualSalesCount;
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuCreateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuCreateReqVO.java
index 87b0dd0b6..c75ed4d2e 100755
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuCreateReqVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuCreateReqVO.java
@@ -1,7 +1,7 @@
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO;
-import io.swagger.annotations.ApiModel;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@@ -9,7 +9,7 @@ import lombok.ToString;
import javax.validation.Valid;
import java.util.List;
-@ApiModel("管理后台 - 商品 SPU 创建 Request VO")
+@Schema(description = "管理后台 - 商品 SPU 创建 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java
index 65cdd22a2..58f9565c8 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuDetailRespVO.java
@@ -2,14 +2,14 @@ package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
import cn.iocoder.yudao.module.product.controller.admin.property.vo.value.ProductPropertyValueDetailRespVO;
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO;
-import io.swagger.annotations.ApiModel;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.util.List;
-@ApiModel(value = "管理后台 - 商品 SPU 详细 Response VO", description = "包括关联的 SKU 等信息")
+@Schema(description = "管理后台 - 商品 SPU 详细 Response VO") // 包括关联的 SKU 等信息
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@@ -22,7 +22,7 @@ public class ProductSpuDetailRespVO extends ProductSpuRespVO {
*/
private List skus;
- @ApiModel(value = "管理后台 - 商品 SKU 详细 Response VO")
+ @Schema(description = "管理后台 - 商品 SKU 详细 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java
index 3d74dc80c..0bfefb8d4 100755
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuPageReqVO.java
@@ -1,46 +1,45 @@
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
-@ApiModel("管理后台 - 商品 SPU 分页 Request VO")
+@Schema(description = "管理后台 - 商品 SPU 分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductSpuPageReqVO extends PageParam {
- @ApiModelProperty(value = "商品名称", example = "yutou")
+ @Schema(description = "商品名称", example = "yutou")
private String name;
- @ApiModelProperty(value = "商品编码", example = "yudaoyuanma")
+ @Schema(description = "商品编码", example = "yudaoyuanma")
private String code;
- @ApiModelProperty(value = "分类编号", example = "1")
+ @Schema(description = "分类编号", example = "1")
private Long categoryId;
- @ApiModelProperty(value = "商品品牌编号", example = "1")
+ @Schema(description = "商品品牌编号", example = "1")
private Long brandId;
- @ApiModelProperty(value = "上下架状态", example = "1", notes = "参见 ProductSpuStatusEnum 枚举值")
+ @Schema(description = "上下架状态", example = "1")
private Integer status;
- @ApiModelProperty(value = "销量最小值", example = "1")
+ @Schema(description = "销量最小值", example = "1")
private Integer salesCountMin;
- @ApiModelProperty(value = "销量最大值", example = "1024")
+ @Schema(description = "销量最大值", example = "1024")
private Integer salesCountMax;
- @ApiModelProperty(value = "市场价最小值", example = "1")
+ @Schema(description = "市场价最小值", example = "1")
private Integer marketPriceMin;
- @ApiModelProperty(value = "市场价最大值", example = "1024")
+ @Schema(description = "市场价最大值", example = "1024")
private Integer marketPriceMax;
- @ApiModelProperty(value = "是否库存告警", example = "true")
+ @Schema(description = "是否库存告警", example = "true")
private Boolean alarmStock;
}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java
index 66b86e0a5..5f088b74b 100755
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuRespVO.java
@@ -1,41 +1,40 @@
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.time.LocalDateTime;
-@ApiModel("管理后台 - 商品 SPU Response VO")
+@Schema(description = "管理后台 - 商品 SPU Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductSpuRespVO extends ProductSpuBaseVO {
- @ApiModelProperty(value = "主键", required = true, example = "1")
+ @Schema(description = "主键", required = true, example = "1")
private Long id;
- @ApiModelProperty(value = "创建时间")
+ @Schema(description = "创建时间")
private LocalDateTime createTime;
// ========== SKU 相关字段 =========
- @ApiModelProperty(value = "库存", required = true, example = "true")
+ @Schema(description = "库存", required = true, example = "true")
private Integer totalStock;
- @ApiModelProperty(value = " 最小价格,单位使用:分", required = true, example = "1024")
+ @Schema(description = " 最小价格,单位使用:分", required = true, example = "1024")
private Integer minPrice;
- @ApiModelProperty(value = "最大价格,单位使用:分", required = true, example = "1024")
+ @Schema(description = "最大价格,单位使用:分", required = true, example = "1024")
private Integer maxPrice;
- @ApiModelProperty(value = "商品销量", example = "1024")
+ @Schema(description = "商品销量", example = "1024")
private Integer salesCount;
// ========== 统计相关字段 =========
- @ApiModelProperty(value = "点击量", example = "1024")
+ @Schema(description = "点击量", example = "1024")
private Integer clickCount;
}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSimpleRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSimpleRespVO.java
index ea2811f8b..9cc7bf169 100755
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSimpleRespVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuSimpleRespVO.java
@@ -1,27 +1,26 @@
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
-@ApiModel("管理后台 - 商品 SPU 精简 Response VO")
+@Schema(description = "管理后台 - 商品 SPU 精简 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductSpuSimpleRespVO extends ProductSpuBaseVO {
- @ApiModelProperty(value = "主键", required = true, example = "1")
+ @Schema(description = "主键", required = true, example = "1")
private Long id;
- @ApiModelProperty(value = "商品名称", required = true, example = "芋道")
+ @Schema(description = "商品名称", required = true, example = "芋道")
private String name;
- @ApiModelProperty(value = " 最小价格,单位使用:分", required = true, example = "1024")
+ @Schema(description = " 最小价格,单位使用:分", required = true, example = "1024")
private Integer minPrice;
- @ApiModelProperty(value = "最大价格,单位使用:分", required = true, example = "1024")
+ @Schema(description = "最大价格,单位使用:分", required = true, example = "1024")
private Integer maxPrice;
}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateReqVO.java
index 378a98dc6..6ea84fb9e 100755
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateReqVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuUpdateReqVO.java
@@ -1,8 +1,7 @@
package cn.iocoder.yudao.module.product.controller.admin.spu.vo;
import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
@@ -11,13 +10,13 @@ import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;
-@ApiModel("管理后台 - 商品 SPU 更新 Request VO")
+@Schema(description = "管理后台 - 商品 SPU 更新 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProductSpuUpdateReqVO extends ProductSpuBaseVO {
- @ApiModelProperty(value = "商品编号", required = true, example = "1")
+ @Schema(description = "商品编号", required = true, example = "1")
@NotNull(message = "商品编号不能为空")
private Long id;
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/AppCategoryController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/AppCategoryController.java
index fec882c48..e484498b8 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/AppCategoryController.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/AppCategoryController.java
@@ -5,8 +5,8 @@ import cn.iocoder.yudao.module.product.controller.app.category.vo.AppCategoryRes
import cn.iocoder.yudao.module.product.convert.category.ProductCategoryConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
import cn.iocoder.yudao.module.product.service.category.ProductCategoryService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -18,7 +18,7 @@ import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
-@Api(tags = "用户 APP - 商品分类")
+@Tag(name = "用户 APP - 商品分类")
@RestController
@RequestMapping("/product/category")
@Validated
@@ -28,7 +28,7 @@ public class AppCategoryController {
private ProductCategoryService categoryService;
@GetMapping("/list")
- @ApiOperation("获得商品分类列表")
+ @Operation(summary = "获得商品分类列表")
public CommonResult> getProductCategoryList() {
List list = categoryService.getEnableCategoryList();
list.sort(Comparator.comparing(ProductCategoryDO::getSort));
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/vo/AppCategoryRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/vo/AppCategoryRespVO.java
index e46a50cd3..1dca05a3a 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/vo/AppCategoryRespVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/category/vo/AppCategoryRespVO.java
@@ -1,28 +1,27 @@
package cn.iocoder.yudao.module.product.controller.app.category.vo;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@Data
-@ApiModel(value = "用户 APP - 商品分类 Response VO")
+@Schema(description = "用户 APP - 商品分类 Response VO")
public class AppCategoryRespVO {
- @ApiModelProperty(value = "分类编号", required = true, example = "2")
+ @Schema(description = "分类编号", required = true, example = "2")
private Long id;
- @ApiModelProperty(value = "父分类编号", required = true, example = "1")
+ @Schema(description = "父分类编号", required = true, example = "1")
@NotNull(message = "父分类编号不能为空")
private Long parentId;
- @ApiModelProperty(value = "分类名称", required = true, example = "办公文具")
+ @Schema(description = "分类名称", required = true, example = "办公文具")
@NotBlank(message = "分类名称不能为空")
private String name;
- @ApiModelProperty(value = "分类图片", required = true)
+ @Schema(description = "分类图片", required = true)
@NotBlank(message = "分类图片不能为空")
private String picUrl;
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/value/AppProductPropertyValueDetailRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/value/AppProductPropertyValueDetailRespVO.java
index 516dd077f..ac687e547 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/value/AppProductPropertyValueDetailRespVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/property/vo/value/AppProductPropertyValueDetailRespVO.java
@@ -1,23 +1,22 @@
package cn.iocoder.yudao.module.product.controller.app.property.vo.value;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
-@ApiModel("用户 App - 商品属性值的明细 Response VO")
+@Schema(description = "用户 App - 商品属性值的明细 Response VO")
@Data
public class AppProductPropertyValueDetailRespVO {
- @ApiModelProperty(value = "属性的编号", required = true, example = "1")
+ @Schema(description = "属性的编号", required = true, example = "1")
private Long propertyId;
- @ApiModelProperty(value = "属性的名称", required = true, example = "颜色")
+ @Schema(description = "属性的名称", required = true, example = "颜色")
private String propertyName;
- @ApiModelProperty(value = "属性值的编号", required = true, example = "1024")
+ @Schema(description = "属性值的编号", required = true, example = "1024")
private Long valueId;
- @ApiModelProperty(value = "属性值的名称", required = true, example = "红色")
+ @Schema(description = "属性值的名称", required = true, example = "红色")
private String valueName;
}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java
index 9116f29cf..d9ab87c72 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java
@@ -3,9 +3,9 @@ package cn.iocoder.yudao.module.product.controller.app.spu;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO;
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuDetailRespVO;
import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageItemRespVO;
+import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO;
import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert;
import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
@@ -15,9 +15,9 @@ import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueServ
import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO;
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
import cn.iocoder.yudao.module.product.service.spu.ProductSpuService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiOperation;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -33,7 +33,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_ENABLE;
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS;
-@Api(tags = "用户 APP - 商品 SPU")
+@Tag(name = "用户 APP - 商品 SPU")
@RestController
@RequestMapping("/product/spu")
@Validated
@@ -47,15 +47,15 @@ public class AppProductSpuController {
private ProductPropertyValueService productPropertyValueService;
@GetMapping("/page")
- @ApiOperation("获得商品 SPU 分页")
+ @Operation(summary = "获得商品 SPU 分页")
public CommonResult> getSpuPage(@Valid AppProductSpuPageReqVO pageVO) {
PageResult pageResult = productSpuService.getSpuPage(pageVO, ProductSpuStatusEnum.ENABLE.getStatus());
return success(ProductSpuConvert.INSTANCE.convertPage02(pageResult));
}
@GetMapping("/get-detail")
- @ApiOperation("获得商品 SPU 明细")
- @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
+ @Operation(summary = "获得商品 SPU 明细")
+ @Parameter(name = "id", description = "编号", required = true)
public CommonResult getSpuDetail(@RequestParam("id") Long id) {
// 获得商品 SPU
ProductSpuDO spu = productSpuService.getSpu(id);
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuDetailRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuDetailRespVO.java
index 699ca1caa..cf5471cba 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuDetailRespVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuDetailRespVO.java
@@ -1,51 +1,50 @@
package cn.iocoder.yudao.module.product.controller.app.spu.vo;
import cn.iocoder.yudao.module.product.controller.app.property.vo.value.AppProductPropertyValueDetailRespVO;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
-@ApiModel("用户 App - 商品 SPU 明细 Response VO")
+@Schema(description = "用户 App - 商品 SPU 明细 Response VO")
@Data
public class AppProductSpuDetailRespVO {
- @ApiModelProperty(value = "商品 SPU 编号", required = true, example = "1")
+ @Schema(description = "商品 SPU 编号", required = true, example = "1")
private Long id;
// ========== 基本信息 =========
- @ApiModelProperty(value = "商品名称", required = true, example = "芋道")
+ @Schema(description = "商品名称", required = true, example = "芋道")
private String name;
- @ApiModelProperty(value = "促销语", example = "好吃!")
+ @Schema(description = "促销语", example = "好吃!")
private String sellPoint;
- @ApiModelProperty(value = "商品详情", required = true, example = "我是商品描述")
+ @Schema(description = "商品详情", required = true, example = "我是商品描述")
private String description;
- @ApiModelProperty(value = "商品分类编号", required = true, example = "1")
+ @Schema(description = "商品分类编号", required = true, example = "1")
private Long categoryId;
- @ApiModelProperty(value = "商品图片的数组", required = true)
+ @Schema(description = "商品图片的数组", required = true)
private List picUrls;
- @ApiModelProperty(value = "商品视频", required = true)
+ @Schema(description = "商品视频", required = true)
private String videoUrl;
// ========== SKU 相关字段 =========
- @ApiModelProperty(value = "规格类型", required = true, example = "1", notes = "参见 ProductSpuSpecTypeEnum 枚举类")
+ @Schema(description = "规格类型", required = true, example = "1")
private Integer specType;
- @ApiModelProperty(value = "是否展示库存", required = true, example = "true")
+ @Schema(description = "是否展示库存", required = true, example = "true")
private Boolean showStock;
- @ApiModelProperty(value = " 最小价格,单位使用:分", required = true, example = "1024")
+ @Schema(description = " 最小价格,单位使用:分", required = true, example = "1024")
private Integer minPrice;
- @ApiModelProperty(value = "最大价格,单位使用:分", required = true, example = "1024")
+ @Schema(description = "最大价格,单位使用:分", required = true, example = "1024")
private Integer maxPrice;
/**
@@ -55,14 +54,14 @@ public class AppProductSpuDetailRespVO {
// ========== 统计相关字段 =========
- @ApiModelProperty(value = "商品销量", required = true, example = "1024")
+ @Schema(description = "商品销量", required = true, example = "1024")
private Integer salesCount;
- @ApiModel("用户 App - 商品 SPU 明细的 SKU 信息")
+ @Schema(description = "用户 App - 商品 SPU 明细的 SKU 信息")
@Data
public static class Sku {
- @ApiModelProperty(value = "商品 SKU 编号", example = "1")
+ @Schema(description = "商品 SKU 编号", example = "1")
private Long id;
/**
@@ -70,22 +69,22 @@ public class AppProductSpuDetailRespVO {
*/
private List properties;
- @ApiModelProperty(value = "销售价格,单位:分", required = true, example = "1024", notes = "单位:分")
+ @Schema(description = "销售价格,单位:分", required = true, example = "1024")
private Integer price;
- @ApiModelProperty(value = "市场价", example = "1024", notes = "单位:分")
+ @Schema(description = "市场价", example = "1024")
private Integer marketPrice;
- @ApiModelProperty(value = "图片地址", required = true, example = "https://www.iocoder.cn/xx.png")
+ @Schema(description = "图片地址", required = true, example = "https://www.iocoder.cn/xx.png")
private String picUrl;
- @ApiModelProperty(value = "库存", required = true, example = "1")
+ @Schema(description = "库存", required = true, example = "1")
private Integer stock;
- @ApiModelProperty(value = "商品重量", example = "1", notes = "单位:kg 千克")
+ @Schema(description = "商品重量", example = "1") // 单位:kg 千克
private Double weight;
- @ApiModelProperty(value = "商品体积", example = "1024", notes = "单位:m^3 平米")
+ @Schema(description = "商品体积", example = "1024") // 单位:m^3 平米
private Double volume;
}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageItemRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageItemRespVO.java
index 60fc9235e..d826900a6 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageItemRespVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageItemRespVO.java
@@ -1,40 +1,39 @@
package cn.iocoder.yudao.module.product.controller.app.spu.vo;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
-@ApiModel("用户 App - 商品 SPU 分页项 Response VO")
+@Schema(description = "用户 App - 商品 SPU 分页项 Response VO")
@Data
public class AppProductSpuPageItemRespVO {
- @ApiModelProperty(value = "商品 SPU 编号", required = true, example = "1")
+ @Schema(description = "商品 SPU 编号", required = true, example = "1")
private Long id;
- @ApiModelProperty(value = "商品名称", required = true, example = "芋道")
+ @Schema(description = "商品名称", required = true, example = "芋道")
@NotEmpty(message = "商品名称不能为空")
private String name;
- @ApiModelProperty(value = "分类编号", required = true)
+ @Schema(description = "分类编号", required = true)
@NotNull(message = "分类编号不能为空")
private Long categoryId;
- @ApiModelProperty(value = "商品图片的数组", required = true)
+ @Schema(description = "商品图片的数组", required = true)
private List picUrls;
- @ApiModelProperty(value = " 最小价格,单位使用:分", required = true, example = "1024")
+ @Schema(description = " 最小价格,单位使用:分", required = true, example = "1024")
private Integer minPrice;
- @ApiModelProperty(value = "最大价格,单位使用:分", required = true, example = "1024")
+ @Schema(description = "最大价格,单位使用:分", required = true, example = "1024")
private Integer maxPrice;
// ========== 统计相关字段 =========
- @ApiModelProperty(value = "商品销量", example = "1024")
+ @Schema(description = "商品销量", example = "1024")
private Integer salesCount;
}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java
index f19a7c21a..dcbd1e190 100644
--- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/vo/AppProductSpuPageReqVO.java
@@ -3,15 +3,14 @@ package cn.iocoder.yudao.module.product.controller.app.spu.vo;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import com.fasterxml.jackson.annotation.JsonIgnore;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.validation.constraints.AssertTrue;
-@ApiModel("用户 App - 商品 SPU 分页 Request VO")
+@Schema(description = "用户 App - 商品 SPU 分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@@ -20,16 +19,16 @@ public class AppProductSpuPageReqVO extends PageParam {
public static final String SORT_FIELD_PRICE = "price";
public static final String SORT_FIELD_SALES_COUNT = "salesCount";
- @ApiModelProperty(value = "分类编号", example = "1")
+ @Schema(description = "分类编号", example = "1")
private Long categoryId;
- @ApiModelProperty(value = "关键字", example = "好看")
+ @Schema(description = "关键字", example = "好看")
private String keyword;
- @ApiModelProperty(value = "排序字段", example = "price", notes = "参见 AppSpuPageReqVO.SORT_FIELD_XXX 常量")
+ @Schema(description = "排序字段", example = "price") // 参见 AppSpuPageReqVO.SORT_FIELD_XXX 常量
private String sortField;
- @ApiModelProperty(value = "排序方式", example = "true", notes = "true - 升序;false - 降序")
+ @Schema(description = "排序方式", example = "true")
private Boolean sortAsc;
@AssertTrue(message = "排序字段不合法")
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/package-info.java
new file mode 100644
index 000000000..d2e1c934a
--- /dev/null
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/package-info.java
@@ -0,0 +1,6 @@
+/**
+ * 属于 product 模块的 framework 封装
+ *
+ * @author 芋道源码
+ */
+package cn.iocoder.yudao.module.product.framework;
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/web/config/ProductWebConfiguration.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/web/config/ProductWebConfiguration.java
new file mode 100644
index 000000000..9d1bf7db9
--- /dev/null
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/web/config/ProductWebConfiguration.java
@@ -0,0 +1,24 @@
+package cn.iocoder.yudao.module.product.framework.web.config;
+
+import cn.iocoder.yudao.framework.swagger.config.YudaoSwaggerAutoConfiguration;
+import org.springdoc.core.GroupedOpenApi;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * product 模块的 web 组件的 Configuration
+ *
+ * @author 芋道源码
+ */
+@Configuration(proxyBeanMethods = false)
+public class ProductWebConfiguration {
+
+ /**
+ * product 模块的 API 分组
+ */
+ @Bean
+ public GroupedOpenApi productGroupedOpenApi() {
+ return YudaoSwaggerAutoConfiguration.buildGroupedOpenApi("product");
+ }
+
+}
diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/web/package-info.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/web/package-info.java
new file mode 100644
index 000000000..f4adb2d76
--- /dev/null
+++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/framework/web/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * product 模块的 web 配置
+ */
+package cn.iocoder.yudao.module.product.framework.web;
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
index aad191337..48079766a 100644
--- 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
@@ -1,3 +1,4 @@
DELETE FROM "product_sku";
-
-DELETE FROM "product_spu";
\ No newline at end of file
+DELETE FROM "product_spu";
+DELETE FROM "product_brand";
+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
index 9d26cc733..8f53ba72f 100644
--- 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
@@ -67,3 +67,18 @@ CREATE TABLE IF NOT EXISTS `product_category` (
`deleted` bit(1) NOT NULL DEFAULT 0 COMMENT '是否删除',
PRIMARY KEY (`id`)
) COMMENT '商品分类';
+
+CREATE TABLE IF NOT EXISTS `product_brand` (
+ `id` bigint NOT NULL AUTO_INCREMENT COMMENT '品牌编号',
+ `name` varchar(128) NOT NULL COMMENT '品牌名称',
+ `pic_url` varchar DEFAULT NULL COMMENT '品牌图片',
+ `sort` int NOT NULL DEFAULT '0' COMMENT '排序字段',
+ `description` varchar(256) 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-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/BannerController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/BannerController.java
index 0fbef12d5..0bf2b2c33 100644
--- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/BannerController.java
+++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/banner/BannerController.java
@@ -2,13 +2,16 @@ package cn.iocoder.yudao.module.promotion.controller.admin.banner;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.*;
+import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerCreateReqVO;
+import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerPageReqVO;
+import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerRespVO;
+import cn.iocoder.yudao.module.promotion.controller.admin.banner.vo.BannerUpdateReqVO;
import cn.iocoder.yudao.module.promotion.convert.banner.BannerConvert;
import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO;
import cn.iocoder.yudao.module.promotion.service.banner.BannerService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiOperation;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -18,7 +21,7 @@ import javax.validation.Valid;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
-@Api(tags = "管理后台 - Banner 管理")
+@Tag(name = "管理后台 - Banner 管理")
@RestController
@RequestMapping("/market/banner")
@Validated
@@ -28,14 +31,14 @@ public class BannerController {
private BannerService bannerService;
@PostMapping("/create")
- @ApiOperation("创建 Banner")
+ @Operation(summary = "创建 Banner")
@PreAuthorize("@ss.hasPermission('market:banner:create')")
public CommonResult createBanner(@Valid @RequestBody BannerCreateReqVO createReqVO) {
return success(bannerService.createBanner(createReqVO));
}
@PutMapping("/update")
- @ApiOperation("更新 Banner")
+ @Operation(summary = "更新 Banner")
@PreAuthorize("@ss.hasPermission('market:banner:update')")
public CommonResult