Commit 352a67c5300dc08f6469839723e3bca52aec8091
1 parent
b0c25ea9
多模块重构 11:修改代码生成器的实现
Showing
45 changed files
with
739 additions
and
288 deletions
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/TestDemoController.http deleted
| 1 | -### 请求 /tool/test-demo/get 接口 => 成功 | |
| 2 | -GET {{baseUrl}}/tool/test-demo/get?id=1 | |
| 3 | -Authorization: Bearer {{token}} | |
| 4 | -tenant-id: {{adminTenentId}} | |
| 5 | - | |
| 6 | -### 请求 /tool/test-demo/list 接口 => 成功 | |
| 7 | -GET {{baseUrl}}/tool/test-demo/list?ids=1 | |
| 8 | -Authorization: Bearer {{token}} | |
| 9 | -tenant-id: {{adminTenentId}} |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/package-info.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.tool.controller.admin.test; | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoBaseVO.java
| 1 | 1 | package cn.iocoder.yudao.module.tool.controller.admin.test.vo; |
| 2 | 2 | |
| 3 | -import io.swagger.annotations.ApiModelProperty; | |
| 4 | -import lombok.Data; | |
| 5 | - | |
| 6 | -import javax.validation.constraints.NotNull; | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | +import javax.validation.constraints.*; | |
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * 字典类型 Base VO,提供给添加、修改、详细的子 VO 使用 |
| ... | ... | @@ -12,23 +12,23 @@ import javax.validation.constraints.NotNull; |
| 12 | 12 | @Data |
| 13 | 13 | public class TestDemoBaseVO { |
| 14 | 14 | |
| 15 | - @ApiModelProperty(value = "名字", required = true, example = "芋道") | |
| 15 | + @ApiModelProperty(value = "名字", required = true) | |
| 16 | 16 | @NotNull(message = "名字不能为空") |
| 17 | 17 | private String name; |
| 18 | 18 | |
| 19 | - @ApiModelProperty(value = "状态", required = true, example = "1") | |
| 19 | + @ApiModelProperty(value = "状态", required = true) | |
| 20 | 20 | @NotNull(message = "状态不能为空") |
| 21 | 21 | private Integer status; |
| 22 | 22 | |
| 23 | - @ApiModelProperty(value = "类型", required = true, example = "2") | |
| 23 | + @ApiModelProperty(value = "类型", required = true) | |
| 24 | 24 | @NotNull(message = "类型不能为空") |
| 25 | 25 | private Integer type; |
| 26 | 26 | |
| 27 | - @ApiModelProperty(value = "分类", required = true, example = "3") | |
| 27 | + @ApiModelProperty(value = "分类", required = true) | |
| 28 | 28 | @NotNull(message = "分类不能为空") |
| 29 | 29 | private Integer category; |
| 30 | 30 | |
| 31 | - @ApiModelProperty(value = "备注", example = "我是备注") | |
| 31 | + @ApiModelProperty(value = "备注") | |
| 32 | 32 | private String remark; |
| 33 | 33 | |
| 34 | 34 | } | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoCreateReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.tool.controller.admin.test.vo; |
| 2 | 2 | |
| 3 | -import io.swagger.annotations.ApiModel; | |
| 4 | -import lombok.Data; | |
| 5 | -import lombok.EqualsAndHashCode; | |
| 6 | -import lombok.ToString; | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | +import javax.validation.constraints.*; | |
| 7 | 7 | |
| 8 | 8 | @ApiModel("管理后台 - 字典类型创建 Request VO") |
| 9 | 9 | @Data | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoExportReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.tool.controller.admin.test.vo; |
| 2 | 2 | |
| 3 | -import io.swagger.annotations.ApiModel; | |
| 4 | -import io.swagger.annotations.ApiModelProperty; | |
| 5 | -import lombok.Data; | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 6 | 7 | import org.springframework.format.annotation.DateTimeFormat; |
| 7 | 8 | |
| 8 | -import java.util.Date; | |
| 9 | - | |
| 10 | 9 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 11 | 10 | |
| 12 | 11 | @ApiModel(value = "管理后台 - 字典类型 Excel 导出 Request VO", description = "参数和 TestDemoPageReqVO 是一致的") |
| 13 | 12 | @Data |
| 14 | 13 | public class TestDemoExportReqVO { |
| 15 | 14 | |
| 16 | - @ApiModelProperty(value = "名字", example = "芋道") | |
| 15 | + @ApiModelProperty(value = "名字") | |
| 17 | 16 | private String name; |
| 18 | 17 | |
| 19 | - @ApiModelProperty(value = "状态", example = "1") | |
| 18 | + @ApiModelProperty(value = "状态") | |
| 20 | 19 | private Integer status; |
| 21 | 20 | |
| 22 | - @ApiModelProperty(value = "类型", example = "2") | |
| 21 | + @ApiModelProperty(value = "类型") | |
| 23 | 22 | private Integer type; |
| 24 | 23 | |
| 25 | - @ApiModelProperty(value = "分类", example = "3") | |
| 24 | + @ApiModelProperty(value = "分类") | |
| 26 | 25 | private Integer category; |
| 27 | 26 | |
| 28 | - @ApiModelProperty(value = "备注", example = "我是备注") | |
| 27 | + @ApiModelProperty(value = "备注") | |
| 29 | 28 | private String remark; |
| 30 | 29 | |
| 31 | 30 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoPageReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.tool.controller.admin.test.vo; |
| 2 | 2 | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 3 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 4 | -import io.swagger.annotations.ApiModel; | |
| 5 | -import io.swagger.annotations.ApiModelProperty; | |
| 6 | -import lombok.Data; | |
| 7 | -import lombok.EqualsAndHashCode; | |
| 8 | -import lombok.ToString; | |
| 9 | 7 | import org.springframework.format.annotation.DateTimeFormat; |
| 10 | 8 | |
| 11 | -import java.util.Date; | |
| 12 | - | |
| 13 | 9 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 14 | 10 | |
| 15 | 11 | @ApiModel("管理后台 - 字典类型分页 Request VO") |
| ... | ... | @@ -18,19 +14,19 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ |
| 18 | 14 | @ToString(callSuper = true) |
| 19 | 15 | public class TestDemoPageReqVO extends PageParam { |
| 20 | 16 | |
| 21 | - @ApiModelProperty(value = "名字", example = "芋道") | |
| 17 | + @ApiModelProperty(value = "名字") | |
| 22 | 18 | private String name; |
| 23 | 19 | |
| 24 | - @ApiModelProperty(value = "状态", example = "1") | |
| 20 | + @ApiModelProperty(value = "状态") | |
| 25 | 21 | private Integer status; |
| 26 | 22 | |
| 27 | - @ApiModelProperty(value = "类型", example = "2") | |
| 23 | + @ApiModelProperty(value = "类型") | |
| 28 | 24 | private Integer type; |
| 29 | 25 | |
| 30 | - @ApiModelProperty(value = "分类", example = "3") | |
| 26 | + @ApiModelProperty(value = "分类") | |
| 31 | 27 | private Integer category; |
| 32 | 28 | |
| 33 | - @ApiModelProperty(value = "备注", example = "我是备注") | |
| 29 | + @ApiModelProperty(value = "备注") | |
| 34 | 30 | private String remark; |
| 35 | 31 | |
| 36 | 32 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoRespVO.java
| 1 | 1 | package cn.iocoder.yudao.module.tool.controller.admin.test.vo; |
| 2 | 2 | |
| 3 | -import io.swagger.annotations.ApiModel; | |
| 4 | -import io.swagger.annotations.ApiModelProperty; | |
| 5 | -import lombok.Data; | |
| 6 | -import lombok.EqualsAndHashCode; | |
| 7 | -import lombok.ToString; | |
| 8 | - | |
| 9 | -import java.util.Date; | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 10 | 6 | |
| 11 | 7 | @ApiModel("管理后台 - 字典类型 Response VO") |
| 12 | 8 | @Data |
| ... | ... | @@ -14,7 +10,7 @@ import java.util.Date; |
| 14 | 10 | @ToString(callSuper = true) |
| 15 | 11 | public class TestDemoRespVO extends TestDemoBaseVO { |
| 16 | 12 | |
| 17 | - @ApiModelProperty(value = "编号", required = true, example = "1") | |
| 13 | + @ApiModelProperty(value = "编号", required = true) | |
| 18 | 14 | private Long id; |
| 19 | 15 | |
| 20 | 16 | @ApiModelProperty(value = "创建时间", required = true) | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoUpdateReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.tool.controller.admin.test.vo; |
| 2 | 2 | |
| 3 | -import io.swagger.annotations.ApiModel; | |
| 4 | -import io.swagger.annotations.ApiModelProperty; | |
| 5 | -import lombok.Data; | |
| 6 | -import lombok.EqualsAndHashCode; | |
| 7 | -import lombok.ToString; | |
| 8 | - | |
| 9 | -import javax.validation.constraints.NotNull; | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | +import javax.validation.constraints.*; | |
| 10 | 7 | |
| 11 | 8 | @ApiModel("管理后台 - 字典类型更新 Request VO") |
| 12 | 9 | @Data |
| ... | ... | @@ -14,7 +11,7 @@ import javax.validation.constraints.NotNull; |
| 14 | 11 | @ToString(callSuper = true) |
| 15 | 12 | public class TestDemoUpdateReqVO extends TestDemoBaseVO { |
| 16 | 13 | |
| 17 | - @ApiModelProperty(value = "编号", required = true, example = "1") | |
| 14 | + @ApiModelProperty(value = "编号", required = true) | |
| 18 | 15 | @NotNull(message = "编号不能为空") |
| 19 | 16 | private Long id; |
| 20 | 17 | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/TestDemoController.java renamed to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/app/test/AppTestDemoController.java
| 1 | -package cn.iocoder.yudao.module.tool.controller.admin.test; | |
| 1 | +package cn.iocoder.yudao.module.tool.controller.app.test; | |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 6 | -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | |
| 7 | -import cn.iocoder.yudao.module.tool.controller.admin.test.vo.*; | |
| 8 | -import cn.iocoder.yudao.module.tool.convert.test.TestDemoConvert; | |
| 9 | -import cn.iocoder.yudao.module.tool.dal.dataobject.test.TestDemoDO; | |
| 10 | -import cn.iocoder.yudao.module.tool.service.test.TestDemoService; | |
| 11 | -import io.swagger.annotations.Api; | |
| 12 | -import io.swagger.annotations.ApiImplicitParam; | |
| 13 | -import io.swagger.annotations.ApiOperation; | |
| 14 | 3 | import org.springframework.security.access.prepost.PreAuthorize; |
| 15 | -import org.springframework.validation.annotation.Validated; | |
| 16 | 4 | import org.springframework.web.bind.annotation.*; |
| 17 | - | |
| 18 | 5 | import javax.annotation.Resource; |
| 19 | -import javax.servlet.http.HttpServletResponse; | |
| 20 | -import javax.validation.Valid; | |
| 6 | +import org.springframework.validation.annotation.Validated; | |
| 7 | + | |
| 8 | +import io.swagger.annotations.*; | |
| 9 | + | |
| 10 | +import javax.validation.constraints.*; | |
| 11 | +import javax.validation.*; | |
| 12 | +import javax.servlet.http.*; | |
| 13 | +import java.util.*; | |
| 21 | 14 | import java.io.IOException; |
| 22 | -import java.util.Collection; | |
| 23 | -import java.util.List; | |
| 24 | 15 | |
| 16 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 17 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 25 | 18 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 26 | -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | |
| 27 | 19 | |
| 28 | -@Api(tags = "管理后台 - 测试示例") | |
| 20 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 21 | + | |
| 22 | +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | |
| 23 | +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; | |
| 24 | + | |
| 25 | +import cn.iocoder.yudao.module.tool.controller.app.test.vo.*; | |
| 26 | +import cn.iocoder.yudao.module.tool.dal.dataobject.test.TestDemoDO; | |
| 27 | +import cn.iocoder.yudao.module.tool.convert.test.TestDemoConvert; | |
| 28 | +import cn.iocoder.yudao.module.tool.service.test.TestDemoService; | |
| 29 | + | |
| 30 | +@Api(tags = "用户 APP - 字典类型") | |
| 29 | 31 | @RestController |
| 30 | 32 | @RequestMapping("/tool/test-demo") |
| 31 | 33 | @Validated |
| 32 | -public class TestDemoController { | |
| 34 | +public class AppTestDemoController { | |
| 33 | 35 | |
| 34 | 36 | @Resource |
| 35 | 37 | private TestDemoService testDemoService; |
| 36 | 38 | |
| 37 | 39 | @PostMapping("/create") |
| 38 | - @ApiOperation("创建测试示例") | |
| 39 | - @PreAuthorize("@ss.hasPermission('tool:test-demo:create')") | |
| 40 | - public CommonResult<Long> createTestDemo(@Valid @RequestBody TestDemoCreateReqVO createReqVO) { | |
| 40 | + @ApiOperation("创建字典类型") | |
| 41 | + public CommonResult<Long> createTestDemo(@Valid @RequestBody AppTestDemoCreateReqVO createReqVO) { | |
| 41 | 42 | return success(testDemoService.createTestDemo(createReqVO)); |
| 42 | 43 | } |
| 43 | 44 | |
| 44 | 45 | @PutMapping("/update") |
| 45 | - @ApiOperation("更新测试示例") | |
| 46 | - @PreAuthorize("@ss.hasPermission('tool:test-demo:update')") | |
| 47 | - public CommonResult<Boolean> updateTestDemo(@Valid @RequestBody TestDemoUpdateReqVO updateReqVO) { | |
| 46 | + @ApiOperation("更新字典类型") | |
| 47 | + public CommonResult<Boolean> updateTestDemo(@Valid @RequestBody AppTestDemoUpdateReqVO updateReqVO) { | |
| 48 | 48 | testDemoService.updateTestDemo(updateReqVO); |
| 49 | 49 | return success(true); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | @DeleteMapping("/delete") |
| 53 | - @ApiOperation("删除测试示例") | |
| 53 | + @ApiOperation("删除字典类型") | |
| 54 | 54 | @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) |
| 55 | - @PreAuthorize("@ss.hasPermission('tool:test-demo:delete')") | |
| 56 | 55 | public CommonResult<Boolean> deleteTestDemo(@RequestParam("id") Long id) { |
| 57 | 56 | testDemoService.deleteTestDemo(id); |
| 58 | 57 | return success(true); |
| 59 | 58 | } |
| 60 | 59 | |
| 61 | 60 | @GetMapping("/get") |
| 62 | - @ApiOperation("获得测试示例") | |
| 63 | - @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) | |
| 61 | + @ApiOperation("获得字典类型") | |
| 62 | + @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) | |
| 64 | 63 | @PreAuthorize("@ss.hasPermission('tool:test-demo:query')") |
| 65 | -// @Lock4j // 分布式锁 | |
| 66 | - public CommonResult<TestDemoRespVO> getTestDemo(@RequestParam("id") Long id) { | |
| 64 | + public CommonResult<AppTestDemoRespVO> getTestDemo(@RequestParam("id") Long id) { | |
| 67 | 65 | TestDemoDO testDemo = testDemoService.getTestDemo(id); |
| 68 | 66 | return success(TestDemoConvert.INSTANCE.convert(testDemo)); |
| 69 | 67 | } |
| 70 | 68 | |
| 71 | 69 | @GetMapping("/list") |
| 72 | - @ApiOperation("获得测试示例列表") | |
| 73 | - @ApiImplicitParam(name = "ids", value = "编号列表", required = true, dataTypeClass = List.class) | |
| 74 | - @PreAuthorize("@ss.hasPermission('tool:test-demo:query')") | |
| 75 | -// @RateLimiter(name = "backendA") | |
| 76 | - public CommonResult<List<TestDemoRespVO>> getTestDemoList(@RequestParam("ids") Collection<Long> ids) { | |
| 70 | + @ApiOperation("获得字典类型列表") | |
| 71 | + @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) | |
| 72 | + public CommonResult<List<AppTestDemoRespVO>> getTestDemoList(@RequestParam("ids") Collection<Long> ids) { | |
| 77 | 73 | List<TestDemoDO> list = testDemoService.getTestDemoList(ids); |
| 78 | 74 | return success(TestDemoConvert.INSTANCE.convertList(list)); |
| 79 | 75 | } |
| 80 | 76 | |
| 81 | 77 | @GetMapping("/page") |
| 82 | - @ApiOperation("获得测试示例分页") | |
| 83 | - @PreAuthorize("@ss.hasPermission('tool:test-demo:query')") | |
| 84 | - public CommonResult<PageResult<TestDemoRespVO>> getTestDemoPage(@Valid TestDemoPageReqVO pageVO) { | |
| 78 | + @ApiOperation("获得字典类型分页") | |
| 79 | + public CommonResult<PageResult<AppTestDemoRespVO>> getTestDemoPage(@Valid AppTestDemoPageReqVO pageVO) { | |
| 85 | 80 | PageResult<TestDemoDO> pageResult = testDemoService.getTestDemoPage(pageVO); |
| 86 | 81 | return success(TestDemoConvert.INSTANCE.convertPage(pageResult)); |
| 87 | 82 | } |
| 88 | 83 | |
| 89 | 84 | @GetMapping("/export-excel") |
| 90 | - @ApiOperation("导出测试示例 Excel") | |
| 91 | - @PreAuthorize("@ss.hasPermission('tool:test-demo:export')") | |
| 85 | + @ApiOperation("导出字典类型 Excel") | |
| 92 | 86 | @OperateLog(type = EXPORT) |
| 93 | - public void exportTestDemoExcel(@Valid TestDemoExportReqVO exportReqVO, | |
| 87 | + public void exportTestDemoExcel(@Valid AppTestDemoExportReqVO exportReqVO, | |
| 94 | 88 | HttpServletResponse response) throws IOException { |
| 95 | 89 | List<TestDemoDO> list = testDemoService.getTestDemoList(exportReqVO); |
| 96 | 90 | // 导出 Excel |
| 97 | - List<TestDemoExcelVO> datas = TestDemoConvert.INSTANCE.convertList02(list); | |
| 98 | - ExcelUtils.write(response, "测试示例.xls", "数据", TestDemoExcelVO.class, datas); | |
| 91 | + List<AppTestDemoExcelVO> datas = TestDemoConvert.INSTANCE.convertList02(list); | |
| 92 | + ExcelUtils.write(response, "字典类型.xls", "数据", AppTestDemoExcelVO.class, datas); | |
| 99 | 93 | } |
| 100 | 94 | |
| 101 | 95 | } | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/app/test/vo/AppTestDemoBaseVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.tool.controller.app.test.vo; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | +import javax.validation.constraints.*; | |
| 7 | + | |
| 8 | +/** | |
| 9 | +* 字典类型 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 10 | +* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 11 | +*/ | |
| 12 | +@Data | |
| 13 | +public class AppTestDemoBaseVO { | |
| 14 | + | |
| 15 | + @ApiModelProperty(value = "名字", required = true) | |
| 16 | + @NotNull(message = "名字不能为空") | |
| 17 | + private String name; | |
| 18 | + | |
| 19 | + @ApiModelProperty(value = "状态", required = true) | |
| 20 | + @NotNull(message = "状态不能为空") | |
| 21 | + private Integer status; | |
| 22 | + | |
| 23 | + @ApiModelProperty(value = "类型", required = true) | |
| 24 | + @NotNull(message = "类型不能为空") | |
| 25 | + private Integer type; | |
| 26 | + | |
| 27 | + @ApiModelProperty(value = "分类", required = true) | |
| 28 | + @NotNull(message = "分类不能为空") | |
| 29 | + private Integer category; | |
| 30 | + | |
| 31 | + @ApiModelProperty(value = "备注") | |
| 32 | + private String remark; | |
| 33 | + | |
| 34 | +} | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/app/test/vo/AppTestDemoCreateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.tool.controller.app.test.vo; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | +import javax.validation.constraints.*; | |
| 7 | + | |
| 8 | +@ApiModel("用户 APP - 字典类型创建 Request VO") | |
| 9 | +@Data | |
| 10 | +@EqualsAndHashCode(callSuper = true) | |
| 11 | +@ToString(callSuper = true) | |
| 12 | +public class AppTestDemoCreateReqVO extends AppTestDemoBaseVO { | |
| 13 | + | |
| 14 | +} | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoExcelVO.java renamed to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/app/test/vo/AppTestDemoExcelVO.java
| 1 | -package cn.iocoder.yudao.module.tool.controller.admin.test.vo; | |
| 1 | +package cn.iocoder.yudao.module.tool.controller.app.test.vo; | |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | |
| 4 | -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | |
| 5 | -import com.alibaba.excel.annotation.ExcelProperty; | |
| 6 | -import lombok.Data; | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 7 | 6 | |
| 8 | -import java.util.Date; | |
| 7 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 9 | 8 | |
| 10 | 9 | /** |
| 11 | - * 测试示例 Excel VO | |
| 10 | + * 字典类型 Excel VO | |
| 12 | 11 | * |
| 13 | - * @author 芋艿 | |
| 12 | + * @author 芋道源码 | |
| 14 | 13 | */ |
| 15 | 14 | @Data |
| 16 | -public class TestDemoExcelVO { | |
| 15 | +public class AppTestDemoExcelVO { | |
| 17 | 16 | |
| 18 | 17 | @ExcelProperty("编号") |
| 19 | 18 | private Long id; |
| ... | ... | @@ -21,16 +20,13 @@ public class TestDemoExcelVO { |
| 21 | 20 | @ExcelProperty("名字") |
| 22 | 21 | private String name; |
| 23 | 22 | |
| 24 | - @ExcelProperty(value = "状态", converter = DictConvert.class) | |
| 25 | - @DictFormat("") | |
| 23 | + @ExcelProperty("状态") | |
| 26 | 24 | private Integer status; |
| 27 | 25 | |
| 28 | - @ExcelProperty(value = "类型", converter = DictConvert.class) | |
| 29 | - @DictFormat("sys_common_status") | |
| 26 | + @ExcelProperty("类型") | |
| 30 | 27 | private Integer type; |
| 31 | 28 | |
| 32 | - @ExcelProperty(value = "分类", converter = DictConvert.class) | |
| 33 | - @DictFormat("inf_redis_timeout_type") | |
| 29 | + @ExcelProperty("分类") | |
| 34 | 30 | private Integer category; |
| 35 | 31 | |
| 36 | 32 | @ExcelProperty("备注") | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/app/test/vo/AppTestDemoExportReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.tool.controller.app.test.vo; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 7 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 8 | + | |
| 9 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 10 | + | |
| 11 | +@ApiModel(value = "用户 APP - 字典类型 Excel 导出 Request VO", description = "参数和 TestDemoPageReqVO 是一致的") | |
| 12 | +@Data | |
| 13 | +public class AppTestDemoExportReqVO { | |
| 14 | + | |
| 15 | + @ApiModelProperty(value = "名字") | |
| 16 | + private String name; | |
| 17 | + | |
| 18 | + @ApiModelProperty(value = "状态") | |
| 19 | + private Integer status; | |
| 20 | + | |
| 21 | + @ApiModelProperty(value = "类型") | |
| 22 | + private Integer type; | |
| 23 | + | |
| 24 | + @ApiModelProperty(value = "分类") | |
| 25 | + private Integer category; | |
| 26 | + | |
| 27 | + @ApiModelProperty(value = "备注") | |
| 28 | + private String remark; | |
| 29 | + | |
| 30 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 31 | + @ApiModelProperty(value = "开始创建时间") | |
| 32 | + private Date beginCreateTime; | |
| 33 | + | |
| 34 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 35 | + @ApiModelProperty(value = "结束创建时间") | |
| 36 | + private Date endCreateTime; | |
| 37 | + | |
| 38 | +} | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/app/test/vo/AppTestDemoPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.tool.controller.app.test.vo; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 7 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 8 | + | |
| 9 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 10 | + | |
| 11 | +@ApiModel("用户 APP - 字典类型分页 Request VO") | |
| 12 | +@Data | |
| 13 | +@EqualsAndHashCode(callSuper = true) | |
| 14 | +@ToString(callSuper = true) | |
| 15 | +public class AppTestDemoPageReqVO extends PageParam { | |
| 16 | + | |
| 17 | + @ApiModelProperty(value = "名字") | |
| 18 | + private String name; | |
| 19 | + | |
| 20 | + @ApiModelProperty(value = "状态") | |
| 21 | + private Integer status; | |
| 22 | + | |
| 23 | + @ApiModelProperty(value = "类型") | |
| 24 | + private Integer type; | |
| 25 | + | |
| 26 | + @ApiModelProperty(value = "分类") | |
| 27 | + private Integer category; | |
| 28 | + | |
| 29 | + @ApiModelProperty(value = "备注") | |
| 30 | + private String remark; | |
| 31 | + | |
| 32 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 33 | + @ApiModelProperty(value = "开始创建时间") | |
| 34 | + private Date beginCreateTime; | |
| 35 | + | |
| 36 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 37 | + @ApiModelProperty(value = "结束创建时间") | |
| 38 | + private Date endCreateTime; | |
| 39 | + | |
| 40 | +} | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/app/test/vo/AppTestDemoRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.tool.controller.app.test.vo; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | + | |
| 7 | +@ApiModel("用户 APP - 字典类型 Response VO") | |
| 8 | +@Data | |
| 9 | +@EqualsAndHashCode(callSuper = true) | |
| 10 | +@ToString(callSuper = true) | |
| 11 | +public class AppTestDemoRespVO extends AppTestDemoBaseVO { | |
| 12 | + | |
| 13 | + @ApiModelProperty(value = "编号", required = true) | |
| 14 | + private Long id; | |
| 15 | + | |
| 16 | + @ApiModelProperty(value = "创建时间", required = true) | |
| 17 | + private Date createTime; | |
| 18 | + | |
| 19 | +} | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/app/test/vo/AppTestDemoUpdateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.tool.controller.app.test.vo; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | +import javax.validation.constraints.*; | |
| 7 | + | |
| 8 | +@ApiModel("用户 APP - 字典类型更新 Request VO") | |
| 9 | +@Data | |
| 10 | +@EqualsAndHashCode(callSuper = true) | |
| 11 | +@ToString(callSuper = true) | |
| 12 | +public class AppTestDemoUpdateReqVO extends AppTestDemoBaseVO { | |
| 13 | + | |
| 14 | + @ApiModelProperty(value = "编号", required = true) | |
| 15 | + @NotNull(message = "编号不能为空") | |
| 16 | + private Long id; | |
| 17 | + | |
| 18 | +} | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/convert/test/TestDemoConvert.java
| ... | ... | @@ -4,29 +4,31 @@ import java.util.*; |
| 4 | 4 | |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 6 | |
| 7 | -import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoCreateReqVO; | |
| 8 | -import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoExcelVO; | |
| 9 | -import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoRespVO; | |
| 10 | -import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoUpdateReqVO; | |
| 11 | 7 | import org.mapstruct.Mapper; |
| 12 | 8 | import org.mapstruct.factory.Mappers; |
| 9 | +import cn.iocoder.yudao.module.tool.controller.app.test.vo.*; | |
| 13 | 10 | import cn.iocoder.yudao.module.tool.dal.dataobject.test.TestDemoDO; |
| 14 | 11 | |
| 12 | +/** | |
| 13 | + * 字典类型 Convert | |
| 14 | + * | |
| 15 | + * @author 芋道源码 | |
| 16 | + */ | |
| 15 | 17 | @Mapper |
| 16 | 18 | public interface TestDemoConvert { |
| 17 | 19 | |
| 18 | 20 | TestDemoConvert INSTANCE = Mappers.getMapper(TestDemoConvert.class); |
| 19 | 21 | |
| 20 | - TestDemoDO convert(TestDemoCreateReqVO bean); | |
| 22 | + TestDemoDO convert(AppTestDemoCreateReqVO bean); | |
| 21 | 23 | |
| 22 | - TestDemoDO convert(TestDemoUpdateReqVO bean); | |
| 24 | + TestDemoDO convert(AppTestDemoUpdateReqVO bean); | |
| 23 | 25 | |
| 24 | - TestDemoRespVO convert(TestDemoDO bean); | |
| 26 | + AppTestDemoRespVO convert(TestDemoDO bean); | |
| 25 | 27 | |
| 26 | - List<TestDemoRespVO> convertList(List<TestDemoDO> list); | |
| 28 | + List<AppTestDemoRespVO> convertList(List<TestDemoDO> list); | |
| 27 | 29 | |
| 28 | - PageResult<TestDemoRespVO> convertPage(PageResult<TestDemoDO> page); | |
| 30 | + PageResult<AppTestDemoRespVO> convertPage(PageResult<TestDemoDO> page); | |
| 29 | 31 | |
| 30 | - List<TestDemoExcelVO> convertList02(List<TestDemoDO> list); | |
| 32 | + List<AppTestDemoExcelVO> convertList02(List<TestDemoDO> list); | |
| 31 | 33 | |
| 32 | 34 | } | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/test/TestDemoDO.java
| 1 | 1 | package cn.iocoder.yudao.module.tool.dal.dataobject.test; |
| 2 | 2 | |
| 3 | 3 | import lombok.*; |
| 4 | +import java.util.*; | |
| 4 | 5 | import com.baomidou.mybatisplus.annotation.*; |
| 5 | 6 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 6 | 7 | |
| 7 | 8 | /** |
| 8 | - * 测试示例 DO | |
| 9 | + * 字典类型 DO | |
| 9 | 10 | * |
| 10 | - * @author 芋艿 | |
| 11 | + * @author 芋道源码 | |
| 11 | 12 | */ |
| 12 | 13 | @TableName("tool_test_demo") |
| 13 | 14 | @Data | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/mysql/test/TestDemoMapper.java
| ... | ... | @@ -3,36 +3,64 @@ package cn.iocoder.yudao.module.tool.dal.mysql.test; |
| 3 | 3 | import java.util.*; |
| 4 | 4 | |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | -import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; | |
| 6 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 7 | 7 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 8 | -import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoExportReqVO; | |
| 9 | -import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoPageReqVO; | |
| 8 | +import cn.iocoder.yudao.module.tool.controller.app.test.vo.AppTestDemoExportReqVO; | |
| 9 | +import cn.iocoder.yudao.module.tool.controller.app.test.vo.AppTestDemoPageReqVO; | |
| 10 | 10 | import cn.iocoder.yudao.module.tool.dal.dataobject.test.TestDemoDO; |
| 11 | 11 | import org.apache.ibatis.annotations.Mapper; |
| 12 | +import cn.iocoder.yudao.module.tool.controller.admin.test.vo.*; | |
| 12 | 13 | |
| 14 | +/** | |
| 15 | + * 字典类型 Mapper | |
| 16 | + * | |
| 17 | + * @author 芋道源码 | |
| 18 | + */ | |
| 13 | 19 | @Mapper |
| 14 | 20 | public interface TestDemoMapper extends BaseMapperX<TestDemoDO> { |
| 15 | 21 | |
| 16 | 22 | default PageResult<TestDemoDO> selectPage(TestDemoPageReqVO reqVO) { |
| 17 | - return selectPage(reqVO, new QueryWrapperX<TestDemoDO>() | |
| 18 | - .likeIfPresent("name", reqVO.getName()) | |
| 19 | - .eqIfPresent("status", reqVO.getStatus()) | |
| 20 | - .eqIfPresent("type", reqVO.getType()) | |
| 21 | - .eqIfPresent("category", reqVO.getCategory()) | |
| 22 | - .eqIfPresent("remark", reqVO.getRemark()) | |
| 23 | - .betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | |
| 24 | - .orderByDesc("id")); | |
| 23 | + return selectPage(reqVO, new LambdaQueryWrapperX<TestDemoDO>() | |
| 24 | + .likeIfPresent(TestDemoDO::getName, reqVO.getName()) | |
| 25 | + .eqIfPresent(TestDemoDO::getStatus, reqVO.getStatus()) | |
| 26 | + .eqIfPresent(TestDemoDO::getType, reqVO.getType()) | |
| 27 | + .eqIfPresent(TestDemoDO::getCategory, reqVO.getCategory()) | |
| 28 | + .eqIfPresent(TestDemoDO::getRemark, reqVO.getRemark()) | |
| 29 | + .betweenIfPresent(TestDemoDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | |
| 30 | + .orderByDesc(TestDemoDO::getId)); | |
| 25 | 31 | } |
| 26 | 32 | |
| 27 | 33 | default List<TestDemoDO> selectList(TestDemoExportReqVO reqVO) { |
| 28 | - return selectList(new QueryWrapperX<TestDemoDO>() | |
| 29 | - .likeIfPresent("name", reqVO.getName()) | |
| 30 | - .eqIfPresent("status", reqVO.getStatus()) | |
| 31 | - .eqIfPresent("type", reqVO.getType()) | |
| 32 | - .eqIfPresent("category", reqVO.getCategory()) | |
| 33 | - .eqIfPresent("remark", reqVO.getRemark()) | |
| 34 | - .betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | |
| 35 | - .orderByDesc("id")); | |
| 34 | + return selectList(new LambdaQueryWrapperX<TestDemoDO>() | |
| 35 | + .likeIfPresent(TestDemoDO::getName, reqVO.getName()) | |
| 36 | + .eqIfPresent(TestDemoDO::getStatus, reqVO.getStatus()) | |
| 37 | + .eqIfPresent(TestDemoDO::getType, reqVO.getType()) | |
| 38 | + .eqIfPresent(TestDemoDO::getCategory, reqVO.getCategory()) | |
| 39 | + .eqIfPresent(TestDemoDO::getRemark, reqVO.getRemark()) | |
| 40 | + .betweenIfPresent(TestDemoDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | |
| 41 | + .orderByDesc(TestDemoDO::getId)); | |
| 42 | + } | |
| 43 | + | |
| 44 | + default PageResult<TestDemoDO> selectPage(AppTestDemoPageReqVO reqVO) { | |
| 45 | + return selectPage(reqVO, new LambdaQueryWrapperX<TestDemoDO>() | |
| 46 | + .likeIfPresent(TestDemoDO::getName, reqVO.getName()) | |
| 47 | + .eqIfPresent(TestDemoDO::getStatus, reqVO.getStatus()) | |
| 48 | + .eqIfPresent(TestDemoDO::getType, reqVO.getType()) | |
| 49 | + .eqIfPresent(TestDemoDO::getCategory, reqVO.getCategory()) | |
| 50 | + .eqIfPresent(TestDemoDO::getRemark, reqVO.getRemark()) | |
| 51 | + .betweenIfPresent(TestDemoDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | |
| 52 | + .orderByDesc(TestDemoDO::getId)); | |
| 53 | + } | |
| 54 | + | |
| 55 | + default List<TestDemoDO> selectList(AppTestDemoExportReqVO reqVO) { | |
| 56 | + return selectList(new LambdaQueryWrapperX<TestDemoDO>() | |
| 57 | + .likeIfPresent(TestDemoDO::getName, reqVO.getName()) | |
| 58 | + .eqIfPresent(TestDemoDO::getStatus, reqVO.getStatus()) | |
| 59 | + .eqIfPresent(TestDemoDO::getType, reqVO.getType()) | |
| 60 | + .eqIfPresent(TestDemoDO::getCategory, reqVO.getCategory()) | |
| 61 | + .eqIfPresent(TestDemoDO::getRemark, reqVO.getRemark()) | |
| 62 | + .betweenIfPresent(TestDemoDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | |
| 63 | + .orderByDesc(TestDemoDO::getId)); | |
| 36 | 64 | } |
| 37 | 65 | |
| 38 | 66 | } | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/enums/codegen/CodegenSceneEnum.java
| 1 | 1 | package cn.iocoder.yudao.module.tool.enums.codegen; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.util.ArrayUtil; | |
| 3 | 4 | import lombok.AllArgsConstructor; |
| 4 | 5 | import lombok.Getter; |
| 5 | 6 | |
| 7 | +import static cn.hutool.core.util.ArrayUtil.*; | |
| 8 | + | |
| 6 | 9 | /** |
| 7 | 10 | * 代码生成的场景枚举 |
| 8 | 11 | * |
| ... | ... | @@ -12,8 +15,8 @@ import lombok.Getter; |
| 12 | 15 | @Getter |
| 13 | 16 | public enum CodegenSceneEnum { |
| 14 | 17 | |
| 15 | - ADMIN(1, "管理后台", "admin"), | |
| 16 | - APP(2, "用户 APP", "app"); | |
| 18 | + ADMIN(1, "管理后台", "admin", ""), | |
| 19 | + APP(2, "用户 APP", "app", "App"); | |
| 17 | 20 | |
| 18 | 21 | /** |
| 19 | 22 | * 场景 |
| ... | ... | @@ -27,5 +30,13 @@ public enum CodegenSceneEnum { |
| 27 | 30 | * 基础包名 |
| 28 | 31 | */ |
| 29 | 32 | private final String basePackage; |
| 33 | + /** | |
| 34 | + * Controller 和 VO 类的前缀 | |
| 35 | + */ | |
| 36 | + private final String prefixClass; | |
| 37 | + | |
| 38 | + public static CodegenSceneEnum valueOf(Integer scene) { | |
| 39 | + return firstMatch(sceneEnum -> sceneEnum.getScene().equals(scene), values()); | |
| 40 | + } | |
| 30 | 41 | |
| 31 | 42 | } | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenEngine.java
| ... | ... | @@ -9,6 +9,8 @@ import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; |
| 9 | 9 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 10 | 10 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 11 | 11 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 12 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 13 | +import cn.iocoder.yudao.module.tool.enums.codegen.CodegenSceneEnum; | |
| 12 | 14 | import cn.iocoder.yudao.module.tool.framework.codegen.config.CodegenProperties; |
| 13 | 15 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; |
| 14 | 16 | import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; |
| ... | ... | @@ -54,22 +56,14 @@ public class CodegenEngine { |
| 54 | 56 | */ |
| 55 | 57 | private static final Map<String, String> TEMPLATES = MapUtil.<String, String>builder(new LinkedHashMap<>()) // 有序 |
| 56 | 58 | // Java module-impl Main |
| 57 | - .put(javaTemplatePath("controller/vo/baseVO"), | |
| 58 | - javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}BaseVO")) | |
| 59 | - .put(javaTemplatePath("controller/vo/createReqVO"), | |
| 60 | - javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}CreateReqVO")) | |
| 61 | - .put(javaTemplatePath("controller/vo/pageReqVO"), | |
| 62 | - javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}PageReqVO")) | |
| 63 | - .put(javaTemplatePath("controller/vo/respVO"), | |
| 64 | - javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}RespVO")) | |
| 65 | - .put(javaTemplatePath("controller/vo/updateReqVO"), | |
| 66 | - javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}UpdateReqVO")) | |
| 67 | - .put(javaTemplatePath("controller/vo/exportReqVO"), | |
| 68 | - javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}ExportReqVO")) | |
| 69 | - .put(javaTemplatePath("controller/vo/excelVO"), | |
| 70 | - javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}ExcelVO")) | |
| 71 | - .put(javaTemplatePath("controller/controller"), | |
| 72 | - javaModuleImplMainFilePath("controller/${table.businessName}/${table.className}Controller")) | |
| 59 | + .put(javaTemplatePath("controller/vo/baseVO"), javaModuleImplVOFilePath("BaseVO")) | |
| 60 | + .put(javaTemplatePath("controller/vo/createReqVO"), javaModuleImplVOFilePath("CreateReqVO")) | |
| 61 | + .put(javaTemplatePath("controller/vo/pageReqVO"), javaModuleImplVOFilePath("PageReqVO")) | |
| 62 | + .put(javaTemplatePath("controller/vo/respVO"), javaModuleImplVOFilePath("RespVO")) | |
| 63 | + .put(javaTemplatePath("controller/vo/updateReqVO"), javaModuleImplVOFilePath("UpdateReqVO")) | |
| 64 | + .put(javaTemplatePath("controller/vo/exportReqVO"), javaModuleImplVOFilePath("ExportReqVO")) | |
| 65 | + .put(javaTemplatePath("controller/vo/excelVO"), javaModuleImplVOFilePath("ExcelVO")) | |
| 66 | + .put(javaTemplatePath("controller/controller"), javaModuleImplControllerFilePath()) | |
| 73 | 67 | .put(javaTemplatePath("convert/convert"), |
| 74 | 68 | javaModuleImplMainFilePath("convert/${table.businessName}/${table.className}Convert")) |
| 75 | 69 | .put(javaTemplatePath("dal/do"), |
| ... | ... | @@ -84,8 +78,7 @@ public class CodegenEngine { |
| 84 | 78 | .put(javaTemplatePath("test/serviceTest"), |
| 85 | 79 | javaModuleImplTestFilePath("service/${table.businessName}/${table.className}ServiceTest")) |
| 86 | 80 | // Java module-api Main |
| 87 | - .put(javaTemplatePath("enums/errorcode"), | |
| 88 | - javaModuleApiMainFilePath("enums/ErrorCodeConstants")) | |
| 81 | + .put(javaTemplatePath("enums/errorcode"), javaModuleApiMainFilePath("enums/ErrorCodeConstants")) | |
| 89 | 82 | // Vue |
| 90 | 83 | .put(vueTemplatePath("views/index.vue"), |
| 91 | 84 | vueFilePath("views/${table.moduleName}/${classNameVar}/index.vue")) |
| ... | ... | @@ -96,9 +89,6 @@ public class CodegenEngine { |
| 96 | 89 | .build(); |
| 97 | 90 | |
| 98 | 91 | @Resource |
| 99 | - private CodegenBuilder codegenBuilder; | |
| 100 | - | |
| 101 | - @Resource | |
| 102 | 92 | private CodegenProperties codegenProperties; |
| 103 | 93 | |
| 104 | 94 | /** |
| ... | ... | @@ -121,8 +111,7 @@ public class CodegenEngine { |
| 121 | 111 | private void initGlobalBindingMap() { |
| 122 | 112 | // 全局配置 |
| 123 | 113 | globalBindingMap.put("basePackage", codegenProperties.getBasePackage()); |
| 124 | - globalBindingMap.put("baseFrameworkPackage", StrUtil.subBefore(codegenProperties.getBasePackage(), | |
| 125 | - '.', true) + '.' + "framework"); // 用于后续获取测试类的 package 地址 | |
| 114 | + globalBindingMap.put("baseFrameworkPackage", codegenProperties.getBasePackage() + '.' + "framework"); // 用于后续获取测试类的 package 地址 | |
| 126 | 115 | // 全局 Java Bean |
| 127 | 116 | globalBindingMap.put("CommonResultClassName", CommonResult.class.getName()); |
| 128 | 117 | globalBindingMap.put("PageResultClassName", PageResult.class.getName()); |
| ... | ... | @@ -132,7 +121,7 @@ public class CodegenEngine { |
| 132 | 121 | // DO 类,独有字段 |
| 133 | 122 | globalBindingMap.put("baseDOFields", CodegenBuilder.BASE_DO_FIELDS); |
| 134 | 123 | globalBindingMap.put("BaseDOClassName", BaseDO.class.getName()); |
| 135 | - globalBindingMap.put("QueryWrapperClassName", QueryWrapperX.class.getName()); | |
| 124 | + globalBindingMap.put("QueryWrapperClassName", LambdaQueryWrapperX.class.getName()); | |
| 136 | 125 | globalBindingMap.put("BaseMapperClassName", BaseMapperX.class.getName()); |
| 137 | 126 | // Util 工具类 |
| 138 | 127 | globalBindingMap.put("ServiceExceptionUtilClassName", ServiceExceptionUtil.class.getName()); |
| ... | ... | @@ -150,13 +139,15 @@ public class CodegenEngine { |
| 150 | 139 | bindingMap.put("table", table); |
| 151 | 140 | bindingMap.put("columns", columns); |
| 152 | 141 | bindingMap.put("primaryColumn", CollectionUtils.findFirst(columns, CodegenColumnDO::getPrimaryKey)); // 主键字段 |
| 142 | + bindingMap.put("sceneEnum", CodegenSceneEnum.valueOf(table.getScene())); | |
| 153 | 143 | // className 相关 |
| 154 | - // 去掉指定前缀 将 TestDictType 转换成 DictType. 因为在 create 等方法后,不需要带上 Test 前缀 | |
| 144 | + // 去掉指定前缀,将 TestDictType 转换成 DictType. 因为在 create 等方法后,不需要带上 Test 前缀 | |
| 155 | 145 | String simpleClassName = removePrefix(table.getClassName(), upperFirst(table.getModuleName())); |
| 156 | 146 | bindingMap.put("simpleClassName", simpleClassName); |
| 157 | 147 | bindingMap.put("simpleClassName_underlineCase", toUnderlineCase(simpleClassName)); // 将 DictType 转换成 dict_type |
| 158 | 148 | bindingMap.put("classNameVar", lowerFirst(simpleClassName)); // 将 DictType 转换成 dictType,用于变量 |
| 159 | - String simpleClassNameStrikeCase = toSymbolCase(simpleClassName, '-'); // 将 DictType 转换成 dict-type | |
| 149 | + // 将 DictType 转换成 dict-type | |
| 150 | + String simpleClassNameStrikeCase = toSymbolCase(simpleClassName, '-'); | |
| 160 | 151 | bindingMap.put("simpleClassName_strikeCase", simpleClassNameStrikeCase); |
| 161 | 152 | // permission 前缀 |
| 162 | 153 | bindingMap.put("permissionPrefix", table.getModuleName() + ":" + simpleClassNameStrikeCase); |
| ... | ... | @@ -176,7 +167,10 @@ public class CodegenEngine { |
| 176 | 167 | getStr(bindingMap, "basePackage").replaceAll("\\.", "/")); |
| 177 | 168 | filePath = StrUtil.replace(filePath, "${classNameVar}", |
| 178 | 169 | getStr(bindingMap, "classNameVar")); |
| 179 | - | |
| 170 | + // sceneEnum 包含的字段 | |
| 171 | + CodegenSceneEnum sceneEnum = (CodegenSceneEnum) bindingMap.get("sceneEnum"); | |
| 172 | + filePath = StrUtil.replace(filePath, "${sceneEnum.prefixClass}", sceneEnum.getPrefixClass()); | |
| 173 | + filePath = StrUtil.replace(filePath, "${sceneEnum.basePackage}", sceneEnum.getBasePackage()); | |
| 180 | 174 | // table 包含的字段 |
| 181 | 175 | CodegenTableDO table = (CodegenTableDO) bindingMap.get("table"); |
| 182 | 176 | filePath = StrUtil.replace(filePath, "${table.moduleName}", table.getModuleName()); |
| ... | ... | @@ -189,13 +183,22 @@ public class CodegenEngine { |
| 189 | 183 | return "codegen/java/" + path + ".vm"; |
| 190 | 184 | } |
| 191 | 185 | |
| 186 | + private static String javaModuleImplVOFilePath(String path) { | |
| 187 | + return javaModuleFilePath("controller/${sceneEnum.basePackage}/${table.businessName}/" + | |
| 188 | + "vo/${sceneEnum.prefixClass}${table.className}" + path, "impl", "main"); | |
| 189 | + } | |
| 190 | + | |
| 191 | + private static String javaModuleImplControllerFilePath() { | |
| 192 | + return javaModuleFilePath("controller/${sceneEnum.basePackage}/${table.businessName}/" + | |
| 193 | + "${sceneEnum.prefixClass}${table.className}Controller", "impl", "main"); | |
| 194 | + } | |
| 195 | + | |
| 192 | 196 | private static String javaModuleImplMainFilePath(String path) { |
| 193 | 197 | return javaModuleFilePath(path, "impl", "main"); |
| 194 | 198 | } |
| 195 | 199 | |
| 196 | 200 | private static String javaModuleApiMainFilePath(String path) { |
| 197 | 201 | return javaModuleFilePath(path, "api", "main"); |
| 198 | - | |
| 199 | 202 | } |
| 200 | 203 | |
| 201 | 204 | private static String javaModuleImplTestFilePath(String path) { | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/test/TestDemoService.java
| ... | ... | @@ -2,18 +2,14 @@ package cn.iocoder.yudao.module.tool.service.test; |
| 2 | 2 | |
| 3 | 3 | import java.util.*; |
| 4 | 4 | import javax.validation.*; |
| 5 | - | |
| 6 | -import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoCreateReqVO; | |
| 7 | -import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoExportReqVO; | |
| 8 | -import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoPageReqVO; | |
| 9 | -import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoUpdateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.tool.controller.app.test.vo.*; | |
| 10 | 6 | import cn.iocoder.yudao.module.tool.dal.dataobject.test.TestDemoDO; |
| 11 | 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 12 | 8 | |
| 13 | 9 | /** |
| 14 | - * 测试示例 Service 接口 | |
| 10 | + * 字典类型 Service 接口 | |
| 15 | 11 | * |
| 16 | - * @author 芋艿 | |
| 12 | + * @author 芋道源码 | |
| 17 | 13 | */ |
| 18 | 14 | public interface TestDemoService { |
| 19 | 15 | |
| ... | ... | @@ -23,14 +19,14 @@ public interface TestDemoService { |
| 23 | 19 | * @param createReqVO 创建信息 |
| 24 | 20 | * @return 编号 |
| 25 | 21 | */ |
| 26 | - Long createTestDemo(@Valid TestDemoCreateReqVO createReqVO); | |
| 22 | + Long createTestDemo(@Valid AppTestDemoCreateReqVO createReqVO); | |
| 27 | 23 | |
| 28 | 24 | /** |
| 29 | 25 | * 更新字典类型 |
| 30 | 26 | * |
| 31 | 27 | * @param updateReqVO 更新信息 |
| 32 | 28 | */ |
| 33 | - void updateTestDemo(@Valid TestDemoUpdateReqVO updateReqVO); | |
| 29 | + void updateTestDemo(@Valid AppTestDemoUpdateReqVO updateReqVO); | |
| 34 | 30 | |
| 35 | 31 | /** |
| 36 | 32 | * 删除字典类型 |
| ... | ... | @@ -61,7 +57,7 @@ public interface TestDemoService { |
| 61 | 57 | * @param pageReqVO 分页查询 |
| 62 | 58 | * @return 字典类型分页 |
| 63 | 59 | */ |
| 64 | - PageResult<TestDemoDO> getTestDemoPage(TestDemoPageReqVO pageReqVO); | |
| 60 | + PageResult<TestDemoDO> getTestDemoPage(AppTestDemoPageReqVO pageReqVO); | |
| 65 | 61 | |
| 66 | 62 | /** |
| 67 | 63 | * 获得字典类型列表, 用于 Excel 导出 |
| ... | ... | @@ -69,6 +65,6 @@ public interface TestDemoService { |
| 69 | 65 | * @param exportReqVO 查询条件 |
| 70 | 66 | * @return 字典类型列表 |
| 71 | 67 | */ |
| 72 | - List<TestDemoDO> getTestDemoList(TestDemoExportReqVO exportReqVO); | |
| 68 | + List<TestDemoDO> getTestDemoList(AppTestDemoExportReqVO exportReqVO); | |
| 73 | 69 | |
| 74 | 70 | } | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/test/TestDemoServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.tool.service.test; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoCreateReqVO; | |
| 4 | -import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoExportReqVO; | |
| 5 | -import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoPageReqVO; | |
| 6 | -import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoUpdateReqVO; | |
| 7 | 3 | import org.springframework.stereotype.Service; |
| 8 | 4 | import javax.annotation.Resource; |
| 9 | 5 | import org.springframework.validation.annotation.Validated; |
| 10 | 6 | |
| 11 | 7 | import java.util.*; |
| 12 | - | |
| 8 | +import cn.iocoder.yudao.module.tool.controller.app.test.vo.*; | |
| 13 | 9 | import cn.iocoder.yudao.module.tool.dal.dataobject.test.TestDemoDO; |
| 14 | 10 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 15 | 11 | |
| ... | ... | @@ -20,9 +16,9 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU |
| 20 | 16 | import static cn.iocoder.yudao.module.tool.enums.ErrorCodeConstants.*; |
| 21 | 17 | |
| 22 | 18 | /** |
| 23 | - * 测试示例 Service 实现类 | |
| 19 | + * 字典类型 Service 实现类 | |
| 24 | 20 | * |
| 25 | - * @author 芋艿 | |
| 21 | + * @author 芋道源码 | |
| 26 | 22 | */ |
| 27 | 23 | @Service |
| 28 | 24 | @Validated |
| ... | ... | @@ -32,7 +28,7 @@ public class TestDemoServiceImpl implements TestDemoService { |
| 32 | 28 | private TestDemoMapper testDemoMapper; |
| 33 | 29 | |
| 34 | 30 | @Override |
| 35 | - public Long createTestDemo(TestDemoCreateReqVO createReqVO) { | |
| 31 | + public Long createTestDemo(AppTestDemoCreateReqVO createReqVO) { | |
| 36 | 32 | // 插入 |
| 37 | 33 | TestDemoDO testDemo = TestDemoConvert.INSTANCE.convert(createReqVO); |
| 38 | 34 | testDemoMapper.insert(testDemo); |
| ... | ... | @@ -41,7 +37,7 @@ public class TestDemoServiceImpl implements TestDemoService { |
| 41 | 37 | } |
| 42 | 38 | |
| 43 | 39 | @Override |
| 44 | - public void updateTestDemo(TestDemoUpdateReqVO updateReqVO) { | |
| 40 | + public void updateTestDemo(AppTestDemoUpdateReqVO updateReqVO) { | |
| 45 | 41 | // 校验存在 |
| 46 | 42 | this.validateTestDemoExists(updateReqVO.getId()); |
| 47 | 43 | // 更新 |
| ... | ... | @@ -74,12 +70,12 @@ public class TestDemoServiceImpl implements TestDemoService { |
| 74 | 70 | } |
| 75 | 71 | |
| 76 | 72 | @Override |
| 77 | - public PageResult<TestDemoDO> getTestDemoPage(TestDemoPageReqVO pageReqVO) { | |
| 73 | + public PageResult<TestDemoDO> getTestDemoPage(AppTestDemoPageReqVO pageReqVO) { | |
| 78 | 74 | return testDemoMapper.selectPage(pageReqVO); |
| 79 | 75 | } |
| 80 | 76 | |
| 81 | 77 | @Override |
| 82 | - public List<TestDemoDO> getTestDemoList(TestDemoExportReqVO exportReqVO) { | |
| 78 | + public List<TestDemoDO> getTestDemoList(AppTestDemoExportReqVO exportReqVO) { | |
| 83 | 79 | return testDemoMapper.selectList(exportReqVO); |
| 84 | 80 | } |
| 85 | 81 | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/controller.vm
| 1 | -package ${basePackage}.module.${table.moduleName}.controller.${table.businessName}; | |
| 1 | +package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}; | |
| 2 | 2 | |
| 3 | 3 | import org.springframework.web.bind.annotation.*; |
| 4 | 4 | import javax.annotation.Resource; |
| 5 | 5 | import org.springframework.validation.annotation.Validated; |
| 6 | -import org.springframework.security.access.prepost.PreAuthorize; | |
| 6 | +#if ($sceneEnum.scene == 1)import org.springframework.security.access.prepost.PreAuthorize;#end | |
| 7 | 7 | |
| 8 | 8 | import io.swagger.annotations.*; |
| 9 | 9 | |
| ... | ... | @@ -22,32 +22,32 @@ import ${ExcelUtilsClassName}; |
| 22 | 22 | import ${OperateLogClassName}; |
| 23 | 23 | import static ${OperateTypeEnumClassName}.*; |
| 24 | 24 | |
| 25 | -import ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo.*; | |
| 25 | +import ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo.*; | |
| 26 | 26 | import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; |
| 27 | 27 | import ${basePackage}.module.${table.moduleName}.convert.${table.businessName}.${table.className}Convert; |
| 28 | 28 | import ${basePackage}.module.${table.moduleName}.service.${table.businessName}.${table.className}Service; |
| 29 | 29 | |
| 30 | -@Api(tags = "${table.classComment}") | |
| 30 | +@Api(tags = "${sceneEnum.name} - ${table.classComment}") | |
| 31 | 31 | @RestController |
| 32 | 32 | ##二级的 businessName 暂时不算在 HTTP 路径上,可以根据需要写 |
| 33 | 33 | @RequestMapping("/${table.moduleName}/${simpleClassName_strikeCase}") |
| 34 | 34 | @Validated |
| 35 | -public class ${table.className}Controller { | |
| 35 | +public class ${sceneEnum.prefixClass}${table.className}Controller { | |
| 36 | 36 | |
| 37 | 37 | @Resource |
| 38 | 38 | private ${table.className}Service ${classNameVar}Service; |
| 39 | 39 | |
| 40 | 40 | @PostMapping("/create") |
| 41 | 41 | @ApiOperation("创建${table.classComment}") |
| 42 | - @PreAuthorize("@ss.hasPermission('${permissionPrefix}:create')") | |
| 43 | - public CommonResult<${primaryColumn.javaType}> create${simpleClassName}(@Valid @RequestBody ${table.className}CreateReqVO createReqVO) { | |
| 42 | +#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:create')")#end | |
| 43 | + public CommonResult<${primaryColumn.javaType}> create${simpleClassName}(@Valid @RequestBody ${sceneEnum.prefixClass}${table.className}CreateReqVO createReqVO) { | |
| 44 | 44 | return success(${classNameVar}Service.create${simpleClassName}(createReqVO)); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | @PutMapping("/update") |
| 48 | 48 | @ApiOperation("更新${table.classComment}") |
| 49 | - @PreAuthorize("@ss.hasPermission('${permissionPrefix}:update')") | |
| 50 | - public CommonResult<Boolean> update${simpleClassName}(@Valid @RequestBody ${table.className}UpdateReqVO updateReqVO) { | |
| 49 | +#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:update')")#end | |
| 50 | + public CommonResult<Boolean> update${simpleClassName}(@Valid @RequestBody ${sceneEnum.prefixClass}${table.className}UpdateReqVO updateReqVO) { | |
| 51 | 51 | ${classNameVar}Service.update${simpleClassName}(updateReqVO); |
| 52 | 52 | return success(true); |
| 53 | 53 | } |
| ... | ... | @@ -55,7 +55,7 @@ public class ${table.className}Controller { |
| 55 | 55 | @DeleteMapping("/delete") |
| 56 | 56 | @ApiOperation("删除${table.classComment}") |
| 57 | 57 | @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = ${primaryColumn.javaType}.class) |
| 58 | - @PreAuthorize("@ss.hasPermission('${permissionPrefix}:delete')") | |
| 58 | +#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:delete')")#end | |
| 59 | 59 | public CommonResult<Boolean> delete${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) { |
| 60 | 60 | ${classNameVar}Service.delete${simpleClassName}(id); |
| 61 | 61 | return success(true); |
| ... | ... | @@ -65,7 +65,7 @@ public class ${table.className}Controller { |
| 65 | 65 | @ApiOperation("获得${table.classComment}") |
| 66 | 66 | @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = ${primaryColumn.javaType}.class) |
| 67 | 67 | @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')") |
| 68 | - public CommonResult<${table.className}RespVO> get${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) { | |
| 68 | + public CommonResult<${sceneEnum.prefixClass}${table.className}RespVO> get${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) { | |
| 69 | 69 | ${table.className}DO ${classNameVar} = ${classNameVar}Service.get${simpleClassName}(id); |
| 70 | 70 | return success(${table.className}Convert.INSTANCE.convert(${classNameVar})); |
| 71 | 71 | } |
| ... | ... | @@ -73,30 +73,30 @@ public class ${table.className}Controller { |
| 73 | 73 | @GetMapping("/list") |
| 74 | 74 | @ApiOperation("获得${table.classComment}列表") |
| 75 | 75 | @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) |
| 76 | - @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')") | |
| 77 | - public CommonResult<List<${table.className}RespVO>> get${simpleClassName}List(@RequestParam("ids") Collection<${primaryColumn.javaType}> ids) { | |
| 76 | +#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")#end | |
| 77 | + public CommonResult<List<${sceneEnum.prefixClass}${table.className}RespVO>> get${simpleClassName}List(@RequestParam("ids") Collection<${primaryColumn.javaType}> ids) { | |
| 78 | 78 | List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(ids); |
| 79 | 79 | return success(${table.className}Convert.INSTANCE.convertList(list)); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | @GetMapping("/page") |
| 83 | 83 | @ApiOperation("获得${table.classComment}分页") |
| 84 | - @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')") | |
| 85 | - public CommonResult<PageResult<${table.className}RespVO>> get${simpleClassName}Page(@Valid ${table.className}PageReqVO pageVO) { | |
| 84 | +#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")#end | |
| 85 | + public CommonResult<PageResult<${sceneEnum.prefixClass}${table.className}RespVO>> get${simpleClassName}Page(@Valid ${sceneEnum.prefixClass}${table.className}PageReqVO pageVO) { | |
| 86 | 86 | PageResult<${table.className}DO> pageResult = ${classNameVar}Service.get${simpleClassName}Page(pageVO); |
| 87 | 87 | return success(${table.className}Convert.INSTANCE.convertPage(pageResult)); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | @GetMapping("/export-excel") |
| 91 | 91 | @ApiOperation("导出${table.classComment} Excel") |
| 92 | - @PreAuthorize("@ss.hasPermission('${permissionPrefix}:export')") | |
| 92 | +#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:export')")#end | |
| 93 | 93 | @OperateLog(type = EXPORT) |
| 94 | - public void export${simpleClassName}Excel(@Valid ${table.className}ExportReqVO exportReqVO, | |
| 94 | + public void export${simpleClassName}Excel(@Valid ${sceneEnum.prefixClass}${table.className}ExportReqVO exportReqVO, | |
| 95 | 95 | HttpServletResponse response) throws IOException { |
| 96 | 96 | List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(exportReqVO); |
| 97 | 97 | // 导出 Excel |
| 98 | - List<${table.className}ExcelVO> datas = ${table.className}Convert.INSTANCE.convertList02(list); | |
| 99 | - ExcelUtils.write(response, "${table.classComment}.xls", "数据", ${table.className}ExcelVO.class, datas); | |
| 98 | + List<${sceneEnum.prefixClass}${table.className}ExcelVO> datas = ${table.className}Convert.INSTANCE.convertList02(list); | |
| 99 | + ExcelUtils.write(response, "${table.classComment}.xls", "数据", ${sceneEnum.prefixClass}${table.className}ExcelVO.class, datas); | |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | } | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/baseVO.vm
| 1 | -package ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo; | |
| 1 | +package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo; | |
| 2 | 2 | |
| 3 | 3 | import lombok.*; |
| 4 | 4 | import java.util.*; |
| ... | ... | @@ -20,7 +20,7 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 20 | 20 | * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 |
| 21 | 21 | */ |
| 22 | 22 | @Data |
| 23 | -public class ${table.className}BaseVO { | |
| 23 | +public class ${sceneEnum.prefixClass}${table.className}BaseVO { | |
| 24 | 24 | |
| 25 | 25 | #foreach ($column in $columns) |
| 26 | 26 | #if (${column.createOperation} && ${column.updateOperation} && ${column.listOperationResult})##通用操作 | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/createReqVO.vm
| 1 | -package ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo; | |
| 1 | +package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo; | |
| 2 | 2 | |
| 3 | 3 | import lombok.*; |
| 4 | 4 | import java.util.*; |
| ... | ... | @@ -15,11 +15,11 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 15 | 15 | #end |
| 16 | 16 | #end |
| 17 | 17 | |
| 18 | -@ApiModel("${table.classComment}创建 Request VO") | |
| 18 | +@ApiModel("${sceneEnum.name} - ${table.classComment}创建 Request VO") | |
| 19 | 19 | @Data |
| 20 | 20 | @EqualsAndHashCode(callSuper = true) |
| 21 | 21 | @ToString(callSuper = true) |
| 22 | -public class ${table.className}CreateReqVO extends ${table.className}BaseVO { | |
| 22 | +public class ${sceneEnum.prefixClass}${table.className}CreateReqVO extends ${sceneEnum.prefixClass}${table.className}BaseVO { | |
| 23 | 23 | |
| 24 | 24 | #foreach ($column in $columns) |
| 25 | 25 | #if (${column.createOperation} && (!${column.updateOperation} || !${column.listOperationResult}))##不是通用字段 | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/excelVO.vm
| 1 | -package ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo; | |
| 1 | +package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo; | |
| 2 | 2 | |
| 3 | 3 | import lombok.*; |
| 4 | 4 | import java.util.*; |
| ... | ... | @@ -20,7 +20,7 @@ import ${DictConvertClassName}; |
| 20 | 20 | * @author ${table.author} |
| 21 | 21 | */ |
| 22 | 22 | @Data |
| 23 | -public class ${table.className}ExcelVO { | |
| 23 | +public class ${sceneEnum.prefixClass}${table.className}ExcelVO { | |
| 24 | 24 | |
| 25 | 25 | #foreach ($column in $columns) |
| 26 | 26 | #if (${column.listOperationResult})##返回字段 | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/exportReqVO.vm
| 1 | -package ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo; | |
| 1 | +package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo; | |
| 2 | 2 | |
| 3 | 3 | import lombok.*; |
| 4 | 4 | import java.util.*; |
| ... | ... | @@ -22,9 +22,9 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 22 | 22 | private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end; |
| 23 | 23 | #end |
| 24 | 24 | |
| 25 | -@ApiModel(value = "${table.classComment} Excel 导出 Request VO", description = "参数和 ${table.className}PageReqVO 是一致的") | |
| 25 | +@ApiModel(value = "${sceneEnum.name} - ${table.classComment} Excel 导出 Request VO", description = "参数和 ${table.className}PageReqVO 是一致的") | |
| 26 | 26 | @Data |
| 27 | -public class ${table.className}ExportReqVO { | |
| 27 | +public class ${sceneEnum.prefixClass}${table.className}ExportReqVO { | |
| 28 | 28 | |
| 29 | 29 | #foreach ($column in $columns) |
| 30 | 30 | #set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写 | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/pageReqVO.vm
| 1 | -package ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo; | |
| 1 | +package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo; | |
| 2 | 2 | |
| 3 | 3 | import lombok.*; |
| 4 | 4 | import java.util.*; |
| ... | ... | @@ -22,11 +22,11 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 22 | 22 | private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end; |
| 23 | 23 | #end |
| 24 | 24 | |
| 25 | -@ApiModel("${table.classComment}分页 Request VO") | |
| 25 | +@ApiModel("${sceneEnum.name} - ${table.classComment}分页 Request VO") | |
| 26 | 26 | @Data |
| 27 | 27 | @EqualsAndHashCode(callSuper = true) |
| 28 | 28 | @ToString(callSuper = true) |
| 29 | -public class ${table.className}PageReqVO extends PageParam { | |
| 29 | +public class ${sceneEnum.prefixClass}${table.className}PageReqVO extends PageParam { | |
| 30 | 30 | |
| 31 | 31 | #foreach ($column in $columns) |
| 32 | 32 | #set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写 | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/respVO.vm
| 1 | -package ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo; | |
| 1 | +package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo; | |
| 2 | 2 | |
| 3 | 3 | import lombok.*; |
| 4 | 4 | import java.util.*; |
| 5 | 5 | import io.swagger.annotations.*; |
| 6 | 6 | |
| 7 | -@ApiModel("${table.classComment} Response VO") | |
| 7 | +@ApiModel("${sceneEnum.name} - ${table.classComment} Response VO") | |
| 8 | 8 | @Data |
| 9 | 9 | @EqualsAndHashCode(callSuper = true) |
| 10 | 10 | @ToString(callSuper = true) |
| 11 | -public class ${table.className}RespVO extends ${table.className}BaseVO { | |
| 11 | +public class ${sceneEnum.prefixClass}${table.className}RespVO extends ${sceneEnum.prefixClass}${table.className}BaseVO { | |
| 12 | 12 | |
| 13 | 13 | #foreach ($column in $columns) |
| 14 | 14 | #if (${column.listOperationResult} && (!${column.createOperation} || !${column.updateOperation}))##不是通用字段 | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/updateReqVO.vm
| 1 | -package ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo; | |
| 1 | +package ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo; | |
| 2 | 2 | |
| 3 | 3 | import lombok.*; |
| 4 | 4 | import java.util.*; |
| ... | ... | @@ -15,11 +15,11 @@ import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 15 | 15 | #end |
| 16 | 16 | #end |
| 17 | 17 | |
| 18 | -@ApiModel("${table.classComment}更新 Request VO") | |
| 18 | +@ApiModel("${sceneEnum.name} - ${table.classComment}更新 Request VO") | |
| 19 | 19 | @Data |
| 20 | 20 | @EqualsAndHashCode(callSuper = true) |
| 21 | 21 | @ToString(callSuper = true) |
| 22 | -public class ${table.className}UpdateReqVO extends ${table.className}BaseVO { | |
| 22 | +public class ${sceneEnum.prefixClass}${table.className}UpdateReqVO extends ${sceneEnum.prefixClass}${table.className}BaseVO { | |
| 23 | 23 | |
| 24 | 24 | #foreach ($column in $columns) |
| 25 | 25 | #if (${column.updateOperation} && (!${column.createOperation} || !${column.listOperationResult}))##不是通用字段 | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/convert/convert.vm
| ... | ... | @@ -6,7 +6,7 @@ import ${PageResultClassName}; |
| 6 | 6 | |
| 7 | 7 | import org.mapstruct.Mapper; |
| 8 | 8 | import org.mapstruct.factory.Mappers; |
| 9 | -import ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo.*; | |
| 9 | +import ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo.*; | |
| 10 | 10 | import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; |
| 11 | 11 | |
| 12 | 12 | /** |
| ... | ... | @@ -19,16 +19,16 @@ public interface ${table.className}Convert { |
| 19 | 19 | |
| 20 | 20 | ${table.className}Convert INSTANCE = Mappers.getMapper(${table.className}Convert.class); |
| 21 | 21 | |
| 22 | - ${table.className}DO convert(${table.className}CreateReqVO bean); | |
| 22 | + ${table.className}DO convert(${sceneEnum.prefixClass}${table.className}CreateReqVO bean); | |
| 23 | 23 | |
| 24 | - ${table.className}DO convert(${table.className}UpdateReqVO bean); | |
| 24 | + ${table.className}DO convert(${sceneEnum.prefixClass}${table.className}UpdateReqVO bean); | |
| 25 | 25 | |
| 26 | - ${table.className}RespVO convert(${table.className}DO bean); | |
| 26 | + ${sceneEnum.prefixClass}${table.className}RespVO convert(${table.className}DO bean); | |
| 27 | 27 | |
| 28 | - List<${table.className}RespVO> convertList(List<${table.className}DO> list); | |
| 28 | + List<${sceneEnum.prefixClass}${table.className}RespVO> convertList(List<${table.className}DO> list); | |
| 29 | 29 | |
| 30 | - PageResult<${table.className}RespVO> convertPage(PageResult<${table.className}DO> page); | |
| 30 | + PageResult<${sceneEnum.prefixClass}${table.className}RespVO> convertPage(PageResult<${table.className}DO> page); | |
| 31 | 31 | |
| 32 | - List<${table.className}ExcelVO> convertList02(List<${table.className}DO> list); | |
| 32 | + List<${sceneEnum.prefixClass}${table.className}ExcelVO> convertList02(List<${table.className}DO> list); | |
| 33 | 33 | |
| 34 | 34 | } | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/dal/mapper.vm
| ... | ... | @@ -7,7 +7,7 @@ import ${QueryWrapperClassName}; |
| 7 | 7 | import ${BaseMapperClassName}; |
| 8 | 8 | import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; |
| 9 | 9 | import org.apache.ibatis.annotations.Mapper; |
| 10 | -import ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo.*; | |
| 10 | +import ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo.*; | |
| 11 | 11 | |
| 12 | 12 | ## 字段模板 |
| 13 | 13 | #macro(listCondition) |
| ... | ... | @@ -15,28 +15,28 @@ import ${basePackage}.module.${table.moduleName}.controller.${table.businessName |
| 15 | 15 | #if (${column.listOperation}) |
| 16 | 16 | #set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写 |
| 17 | 17 | #if (${column.listOperationCondition} == "=")##情况一,= 的时候 |
| 18 | - .eqIfPresent("${column.columnName}", reqVO.get${JavaField}()) | |
| 18 | + .eqIfPresent(${table.className}DO::get${JavaField}, reqVO.get${JavaField}()) | |
| 19 | 19 | #end |
| 20 | 20 | #if (${column.listOperationCondition} == "!=")##情况二,!= 的时候 |
| 21 | - .neIfPresent("${column.columnName}", reqVO.get${JavaField}()) | |
| 21 | + .neIfPresent(${table.className}DO::get${JavaField}, reqVO.get${JavaField}()) | |
| 22 | 22 | #end |
| 23 | 23 | #if (${column.listOperationCondition} == ">")##情况三,> 的时候 |
| 24 | - .gtIfPresent("${column.columnName}", reqVO.get${JavaField}()) | |
| 24 | + .gtIfPresent(${table.className}DO::get${JavaField}, reqVO.get${JavaField}()) | |
| 25 | 25 | #end |
| 26 | 26 | #if (${column.listOperationCondition} == ">=")##情况四,>= 的时候 |
| 27 | - .geIfPresent("${column.columnName}", reqVO.get${JavaField}()) | |
| 27 | + .geIfPresent(${table.className}DO::get${JavaField}, reqVO.get${JavaField}()) | |
| 28 | 28 | #end |
| 29 | 29 | #if (${column.listOperationCondition} == "<")##情况五,< 的时候 |
| 30 | - .ltIfPresent("${column.columnName}", reqVO.get${JavaField}()) | |
| 30 | + .ltIfPresent(${table.className}DO::get${JavaField}, reqVO.get${JavaField}()) | |
| 31 | 31 | #end |
| 32 | 32 | #if (${column.listOperationCondition} == "<=")##情况五,<= 的时候 |
| 33 | - .leIfPresent("${column.columnName}", reqVO.get${JavaField}()) | |
| 33 | + .leIfPresent(${table.className}DO::get${JavaField}, reqVO.get${JavaField}()) | |
| 34 | 34 | #end |
| 35 | 35 | #if (${column.listOperationCondition} == "LIKE")##情况七,Like 的时候 |
| 36 | - .likeIfPresent("${column.columnName}", reqVO.get${JavaField}()) | |
| 36 | + .likeIfPresent(${table.className}DO::get${JavaField}, reqVO.get${JavaField}()) | |
| 37 | 37 | #end |
| 38 | 38 | #if (${column.listOperationCondition} == "BETWEEN")##情况八,Between 的时候 |
| 39 | - .betweenIfPresent("${column.columnName}", reqVO.getBegin${JavaField}(), reqVO.getEnd${JavaField}()) | |
| 39 | + .betweenIfPresent(${table.className}DO::get${JavaField}, reqVO.getBegin${JavaField}(), reqVO.getEnd${JavaField}()) | |
| 40 | 40 | #end |
| 41 | 41 | #end |
| 42 | 42 | #end |
| ... | ... | @@ -49,18 +49,18 @@ import ${basePackage}.module.${table.moduleName}.controller.${table.businessName |
| 49 | 49 | @Mapper |
| 50 | 50 | public interface ${table.className}Mapper extends BaseMapperX<${table.className}DO> { |
| 51 | 51 | |
| 52 | - default PageResult<${table.className}DO> selectPage(${table.className}PageReqVO reqVO) { | |
| 53 | - return selectPage(reqVO, new QueryWrapperX<${table.className}DO>() | |
| 52 | + default PageResult<${table.className}DO> selectPage(${sceneEnum.prefixClass}${table.className}PageReqVO reqVO) { | |
| 53 | + return selectPage(reqVO, new LambdaQueryWrapperX<${table.className}DO>() | |
| 54 | 54 | #listCondition() |
| 55 | - .orderByDesc("id")## 大多数情况下,id 倒序 | |
| 56 | - ); | |
| 55 | + .orderByDesc(${table.className}DO::getId));## 大多数情况下,id 倒序 | |
| 56 | + | |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - default List<${table.className}DO> selectList(${table.className}ExportReqVO reqVO) { | |
| 60 | - return selectList(new QueryWrapperX<${table.className}DO>() | |
| 59 | + default List<${table.className}DO> selectList(${sceneEnum.prefixClass}${table.className}ExportReqVO reqVO) { | |
| 60 | + return selectList(new LambdaQueryWrapperX<${table.className}DO>() | |
| 61 | 61 | #listCondition() |
| 62 | - .orderByDesc("id")## 大多数情况下,id 倒序 | |
| 63 | - ); | |
| 62 | + .orderByDesc(${table.className}DO::getId));## 大多数情况下,id 倒序 | |
| 63 | + | |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | } | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/enums/errorcode.vm
| 1 | +// TODO 待办:请将下面的错误码复制到 yudao-module-${table.moduleName}-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! | |
| 1 | 2 | // ========== ${table.classComment} TODO 补充编号 ========== |
| 2 | 3 | ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS = new ErrorCode(TODO 补充编号, "${table.classComment}不存在"); | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/service/service.vm
| ... | ... | @@ -2,7 +2,7 @@ package ${basePackage}.module.${table.moduleName}.service.${table.businessName}; |
| 2 | 2 | |
| 3 | 3 | import java.util.*; |
| 4 | 4 | import javax.validation.*; |
| 5 | -import ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo.*; | |
| 5 | +import ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo.*; | |
| 6 | 6 | import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; |
| 7 | 7 | import ${PageResultClassName}; |
| 8 | 8 | |
| ... | ... | @@ -19,14 +19,14 @@ public interface ${table.className}Service { |
| 19 | 19 | * @param createReqVO 创建信息 |
| 20 | 20 | * @return 编号 |
| 21 | 21 | */ |
| 22 | - ${primaryColumn.javaType} create${simpleClassName}(@Valid ${table.className}CreateReqVO createReqVO); | |
| 22 | + ${primaryColumn.javaType} create${simpleClassName}(@Valid ${sceneEnum.prefixClass}${table.className}CreateReqVO createReqVO); | |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * 更新${table.classComment} |
| 26 | 26 | * |
| 27 | 27 | * @param updateReqVO 更新信息 |
| 28 | 28 | */ |
| 29 | - void update${simpleClassName}(@Valid ${table.className}UpdateReqVO updateReqVO); | |
| 29 | + void update${simpleClassName}(@Valid ${sceneEnum.prefixClass}${table.className}UpdateReqVO updateReqVO); | |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * 删除${table.classComment} |
| ... | ... | @@ -57,7 +57,7 @@ public interface ${table.className}Service { |
| 57 | 57 | * @param pageReqVO 分页查询 |
| 58 | 58 | * @return ${table.classComment}分页 |
| 59 | 59 | */ |
| 60 | - PageResult<${table.className}DO> get${simpleClassName}Page(${table.className}PageReqVO pageReqVO); | |
| 60 | + PageResult<${table.className}DO> get${simpleClassName}Page(${sceneEnum.prefixClass}${table.className}PageReqVO pageReqVO); | |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * 获得${table.classComment}列表, 用于 Excel 导出 |
| ... | ... | @@ -65,6 +65,6 @@ public interface ${table.className}Service { |
| 65 | 65 | * @param exportReqVO 查询条件 |
| 66 | 66 | * @return ${table.classComment}列表 |
| 67 | 67 | */ |
| 68 | - List<${table.className}DO> get${simpleClassName}List(${table.className}ExportReqVO exportReqVO); | |
| 68 | + List<${table.className}DO> get${simpleClassName}List(${sceneEnum.prefixClass}${table.className}ExportReqVO exportReqVO); | |
| 69 | 69 | |
| 70 | 70 | } | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/service/serviceImpl.vm
| ... | ... | @@ -5,13 +5,12 @@ import javax.annotation.Resource; |
| 5 | 5 | import org.springframework.validation.annotation.Validated; |
| 6 | 6 | |
| 7 | 7 | import java.util.*; |
| 8 | -import ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo.*; | |
| 8 | +import ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo.*; | |
| 9 | 9 | import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; |
| 10 | 10 | import ${PageResultClassName}; |
| 11 | 11 | |
| 12 | 12 | import ${basePackage}.module.${table.moduleName}.convert.${table.businessName}.${table.className}Convert; |
| 13 | 13 | import ${basePackage}.module.${table.moduleName}.dal.mysql.${table.businessName}.${table.className}Mapper; |
| 14 | -import ${basePackage}.module.${table.moduleName}.service.${table.businessName}.${table.className}Service; | |
| 15 | 14 | |
| 16 | 15 | import static ${ServiceExceptionUtilClassName}.exception; |
| 17 | 16 | import static ${basePackage}.module.${table.moduleName}.enums.ErrorCodeConstants.*; |
| ... | ... | @@ -29,7 +28,7 @@ public class ${table.className}ServiceImpl implements ${table.className}Service |
| 29 | 28 | private ${table.className}Mapper ${classNameVar}Mapper; |
| 30 | 29 | |
| 31 | 30 | @Override |
| 32 | - public ${primaryColumn.javaType} create${simpleClassName}(${table.className}CreateReqVO createReqVO) { | |
| 31 | + public ${primaryColumn.javaType} create${simpleClassName}(${sceneEnum.prefixClass}${table.className}CreateReqVO createReqVO) { | |
| 33 | 32 | // 插入 |
| 34 | 33 | ${table.className}DO ${classNameVar} = ${table.className}Convert.INSTANCE.convert(createReqVO); |
| 35 | 34 | ${classNameVar}Mapper.insert(${classNameVar}); |
| ... | ... | @@ -38,7 +37,7 @@ public class ${table.className}ServiceImpl implements ${table.className}Service |
| 38 | 37 | } |
| 39 | 38 | |
| 40 | 39 | @Override |
| 41 | - public void update${simpleClassName}(${table.className}UpdateReqVO updateReqVO) { | |
| 40 | + public void update${simpleClassName}(${sceneEnum.prefixClass}${table.className}UpdateReqVO updateReqVO) { | |
| 42 | 41 | // 校验存在 |
| 43 | 42 | this.validate${simpleClassName}Exists(updateReqVO.getId()); |
| 44 | 43 | // 更新 |
| ... | ... | @@ -71,12 +70,12 @@ public class ${table.className}ServiceImpl implements ${table.className}Service |
| 71 | 70 | } |
| 72 | 71 | |
| 73 | 72 | @Override |
| 74 | - public PageResult<${table.className}DO> get${simpleClassName}Page(${table.className}PageReqVO pageReqVO) { | |
| 73 | + public PageResult<${table.className}DO> get${simpleClassName}Page(${sceneEnum.prefixClass}${table.className}PageReqVO pageReqVO) { | |
| 75 | 74 | return ${classNameVar}Mapper.selectPage(pageReqVO); |
| 76 | 75 | } |
| 77 | 76 | |
| 78 | 77 | @Override |
| 79 | - public List<${table.className}DO> get${simpleClassName}List(${table.className}ExportReqVO exportReqVO) { | |
| 78 | + public List<${table.className}DO> get${simpleClassName}List(${sceneEnum.prefixClass}${table.className}ExportReqVO exportReqVO) { | |
| 80 | 79 | return ${classNameVar}Mapper.selectList(exportReqVO); |
| 81 | 80 | } |
| 82 | 81 | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/test/serviceTest.vm
| ... | ... | @@ -5,9 +5,9 @@ import org.springframework.boot.test.mock.mockito.MockBean; |
| 5 | 5 | |
| 6 | 6 | import javax.annotation.Resource; |
| 7 | 7 | |
| 8 | -import ${basePackage}.BaseDbUnitTest; | |
| 9 | -import ${basePackage}.module.${table.moduleName}.service.${table.businessName}.impl.${table.className}ServiceImpl; | |
| 10 | -import ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo.*; | |
| 8 | +import ${basePackage}.module.${table.moduleName}.test.BaseDbUnitTest;## 每个项目,默认有一个基础 DB Test 基类 | |
| 9 | + | |
| 10 | +import ${basePackage}.module.${table.moduleName}.controller.${sceneEnum.basePackage}.${table.businessName}.vo.*; | |
| 11 | 11 | import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; |
| 12 | 12 | import ${basePackage}.module.${table.moduleName}.dal.mysql.${table.businessName}.${table.className}Mapper; |
| 13 | 13 | import ${PageResultClassName}; |
| ... | ... | @@ -45,7 +45,7 @@ import static org.mockito.Mockito.*; |
| 45 | 45 | #end |
| 46 | 46 | #end |
| 47 | 47 | // 准备参数 |
| 48 | - ${table.className}${VO} reqVO = new ${table.className}${VO}(); | |
| 48 | + ${sceneEnum.prefixClass}${table.className}${VO} reqVO = new ${sceneEnum.prefixClass}${table.className}${VO}(); | |
| 49 | 49 | #foreach ($column in $columns) |
| 50 | 50 | #if (${column.listOperation}) |
| 51 | 51 | #set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写 |
| ... | ... | @@ -64,7 +64,7 @@ import static org.mockito.Mockito.*; |
| 64 | 64 | * @author ${table.author} |
| 65 | 65 | */ |
| 66 | 66 | @Import(${table.className}ServiceImpl.class) |
| 67 | -public class ${table.className}ServiceTest extends BaseDbUnitTest { | |
| 67 | +public class ${table.className}ServiceImplTest extends BaseDbUnitTest { | |
| 68 | 68 | |
| 69 | 69 | @Resource |
| 70 | 70 | private ${table.className}ServiceImpl ${classNameVar}Service; |
| ... | ... | @@ -75,7 +75,7 @@ public class ${table.className}ServiceTest extends BaseDbUnitTest { |
| 75 | 75 | @Test |
| 76 | 76 | public void testCreate${simpleClassName}_success() { |
| 77 | 77 | // 准备参数 |
| 78 | - ${table.className}CreateReqVO reqVO = randomPojo(${table.className}CreateReqVO.class); | |
| 78 | + ${sceneEnum.prefixClass}${table.className}CreateReqVO reqVO = randomPojo(${sceneEnum.prefixClass}${table.className}CreateReqVO.class); | |
| 79 | 79 | |
| 80 | 80 | // 调用 |
| 81 | 81 | ${primaryColumn.javaType} ${classNameVar}Id = ${classNameVar}Service.create${simpleClassName}(reqVO); |
| ... | ... | @@ -92,7 +92,7 @@ public class ${table.className}ServiceTest extends BaseDbUnitTest { |
| 92 | 92 | ${table.className}DO db${simpleClassName} = randomPojo(${table.className}DO.class); |
| 93 | 93 | ${classNameVar}Mapper.insert(db${simpleClassName});// @Sql: 先插入出一条存在的数据 |
| 94 | 94 | // 准备参数 |
| 95 | - ${table.className}UpdateReqVO reqVO = randomPojo(${table.className}UpdateReqVO.class, o -> { | |
| 95 | + ${sceneEnum.prefixClass}${table.className}UpdateReqVO reqVO = randomPojo(${sceneEnum.prefixClass}${table.className}UpdateReqVO.class, o -> { | |
| 96 | 96 | o.setId(db${simpleClassName}.getId()); // 设置更新的 ID |
| 97 | 97 | }); |
| 98 | 98 | |
| ... | ... | @@ -106,7 +106,7 @@ public class ${table.className}ServiceTest extends BaseDbUnitTest { |
| 106 | 106 | @Test |
| 107 | 107 | public void testUpdate${simpleClassName}_notExists() { |
| 108 | 108 | // 准备参数 |
| 109 | - ${table.className}UpdateReqVO reqVO = randomPojo(${table.className}UpdateReqVO.class); | |
| 109 | + ${sceneEnum.prefixClass}${table.className}UpdateReqVO reqVO = randomPojo(${sceneEnum.prefixClass}${table.className}UpdateReqVO.class); | |
| 110 | 110 | |
| 111 | 111 | // 调用, 并断言异常 |
| 112 | 112 | assertServiceException(() -> ${classNameVar}Service.update${simpleClassName}(reqVO), ${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS); | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/test/java/cn/iocoder/yudao/module/tool/service/package-info.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.tool.service; | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/test/java/cn/iocoder/yudao/module/tool/service/test/TestDemoServiceImplTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.tool.service.test; | |
| 2 | + | |
| 3 | +import org.junit.jupiter.api.Test; | |
| 4 | +import org.springframework.boot.test.mock.mockito.MockBean; | |
| 5 | + | |
| 6 | +import javax.annotation.Resource; | |
| 7 | + | |
| 8 | +import cn.iocoder.yudao.module.tool.test.BaseDbUnitTest; | |
| 9 | +import cn.iocoder.yudao.module.tool.controller.app.test.vo.*; | |
| 10 | +import cn.iocoder.yudao.module.tool.dal.dataobject.test.TestDemoDO; | |
| 11 | +import cn.iocoder.yudao.module.tool.dal.mysql.test.TestDemoMapper; | |
| 12 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 13 | + | |
| 14 | +import javax.annotation.Resource; | |
| 15 | +import org.springframework.context.annotation.Import; | |
| 16 | +import java.util.*; | |
| 17 | + | |
| 18 | +import static cn.hutool.core.util.RandomUtil.*; | |
| 19 | +import static cn.iocoder.yudao.module.tool.enums.ErrorCodeConstants.*; | |
| 20 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; | |
| 21 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | |
| 22 | +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; | |
| 23 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; | |
| 24 | +import static org.junit.jupiter.api.Assertions.*; | |
| 25 | +import static org.mockito.Mockito.*; | |
| 26 | + | |
| 27 | +/** | |
| 28 | +* {@link TestDemoServiceImpl} 的单元测试类 | |
| 29 | +* | |
| 30 | +* @author 芋道源码 | |
| 31 | +*/ | |
| 32 | +@Import(TestDemoServiceImpl.class) | |
| 33 | +public class TestDemoServiceImplTest extends BaseDbUnitTest { | |
| 34 | + | |
| 35 | + @Resource | |
| 36 | + private TestDemoServiceImpl testDemoService; | |
| 37 | + | |
| 38 | + @Resource | |
| 39 | + private TestDemoMapper testDemoMapper; | |
| 40 | + | |
| 41 | + @Test | |
| 42 | + public void testCreateTestDemo_success() { | |
| 43 | + // 准备参数 | |
| 44 | + AppTestDemoCreateReqVO reqVO = randomPojo(AppTestDemoCreateReqVO.class); | |
| 45 | + | |
| 46 | + // 调用 | |
| 47 | + Long testDemoId = testDemoService.createTestDemo(reqVO); | |
| 48 | + // 断言 | |
| 49 | + assertNotNull(testDemoId); | |
| 50 | + // 校验记录的属性是否正确 | |
| 51 | + TestDemoDO testDemo = testDemoMapper.selectById(testDemoId); | |
| 52 | + assertPojoEquals(reqVO, testDemo); | |
| 53 | + } | |
| 54 | + | |
| 55 | + @Test | |
| 56 | + public void testUpdateTestDemo_success() { | |
| 57 | + // mock 数据 | |
| 58 | + TestDemoDO dbTestDemo = randomPojo(TestDemoDO.class); | |
| 59 | + testDemoMapper.insert(dbTestDemo);// @Sql: 先插入出一条存在的数据 | |
| 60 | + // 准备参数 | |
| 61 | + AppTestDemoUpdateReqVO reqVO = randomPojo(AppTestDemoUpdateReqVO.class, o -> { | |
| 62 | + o.setId(dbTestDemo.getId()); // 设置更新的 ID | |
| 63 | + }); | |
| 64 | + | |
| 65 | + // 调用 | |
| 66 | + testDemoService.updateTestDemo(reqVO); | |
| 67 | + // 校验是否更新正确 | |
| 68 | + TestDemoDO testDemo = testDemoMapper.selectById(reqVO.getId()); // 获取最新的 | |
| 69 | + assertPojoEquals(reqVO, testDemo); | |
| 70 | + } | |
| 71 | + | |
| 72 | + @Test | |
| 73 | + public void testUpdateTestDemo_notExists() { | |
| 74 | + // 准备参数 | |
| 75 | + AppTestDemoUpdateReqVO reqVO = randomPojo(AppTestDemoUpdateReqVO.class); | |
| 76 | + | |
| 77 | + // 调用, 并断言异常 | |
| 78 | + assertServiceException(() -> testDemoService.updateTestDemo(reqVO), TEST_DEMO_NOT_EXISTS); | |
| 79 | + } | |
| 80 | + | |
| 81 | + @Test | |
| 82 | + public void testDeleteTestDemo_success() { | |
| 83 | + // mock 数据 | |
| 84 | + TestDemoDO dbTestDemo = randomPojo(TestDemoDO.class); | |
| 85 | + testDemoMapper.insert(dbTestDemo);// @Sql: 先插入出一条存在的数据 | |
| 86 | + // 准备参数 | |
| 87 | + Long id = dbTestDemo.getId(); | |
| 88 | + | |
| 89 | + // 调用 | |
| 90 | + testDemoService.deleteTestDemo(id); | |
| 91 | + // 校验数据不存在了 | |
| 92 | + assertNull(testDemoMapper.selectById(id)); | |
| 93 | + } | |
| 94 | + | |
| 95 | + @Test | |
| 96 | + public void testDeleteTestDemo_notExists() { | |
| 97 | + // 准备参数 | |
| 98 | + Long id = randomLongId(); | |
| 99 | + | |
| 100 | + // 调用, 并断言异常 | |
| 101 | + assertServiceException(() -> testDemoService.deleteTestDemo(id), TEST_DEMO_NOT_EXISTS); | |
| 102 | + } | |
| 103 | + | |
| 104 | + @Test // TODO 请修改 null 为需要的值 | |
| 105 | + public void testGetTestDemoPage() { | |
| 106 | + // mock 数据 | |
| 107 | + TestDemoDO dbTestDemo = randomPojo(TestDemoDO.class, o -> { // 等会查询到 | |
| 108 | + o.setName(null); | |
| 109 | + o.setStatus(null); | |
| 110 | + o.setType(null); | |
| 111 | + o.setCategory(null); | |
| 112 | + o.setRemark(null); | |
| 113 | + o.setCreateTime(null); | |
| 114 | + }); | |
| 115 | + testDemoMapper.insert(dbTestDemo); | |
| 116 | + // 测试 name 不匹配 | |
| 117 | + testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setName(null))); | |
| 118 | + // 测试 status 不匹配 | |
| 119 | + testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setStatus(null))); | |
| 120 | + // 测试 type 不匹配 | |
| 121 | + testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setType(null))); | |
| 122 | + // 测试 category 不匹配 | |
| 123 | + testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setCategory(null))); | |
| 124 | + // 测试 remark 不匹配 | |
| 125 | + testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setRemark(null))); | |
| 126 | + // 测试 createTime 不匹配 | |
| 127 | + testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setCreateTime(null))); | |
| 128 | + // 准备参数 | |
| 129 | + AppTestDemoPageReqVO reqVO = new AppTestDemoPageReqVO(); | |
| 130 | + reqVO.setName(null); | |
| 131 | + reqVO.setStatus(null); | |
| 132 | + reqVO.setType(null); | |
| 133 | + reqVO.setCategory(null); | |
| 134 | + reqVO.setRemark(null); | |
| 135 | + reqVO.setBeginCreateTime(null); | |
| 136 | + reqVO.setEndCreateTime(null); | |
| 137 | + | |
| 138 | + // 调用 | |
| 139 | + PageResult<TestDemoDO> pageResult = testDemoService.getTestDemoPage(reqVO); | |
| 140 | + // 断言 | |
| 141 | + assertEquals(1, pageResult.getTotal()); | |
| 142 | + assertEquals(1, pageResult.getList().size()); | |
| 143 | + assertPojoEquals(dbTestDemo, pageResult.getList().get(0)); | |
| 144 | + } | |
| 145 | + | |
| 146 | + @Test // TODO 请修改 null 为需要的值 | |
| 147 | + public void testGetTestDemoList() { | |
| 148 | + // mock 数据 | |
| 149 | + TestDemoDO dbTestDemo = randomPojo(TestDemoDO.class, o -> { // 等会查询到 | |
| 150 | + o.setName(null); | |
| 151 | + o.setStatus(null); | |
| 152 | + o.setType(null); | |
| 153 | + o.setCategory(null); | |
| 154 | + o.setRemark(null); | |
| 155 | + o.setCreateTime(null); | |
| 156 | + }); | |
| 157 | + testDemoMapper.insert(dbTestDemo); | |
| 158 | + // 测试 name 不匹配 | |
| 159 | + testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setName(null))); | |
| 160 | + // 测试 status 不匹配 | |
| 161 | + testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setStatus(null))); | |
| 162 | + // 测试 type 不匹配 | |
| 163 | + testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setType(null))); | |
| 164 | + // 测试 category 不匹配 | |
| 165 | + testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setCategory(null))); | |
| 166 | + // 测试 remark 不匹配 | |
| 167 | + testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setRemark(null))); | |
| 168 | + // 测试 createTime 不匹配 | |
| 169 | + testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setCreateTime(null))); | |
| 170 | + // 准备参数 | |
| 171 | + AppTestDemoExportReqVO reqVO = new AppTestDemoExportReqVO(); | |
| 172 | + reqVO.setName(null); | |
| 173 | + reqVO.setStatus(null); | |
| 174 | + reqVO.setType(null); | |
| 175 | + reqVO.setCategory(null); | |
| 176 | + reqVO.setRemark(null); | |
| 177 | + reqVO.setBeginCreateTime(null); | |
| 178 | + reqVO.setEndCreateTime(null); | |
| 179 | + | |
| 180 | + // 调用 | |
| 181 | + List<TestDemoDO> list = testDemoService.getTestDemoList(reqVO); | |
| 182 | + // 断言 | |
| 183 | + assertEquals(1, list.size()); | |
| 184 | + assertPojoEquals(dbTestDemo, list.get(0)); | |
| 185 | + } | |
| 186 | + | |
| 187 | +} | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/test/java/cn/iocoder/yudao/module/tool/test/BaseDbUnitTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.tool.test; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; | |
| 5 | +import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; | |
| 6 | +import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration; | |
| 7 | +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; | |
| 8 | +import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; | |
| 9 | +import org.springframework.boot.test.context.SpringBootTest; | |
| 10 | +import org.springframework.context.annotation.Import; | |
| 11 | +import org.springframework.test.context.ActiveProfiles; | |
| 12 | +import org.springframework.test.context.jdbc.Sql; | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * 依赖内存 DB 的单元测试 | |
| 16 | + * | |
| 17 | + * 注意,Service 层同样适用。对于 Service 层的单元测试,我们针对自己模块的 Mapper 走的是 H2 内存数据库,针对别的模块的 Service 走的是 Mock 方法 | |
| 18 | + * | |
| 19 | + * @author 芋道源码 | |
| 20 | + */ | |
| 21 | +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseDbUnitTest.Application.class) | |
| 22 | +@ActiveProfiles("unit-test") // 设置使用 application-unit-test 配置文件 | |
| 23 | +@Sql(scripts = "/sql/clean.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) // 每个单元测试结束后,清理 DB | |
| 24 | +public class BaseDbUnitTest { | |
| 25 | + | |
| 26 | + @Import({ | |
| 27 | + // DB 配置类 | |
| 28 | + YudaoDataSourceAutoConfiguration.class, // 自己的 DB 配置类 | |
| 29 | + DataSourceAutoConfiguration.class, // Spring DB 自动配置类 | |
| 30 | + DataSourceTransactionManagerAutoConfiguration.class, // Spring 事务自动配置类 | |
| 31 | + DruidDataSourceAutoConfigure.class, // Druid 自动配置类 | |
| 32 | + // MyBatis 配置类 | |
| 33 | + YudaoMybatisAutoConfiguration.class, // 自己的 MyBatis 配置类 | |
| 34 | + MybatisPlusAutoConfiguration.class, // MyBatis 的自动配置类 | |
| 35 | + }) | |
| 36 | + public static class Application { | |
| 37 | + } | |
| 38 | + | |
| 39 | +} | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/test/resources/application-unit-test.yaml
0 → 100644
| 1 | +spring: | |
| 2 | + main: | |
| 3 | + lazy-initialization: true # 开启懒加载,加快速度 | |
| 4 | + banner-mode: off # 单元测试,禁用 Banner | |
| 5 | + | |
| 6 | +--- #################### 数据库相关配置 #################### | |
| 7 | + | |
| 8 | +spring: | |
| 9 | + # 数据源配置项 | |
| 10 | + datasource: | |
| 11 | + name: ruoyi-vue-pro | |
| 12 | + url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 | |
| 13 | + driver-class-name: org.h2.Driver | |
| 14 | + username: sa | |
| 15 | + password: | |
| 16 | + schema: classpath:sql/create_tables.sql # MySQL 转 H2 的语句,使用 https://www.jooq.org/translate/ 工具 | |
| 17 | + druid: | |
| 18 | + async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 | |
| 19 | + initial-size: 1 # 单元测试,配置为 1,提升启动速度 | |
| 20 | + | |
| 21 | + # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 | |
| 22 | + redis: | |
| 23 | + host: 127.0.0.1 # 地址 | |
| 24 | + port: 16379 # 端口(单元测试,使用 16379 端口) | |
| 25 | + database: 0 # 数据库索引 | |
| 26 | + | |
| 27 | +mybatis: | |
| 28 | + lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 | |
| 29 | + | |
| 30 | +--- #################### 定时任务相关配置 #################### | |
| 31 | + | |
| 32 | +--- #################### 配置中心相关配置 #################### | |
| 33 | + | |
| 34 | +--- #################### 服务保障相关配置 #################### | |
| 35 | + | |
| 36 | +# Lock4j 配置项(单元测试,禁用 Lock4j) | |
| 37 | + | |
| 38 | +# Resilience4j 配置项 | |
| 39 | + | |
| 40 | +--- #################### 监控相关配置 #################### | |
| 41 | + | |
| 42 | +--- #################### 芋道相关配置 #################### | |
| 43 | + | |
| 44 | +# 芋道配置项,设置当前项目所有自定义的配置 | |
| 45 | +yudao: | |
| 46 | + info: | |
| 47 | + base-package: cn.iocoder.yudao.module | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/test/resources/logback.xml
0 → 100644
yudao-module-tool/yudao-module-tool-impl/src/test/resources/sql/clean.sql
0 → 100644
yudao-module-tool/yudao-module-tool-impl/src/test/resources/sql/create_tables.sql
0 → 100644
更新日志.md
| ... | ... | @@ -10,6 +10,10 @@ |
| 10 | 10 | * 用户前台的社交登陆 |
| 11 | 11 | * 用户前台的修改手机、修改密码、忘记密码 |
| 12 | 12 | |
| 13 | +*【优化】操作日志新增用户类型,实现 APP 端的 API 的操作日志的记录 | |
| 14 | +*【修复】管理后台 UI 超时登录后,返回登陆界面时,由于未登陆加载不到字典数据,导致报错的问题 | |
| 15 | + | |
| 16 | + | |
| 13 | 17 | ## [v1.4.0] 计划,预计 2022.02.28 发布 |
| 14 | 18 | |
| 15 | 19 | ### ⚠️ Warning |
| ... | ... | @@ -18,9 +22,9 @@ |
| 18 | 22 | |
| 19 | 23 | ### ⭐ New Features |
| 20 | 24 | |
| 21 | -*【优化】操作日志新增用户类型,实现 APP 端的 API 的操作日志的记录 | |
| 22 | 25 | *【重构】大模块按照多 Maven Module 的方式拆分,提升可维护性,为后续重构 onemall 提供基础 |
| 23 | -*【重构】Spring Security 支持读取多种用户类型,从不同的数据库表,从而实现单项目提供管理后台、用户 APP 的不同 RESTful API 接口 | |
| 26 | +*【新增】Spring Security 支持读取多种用户类型,从不同的数据库表,从而实现单项目提供管理后台、用户 APP 的不同 RESTful API 接口 | |
| 27 | +*【新增】代码生成器支持多 Maven Module 的方式生成代码,支持管理后台、用户 APP 两种场景的 RESTful API 的生成 | |
| 24 | 28 | *【重构】将数据库文档调整到 tool 模块,更加明确 |
| 25 | 29 | |
| 26 | 30 | ### 🐞 Bug Fixes |
| ... | ... | @@ -28,7 +32,6 @@ |
| 28 | 32 | *【修复】用户无权限访问 指定 API 时,未返回 FORBIDDEN 结果码 |
| 29 | 33 | *【修复】定时任务刷新本地缓存时,无租户上线文,导致查询报错 |
| 30 | 34 | *【修复】配置中心只加载了删除的配置 |
| 31 | -*【修复】管理后台 UI 超时登录后,返回登陆界面时,由于未登陆加载不到字典数据,导致报错的问题 | |
| 32 | 35 | |
| 33 | 36 | ### 🔨 Dependency Upgrades |
| 34 | 37 | ... | ... |