mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-01 02:38:43 +08:00 
			
		
		
		
	多模块重构 11:代码生成器,支持多租户
This commit is contained in:
		| @@ -1 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.tool.controller.admin.test; | ||||
| @@ -1,34 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.tool.controller.admin.test.vo; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import io.swagger.annotations.*; | ||||
| import javax.validation.constraints.*; | ||||
|  | ||||
| /** | ||||
| * 字典类型 Base VO,提供给添加、修改、详细的子 VO 使用 | ||||
| * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||||
| */ | ||||
| @Data | ||||
| public class TestDemoBaseVO { | ||||
|  | ||||
|     @ApiModelProperty(value = "名字", required = true) | ||||
|     @NotNull(message = "名字不能为空") | ||||
|     private String name; | ||||
|  | ||||
|     @ApiModelProperty(value = "状态", required = true) | ||||
|     @NotNull(message = "状态不能为空") | ||||
|     private Integer status; | ||||
|  | ||||
|     @ApiModelProperty(value = "类型", required = true) | ||||
|     @NotNull(message = "类型不能为空") | ||||
|     private Integer type; | ||||
|  | ||||
|     @ApiModelProperty(value = "分类", required = true) | ||||
|     @NotNull(message = "分类不能为空") | ||||
|     private Integer category; | ||||
|  | ||||
|     @ApiModelProperty(value = "备注") | ||||
|     private String remark; | ||||
|  | ||||
| } | ||||
| @@ -1,14 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.tool.controller.admin.test.vo; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import io.swagger.annotations.*; | ||||
| import javax.validation.constraints.*; | ||||
|  | ||||
| @ApiModel("管理后台 - 字典类型创建 Request VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class TestDemoCreateReqVO extends TestDemoBaseVO { | ||||
|  | ||||
| } | ||||
| @@ -1,38 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.tool.controller.admin.test.vo; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import io.swagger.annotations.*; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||||
|  | ||||
| @ApiModel(value = "管理后台 - 字典类型 Excel 导出 Request VO", description = "参数和 TestDemoPageReqVO 是一致的") | ||||
| @Data | ||||
| public class TestDemoExportReqVO { | ||||
|  | ||||
|     @ApiModelProperty(value = "名字") | ||||
|     private String name; | ||||
|  | ||||
|     @ApiModelProperty(value = "状态") | ||||
|     private Integer status; | ||||
|  | ||||
|     @ApiModelProperty(value = "类型") | ||||
|     private Integer type; | ||||
|  | ||||
|     @ApiModelProperty(value = "分类") | ||||
|     private Integer category; | ||||
|  | ||||
|     @ApiModelProperty(value = "备注") | ||||
|     private String remark; | ||||
|  | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     @ApiModelProperty(value = "开始创建时间") | ||||
|     private Date beginCreateTime; | ||||
|  | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     @ApiModelProperty(value = "结束创建时间") | ||||
|     private Date endCreateTime; | ||||
|  | ||||
| } | ||||
| @@ -1,40 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.tool.controller.admin.test.vo; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import io.swagger.annotations.*; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||||
|  | ||||
| @ApiModel("管理后台 - 字典类型分页 Request VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class TestDemoPageReqVO extends PageParam { | ||||
|  | ||||
|     @ApiModelProperty(value = "名字") | ||||
|     private String name; | ||||
|  | ||||
|     @ApiModelProperty(value = "状态") | ||||
|     private Integer status; | ||||
|  | ||||
|     @ApiModelProperty(value = "类型") | ||||
|     private Integer type; | ||||
|  | ||||
|     @ApiModelProperty(value = "分类") | ||||
|     private Integer category; | ||||
|  | ||||
|     @ApiModelProperty(value = "备注") | ||||
|     private String remark; | ||||
|  | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     @ApiModelProperty(value = "开始创建时间") | ||||
|     private Date beginCreateTime; | ||||
|  | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     @ApiModelProperty(value = "结束创建时间") | ||||
|     private Date endCreateTime; | ||||
|  | ||||
| } | ||||
| @@ -1,19 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.tool.controller.admin.test.vo; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import io.swagger.annotations.*; | ||||
|  | ||||
| @ApiModel("管理后台 - 字典类型 Response VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class TestDemoRespVO extends TestDemoBaseVO { | ||||
|  | ||||
|     @ApiModelProperty(value = "编号", required = true) | ||||
|     private Long id; | ||||
|  | ||||
|     @ApiModelProperty(value = "创建时间", required = true) | ||||
|     private Date createTime; | ||||
|  | ||||
| } | ||||
| @@ -1,18 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.tool.controller.admin.test.vo; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import io.swagger.annotations.*; | ||||
| import javax.validation.constraints.*; | ||||
|  | ||||
| @ApiModel("管理后台 - 字典类型更新 Request VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class TestDemoUpdateReqVO extends TestDemoBaseVO { | ||||
|  | ||||
|     @ApiModelProperty(value = "编号", required = true) | ||||
|     @NotNull(message = "编号不能为空") | ||||
|     private Long id; | ||||
|  | ||||
| } | ||||
| @@ -1,95 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.tool.controller.app.test; | ||||
|  | ||||
| import org.springframework.security.access.prepost.PreAuthorize; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import javax.annotation.Resource; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
|  | ||||
| import io.swagger.annotations.*; | ||||
|  | ||||
| import javax.validation.constraints.*; | ||||
| import javax.validation.*; | ||||
| import javax.servlet.http.*; | ||||
| import java.util.*; | ||||
| import java.io.IOException; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||||
| import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||||
| import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; | ||||
|  | ||||
| import cn.iocoder.yudao.module.tool.controller.app.test.vo.*; | ||||
| import cn.iocoder.yudao.module.tool.dal.dataobject.test.TestDemoDO; | ||||
| import cn.iocoder.yudao.module.tool.convert.test.TestDemoConvert; | ||||
| import cn.iocoder.yudao.module.tool.service.test.TestDemoService; | ||||
|  | ||||
| @Api(tags = "用户 APP - 字典类型") | ||||
| @RestController | ||||
| @RequestMapping("/tool/test-demo") | ||||
| @Validated | ||||
| public class AppTestDemoController { | ||||
|  | ||||
|     @Resource | ||||
|     private TestDemoService testDemoService; | ||||
|  | ||||
|     @PostMapping("/create") | ||||
|     @ApiOperation("创建字典类型") | ||||
|     public CommonResult<Long> createTestDemo(@Valid @RequestBody AppTestDemoCreateReqVO createReqVO) { | ||||
|         return success(testDemoService.createTestDemo(createReqVO)); | ||||
|     } | ||||
|  | ||||
|     @PutMapping("/update") | ||||
|     @ApiOperation("更新字典类型") | ||||
|     public CommonResult<Boolean> updateTestDemo(@Valid @RequestBody AppTestDemoUpdateReqVO updateReqVO) { | ||||
|         testDemoService.updateTestDemo(updateReqVO); | ||||
|         return success(true); | ||||
|     } | ||||
|  | ||||
|     @DeleteMapping("/delete") | ||||
|     @ApiOperation("删除字典类型") | ||||
|     @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) | ||||
|     public CommonResult<Boolean> deleteTestDemo(@RequestParam("id") Long id) { | ||||
|         testDemoService.deleteTestDemo(id); | ||||
|         return success(true); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/get") | ||||
|     @ApiOperation("获得字典类型") | ||||
|     @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) | ||||
|     @PreAuthorize("@ss.hasPermission('tool:test-demo:query')") | ||||
|     public CommonResult<AppTestDemoRespVO> getTestDemo(@RequestParam("id") Long id) { | ||||
|         TestDemoDO testDemo = testDemoService.getTestDemo(id); | ||||
|         return success(TestDemoConvert.INSTANCE.convert(testDemo)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/list") | ||||
|     @ApiOperation("获得字典类型列表") | ||||
|     @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) | ||||
|     public CommonResult<List<AppTestDemoRespVO>> getTestDemoList(@RequestParam("ids") Collection<Long> ids) { | ||||
|         List<TestDemoDO> list = testDemoService.getTestDemoList(ids); | ||||
|         return success(TestDemoConvert.INSTANCE.convertList(list)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/page") | ||||
|     @ApiOperation("获得字典类型分页") | ||||
|     public CommonResult<PageResult<AppTestDemoRespVO>> getTestDemoPage(@Valid AppTestDemoPageReqVO pageVO) { | ||||
|         PageResult<TestDemoDO> pageResult = testDemoService.getTestDemoPage(pageVO); | ||||
|         return success(TestDemoConvert.INSTANCE.convertPage(pageResult)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/export-excel") | ||||
|     @ApiOperation("导出字典类型 Excel") | ||||
|     @OperateLog(type = EXPORT) | ||||
|     public void exportTestDemoExcel(@Valid AppTestDemoExportReqVO exportReqVO, | ||||
|                                     HttpServletResponse response) throws IOException { | ||||
|         List<TestDemoDO> list = testDemoService.getTestDemoList(exportReqVO); | ||||
|         // 导出 Excel | ||||
|         List<AppTestDemoExcelVO> datas = TestDemoConvert.INSTANCE.convertList02(list); | ||||
|         ExcelUtils.write(response, "字典类型.xls", "数据", AppTestDemoExcelVO.class, datas); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -1,34 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.tool.controller.app.test.vo; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import io.swagger.annotations.*; | ||||
| import javax.validation.constraints.*; | ||||
|  | ||||
| /** | ||||
| * 字典类型 Base VO,提供给添加、修改、详细的子 VO 使用 | ||||
| * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||||
| */ | ||||
| @Data | ||||
| public class AppTestDemoBaseVO { | ||||
|  | ||||
|     @ApiModelProperty(value = "名字", required = true) | ||||
|     @NotNull(message = "名字不能为空") | ||||
|     private String name; | ||||
|  | ||||
|     @ApiModelProperty(value = "状态", required = true) | ||||
|     @NotNull(message = "状态不能为空") | ||||
|     private Integer status; | ||||
|  | ||||
|     @ApiModelProperty(value = "类型", required = true) | ||||
|     @NotNull(message = "类型不能为空") | ||||
|     private Integer type; | ||||
|  | ||||
|     @ApiModelProperty(value = "分类", required = true) | ||||
|     @NotNull(message = "分类不能为空") | ||||
|     private Integer category; | ||||
|  | ||||
|     @ApiModelProperty(value = "备注") | ||||
|     private String remark; | ||||
|  | ||||
| } | ||||
| @@ -1,14 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.tool.controller.app.test.vo; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import io.swagger.annotations.*; | ||||
| import javax.validation.constraints.*; | ||||
|  | ||||
| @ApiModel("用户 APP - 字典类型创建 Request VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class AppTestDemoCreateReqVO extends AppTestDemoBaseVO { | ||||
|  | ||||
| } | ||||
| @@ -1,38 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.tool.controller.app.test.vo; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import io.swagger.annotations.*; | ||||
|  | ||||
| import com.alibaba.excel.annotation.ExcelProperty; | ||||
|  | ||||
| /** | ||||
|  * 字典类型 Excel VO | ||||
|  * | ||||
|  * @author 芋道源码 | ||||
|  */ | ||||
| @Data | ||||
| public class AppTestDemoExcelVO { | ||||
|  | ||||
|     @ExcelProperty("编号") | ||||
|     private Long id; | ||||
|  | ||||
|     @ExcelProperty("名字") | ||||
|     private String name; | ||||
|  | ||||
|     @ExcelProperty("状态") | ||||
|     private Integer status; | ||||
|  | ||||
|     @ExcelProperty("类型") | ||||
|     private Integer type; | ||||
|  | ||||
|     @ExcelProperty("分类") | ||||
|     private Integer category; | ||||
|  | ||||
|     @ExcelProperty("备注") | ||||
|     private String remark; | ||||
|  | ||||
|     @ExcelProperty("创建时间") | ||||
|     private Date createTime; | ||||
|  | ||||
| } | ||||
| @@ -1,38 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.tool.controller.app.test.vo; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import io.swagger.annotations.*; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||||
|  | ||||
| @ApiModel(value = "用户 APP - 字典类型 Excel 导出 Request VO", description = "参数和 TestDemoPageReqVO 是一致的") | ||||
| @Data | ||||
| public class AppTestDemoExportReqVO { | ||||
|  | ||||
|     @ApiModelProperty(value = "名字") | ||||
|     private String name; | ||||
|  | ||||
|     @ApiModelProperty(value = "状态") | ||||
|     private Integer status; | ||||
|  | ||||
|     @ApiModelProperty(value = "类型") | ||||
|     private Integer type; | ||||
|  | ||||
|     @ApiModelProperty(value = "分类") | ||||
|     private Integer category; | ||||
|  | ||||
|     @ApiModelProperty(value = "备注") | ||||
|     private String remark; | ||||
|  | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     @ApiModelProperty(value = "开始创建时间") | ||||
|     private Date beginCreateTime; | ||||
|  | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     @ApiModelProperty(value = "结束创建时间") | ||||
|     private Date endCreateTime; | ||||
|  | ||||
| } | ||||
| @@ -1,40 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.tool.controller.app.test.vo; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import io.swagger.annotations.*; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||||
|  | ||||
| @ApiModel("用户 APP - 字典类型分页 Request VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class AppTestDemoPageReqVO extends PageParam { | ||||
|  | ||||
|     @ApiModelProperty(value = "名字") | ||||
|     private String name; | ||||
|  | ||||
|     @ApiModelProperty(value = "状态") | ||||
|     private Integer status; | ||||
|  | ||||
|     @ApiModelProperty(value = "类型") | ||||
|     private Integer type; | ||||
|  | ||||
|     @ApiModelProperty(value = "分类") | ||||
|     private Integer category; | ||||
|  | ||||
|     @ApiModelProperty(value = "备注") | ||||
|     private String remark; | ||||
|  | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     @ApiModelProperty(value = "开始创建时间") | ||||
|     private Date beginCreateTime; | ||||
|  | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     @ApiModelProperty(value = "结束创建时间") | ||||
|     private Date endCreateTime; | ||||
|  | ||||
| } | ||||
| @@ -1,19 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.tool.controller.app.test.vo; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import io.swagger.annotations.*; | ||||
|  | ||||
| @ApiModel("用户 APP - 字典类型 Response VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class AppTestDemoRespVO extends AppTestDemoBaseVO { | ||||
|  | ||||
|     @ApiModelProperty(value = "编号", required = true) | ||||
|     private Long id; | ||||
|  | ||||
|     @ApiModelProperty(value = "创建时间", required = true) | ||||
|     private Date createTime; | ||||
|  | ||||
| } | ||||
| @@ -1,18 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.tool.controller.app.test.vo; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import io.swagger.annotations.*; | ||||
| import javax.validation.constraints.*; | ||||
|  | ||||
| @ApiModel("用户 APP - 字典类型更新 Request VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class AppTestDemoUpdateReqVO extends AppTestDemoBaseVO { | ||||
|  | ||||
|     @ApiModelProperty(value = "编号", required = true) | ||||
|     @NotNull(message = "编号不能为空") | ||||
|     private Long id; | ||||
|  | ||||
| } | ||||
| @@ -1,34 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.tool.convert.test; | ||||
|  | ||||
| import java.util.*; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
|  | ||||
| import org.mapstruct.Mapper; | ||||
| import org.mapstruct.factory.Mappers; | ||||
| import cn.iocoder.yudao.module.tool.controller.app.test.vo.*; | ||||
| import cn.iocoder.yudao.module.tool.dal.dataobject.test.TestDemoDO; | ||||
|  | ||||
| /** | ||||
|  * 字典类型 Convert | ||||
|  * | ||||
|  * @author 芋道源码 | ||||
|  */ | ||||
| @Mapper | ||||
| public interface TestDemoConvert { | ||||
|  | ||||
|     TestDemoConvert INSTANCE = Mappers.getMapper(TestDemoConvert.class); | ||||
|  | ||||
|     TestDemoDO convert(AppTestDemoCreateReqVO bean); | ||||
|  | ||||
|     TestDemoDO convert(AppTestDemoUpdateReqVO bean); | ||||
|  | ||||
|     AppTestDemoRespVO convert(TestDemoDO bean); | ||||
|  | ||||
|     List<AppTestDemoRespVO> convertList(List<TestDemoDO> list); | ||||
|  | ||||
|     PageResult<AppTestDemoRespVO> convertPage(PageResult<TestDemoDO> page); | ||||
|  | ||||
|     List<AppTestDemoExcelVO> convertList02(List<TestDemoDO> list); | ||||
|  | ||||
| } | ||||
| @@ -1,48 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.tool.dal.dataobject.test; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import com.baomidou.mybatisplus.annotation.*; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||||
|  | ||||
| /** | ||||
|  * 字典类型 DO | ||||
|  * | ||||
|  * @author 芋道源码 | ||||
|  */ | ||||
| @TableName("tool_test_demo") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| @Builder | ||||
| @NoArgsConstructor | ||||
| @AllArgsConstructor | ||||
| public class TestDemoDO extends BaseDO { | ||||
|  | ||||
|     /** | ||||
|      * 编号 | ||||
|      */ | ||||
|     @TableId | ||||
|     private Long id; | ||||
|     /** | ||||
|      * 名字 | ||||
|      */ | ||||
|     private String name; | ||||
|     /** | ||||
|      * 状态 | ||||
|      */ | ||||
|     private Integer status; | ||||
|     /** | ||||
|      * 类型 | ||||
|      */ | ||||
|     private Integer type; | ||||
|     /** | ||||
|      * 分类 | ||||
|      */ | ||||
|     private Integer category; | ||||
|     /** | ||||
|      * 备注 | ||||
|      */ | ||||
|     private String remark; | ||||
|  | ||||
| } | ||||
| @@ -1,66 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.tool.dal.mysql.test; | ||||
|  | ||||
| import java.util.*; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||||
| import cn.iocoder.yudao.module.tool.controller.app.test.vo.AppTestDemoExportReqVO; | ||||
| import cn.iocoder.yudao.module.tool.controller.app.test.vo.AppTestDemoPageReqVO; | ||||
| import cn.iocoder.yudao.module.tool.dal.dataobject.test.TestDemoDO; | ||||
| import org.apache.ibatis.annotations.Mapper; | ||||
| import cn.iocoder.yudao.module.tool.controller.admin.test.vo.*; | ||||
|  | ||||
| /** | ||||
|  * 字典类型 Mapper | ||||
|  * | ||||
|  * @author 芋道源码 | ||||
|  */ | ||||
| @Mapper | ||||
| public interface TestDemoMapper extends BaseMapperX<TestDemoDO> { | ||||
|  | ||||
|     default PageResult<TestDemoDO> selectPage(TestDemoPageReqVO reqVO) { | ||||
|         return selectPage(reqVO, new LambdaQueryWrapperX<TestDemoDO>() | ||||
|                 .likeIfPresent(TestDemoDO::getName, reqVO.getName()) | ||||
|                 .eqIfPresent(TestDemoDO::getStatus, reqVO.getStatus()) | ||||
|                 .eqIfPresent(TestDemoDO::getType, reqVO.getType()) | ||||
|                 .eqIfPresent(TestDemoDO::getCategory, reqVO.getCategory()) | ||||
|                 .eqIfPresent(TestDemoDO::getRemark, reqVO.getRemark()) | ||||
|                 .betweenIfPresent(TestDemoDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | ||||
|                 .orderByDesc(TestDemoDO::getId)); | ||||
|     } | ||||
|  | ||||
|     default List<TestDemoDO> selectList(TestDemoExportReqVO reqVO) { | ||||
|         return selectList(new LambdaQueryWrapperX<TestDemoDO>() | ||||
|                 .likeIfPresent(TestDemoDO::getName, reqVO.getName()) | ||||
|                 .eqIfPresent(TestDemoDO::getStatus, reqVO.getStatus()) | ||||
|                 .eqIfPresent(TestDemoDO::getType, reqVO.getType()) | ||||
|                 .eqIfPresent(TestDemoDO::getCategory, reqVO.getCategory()) | ||||
|                 .eqIfPresent(TestDemoDO::getRemark, reqVO.getRemark()) | ||||
|                 .betweenIfPresent(TestDemoDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | ||||
|                 .orderByDesc(TestDemoDO::getId)); | ||||
|     } | ||||
|  | ||||
|     default PageResult<TestDemoDO> selectPage(AppTestDemoPageReqVO reqVO) { | ||||
|         return selectPage(reqVO, new LambdaQueryWrapperX<TestDemoDO>() | ||||
|                 .likeIfPresent(TestDemoDO::getName, reqVO.getName()) | ||||
|                 .eqIfPresent(TestDemoDO::getStatus, reqVO.getStatus()) | ||||
|                 .eqIfPresent(TestDemoDO::getType, reqVO.getType()) | ||||
|                 .eqIfPresent(TestDemoDO::getCategory, reqVO.getCategory()) | ||||
|                 .eqIfPresent(TestDemoDO::getRemark, reqVO.getRemark()) | ||||
|                 .betweenIfPresent(TestDemoDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | ||||
|                 .orderByDesc(TestDemoDO::getId)); | ||||
|     } | ||||
|  | ||||
|     default List<TestDemoDO> selectList(AppTestDemoExportReqVO reqVO) { | ||||
|         return selectList(new LambdaQueryWrapperX<TestDemoDO>() | ||||
|                 .likeIfPresent(TestDemoDO::getName, reqVO.getName()) | ||||
|                 .eqIfPresent(TestDemoDO::getStatus, reqVO.getStatus()) | ||||
|                 .eqIfPresent(TestDemoDO::getType, reqVO.getType()) | ||||
|                 .eqIfPresent(TestDemoDO::getCategory, reqVO.getCategory()) | ||||
|                 .eqIfPresent(TestDemoDO::getRemark, reqVO.getRemark()) | ||||
|                 .betweenIfPresent(TestDemoDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | ||||
|                 .orderByDesc(TestDemoDO::getId)); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.tool.service.codegen.inner; | ||||
| import cn.hutool.core.map.MapUtil; | ||||
| import cn.hutool.core.util.StrUtil; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||||
| import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; | ||||
| import cn.iocoder.yudao.module.tool.convert.codegen.CodegenConvert; | ||||
| import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenColumnDO; | ||||
| import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenTableDO; | ||||
| @@ -55,7 +56,11 @@ public class CodegenBuilder { | ||||
|                     .build(); | ||||
|  | ||||
|     /** | ||||
|      * {@link BaseDO} 的字段 | ||||
|      * 多租户编号的字段名 | ||||
|      */ | ||||
|     public static final String TENANT_ID_FIELD = "tenant_id"; | ||||
|     /** | ||||
|      * {@link TenantBaseDO} 的字段 | ||||
|      */ | ||||
|     public static final Set<String> BASE_DO_FIELDS = new HashSet<>(); | ||||
|     /** | ||||
| @@ -91,7 +96,7 @@ public class CodegenBuilder { | ||||
|             .build(); | ||||
|  | ||||
|     static { | ||||
|         Arrays.stream(BaseDO.class.getDeclaredFields()).forEach(field -> BASE_DO_FIELDS.add(field.getName())); | ||||
|         Arrays.stream(TenantBaseDO.class.getDeclaredFields()).forEach(field -> BASE_DO_FIELDS.add(field.getName())); | ||||
|         // 处理 OPERATION 相关的字段 | ||||
|         CREATE_OPERATION_EXCLUDE_COLUMN.addAll(BASE_DO_FIELDS); | ||||
|         UPDATE_OPERATION_EXCLUDE_COLUMN.addAll(BASE_DO_FIELDS); | ||||
|   | ||||
| @@ -1,6 +1,8 @@ | ||||
| package cn.iocoder.yudao.module.tool.service.codegen.inner; | ||||
|  | ||||
| import cn.hutool.core.collection.ListUtil; | ||||
| import cn.hutool.core.map.MapUtil; | ||||
| import cn.hutool.core.util.ArrayUtil; | ||||
| import cn.hutool.core.util.StrUtil; | ||||
| import cn.hutool.extra.template.TemplateConfig; | ||||
| import cn.hutool.extra.template.TemplateEngine; | ||||
| @@ -10,6 +12,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||||
| import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; | ||||
| import cn.iocoder.yudao.module.tool.enums.codegen.CodegenSceneEnum; | ||||
| import cn.iocoder.yudao.module.tool.framework.codegen.config.CodegenProperties; | ||||
| import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; | ||||
| @@ -121,7 +124,6 @@ public class CodegenEngine { | ||||
|         globalBindingMap.put("DictFormatClassName", DictFormat.class.getName()); | ||||
|         // DO 类,独有字段 | ||||
|         globalBindingMap.put("baseDOFields", CodegenBuilder.BASE_DO_FIELDS); | ||||
|         globalBindingMap.put("BaseDOClassName", BaseDO.class.getName()); | ||||
|         globalBindingMap.put("QueryWrapperClassName", LambdaQueryWrapperX.class.getName()); | ||||
|         globalBindingMap.put("BaseMapperClassName", BaseMapperX.class.getName()); | ||||
|         // Util 工具类 | ||||
| @@ -141,6 +143,7 @@ public class CodegenEngine { | ||||
|         bindingMap.put("columns", columns); | ||||
|         bindingMap.put("primaryColumn", CollectionUtils.findFirst(columns, CodegenColumnDO::getPrimaryKey)); // 主键字段 | ||||
|         bindingMap.put("sceneEnum", CodegenSceneEnum.valueOf(table.getScene())); | ||||
|  | ||||
|         // className 相关 | ||||
|         // 去掉指定前缀,将 TestDictType 转换成 DictType. 因为在 create 等方法后,不需要带上 Test 前缀 | ||||
|         String simpleClassName = removePrefix(table.getClassName(), upperFirst(table.getModuleName())); | ||||
| @@ -153,6 +156,15 @@ public class CodegenEngine { | ||||
|         // permission 前缀 | ||||
|         bindingMap.put("permissionPrefix", table.getModuleName() + ":" + simpleClassNameStrikeCase); | ||||
|  | ||||
|         // 如果多租户,则进行覆盖 DB 独有字段 | ||||
|         if (CollectionUtils.findFirst(columns, column -> column.getColumnName().equals(CodegenBuilder.TENANT_ID_FIELD)) != null) { | ||||
|             globalBindingMap.put("BaseDOClassName", TenantBaseDO.class.getName()); | ||||
|             globalBindingMap.put("BaseDOClassName_simple", TenantBaseDO.class.getSimpleName()); | ||||
|         } else { | ||||
|             globalBindingMap.put("BaseDOClassName", BaseDO.class.getName()); | ||||
|             globalBindingMap.put("BaseDOClassName_simple", BaseDO.class.getSimpleName()); | ||||
|         } | ||||
|  | ||||
|         // 执行生成 | ||||
|         final Map<String, String> result = Maps.newLinkedHashMapWithExpectedSize(TEMPLATES.size()); // 有序 | ||||
|         TEMPLATES.forEach((vmPath, filePath) -> { | ||||
|   | ||||
| @@ -1,70 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.tool.service.test; | ||||
|  | ||||
| import java.util.*; | ||||
| import javax.validation.*; | ||||
| import cn.iocoder.yudao.module.tool.controller.app.test.vo.*; | ||||
| import cn.iocoder.yudao.module.tool.dal.dataobject.test.TestDemoDO; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
|  | ||||
| /** | ||||
|  * 字典类型 Service 接口 | ||||
|  * | ||||
|  * @author 芋道源码 | ||||
|  */ | ||||
| public interface TestDemoService { | ||||
|  | ||||
|     /** | ||||
|      * 创建字典类型 | ||||
|      * | ||||
|      * @param createReqVO 创建信息 | ||||
|      * @return 编号 | ||||
|      */ | ||||
|     Long createTestDemo(@Valid AppTestDemoCreateReqVO createReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 更新字典类型 | ||||
|      * | ||||
|      * @param updateReqVO 更新信息 | ||||
|      */ | ||||
|     void updateTestDemo(@Valid AppTestDemoUpdateReqVO updateReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 删除字典类型 | ||||
|      * | ||||
|      * @param id 编号 | ||||
|      */ | ||||
|     void deleteTestDemo(Long id); | ||||
|  | ||||
|     /** | ||||
|      * 获得字典类型 | ||||
|      * | ||||
|      * @param id 编号 | ||||
|      * @return 字典类型 | ||||
|      */ | ||||
|     TestDemoDO getTestDemo(Long id); | ||||
|  | ||||
|     /** | ||||
|      * 获得字典类型列表 | ||||
|      * | ||||
|      * @param ids 编号 | ||||
|      * @return 字典类型列表 | ||||
|      */ | ||||
|     List<TestDemoDO> getTestDemoList(Collection<Long> ids); | ||||
|  | ||||
|     /** | ||||
|      * 获得字典类型分页 | ||||
|      * | ||||
|      * @param pageReqVO 分页查询 | ||||
|      * @return 字典类型分页 | ||||
|      */ | ||||
|     PageResult<TestDemoDO> getTestDemoPage(AppTestDemoPageReqVO pageReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 获得字典类型列表, 用于 Excel 导出 | ||||
|      * | ||||
|      * @param exportReqVO 查询条件 | ||||
|      * @return 字典类型列表 | ||||
|      */ | ||||
|     List<TestDemoDO> getTestDemoList(AppTestDemoExportReqVO exportReqVO); | ||||
|  | ||||
| } | ||||
| @@ -1,82 +0,0 @@ | ||||
| package cn.iocoder.yudao.module.tool.service.test; | ||||
|  | ||||
| import org.springframework.stereotype.Service; | ||||
| import javax.annotation.Resource; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
|  | ||||
| import java.util.*; | ||||
| import cn.iocoder.yudao.module.tool.controller.app.test.vo.*; | ||||
| import cn.iocoder.yudao.module.tool.dal.dataobject.test.TestDemoDO; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
|  | ||||
| import cn.iocoder.yudao.module.tool.convert.test.TestDemoConvert; | ||||
| import cn.iocoder.yudao.module.tool.dal.mysql.test.TestDemoMapper; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||||
| import static cn.iocoder.yudao.module.tool.enums.ErrorCodeConstants.*; | ||||
|  | ||||
| /** | ||||
|  * 字典类型 Service 实现类 | ||||
|  * | ||||
|  * @author 芋道源码 | ||||
|  */ | ||||
| @Service | ||||
| @Validated | ||||
| public class TestDemoServiceImpl implements TestDemoService { | ||||
|  | ||||
|     @Resource | ||||
|     private TestDemoMapper testDemoMapper; | ||||
|  | ||||
|     @Override | ||||
|     public Long createTestDemo(AppTestDemoCreateReqVO createReqVO) { | ||||
|         // 插入 | ||||
|         TestDemoDO testDemo = TestDemoConvert.INSTANCE.convert(createReqVO); | ||||
|         testDemoMapper.insert(testDemo); | ||||
|         // 返回 | ||||
|         return testDemo.getId(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void updateTestDemo(AppTestDemoUpdateReqVO updateReqVO) { | ||||
|         // 校验存在 | ||||
|         this.validateTestDemoExists(updateReqVO.getId()); | ||||
|         // 更新 | ||||
|         TestDemoDO updateObj = TestDemoConvert.INSTANCE.convert(updateReqVO); | ||||
|         testDemoMapper.updateById(updateObj); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void deleteTestDemo(Long id) { | ||||
|         // 校验存在 | ||||
|         this.validateTestDemoExists(id); | ||||
|         // 删除 | ||||
|         testDemoMapper.deleteById(id); | ||||
|     } | ||||
|  | ||||
|     private void validateTestDemoExists(Long id) { | ||||
|         if (testDemoMapper.selectById(id) == null) { | ||||
|             throw exception(TEST_DEMO_NOT_EXISTS); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public TestDemoDO getTestDemo(Long id) { | ||||
|         return testDemoMapper.selectById(id); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<TestDemoDO> getTestDemoList(Collection<Long> ids) { | ||||
|         return testDemoMapper.selectBatchIds(ids); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public PageResult<TestDemoDO> getTestDemoPage(AppTestDemoPageReqVO pageReqVO) { | ||||
|         return testDemoMapper.selectPage(pageReqVO); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<TestDemoDO> getTestDemoList(AppTestDemoExportReqVO exportReqVO) { | ||||
|         return testDemoMapper.selectList(exportReqVO); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -17,7 +17,7 @@ import ${BaseDOClassName}; | ||||
| @Builder | ||||
| @NoArgsConstructor | ||||
| @AllArgsConstructor | ||||
| public class ${table.className}DO extends BaseDO { | ||||
| public class ${table.className}DO extends ${BaseDOClassName_simple} { | ||||
|  | ||||
| #foreach ($column in $columns) | ||||
| #if (!${baseDOFields.contains(${column.javaField})})##排除 BaseDO 的字段 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV