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..03fbbbb3b 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 @@ -1,15 +1,17 @@ +## @formatter:off package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}; import org.springframework.web.bind.annotation.*; -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.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; +import jakarta.annotation.Resource; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.Valid; import java.util.*; import java.io.IOException; @@ -22,12 +24,13 @@ import ${ExcelUtilsClassName}; import ${OperateLogClassName}; import static ${OperateTypeEnumClassName}.*; +import ${basePackage}.framework.operatelog.core.annotations.OperateLog; import ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo.*; import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; 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,72 +41,79 @@ public class ${sceneEnum.prefixClass}${table.className}Controller { private ${table.className}Service ${classNameVar}Service; @PostMapping("/create") - @ApiOperation("创建${table.classComment}") -#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:create')")#end - + @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) { return success(${classNameVar}Service.create${simpleClassName}(createReqVO)); } @PutMapping("/update") - @ApiOperation("更新${table.classComment}") -#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:update')")#end - + @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) { ${classNameVar}Service.update${simpleClassName}(updateReqVO); return success(true); } @DeleteMapping("/delete") - @ApiOperation("删除${table.classComment}") - @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = ${primaryColumn.javaType}.class) -#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:delete')")#end - + @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) { ${classNameVar}Service.delete${simpleClassName}(id); return success(true); } @GetMapping("/get") - @ApiOperation("获得${table.classComment}") - @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = ${primaryColumn.javaType}.class) -#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")#end - + @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) { ${table.className}DO ${classNameVar} = ${classNameVar}Service.get${simpleClassName}(id); return success(${table.className}Convert.INSTANCE.convert(${classNameVar})); } @GetMapping("/list") - @ApiOperation("获得${table.classComment}列表") - @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) -#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")#end - + @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) { List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(ids); return success(${table.className}Convert.INSTANCE.convertList(list)); } @GetMapping("/page") - @ApiOperation("获得${table.classComment}分页") -#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")#end - + @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) { PageResult<${table.className}DO> pageResult = ${classNameVar}Service.get${simpleClassName}Page(pageVO); return success(${table.className}Convert.INSTANCE.convertPage(pageResult)); } @GetMapping("/export-excel") - @ApiOperation("导出${table.classComment} Excel") -#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:export')")#end - + @Operation(summary = "导出${table.classComment} Excel") + #if ($sceneEnum.scene == 1) + @PreAuthorize("@ss.hasPermission('${permissionPrefix}:export')") + #end @OperateLog(type = EXPORT) public void export${simpleClassName}Excel(@Valid ${sceneEnum.prefixClass}${table.className}ExportReqVO exportReqVO, HttpServletResponse response) throws IOException { List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(exportReqVO); // 导出 Excel List<${sceneEnum.prefixClass}${table.className}ExcelVO> datas = ${table.className}Convert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "${table.classComment}.xls", "数据", ${sceneEnum.prefixClass}${table.className}ExcelVO.class, datas); + ExcelUtils.write(response, "${table.classComment}.xls","数据", ${sceneEnum.prefixClass}${table.className}ExcelVO.class, datas); } } 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..a2b4b6db9 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,6 @@ +## @formatter:off ## 提供给 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}), requiredMode = Schema.RequiredMode.REQUIRED#end#if ("$!column.example" != ""), example = "${column.example}"#end) #if (!${column.nullable})## 判断 @NotEmpty 和 @NotNull 注解 #if (${field.fieldType} == 'String') @NotEmpty(message = "${column.columnComment}不能为空") @@ -10,4 +11,4 @@ #if (${column.javaType} == "LocalDateTime")## 时间类型 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) #end - private ${column.javaType} ${column.javaField}; + private ${column.javaType} ${column.javaField}; \ No newline at end of file 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..9419c4c7b 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,3 +1,4 @@ +## @formatter:off package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo; import lombok.*; @@ -10,12 +11,11 @@ import java.math.BigDecimal; import java.time.LocalDateTime; #end #end -import io.swagger.annotations.*; -import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.*; ## 处理 Date 字段的引入 #foreach ($column in $columns) -#if (${column.createOperation} && ${column.updateOperation} && ${column.listOperationResult} - && ${column.javaType} == "LocalDateTime")## 时间类型 +#if (${column.createOperation} && ${column.updateOperation} && ${column.listOperationResult} && ${column.javaType} == "LocalDateTime")## 时间类型 import org.springframework.format.annotation.DateTimeFormat; import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; 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..ecef348f5 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 @@ -1,13 +1,13 @@ +## @formatter:off package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo; import lombok.*; import java.util.*; -import io.swagger.annotations.*; -import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.*; ## 处理 Date 字段的引入 #foreach ($column in $columns) -#if (${column.createOperation} && (!${column.updateOperation} || !${column.listOperationResult}) - && ${column.javaType} == "LocalDateTime")## 时间类型 +#if (${column.createOperation} && (!${column.updateOperation} || !${column.listOperationResult}) && ${column.javaType} == "LocalDateTime")## 时间类型 import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @@ -15,7 +15,7 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; #end #end -@ApiModel("${sceneEnum.name} - ${table.classComment}创建 Request VO") +@Schema(name = "${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..86ec3e612 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,3 +1,4 @@ +## @formatter:off package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo; import lombok.*; @@ -10,8 +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) #if ("$!column.dictType" != "")## 有设置数据字典 @@ -23,10 +22,10 @@ import ${DictConvertClassName}; #end /** - * ${table.classComment} Excel VO - * - * @author ${table.author} - */ +* ${table.classComment} Excel VO +* +* @author ${table.author} +*/ @Data public class ${sceneEnum.prefixClass}${table.className}ExcelVO { 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..303232b95 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 @@ -1,8 +1,9 @@ +## @formatter:off package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo; 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 +17,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(name = "${sceneEnum.name} - ${table.classComment} Excel 导出 Request VO", description = "参数和 ${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..8a3855754 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 @@ -1,8 +1,9 @@ +## @formatter:off package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo; 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 +17,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(name = "${sceneEnum.name} - ${table.classComment}分页 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) @@ -29,7 +30,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..7261ec3ce 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,15 +1,16 @@ +## @formatter:off package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo; import lombok.*; +import io.swagger.v3.oas.annotations.media.Schema; #foreach ($column in $columns) #if (${column.javaType} == "LocalDateTime") import java.time.LocalDateTime; #break #end #end -import io.swagger.annotations.*; -@ApiModel("${sceneEnum.name} - ${table.classComment} Response VO") +@Schema(name = "${sceneEnum.name} - ${table.classComment} Response VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) @@ -17,7 +18,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}), requiredMode = Schema.RequiredMode.REQUIRED#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..823f3f8f4 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,13 +1,13 @@ +## @formatter:off package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo; import lombok.*; import java.util.*; -import io.swagger.annotations.*; -import javax.validation.constraints.*; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.*; ## 处理 Date 字段的引入 #foreach ($column in $columns) -#if (${column.updateOperation} && (!${column.createOperation} || !${column.listOperationResult}) - && ${column.javaType} == "LocalDateTime")## 时间类型 +#if (${column.updateOperation} && (!${column.createOperation} || !${column.listOperationResult}) && ${column.javaType} == "LocalDateTime")## 时间类型 import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @@ -15,7 +15,7 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; #end #end -@ApiModel("${sceneEnum.name} - ${table.classComment}更新 Request VO") +@Schema(name = "${sceneEnum.name} - ${table.classComment}更新 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true)