Commit 8e3d7663bba7e7f2774af775be46672e35ad107f
1 parent
24e083b3
多模块重构 11:代码生成器,支持多租户
Showing
27 changed files
with
34 additions
and
831 deletions
yudao-module-tool/yudao-module-tool-impl/pom.xml
| @@ -38,6 +38,10 @@ | @@ -38,6 +38,10 @@ | ||
| 38 | <groupId>cn.iocoder.boot</groupId> | 38 | <groupId>cn.iocoder.boot</groupId> |
| 39 | <artifactId>yudao-spring-boot-starter-biz-dict</artifactId> | 39 | <artifactId>yudao-spring-boot-starter-biz-dict</artifactId> |
| 40 | </dependency> | 40 | </dependency> |
| 41 | + <dependency> | ||
| 42 | + <groupId>cn.iocoder.boot</groupId> | ||
| 43 | + <artifactId>yudao-spring-boot-starter-biz-tenant</artifactId> | ||
| 44 | + </dependency> | ||
| 41 | 45 | ||
| 42 | <!-- Web 相关 --> | 46 | <!-- Web 相关 --> |
| 43 | <dependency> | 47 | <dependency> |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/package-info.java deleted
| 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 deleted
| 1 | -package cn.iocoder.yudao.module.tool.controller.admin.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 TestDemoBaseVO { | ||
| 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/admin/test/vo/TestDemoCreateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.tool.controller.admin.test.vo; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | -import java.util.*; | ||
| 5 | -import io.swagger.annotations.*; | ||
| 6 | -import javax.validation.constraints.*; | ||
| 7 | - | ||
| 8 | -@ApiModel("管理后台 - 字典类型创建 Request VO") | ||
| 9 | -@Data | ||
| 10 | -@EqualsAndHashCode(callSuper = true) | ||
| 11 | -@ToString(callSuper = true) | ||
| 12 | -public class TestDemoCreateReqVO extends TestDemoBaseVO { | ||
| 13 | - | ||
| 14 | -} |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoExportReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.tool.controller.admin.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 = "管理后台 - 字典类型 Excel 导出 Request VO", description = "参数和 TestDemoPageReqVO 是一致的") | ||
| 12 | -@Data | ||
| 13 | -public class TestDemoExportReqVO { | ||
| 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/admin/test/vo/TestDemoPageReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.tool.controller.admin.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("管理后台 - 字典类型分页 Request VO") | ||
| 12 | -@Data | ||
| 13 | -@EqualsAndHashCode(callSuper = true) | ||
| 14 | -@ToString(callSuper = true) | ||
| 15 | -public class TestDemoPageReqVO 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/admin/test/vo/TestDemoRespVO.java deleted
| 1 | -package cn.iocoder.yudao.module.tool.controller.admin.test.vo; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | -import java.util.*; | ||
| 5 | -import io.swagger.annotations.*; | ||
| 6 | - | ||
| 7 | -@ApiModel("管理后台 - 字典类型 Response VO") | ||
| 8 | -@Data | ||
| 9 | -@EqualsAndHashCode(callSuper = true) | ||
| 10 | -@ToString(callSuper = true) | ||
| 11 | -public class TestDemoRespVO extends TestDemoBaseVO { | ||
| 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/admin/test/vo/TestDemoUpdateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.tool.controller.admin.test.vo; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | -import java.util.*; | ||
| 5 | -import io.swagger.annotations.*; | ||
| 6 | -import javax.validation.constraints.*; | ||
| 7 | - | ||
| 8 | -@ApiModel("管理后台 - 字典类型更新 Request VO") | ||
| 9 | -@Data | ||
| 10 | -@EqualsAndHashCode(callSuper = true) | ||
| 11 | -@ToString(callSuper = true) | ||
| 12 | -public class TestDemoUpdateReqVO extends TestDemoBaseVO { | ||
| 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/controller/app/test/AppTestDemoController.java deleted
| 1 | -package cn.iocoder.yudao.module.tool.controller.app.test; | ||
| 2 | - | ||
| 3 | -import org.springframework.security.access.prepost.PreAuthorize; | ||
| 4 | -import org.springframework.web.bind.annotation.*; | ||
| 5 | -import javax.annotation.Resource; | ||
| 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.*; | ||
| 14 | -import java.io.IOException; | ||
| 15 | - | ||
| 16 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 17 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 18 | -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 19 | - | ||
| 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 - 字典类型") | ||
| 31 | -@RestController | ||
| 32 | -@RequestMapping("/tool/test-demo") | ||
| 33 | -@Validated | ||
| 34 | -public class AppTestDemoController { | ||
| 35 | - | ||
| 36 | - @Resource | ||
| 37 | - private TestDemoService testDemoService; | ||
| 38 | - | ||
| 39 | - @PostMapping("/create") | ||
| 40 | - @ApiOperation("创建字典类型") | ||
| 41 | - public CommonResult<Long> createTestDemo(@Valid @RequestBody AppTestDemoCreateReqVO createReqVO) { | ||
| 42 | - return success(testDemoService.createTestDemo(createReqVO)); | ||
| 43 | - } | ||
| 44 | - | ||
| 45 | - @PutMapping("/update") | ||
| 46 | - @ApiOperation("更新字典类型") | ||
| 47 | - public CommonResult<Boolean> updateTestDemo(@Valid @RequestBody AppTestDemoUpdateReqVO updateReqVO) { | ||
| 48 | - testDemoService.updateTestDemo(updateReqVO); | ||
| 49 | - return success(true); | ||
| 50 | - } | ||
| 51 | - | ||
| 52 | - @DeleteMapping("/delete") | ||
| 53 | - @ApiOperation("删除字典类型") | ||
| 54 | - @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) | ||
| 55 | - public CommonResult<Boolean> deleteTestDemo(@RequestParam("id") Long id) { | ||
| 56 | - testDemoService.deleteTestDemo(id); | ||
| 57 | - return success(true); | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | - @GetMapping("/get") | ||
| 61 | - @ApiOperation("获得字典类型") | ||
| 62 | - @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) | ||
| 63 | - @PreAuthorize("@ss.hasPermission('tool:test-demo:query')") | ||
| 64 | - public CommonResult<AppTestDemoRespVO> getTestDemo(@RequestParam("id") Long id) { | ||
| 65 | - TestDemoDO testDemo = testDemoService.getTestDemo(id); | ||
| 66 | - return success(TestDemoConvert.INSTANCE.convert(testDemo)); | ||
| 67 | - } | ||
| 68 | - | ||
| 69 | - @GetMapping("/list") | ||
| 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) { | ||
| 73 | - List<TestDemoDO> list = testDemoService.getTestDemoList(ids); | ||
| 74 | - return success(TestDemoConvert.INSTANCE.convertList(list)); | ||
| 75 | - } | ||
| 76 | - | ||
| 77 | - @GetMapping("/page") | ||
| 78 | - @ApiOperation("获得字典类型分页") | ||
| 79 | - public CommonResult<PageResult<AppTestDemoRespVO>> getTestDemoPage(@Valid AppTestDemoPageReqVO pageVO) { | ||
| 80 | - PageResult<TestDemoDO> pageResult = testDemoService.getTestDemoPage(pageVO); | ||
| 81 | - return success(TestDemoConvert.INSTANCE.convertPage(pageResult)); | ||
| 82 | - } | ||
| 83 | - | ||
| 84 | - @GetMapping("/export-excel") | ||
| 85 | - @ApiOperation("导出字典类型 Excel") | ||
| 86 | - @OperateLog(type = EXPORT) | ||
| 87 | - public void exportTestDemoExcel(@Valid AppTestDemoExportReqVO exportReqVO, | ||
| 88 | - HttpServletResponse response) throws IOException { | ||
| 89 | - List<TestDemoDO> list = testDemoService.getTestDemoList(exportReqVO); | ||
| 90 | - // 导出 Excel | ||
| 91 | - List<AppTestDemoExcelVO> datas = TestDemoConvert.INSTANCE.convertList02(list); | ||
| 92 | - ExcelUtils.write(response, "字典类型.xls", "数据", AppTestDemoExcelVO.class, datas); | ||
| 93 | - } | ||
| 94 | - | ||
| 95 | -} |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/app/test/vo/AppTestDemoBaseVO.java deleted
| 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 deleted
| 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/app/test/vo/AppTestDemoExcelVO.java deleted
| 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 | -import com.alibaba.excel.annotation.ExcelProperty; | ||
| 8 | - | ||
| 9 | -/** | ||
| 10 | - * 字典类型 Excel VO | ||
| 11 | - * | ||
| 12 | - * @author 芋道源码 | ||
| 13 | - */ | ||
| 14 | -@Data | ||
| 15 | -public class AppTestDemoExcelVO { | ||
| 16 | - | ||
| 17 | - @ExcelProperty("编号") | ||
| 18 | - private Long id; | ||
| 19 | - | ||
| 20 | - @ExcelProperty("名字") | ||
| 21 | - private String name; | ||
| 22 | - | ||
| 23 | - @ExcelProperty("状态") | ||
| 24 | - private Integer status; | ||
| 25 | - | ||
| 26 | - @ExcelProperty("类型") | ||
| 27 | - private Integer type; | ||
| 28 | - | ||
| 29 | - @ExcelProperty("分类") | ||
| 30 | - private Integer category; | ||
| 31 | - | ||
| 32 | - @ExcelProperty("备注") | ||
| 33 | - private String remark; | ||
| 34 | - | ||
| 35 | - @ExcelProperty("创建时间") | ||
| 36 | - private Date createTime; | ||
| 37 | - | ||
| 38 | -} |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/app/test/vo/AppTestDemoExportReqVO.java deleted
| 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 deleted
| 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 deleted
| 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 deleted
| 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 deleted
| 1 | -package cn.iocoder.yudao.module.tool.convert.test; | ||
| 2 | - | ||
| 3 | -import java.util.*; | ||
| 4 | - | ||
| 5 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | - | ||
| 7 | -import org.mapstruct.Mapper; | ||
| 8 | -import org.mapstruct.factory.Mappers; | ||
| 9 | -import cn.iocoder.yudao.module.tool.controller.app.test.vo.*; | ||
| 10 | -import cn.iocoder.yudao.module.tool.dal.dataobject.test.TestDemoDO; | ||
| 11 | - | ||
| 12 | -/** | ||
| 13 | - * 字典类型 Convert | ||
| 14 | - * | ||
| 15 | - * @author 芋道源码 | ||
| 16 | - */ | ||
| 17 | -@Mapper | ||
| 18 | -public interface TestDemoConvert { | ||
| 19 | - | ||
| 20 | - TestDemoConvert INSTANCE = Mappers.getMapper(TestDemoConvert.class); | ||
| 21 | - | ||
| 22 | - TestDemoDO convert(AppTestDemoCreateReqVO bean); | ||
| 23 | - | ||
| 24 | - TestDemoDO convert(AppTestDemoUpdateReqVO bean); | ||
| 25 | - | ||
| 26 | - AppTestDemoRespVO convert(TestDemoDO bean); | ||
| 27 | - | ||
| 28 | - List<AppTestDemoRespVO> convertList(List<TestDemoDO> list); | ||
| 29 | - | ||
| 30 | - PageResult<AppTestDemoRespVO> convertPage(PageResult<TestDemoDO> page); | ||
| 31 | - | ||
| 32 | - List<AppTestDemoExcelVO> convertList02(List<TestDemoDO> list); | ||
| 33 | - | ||
| 34 | -} |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/test/TestDemoDO.java deleted
| 1 | -package cn.iocoder.yudao.module.tool.dal.dataobject.test; | ||
| 2 | - | ||
| 3 | -import lombok.*; | ||
| 4 | -import java.util.*; | ||
| 5 | -import com.baomidou.mybatisplus.annotation.*; | ||
| 6 | -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * 字典类型 DO | ||
| 10 | - * | ||
| 11 | - * @author 芋道源码 | ||
| 12 | - */ | ||
| 13 | -@TableName("tool_test_demo") | ||
| 14 | -@Data | ||
| 15 | -@EqualsAndHashCode(callSuper = true) | ||
| 16 | -@ToString(callSuper = true) | ||
| 17 | -@Builder | ||
| 18 | -@NoArgsConstructor | ||
| 19 | -@AllArgsConstructor | ||
| 20 | -public class TestDemoDO extends BaseDO { | ||
| 21 | - | ||
| 22 | - /** | ||
| 23 | - * 编号 | ||
| 24 | - */ | ||
| 25 | - @TableId | ||
| 26 | - private Long id; | ||
| 27 | - /** | ||
| 28 | - * 名字 | ||
| 29 | - */ | ||
| 30 | - private String name; | ||
| 31 | - /** | ||
| 32 | - * 状态 | ||
| 33 | - */ | ||
| 34 | - private Integer status; | ||
| 35 | - /** | ||
| 36 | - * 类型 | ||
| 37 | - */ | ||
| 38 | - private Integer type; | ||
| 39 | - /** | ||
| 40 | - * 分类 | ||
| 41 | - */ | ||
| 42 | - private Integer category; | ||
| 43 | - /** | ||
| 44 | - * 备注 | ||
| 45 | - */ | ||
| 46 | - private String remark; | ||
| 47 | - | ||
| 48 | -} |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/mysql/test/TestDemoMapper.java deleted
| 1 | -package cn.iocoder.yudao.module.tool.dal.mysql.test; | ||
| 2 | - | ||
| 3 | -import java.util.*; | ||
| 4 | - | ||
| 5 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 7 | -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 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 | -import cn.iocoder.yudao.module.tool.dal.dataobject.test.TestDemoDO; | ||
| 11 | -import org.apache.ibatis.annotations.Mapper; | ||
| 12 | -import cn.iocoder.yudao.module.tool.controller.admin.test.vo.*; | ||
| 13 | - | ||
| 14 | -/** | ||
| 15 | - * 字典类型 Mapper | ||
| 16 | - * | ||
| 17 | - * @author 芋道源码 | ||
| 18 | - */ | ||
| 19 | -@Mapper | ||
| 20 | -public interface TestDemoMapper extends BaseMapperX<TestDemoDO> { | ||
| 21 | - | ||
| 22 | - default PageResult<TestDemoDO> selectPage(TestDemoPageReqVO reqVO) { | ||
| 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)); | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - default List<TestDemoDO> selectList(TestDemoExportReqVO reqVO) { | ||
| 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)); | ||
| 64 | - } | ||
| 65 | - | ||
| 66 | -} |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenBuilder.java
| @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.tool.service.codegen.inner; | @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.tool.service.codegen.inner; | ||
| 3 | import cn.hutool.core.map.MapUtil; | 3 | import cn.hutool.core.map.MapUtil; |
| 4 | import cn.hutool.core.util.StrUtil; | 4 | import cn.hutool.core.util.StrUtil; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 5 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 6 | +import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; | ||
| 6 | import cn.iocoder.yudao.module.tool.convert.codegen.CodegenConvert; | 7 | import cn.iocoder.yudao.module.tool.convert.codegen.CodegenConvert; |
| 7 | import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenColumnDO; | 8 | import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenColumnDO; |
| 8 | import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenTableDO; | 9 | import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenTableDO; |
| @@ -55,7 +56,11 @@ public class CodegenBuilder { | @@ -55,7 +56,11 @@ public class CodegenBuilder { | ||
| 55 | .build(); | 56 | .build(); |
| 56 | 57 | ||
| 57 | /** | 58 | /** |
| 58 | - * {@link BaseDO} 的字段 | 59 | + * 多租户编号的字段名 |
| 60 | + */ | ||
| 61 | + public static final String TENANT_ID_FIELD = "tenant_id"; | ||
| 62 | + /** | ||
| 63 | + * {@link TenantBaseDO} 的字段 | ||
| 59 | */ | 64 | */ |
| 60 | public static final Set<String> BASE_DO_FIELDS = new HashSet<>(); | 65 | public static final Set<String> BASE_DO_FIELDS = new HashSet<>(); |
| 61 | /** | 66 | /** |
| @@ -91,7 +96,7 @@ public class CodegenBuilder { | @@ -91,7 +96,7 @@ public class CodegenBuilder { | ||
| 91 | .build(); | 96 | .build(); |
| 92 | 97 | ||
| 93 | static { | 98 | static { |
| 94 | - Arrays.stream(BaseDO.class.getDeclaredFields()).forEach(field -> BASE_DO_FIELDS.add(field.getName())); | 99 | + Arrays.stream(TenantBaseDO.class.getDeclaredFields()).forEach(field -> BASE_DO_FIELDS.add(field.getName())); |
| 95 | // 处理 OPERATION 相关的字段 | 100 | // 处理 OPERATION 相关的字段 |
| 96 | CREATE_OPERATION_EXCLUDE_COLUMN.addAll(BASE_DO_FIELDS); | 101 | CREATE_OPERATION_EXCLUDE_COLUMN.addAll(BASE_DO_FIELDS); |
| 97 | UPDATE_OPERATION_EXCLUDE_COLUMN.addAll(BASE_DO_FIELDS); | 102 | UPDATE_OPERATION_EXCLUDE_COLUMN.addAll(BASE_DO_FIELDS); |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenEngine.java
| 1 | package cn.iocoder.yudao.module.tool.service.codegen.inner; | 1 | package cn.iocoder.yudao.module.tool.service.codegen.inner; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.collection.ListUtil; | ||
| 3 | import cn.hutool.core.map.MapUtil; | 4 | import cn.hutool.core.map.MapUtil; |
| 5 | +import cn.hutool.core.util.ArrayUtil; | ||
| 4 | import cn.hutool.core.util.StrUtil; | 6 | import cn.hutool.core.util.StrUtil; |
| 5 | import cn.hutool.extra.template.TemplateConfig; | 7 | import cn.hutool.extra.template.TemplateConfig; |
| 6 | import cn.hutool.extra.template.TemplateEngine; | 8 | import cn.hutool.extra.template.TemplateEngine; |
| @@ -10,6 +12,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; | @@ -10,6 +12,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 10 | import cn.iocoder.yudao.framework.common.pojo.PageParam; | 12 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 11 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 13 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 12 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | 14 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 15 | +import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; | ||
| 13 | import cn.iocoder.yudao.module.tool.enums.codegen.CodegenSceneEnum; | 16 | import cn.iocoder.yudao.module.tool.enums.codegen.CodegenSceneEnum; |
| 14 | import cn.iocoder.yudao.module.tool.framework.codegen.config.CodegenProperties; | 17 | import cn.iocoder.yudao.module.tool.framework.codegen.config.CodegenProperties; |
| 15 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; | 18 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; |
| @@ -121,7 +124,6 @@ public class CodegenEngine { | @@ -121,7 +124,6 @@ public class CodegenEngine { | ||
| 121 | globalBindingMap.put("DictFormatClassName", DictFormat.class.getName()); | 124 | globalBindingMap.put("DictFormatClassName", DictFormat.class.getName()); |
| 122 | // DO 类,独有字段 | 125 | // DO 类,独有字段 |
| 123 | globalBindingMap.put("baseDOFields", CodegenBuilder.BASE_DO_FIELDS); | 126 | globalBindingMap.put("baseDOFields", CodegenBuilder.BASE_DO_FIELDS); |
| 124 | - globalBindingMap.put("BaseDOClassName", BaseDO.class.getName()); | ||
| 125 | globalBindingMap.put("QueryWrapperClassName", LambdaQueryWrapperX.class.getName()); | 127 | globalBindingMap.put("QueryWrapperClassName", LambdaQueryWrapperX.class.getName()); |
| 126 | globalBindingMap.put("BaseMapperClassName", BaseMapperX.class.getName()); | 128 | globalBindingMap.put("BaseMapperClassName", BaseMapperX.class.getName()); |
| 127 | // Util 工具类 | 129 | // Util 工具类 |
| @@ -141,6 +143,7 @@ public class CodegenEngine { | @@ -141,6 +143,7 @@ public class CodegenEngine { | ||
| 141 | bindingMap.put("columns", columns); | 143 | bindingMap.put("columns", columns); |
| 142 | bindingMap.put("primaryColumn", CollectionUtils.findFirst(columns, CodegenColumnDO::getPrimaryKey)); // 主键字段 | 144 | bindingMap.put("primaryColumn", CollectionUtils.findFirst(columns, CodegenColumnDO::getPrimaryKey)); // 主键字段 |
| 143 | bindingMap.put("sceneEnum", CodegenSceneEnum.valueOf(table.getScene())); | 145 | bindingMap.put("sceneEnum", CodegenSceneEnum.valueOf(table.getScene())); |
| 146 | + | ||
| 144 | // className 相关 | 147 | // className 相关 |
| 145 | // 去掉指定前缀,将 TestDictType 转换成 DictType. 因为在 create 等方法后,不需要带上 Test 前缀 | 148 | // 去掉指定前缀,将 TestDictType 转换成 DictType. 因为在 create 等方法后,不需要带上 Test 前缀 |
| 146 | String simpleClassName = removePrefix(table.getClassName(), upperFirst(table.getModuleName())); | 149 | String simpleClassName = removePrefix(table.getClassName(), upperFirst(table.getModuleName())); |
| @@ -153,6 +156,15 @@ public class CodegenEngine { | @@ -153,6 +156,15 @@ public class CodegenEngine { | ||
| 153 | // permission 前缀 | 156 | // permission 前缀 |
| 154 | bindingMap.put("permissionPrefix", table.getModuleName() + ":" + simpleClassNameStrikeCase); | 157 | bindingMap.put("permissionPrefix", table.getModuleName() + ":" + simpleClassNameStrikeCase); |
| 155 | 158 | ||
| 159 | + // 如果多租户,则进行覆盖 DB 独有字段 | ||
| 160 | + if (CollectionUtils.findFirst(columns, column -> column.getColumnName().equals(CodegenBuilder.TENANT_ID_FIELD)) != null) { | ||
| 161 | + globalBindingMap.put("BaseDOClassName", TenantBaseDO.class.getName()); | ||
| 162 | + globalBindingMap.put("BaseDOClassName_simple", TenantBaseDO.class.getSimpleName()); | ||
| 163 | + } else { | ||
| 164 | + globalBindingMap.put("BaseDOClassName", BaseDO.class.getName()); | ||
| 165 | + globalBindingMap.put("BaseDOClassName_simple", BaseDO.class.getSimpleName()); | ||
| 166 | + } | ||
| 167 | + | ||
| 156 | // 执行生成 | 168 | // 执行生成 |
| 157 | final Map<String, String> result = Maps.newLinkedHashMapWithExpectedSize(TEMPLATES.size()); // 有序 | 169 | final Map<String, String> result = Maps.newLinkedHashMapWithExpectedSize(TEMPLATES.size()); // 有序 |
| 158 | TEMPLATES.forEach((vmPath, filePath) -> { | 170 | TEMPLATES.forEach((vmPath, filePath) -> { |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/test/TestDemoService.java deleted
| 1 | -package cn.iocoder.yudao.module.tool.service.test; | ||
| 2 | - | ||
| 3 | -import java.util.*; | ||
| 4 | -import javax.validation.*; | ||
| 5 | -import cn.iocoder.yudao.module.tool.controller.app.test.vo.*; | ||
| 6 | -import cn.iocoder.yudao.module.tool.dal.dataobject.test.TestDemoDO; | ||
| 7 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 8 | - | ||
| 9 | -/** | ||
| 10 | - * 字典类型 Service 接口 | ||
| 11 | - * | ||
| 12 | - * @author 芋道源码 | ||
| 13 | - */ | ||
| 14 | -public interface TestDemoService { | ||
| 15 | - | ||
| 16 | - /** | ||
| 17 | - * 创建字典类型 | ||
| 18 | - * | ||
| 19 | - * @param createReqVO 创建信息 | ||
| 20 | - * @return 编号 | ||
| 21 | - */ | ||
| 22 | - Long createTestDemo(@Valid AppTestDemoCreateReqVO createReqVO); | ||
| 23 | - | ||
| 24 | - /** | ||
| 25 | - * 更新字典类型 | ||
| 26 | - * | ||
| 27 | - * @param updateReqVO 更新信息 | ||
| 28 | - */ | ||
| 29 | - void updateTestDemo(@Valid AppTestDemoUpdateReqVO updateReqVO); | ||
| 30 | - | ||
| 31 | - /** | ||
| 32 | - * 删除字典类型 | ||
| 33 | - * | ||
| 34 | - * @param id 编号 | ||
| 35 | - */ | ||
| 36 | - void deleteTestDemo(Long id); | ||
| 37 | - | ||
| 38 | - /** | ||
| 39 | - * 获得字典类型 | ||
| 40 | - * | ||
| 41 | - * @param id 编号 | ||
| 42 | - * @return 字典类型 | ||
| 43 | - */ | ||
| 44 | - TestDemoDO getTestDemo(Long id); | ||
| 45 | - | ||
| 46 | - /** | ||
| 47 | - * 获得字典类型列表 | ||
| 48 | - * | ||
| 49 | - * @param ids 编号 | ||
| 50 | - * @return 字典类型列表 | ||
| 51 | - */ | ||
| 52 | - List<TestDemoDO> getTestDemoList(Collection<Long> ids); | ||
| 53 | - | ||
| 54 | - /** | ||
| 55 | - * 获得字典类型分页 | ||
| 56 | - * | ||
| 57 | - * @param pageReqVO 分页查询 | ||
| 58 | - * @return 字典类型分页 | ||
| 59 | - */ | ||
| 60 | - PageResult<TestDemoDO> getTestDemoPage(AppTestDemoPageReqVO pageReqVO); | ||
| 61 | - | ||
| 62 | - /** | ||
| 63 | - * 获得字典类型列表, 用于 Excel 导出 | ||
| 64 | - * | ||
| 65 | - * @param exportReqVO 查询条件 | ||
| 66 | - * @return 字典类型列表 | ||
| 67 | - */ | ||
| 68 | - List<TestDemoDO> getTestDemoList(AppTestDemoExportReqVO exportReqVO); | ||
| 69 | - | ||
| 70 | -} |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/test/TestDemoServiceImpl.java deleted
| 1 | -package cn.iocoder.yudao.module.tool.service.test; | ||
| 2 | - | ||
| 3 | -import org.springframework.stereotype.Service; | ||
| 4 | -import javax.annotation.Resource; | ||
| 5 | -import org.springframework.validation.annotation.Validated; | ||
| 6 | - | ||
| 7 | -import java.util.*; | ||
| 8 | -import cn.iocoder.yudao.module.tool.controller.app.test.vo.*; | ||
| 9 | -import cn.iocoder.yudao.module.tool.dal.dataobject.test.TestDemoDO; | ||
| 10 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 11 | - | ||
| 12 | -import cn.iocoder.yudao.module.tool.convert.test.TestDemoConvert; | ||
| 13 | -import cn.iocoder.yudao.module.tool.dal.mysql.test.TestDemoMapper; | ||
| 14 | - | ||
| 15 | -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 16 | -import static cn.iocoder.yudao.module.tool.enums.ErrorCodeConstants.*; | ||
| 17 | - | ||
| 18 | -/** | ||
| 19 | - * 字典类型 Service 实现类 | ||
| 20 | - * | ||
| 21 | - * @author 芋道源码 | ||
| 22 | - */ | ||
| 23 | -@Service | ||
| 24 | -@Validated | ||
| 25 | -public class TestDemoServiceImpl implements TestDemoService { | ||
| 26 | - | ||
| 27 | - @Resource | ||
| 28 | - private TestDemoMapper testDemoMapper; | ||
| 29 | - | ||
| 30 | - @Override | ||
| 31 | - public Long createTestDemo(AppTestDemoCreateReqVO createReqVO) { | ||
| 32 | - // 插入 | ||
| 33 | - TestDemoDO testDemo = TestDemoConvert.INSTANCE.convert(createReqVO); | ||
| 34 | - testDemoMapper.insert(testDemo); | ||
| 35 | - // 返回 | ||
| 36 | - return testDemo.getId(); | ||
| 37 | - } | ||
| 38 | - | ||
| 39 | - @Override | ||
| 40 | - public void updateTestDemo(AppTestDemoUpdateReqVO updateReqVO) { | ||
| 41 | - // 校验存在 | ||
| 42 | - this.validateTestDemoExists(updateReqVO.getId()); | ||
| 43 | - // 更新 | ||
| 44 | - TestDemoDO updateObj = TestDemoConvert.INSTANCE.convert(updateReqVO); | ||
| 45 | - testDemoMapper.updateById(updateObj); | ||
| 46 | - } | ||
| 47 | - | ||
| 48 | - @Override | ||
| 49 | - public void deleteTestDemo(Long id) { | ||
| 50 | - // 校验存在 | ||
| 51 | - this.validateTestDemoExists(id); | ||
| 52 | - // 删除 | ||
| 53 | - testDemoMapper.deleteById(id); | ||
| 54 | - } | ||
| 55 | - | ||
| 56 | - private void validateTestDemoExists(Long id) { | ||
| 57 | - if (testDemoMapper.selectById(id) == null) { | ||
| 58 | - throw exception(TEST_DEMO_NOT_EXISTS); | ||
| 59 | - } | ||
| 60 | - } | ||
| 61 | - | ||
| 62 | - @Override | ||
| 63 | - public TestDemoDO getTestDemo(Long id) { | ||
| 64 | - return testDemoMapper.selectById(id); | ||
| 65 | - } | ||
| 66 | - | ||
| 67 | - @Override | ||
| 68 | - public List<TestDemoDO> getTestDemoList(Collection<Long> ids) { | ||
| 69 | - return testDemoMapper.selectBatchIds(ids); | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | - @Override | ||
| 73 | - public PageResult<TestDemoDO> getTestDemoPage(AppTestDemoPageReqVO pageReqVO) { | ||
| 74 | - return testDemoMapper.selectPage(pageReqVO); | ||
| 75 | - } | ||
| 76 | - | ||
| 77 | - @Override | ||
| 78 | - public List<TestDemoDO> getTestDemoList(AppTestDemoExportReqVO exportReqVO) { | ||
| 79 | - return testDemoMapper.selectList(exportReqVO); | ||
| 80 | - } | ||
| 81 | - | ||
| 82 | -} |
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/dal/do.vm
| @@ -17,7 +17,7 @@ import ${BaseDOClassName}; | @@ -17,7 +17,7 @@ import ${BaseDOClassName}; | ||
| 17 | @Builder | 17 | @Builder |
| 18 | @NoArgsConstructor | 18 | @NoArgsConstructor |
| 19 | @AllArgsConstructor | 19 | @AllArgsConstructor |
| 20 | -public class ${table.className}DO extends BaseDO { | 20 | +public class ${table.className}DO extends ${BaseDOClassName_simple} { |
| 21 | 21 | ||
| 22 | #foreach ($column in $columns) | 22 | #foreach ($column in $columns) |
| 23 | #if (!${baseDOFields.contains(${column.javaField})})##排除 BaseDO 的字段 | 23 | #if (!${baseDOFields.contains(${column.javaField})})##排除 BaseDO 的字段 |
yudao-module-tool/yudao-module-tool-impl/src/test/java/cn/iocoder/yudao/module/tool/test/BaseDbUnitTest.java deleted
| 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-ui-admin/src/views/tool/codegen/index.vue
| @@ -3,34 +3,16 @@ | @@ -3,34 +3,16 @@ | ||
| 3 | <!-- 操作工作栏 --> | 3 | <!-- 操作工作栏 --> |
| 4 | <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | 4 | <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> |
| 5 | <el-form-item label="表名称" prop="tableName"> | 5 | <el-form-item label="表名称" prop="tableName"> |
| 6 | - <el-input | ||
| 7 | - v-model="queryParams.tableName" | ||
| 8 | - placeholder="请输入表名称" | ||
| 9 | - clearable | ||
| 10 | - size="small" | ||
| 11 | - @keyup.enter.native="handleQuery" | ||
| 12 | - /> | 6 | + <el-input v-model="queryParams.tableName" placeholder="请输入表名称" clearable size="small" |
| 7 | + @keyup.enter.native="handleQuery"/> | ||
| 13 | </el-form-item> | 8 | </el-form-item> |
| 14 | <el-form-item label="表描述" prop="tableComment"> | 9 | <el-form-item label="表描述" prop="tableComment"> |
| 15 | - <el-input | ||
| 16 | - v-model="queryParams.tableComment" | ||
| 17 | - placeholder="请输入表描述" | ||
| 18 | - clearable | ||
| 19 | - size="small" | ||
| 20 | - @keyup.enter.native="handleQuery" | ||
| 21 | - /> | 10 | + <el-input v-model="queryParams.tableComment" placeholder="请输入表描述" clearable size="small" |
| 11 | + @keyup.enter.native="handleQuery"/> | ||
| 22 | </el-form-item> | 12 | </el-form-item> |
| 23 | <el-form-item label="创建时间"> | 13 | <el-form-item label="创建时间"> |
| 24 | - <el-date-picker | ||
| 25 | - v-model="dateRange" | ||
| 26 | - size="small" | ||
| 27 | - style="width: 240px" | ||
| 28 | - value-format="yyyy-MM-dd" | ||
| 29 | - type="daterange" | ||
| 30 | - range-separator="-" | ||
| 31 | - start-placeholder="开始日期" | ||
| 32 | - end-placeholder="结束日期" | ||
| 33 | - ></el-date-picker> | 14 | + <el-date-picker v-model="dateRange" size="small" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" |
| 15 | + range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"/> | ||
| 34 | </el-form-item> | 16 | </el-form-item> |
| 35 | <el-form-item> | 17 | <el-form-item> |
| 36 | <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | 18 | <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> |
| @@ -79,11 +61,11 @@ | @@ -79,11 +61,11 @@ | ||
| 79 | <!-- 预览界面 --> | 61 | <!-- 预览界面 --> |
| 80 | <el-dialog :title="preview.title" :visible.sync="preview.open" width="90%" top="5vh" append-to-body> | 62 | <el-dialog :title="preview.title" :visible.sync="preview.open" width="90%" top="5vh" append-to-body> |
| 81 | <el-row> | 63 | <el-row> |
| 82 | - <el-col :span="7"> | 64 | + <el-col :span="9"> |
| 83 | <el-tree :data="preview.fileTree" :expand-on-click-node="false" default-expand-all highlight-current | 65 | <el-tree :data="preview.fileTree" :expand-on-click-node="false" default-expand-all highlight-current |
| 84 | @node-click="handleNodeClick"/> | 66 | @node-click="handleNodeClick"/> |
| 85 | </el-col> | 67 | </el-col> |
| 86 | - <el-col :span="17"> | 68 | + <el-col :span="15"> |
| 87 | <el-tabs v-model="preview.activeName"> | 69 | <el-tabs v-model="preview.activeName"> |
| 88 | <el-tab-pane v-for="item in preview.data" :label="item.filePath.substring(item.filePath.lastIndexOf('/') + 1)" | 70 | <el-tab-pane v-for="item in preview.data" :label="item.filePath.substring(item.filePath.lastIndexOf('/') + 1)" |
| 89 | :name="item.filePath" :key="item.filePath"> | 71 | :name="item.filePath" :key="item.filePath"> |
| @@ -252,7 +234,6 @@ export default { | @@ -252,7 +234,6 @@ export default { | ||
| 252 | previewCodegen(row.id).then(response => { | 234 | previewCodegen(row.id).then(response => { |
| 253 | this.preview.data = response.data; | 235 | this.preview.data = response.data; |
| 254 | let files = this.handleFiles(response.data); | 236 | let files = this.handleFiles(response.data); |
| 255 | - // console.log(files) | ||
| 256 | this.preview.fileTree = this.handleTree(files, "id", "parentId", "children", | 237 | this.preview.fileTree = this.handleTree(files, "id", "parentId", "children", |
| 257 | "/"); // "/" 为根节点 | 238 | "/"); // "/" 为根节点 |
| 258 | // console.log(this.preview.fileTree) | 239 | // console.log(this.preview.fileTree) |
更新日志.md
| @@ -24,7 +24,7 @@ | @@ -24,7 +24,7 @@ | ||
| 24 | 24 | ||
| 25 | *【重构】大模块按照多 Maven Module 的方式拆分,提升可维护性,为后续重构 onemall 提供基础 | 25 | *【重构】大模块按照多 Maven Module 的方式拆分,提升可维护性,为后续重构 onemall 提供基础 |
| 26 | *【新增】Spring Security 支持读取多种用户类型,从不同的数据库表,从而实现单项目提供管理后台、用户 APP 的不同 RESTful API 接口 | 26 | *【新增】Spring Security 支持读取多种用户类型,从不同的数据库表,从而实现单项目提供管理后台、用户 APP 的不同 RESTful API 接口 |
| 27 | -*【新增】代码生成器支持多 Maven Module 的方式生成代码,支持管理后台、用户 APP 两种场景的 RESTful API 的生成,支持 H2 测试数据库的生成 | 27 | +*【新增】代码生成器支持多 Maven Module 的方式生成代码,支持管理后台、用户 APP 两种场景的 RESTful API 的生成,支持 H2 SQL 脚本的生成 |
| 28 | *【重构】将数据库文档调整到 tool 模块,更加明确 | 28 | *【重构】将数据库文档调整到 tool 模块,更加明确 |
| 29 | 29 | ||
| 30 | ### 🐞 Bug Fixes | 30 | ### 🐞 Bug Fixes |