Commit eb3d0386eed53c9ceecca4beff5a7180ea28dc23
1 parent
392dfa47
代码生成器,增加 excel 导出功能
Showing
34 changed files
with
761 additions
and
68 deletions
src/main/java/cn/iocoder/dashboard/modules/infra/enums/InfErrorCodeConstants.java
src/main/java/cn/iocoder/dashboard/modules/system/enums/SysErrorCodeConstants.java
| ... | ... | @@ -75,7 +75,4 @@ public interface SysErrorCodeConstants { |
| 75 | 75 | // ========== 文件 1002009000 ========== |
| 76 | 76 | ErrorCode FILE_PATH_EXISTS = new ErrorCode(1002009001, "文件路径已经存在"); |
| 77 | 77 | |
| 78 | - // ========== 字典类型(测试) 1002010000 ========== | |
| 79 | - ErrorCode TEST_DEMO_NOT_EXISTS = new ErrorCode(1002010000, "字典类型不存在}"); | |
| 80 | - | |
| 81 | 78 | } | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/enums/dict/SysDictTypeEnum.java
| ... | ... | @@ -16,6 +16,8 @@ public enum SysDictTypeEnum { |
| 16 | 16 | SYS_LOGIN_RESULT("sys_login_result"), // 登陆结果 |
| 17 | 17 | SYS_CONFIG_TYPE("sys_config_type"), // 参数配置类型 |
| 18 | 18 | SYS_BOOLEAN_STRING("sys_boolean_string"), // Boolean 是否类型 |
| 19 | + | |
| 20 | + INF_REDIS_TIMEOUT_TYPE("inf_redis_timeout_type"), // Redis 超时类型 | |
| 19 | 21 | ; |
| 20 | 22 | |
| 21 | 23 | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/tool/controller/package-info.java deleted
| 1 | -package cn.iocoder.dashboard.modules.tool.controller; |
src/main/java/cn/iocoder/dashboard/modules/tool/controller/test/ToolTestDemoController.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.tool.controller.test; | |
| 2 | + | |
| 3 | +import cn.iocoder.dashboard.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.dashboard.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.dashboard.framework.excel.core.util.ExcelUtils; | |
| 6 | +import cn.iocoder.dashboard.modules.tool.controller.test.vo.*; | |
| 7 | +import cn.iocoder.dashboard.modules.tool.convert.test.ToolTestDemoConvert; | |
| 8 | +import cn.iocoder.dashboard.modules.tool.dal.dataobject.test.ToolTestDemoDO; | |
| 9 | +import cn.iocoder.dashboard.modules.tool.service.test.ToolTestDemoService; | |
| 10 | +import io.swagger.annotations.Api; | |
| 11 | +import io.swagger.annotations.ApiImplicitParam; | |
| 12 | +import io.swagger.annotations.ApiOperation; | |
| 13 | +import org.springframework.validation.annotation.Validated; | |
| 14 | +import org.springframework.web.bind.annotation.*; | |
| 15 | + | |
| 16 | +import javax.annotation.Resource; | |
| 17 | +import javax.servlet.http.HttpServletResponse; | |
| 18 | +import javax.validation.Valid; | |
| 19 | +import java.io.IOException; | |
| 20 | +import java.util.Collection; | |
| 21 | +import java.util.List; | |
| 22 | + | |
| 23 | +import static cn.iocoder.dashboard.common.pojo.CommonResult.success; | |
| 24 | + | |
| 25 | +@Api(tags = "字典类型") | |
| 26 | +@RestController | |
| 27 | +@RequestMapping("/tool/test-demo") | |
| 28 | +@Validated | |
| 29 | +public class ToolTestDemoController { | |
| 30 | + | |
| 31 | + @Resource | |
| 32 | + private ToolTestDemoService testDemoService; | |
| 33 | + | |
| 34 | + @ApiOperation("创建字典类型") | |
| 35 | + @PostMapping("/create") | |
| 36 | + public CommonResult<Long> createTestDemo(@Valid ToolTestDemoCreateReqVO createReqVO) { | |
| 37 | + return success(testDemoService.createTestDemo(createReqVO)); | |
| 38 | + } | |
| 39 | + | |
| 40 | + @ApiOperation("更新字典类型") | |
| 41 | + @PutMapping("/update") | |
| 42 | + public CommonResult<Boolean> updateTestDemo(@Valid ToolTestDemoUpdateReqVO updateReqVO) { | |
| 43 | + testDemoService.updateTestDemo(updateReqVO); | |
| 44 | + return success(true); | |
| 45 | + } | |
| 46 | + | |
| 47 | + @ApiOperation("删除字典类型") | |
| 48 | + @DeleteMapping("/delete") | |
| 49 | + @ApiImplicitParam(name = "id", value = "编号", required = true) | |
| 50 | + public CommonResult<Boolean> deleteTestDemo(@RequestParam("id") Long id) { | |
| 51 | + testDemoService.deleteTestDemo(id); | |
| 52 | + return success(true); | |
| 53 | + } | |
| 54 | + | |
| 55 | + @GetMapping("/get") | |
| 56 | + @ApiOperation("获得字典类型") | |
| 57 | + @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) | |
| 58 | + public CommonResult<ToolTestDemoRespVO> getTestDemo(@RequestParam("id") Long id) { | |
| 59 | + ToolTestDemoDO testDemo = testDemoService.getTestDemo(id); | |
| 60 | + return success(ToolTestDemoConvert.INSTANCE.convert(testDemo)); | |
| 61 | + } | |
| 62 | + | |
| 63 | + @GetMapping("/list") | |
| 64 | + @ApiOperation("获得字典类型列表") | |
| 65 | + @ApiImplicitParam(name = "ids", value = "编号列表", required = true, dataTypeClass = List.class) | |
| 66 | + public CommonResult<List<ToolTestDemoRespVO>> getTestDemoList(@RequestParam("ids") Collection<Long> ids) { | |
| 67 | + List<ToolTestDemoDO> list = testDemoService.getTestDemoList(ids); | |
| 68 | + return success(ToolTestDemoConvert.INSTANCE.convertList(list)); | |
| 69 | + } | |
| 70 | + | |
| 71 | + @ApiOperation("获得字典类型分页") | |
| 72 | + @GetMapping("/page") | |
| 73 | + public CommonResult<PageResult<ToolTestDemoRespVO>> getTestDemoPage(@Valid ToolTestDemoPageReqVO pageVO) { | |
| 74 | + PageResult<ToolTestDemoDO> pageResult = testDemoService.getTestDemoPage(pageVO); | |
| 75 | + return success(ToolTestDemoConvert.INSTANCE.convertPage(pageResult)); | |
| 76 | + } | |
| 77 | + | |
| 78 | + @GetMapping("/export-excel") | |
| 79 | + @ApiOperation("导出字典类型 Excel") | |
| 80 | + public void exportTestDemoExcel(@Valid ToolTestDemoExportReqVO exportReqVO, | |
| 81 | + HttpServletResponse response) throws IOException { | |
| 82 | + List<ToolTestDemoDO> list = testDemoService.getTestDemoList(exportReqVO); | |
| 83 | + // 导出 Excel | |
| 84 | + List<ToolTestDemoExcelVO> datas = ToolTestDemoConvert.INSTANCE.convertList02(list); | |
| 85 | + ExcelUtils.write(response, "字典类型.xls", "数据", ToolTestDemoExcelVO.class, datas); | |
| 86 | + } | |
| 87 | + | |
| 88 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/tool/controller/test/vo/ToolTestDemoBaseVO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.tool.controller.test.vo; | |
| 2 | + | |
| 3 | +import io.swagger.annotations.ApiModelProperty; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import javax.validation.constraints.NotNull; | |
| 7 | + | |
| 8 | +/** | |
| 9 | +* 字典类型 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 10 | +* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 11 | +*/ | |
| 12 | +@Data | |
| 13 | +public class ToolTestDemoBaseVO { | |
| 14 | + | |
| 15 | + @ApiModelProperty(value = "名字", required = true, example = "芋道") | |
| 16 | + @NotNull(message = "名字不能为空") | |
| 17 | + private String name; | |
| 18 | + | |
| 19 | + @ApiModelProperty(value = "状态", required = true, example = "1") | |
| 20 | + @NotNull(message = "状态不能为空") | |
| 21 | + private Integer status; | |
| 22 | + | |
| 23 | + @ApiModelProperty(value = "类型", required = true, example = "2") | |
| 24 | + @NotNull(message = "类型不能为空") | |
| 25 | + private Integer type; | |
| 26 | + | |
| 27 | + @ApiModelProperty(value = "分类", required = true, example = "3") | |
| 28 | + @NotNull(message = "分类不能为空") | |
| 29 | + private Integer category; | |
| 30 | + | |
| 31 | + @ApiModelProperty(value = "备注", example = "我是备注") | |
| 32 | + private String remark; | |
| 33 | + | |
| 34 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/tool/controller/test/vo/ToolTestDemoCreateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.tool.controller.test.vo; | |
| 2 | + | |
| 3 | +import io.swagger.annotations.ApiModel; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +@ApiModel("字典类型创建 Request VO") | |
| 9 | +@Data | |
| 10 | +@EqualsAndHashCode(callSuper = true) | |
| 11 | +@ToString(callSuper = true) | |
| 12 | +public class ToolTestDemoCreateReqVO extends ToolTestDemoBaseVO { | |
| 13 | + | |
| 14 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/tool/controller/test/vo/ToolTestDemoExcelVO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.tool.controller.test.vo; | |
| 2 | + | |
| 3 | +import cn.iocoder.dashboard.framework.excel.core.annotations.DictFormat; | |
| 4 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 5 | +import lombok.Data; | |
| 6 | + | |
| 7 | +import java.util.Date; | |
| 8 | + | |
| 9 | +import static cn.iocoder.dashboard.modules.system.enums.dict.SysDictTypeEnum.*; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 字典类型 Excel VO | |
| 13 | + * | |
| 14 | + * @author 芋艿 | |
| 15 | + */ | |
| 16 | +@Data | |
| 17 | +public class ToolTestDemoExcelVO { | |
| 18 | + | |
| 19 | + @ExcelProperty("编号") | |
| 20 | + private Long id; | |
| 21 | + | |
| 22 | + @ExcelProperty("名字") | |
| 23 | + private String name; | |
| 24 | + | |
| 25 | + @ExcelProperty("状态") | |
| 26 | + @DictFormat(SYS_COMMON_STATUS) | |
| 27 | + private Integer status; | |
| 28 | + | |
| 29 | + @ExcelProperty("类型") | |
| 30 | + @DictFormat(SYS_OPERATE_TYPE) | |
| 31 | + private Integer type; | |
| 32 | + | |
| 33 | + @ExcelProperty("分类") | |
| 34 | + @DictFormat(INF_REDIS_TIMEOUT_TYPE) | |
| 35 | + private Integer category; | |
| 36 | + | |
| 37 | + @ExcelProperty("备注") | |
| 38 | + private String remark; | |
| 39 | + | |
| 40 | + @ExcelProperty("创建时间") | |
| 41 | + private Date createTime; | |
| 42 | + | |
| 43 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/tool/controller/test/vo/ToolTestDemoExportReqVO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.tool.controller.test.vo; | |
| 2 | + | |
| 3 | +import io.swagger.annotations.ApiModel; | |
| 4 | +import io.swagger.annotations.ApiModelProperty; | |
| 5 | +import lombok.Data; | |
| 6 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 7 | + | |
| 8 | +import java.util.Date; | |
| 9 | + | |
| 10 | +import static cn.iocoder.dashboard.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 11 | + | |
| 12 | +@ApiModel(value = "字典类型 Excel 导出 Request VO", description = "参数和 ToolTestDemoPageReqVO 是一致的") | |
| 13 | +@Data | |
| 14 | +public class ToolTestDemoExportReqVO { | |
| 15 | + | |
| 16 | + @ApiModelProperty(value = "名字", example = "芋道") | |
| 17 | + private String name; | |
| 18 | + | |
| 19 | + @ApiModelProperty(value = "状态", example = "1") | |
| 20 | + private Integer status; | |
| 21 | + | |
| 22 | + @ApiModelProperty(value = "类型", example = "2") | |
| 23 | + private Integer type; | |
| 24 | + | |
| 25 | + @ApiModelProperty(value = "分类", example = "3") | |
| 26 | + private Integer category; | |
| 27 | + | |
| 28 | + @ApiModelProperty(value = "备注", example = "我是备注") | |
| 29 | + private String remark; | |
| 30 | + | |
| 31 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 32 | + @ApiModelProperty(value = "开始创建时间") | |
| 33 | + private Date beginCreateTime; | |
| 34 | + | |
| 35 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 36 | + @ApiModelProperty(value = "结束创建时间") | |
| 37 | + private Date endCreateTime; | |
| 38 | + | |
| 39 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/tool/controller/test/vo/ToolTestDemoPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.tool.controller.test.vo; | |
| 2 | + | |
| 3 | +import cn.iocoder.dashboard.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 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 10 | + | |
| 11 | +import java.util.Date; | |
| 12 | + | |
| 13 | +import static cn.iocoder.dashboard.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 14 | + | |
| 15 | +@ApiModel("字典类型分页 Request VO") | |
| 16 | +@Data | |
| 17 | +@EqualsAndHashCode(callSuper = true) | |
| 18 | +@ToString(callSuper = true) | |
| 19 | +public class ToolTestDemoPageReqVO extends PageParam { | |
| 20 | + | |
| 21 | + @ApiModelProperty(value = "名字", example = "芋道") | |
| 22 | + private String name; | |
| 23 | + | |
| 24 | + @ApiModelProperty(value = "状态", example = "1") | |
| 25 | + private Integer status; | |
| 26 | + | |
| 27 | + @ApiModelProperty(value = "类型", example = "2") | |
| 28 | + private Integer type; | |
| 29 | + | |
| 30 | + @ApiModelProperty(value = "分类", example = "3") | |
| 31 | + private Integer category; | |
| 32 | + | |
| 33 | + @ApiModelProperty(value = "备注", example = "我是备注") | |
| 34 | + private String remark; | |
| 35 | + | |
| 36 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 37 | + @ApiModelProperty(value = "开始创建时间") | |
| 38 | + private Date beginCreateTime; | |
| 39 | + | |
| 40 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 41 | + @ApiModelProperty(value = "结束创建时间") | |
| 42 | + private Date endCreateTime; | |
| 43 | + | |
| 44 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/tool/controller/test/vo/ToolTestDemoRespVO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.tool.controller.test.vo; | |
| 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; | |
| 10 | + | |
| 11 | +@ApiModel("字典类型 Response VO") | |
| 12 | +@Data | |
| 13 | +@EqualsAndHashCode(callSuper = true) | |
| 14 | +@ToString(callSuper = true) | |
| 15 | +public class ToolTestDemoRespVO extends ToolTestDemoBaseVO { | |
| 16 | + | |
| 17 | + @ApiModelProperty(value = "编号", required = true, example = "1") | |
| 18 | + private Long id; | |
| 19 | + | |
| 20 | + @ApiModelProperty(value = "创建时间", required = true) | |
| 21 | + private Date createTime; | |
| 22 | + | |
| 23 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/tool/controller/test/vo/ToolTestDemoUpdateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.tool.controller.test.vo; | |
| 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; | |
| 10 | + | |
| 11 | +@ApiModel("字典类型更新 Request VO") | |
| 12 | +@Data | |
| 13 | +@EqualsAndHashCode(callSuper = true) | |
| 14 | +@ToString(callSuper = true) | |
| 15 | +public class ToolTestDemoUpdateReqVO extends ToolTestDemoBaseVO { | |
| 16 | + | |
| 17 | + @ApiModelProperty(value = "编号", required = true, example = "1") | |
| 18 | + @NotNull(message = "编号不能为空") | |
| 19 | + private Long id; | |
| 20 | + | |
| 21 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/tool/convert/package-info.java deleted
| 1 | -package cn.iocoder.dashboard.modules.tool.convert; |
src/main/java/cn/iocoder/dashboard/modules/tool/convert/test/ToolTestDemoConvert.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.tool.convert.test; | |
| 2 | + | |
| 3 | +import cn.iocoder.dashboard.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.dashboard.modules.tool.controller.test.vo.ToolTestDemoCreateReqVO; | |
| 5 | +import cn.iocoder.dashboard.modules.tool.controller.test.vo.ToolTestDemoExcelVO; | |
| 6 | +import cn.iocoder.dashboard.modules.tool.controller.test.vo.ToolTestDemoRespVO; | |
| 7 | +import cn.iocoder.dashboard.modules.tool.controller.test.vo.ToolTestDemoUpdateReqVO; | |
| 8 | +import cn.iocoder.dashboard.modules.tool.dal.dataobject.test.ToolTestDemoDO; | |
| 9 | +import org.mapstruct.Mapper; | |
| 10 | +import org.mapstruct.factory.Mappers; | |
| 11 | + | |
| 12 | +import java.util.List; | |
| 13 | + | |
| 14 | +/** | |
| 15 | +* 字典类型 Convert | |
| 16 | +* | |
| 17 | +* @author 芋艿 | |
| 18 | +*/ | |
| 19 | +@Mapper | |
| 20 | +public interface ToolTestDemoConvert { | |
| 21 | + | |
| 22 | + ToolTestDemoConvert INSTANCE = Mappers.getMapper(ToolTestDemoConvert.class); | |
| 23 | + | |
| 24 | + ToolTestDemoDO convert(ToolTestDemoCreateReqVO bean); | |
| 25 | + | |
| 26 | + ToolTestDemoDO convert(ToolTestDemoUpdateReqVO bean); | |
| 27 | + | |
| 28 | + ToolTestDemoRespVO convert(ToolTestDemoDO bean); | |
| 29 | + | |
| 30 | + List<ToolTestDemoRespVO> convertList(List<ToolTestDemoDO> list); | |
| 31 | + | |
| 32 | + PageResult<ToolTestDemoRespVO> convertPage(PageResult<ToolTestDemoDO> page); | |
| 33 | + | |
| 34 | + List<ToolTestDemoExcelVO> convertList02(List<ToolTestDemoDO> list); | |
| 35 | + | |
| 36 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/tool/dal/dataobject/package-info.java deleted
| 1 | -package cn.iocoder.dashboard.modules.tool.dal.dataobject; |
src/main/java/cn/iocoder/dashboard/modules/tool/dal/dataobject/test/ToolTestDemoDO.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.tool.dal.dataobject.test; | |
| 2 | + | |
| 3 | +import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 5 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 6 | +import lombok.*; | |
| 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 ToolTestDemoDO extends BaseDO { | |
| 21 | + | |
| 22 | + /** | |
| 23 | + * 编号 | |
| 24 | + */ | |
| 25 | + @TableId | |
| 26 | + private Long id; | |
| 27 | + /** | |
| 28 | + * 名字 | |
| 29 | + */ | |
| 30 | + private String name; | |
| 31 | + /** | |
| 32 | + * 状态 | |
| 33 | + * | |
| 34 | + * 枚举 {@link cn.iocoder.dashboard.common.enums.CommonStatusEnum} | |
| 35 | + */ | |
| 36 | + private Integer status; | |
| 37 | + /** | |
| 38 | + * 类型 | |
| 39 | + * | |
| 40 | + * 枚举 {@link cn.iocoder.dashboard.framework.logger.operatelog.core.enums.OperateTypeEnum} | |
| 41 | + */ | |
| 42 | + private Integer type; | |
| 43 | + /** | |
| 44 | + * 分类 | |
| 45 | + * | |
| 46 | + * 枚举 {@link cn.iocoder.dashboard.framework.redis.core.RedisKeyDefine.TimeoutTypeEnum} | |
| 47 | + */ | |
| 48 | + private Integer category; | |
| 49 | + /** | |
| 50 | + * 备注 | |
| 51 | + */ | |
| 52 | + private String remark; | |
| 53 | + | |
| 54 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/tool/dal/mysql/package-info.java deleted
| 1 | -package cn.iocoder.dashboard.modules.tool.dal.mysql; |
src/main/java/cn/iocoder/dashboard/modules/tool/dal/mysql/test/ToolTestDemoMapper.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.tool.dal.mysql.test; | |
| 2 | + | |
| 3 | +import cn.iocoder.dashboard.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.dashboard.framework.mybatis.core.mapper.BaseMapperX; | |
| 5 | +import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX; | |
| 6 | +import cn.iocoder.dashboard.modules.tool.controller.test.vo.ToolTestDemoExportReqVO; | |
| 7 | +import cn.iocoder.dashboard.modules.tool.controller.test.vo.ToolTestDemoPageReqVO; | |
| 8 | +import cn.iocoder.dashboard.modules.tool.dal.dataobject.test.ToolTestDemoDO; | |
| 9 | +import org.apache.ibatis.annotations.Mapper; | |
| 10 | + | |
| 11 | +import java.util.List; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 字典类型 Mapper | |
| 15 | + * | |
| 16 | + * @author 芋艿 | |
| 17 | + */ | |
| 18 | +@Mapper | |
| 19 | +public interface ToolTestDemoMapper extends BaseMapperX<ToolTestDemoDO> { | |
| 20 | + | |
| 21 | + default PageResult<ToolTestDemoDO> selectPage(ToolTestDemoPageReqVO reqVO) { | |
| 22 | + return selectPage(reqVO, new QueryWrapperX<ToolTestDemoDO>() | |
| 23 | + .likeIfPresent("name", reqVO.getName()) | |
| 24 | + .eqIfPresent("status", reqVO.getStatus()) | |
| 25 | + .eqIfPresent("type", reqVO.getType()) | |
| 26 | + .eqIfPresent("category", reqVO.getCategory()) | |
| 27 | + .eqIfPresent("remark", reqVO.getRemark()) | |
| 28 | + .betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | |
| 29 | + ); | |
| 30 | + } | |
| 31 | + | |
| 32 | + default List<ToolTestDemoDO> selectList(ToolTestDemoExportReqVO reqVO) { | |
| 33 | + return selectList(new QueryWrapperX<ToolTestDemoDO>() | |
| 34 | + .likeIfPresent("name", reqVO.getName()) | |
| 35 | + .eqIfPresent("status", reqVO.getStatus()) | |
| 36 | + .eqIfPresent("type", reqVO.getType()) | |
| 37 | + .eqIfPresent("category", reqVO.getCategory()) | |
| 38 | + .eqIfPresent("remark", reqVO.getRemark()) | |
| 39 | + .betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | |
| 40 | + ); | |
| 41 | + } | |
| 42 | + | |
| 43 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/tool/enums/ToolErrorCodeConstants.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.tool.enums; | |
| 2 | + | |
| 3 | +import cn.iocoder.dashboard.common.exception.ErrorCode; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * Tool 错误码枚举类 | |
| 7 | + * | |
| 8 | + * tool 系统,使用 1-003-000-000 段 | |
| 9 | + */ | |
| 10 | +public interface ToolErrorCodeConstants { | |
| 11 | + | |
| 12 | + // ========== 字典类型(测试) 1003000000 ========== | |
| 13 | + ErrorCode TEST_DEMO_NOT_EXISTS = new ErrorCode(1003000000, "测试示例不存在"); | |
| 14 | + | |
| 15 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/tool/enums/package-info.java deleted
| 1 | -package cn.iocoder.dashboard.modules.tool.enums; |
src/main/java/cn/iocoder/dashboard/modules/tool/service/codegen/impl/ToolCodegenEngine.java
| ... | ... | @@ -10,9 +10,12 @@ import cn.iocoder.dashboard.common.pojo.CommonResult; |
| 10 | 10 | import cn.iocoder.dashboard.common.pojo.PageParam; |
| 11 | 11 | import cn.iocoder.dashboard.common.pojo.PageResult; |
| 12 | 12 | import cn.iocoder.dashboard.framework.codegen.config.CodegenProperties; |
| 13 | +import cn.iocoder.dashboard.framework.excel.core.annotations.DictFormat; | |
| 14 | +import cn.iocoder.dashboard.framework.excel.core.util.ExcelUtils; | |
| 13 | 15 | import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO; |
| 14 | 16 | import cn.iocoder.dashboard.framework.mybatis.core.mapper.BaseMapperX; |
| 15 | 17 | import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX; |
| 18 | +import cn.iocoder.dashboard.modules.system.enums.dict.SysDictTypeEnum; | |
| 16 | 19 | import cn.iocoder.dashboard.modules.tool.dal.dataobject.codegen.ToolCodegenColumnDO; |
| 17 | 20 | import cn.iocoder.dashboard.modules.tool.dal.dataobject.codegen.ToolCodegenTableDO; |
| 18 | 21 | import cn.iocoder.dashboard.util.collection.CollectionUtils; |
| ... | ... | @@ -59,6 +62,10 @@ public class ToolCodegenEngine { |
| 59 | 62 | javaFilePath("controller/${table.businessName}/vo/${table.className}RespVO")) |
| 60 | 63 | .put(javaTemplatePath("controller/vo/updateReqVO"), |
| 61 | 64 | javaFilePath("controller/${table.businessName}/vo/${table.className}UpdateReqVO")) |
| 65 | + .put(javaTemplatePath("controller/vo/exportReqVO"), | |
| 66 | + javaFilePath("controller/${table.businessName}/vo/${table.className}ExportReqVO")) | |
| 67 | + .put(javaTemplatePath("controller/vo/excelVO"), | |
| 68 | + javaFilePath("controller/${table.businessName}/vo/${table.className}ExcelVO")) | |
| 62 | 69 | .put(javaTemplatePath("convert/convert"), |
| 63 | 70 | javaFilePath("convert/${table.businessName}/${table.className}Convert")) |
| 64 | 71 | .put(javaTemplatePath("dal/do"), |
| ... | ... | @@ -106,15 +113,19 @@ public class ToolCodegenEngine { |
| 106 | 113 | // 全局 Java Bean |
| 107 | 114 | globalBindingMap.put("CommonResultClassName", CommonResult.class.getName()); |
| 108 | 115 | globalBindingMap.put("PageResultClassName", PageResult.class.getName()); |
| 109 | - globalBindingMap.put("DateUtilsClassName", DateUtils.class.getName()); | |
| 110 | - globalBindingMap.put("ServiceExceptionUtilClassName", ServiceExceptionUtil.class.getName()); | |
| 111 | 116 | // VO 类,独有字段 |
| 112 | 117 | globalBindingMap.put("PageParamClassName", PageParam.class.getName()); |
| 118 | + globalBindingMap.put("DictFormatClassName", DictFormat.class.getName()); | |
| 119 | + globalBindingMap.put("SysDictTypeEnumClassName", SysDictTypeEnum.class.getName()); | |
| 113 | 120 | // DO 类,独有字段 |
| 114 | 121 | globalBindingMap.put("baseDOFields", ToolCodegenBuilder.BASE_DO_FIELDS); |
| 115 | 122 | globalBindingMap.put("BaseDOClassName", BaseDO.class.getName()); |
| 116 | 123 | globalBindingMap.put("QueryWrapperClassName", QueryWrapperX.class.getName()); |
| 117 | 124 | globalBindingMap.put("BaseMapperClassName", BaseMapperX.class.getName()); |
| 125 | + // Util 了诶 | |
| 126 | + globalBindingMap.put("ServiceExceptionUtilClassName", ServiceExceptionUtil.class.getName()); | |
| 127 | + globalBindingMap.put("DateUtilsClassName", DateUtils.class.getName()); | |
| 128 | + globalBindingMap.put("ExcelUtilsClassName", ExcelUtils.class.getName()); | |
| 118 | 129 | } |
| 119 | 130 | |
| 120 | 131 | public Map<String, String> execute(ToolCodegenTableDO table, List<ToolCodegenColumnDO> columns) { | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/tool/service/package-info.java deleted
| 1 | -package cn.iocoder.dashboard.modules.tool.service; |
src/main/java/cn/iocoder/dashboard/modules/tool/service/test/ToolTestDemoService.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.tool.service.test; | |
| 2 | + | |
| 3 | +import cn.iocoder.dashboard.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.dashboard.modules.tool.controller.test.vo.ToolTestDemoCreateReqVO; | |
| 5 | +import cn.iocoder.dashboard.modules.tool.controller.test.vo.ToolTestDemoExportReqVO; | |
| 6 | +import cn.iocoder.dashboard.modules.tool.controller.test.vo.ToolTestDemoPageReqVO; | |
| 7 | +import cn.iocoder.dashboard.modules.tool.controller.test.vo.ToolTestDemoUpdateReqVO; | |
| 8 | +import cn.iocoder.dashboard.modules.tool.dal.dataobject.test.ToolTestDemoDO; | |
| 9 | + | |
| 10 | +import javax.validation.Valid; | |
| 11 | +import java.util.Collection; | |
| 12 | +import java.util.List; | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * 字典类型 Service 接口 | |
| 16 | + * | |
| 17 | + * @author 芋艿 | |
| 18 | + */ | |
| 19 | +public interface ToolTestDemoService { | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * 创建字典类型 | |
| 23 | + * | |
| 24 | + * @param createReqVO 创建信息 | |
| 25 | + * @return 编号 | |
| 26 | + */ | |
| 27 | + Long createTestDemo(@Valid ToolTestDemoCreateReqVO createReqVO); | |
| 28 | + | |
| 29 | + /** | |
| 30 | + * 更新字典类型 | |
| 31 | + * | |
| 32 | + * @param updateReqVO 更新信息 | |
| 33 | + */ | |
| 34 | + void updateTestDemo(@Valid ToolTestDemoUpdateReqVO updateReqVO); | |
| 35 | + | |
| 36 | + /** | |
| 37 | + * 删除字典类型 | |
| 38 | + * | |
| 39 | + * @param id 编号 | |
| 40 | + */ | |
| 41 | + void deleteTestDemo(Long id); | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * 获得字典类型 | |
| 45 | + * | |
| 46 | + * @param id 编号 | |
| 47 | + * @return 字典类型 | |
| 48 | + */ | |
| 49 | + ToolTestDemoDO getTestDemo(Long id); | |
| 50 | + | |
| 51 | + /** | |
| 52 | + * 获得字典类型列表 | |
| 53 | + * | |
| 54 | + * @param ids 编号 | |
| 55 | + * @return 字典类型列表 | |
| 56 | + */ | |
| 57 | + List<ToolTestDemoDO> getTestDemoList(Collection<Long> ids); | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * 获得字典类型分页 | |
| 61 | + * | |
| 62 | + * @param pageReqVO 分页查询 | |
| 63 | + * @return 字典类型分页 | |
| 64 | + */ | |
| 65 | + PageResult<ToolTestDemoDO> getTestDemoPage(ToolTestDemoPageReqVO pageReqVO); | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * 获得字典类型列表, 用于 Excel 导出 | |
| 69 | + * | |
| 70 | + * @param exportReqVO 查询条件 | |
| 71 | + * @return 字典类型分页 | |
| 72 | + */ | |
| 73 | + List<ToolTestDemoDO> getTestDemoList(ToolTestDemoExportReqVO exportReqVO); | |
| 74 | + | |
| 75 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/tool/service/test/impl/ToolTestDemoServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.dashboard.modules.tool.service.test.impl; | |
| 2 | + | |
| 3 | +import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil; | |
| 4 | +import cn.iocoder.dashboard.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.dashboard.modules.tool.controller.test.vo.ToolTestDemoCreateReqVO; | |
| 6 | +import cn.iocoder.dashboard.modules.tool.controller.test.vo.ToolTestDemoExportReqVO; | |
| 7 | +import cn.iocoder.dashboard.modules.tool.controller.test.vo.ToolTestDemoPageReqVO; | |
| 8 | +import cn.iocoder.dashboard.modules.tool.controller.test.vo.ToolTestDemoUpdateReqVO; | |
| 9 | +import cn.iocoder.dashboard.modules.tool.convert.test.ToolTestDemoConvert; | |
| 10 | +import cn.iocoder.dashboard.modules.tool.dal.dataobject.test.ToolTestDemoDO; | |
| 11 | +import cn.iocoder.dashboard.modules.tool.dal.mysql.test.ToolTestDemoMapper; | |
| 12 | +import cn.iocoder.dashboard.modules.tool.service.test.ToolTestDemoService; | |
| 13 | +import org.springframework.stereotype.Service; | |
| 14 | +import org.springframework.validation.annotation.Validated; | |
| 15 | + | |
| 16 | +import javax.annotation.Resource; | |
| 17 | +import java.util.Collection; | |
| 18 | +import java.util.List; | |
| 19 | + | |
| 20 | +import static cn.iocoder.dashboard.modules.tool.enums.ToolErrorCodeConstants.TEST_DEMO_NOT_EXISTS; | |
| 21 | + | |
| 22 | +/** | |
| 23 | + * 字典类型 Service 实现类 | |
| 24 | + * | |
| 25 | + * @author 芋艿 | |
| 26 | + */ | |
| 27 | +@Service | |
| 28 | +@Validated | |
| 29 | +public class ToolTestDemoServiceImpl implements ToolTestDemoService { | |
| 30 | + | |
| 31 | + @Resource | |
| 32 | + private ToolTestDemoMapper testDemoMapper; | |
| 33 | + | |
| 34 | + @Override | |
| 35 | + public Long createTestDemo(ToolTestDemoCreateReqVO createReqVO) { | |
| 36 | + // 插入 | |
| 37 | + ToolTestDemoDO testDemo = ToolTestDemoConvert.INSTANCE.convert(createReqVO); | |
| 38 | + testDemoMapper.insert(testDemo); | |
| 39 | + // 返回 | |
| 40 | + return testDemo.getId(); | |
| 41 | + } | |
| 42 | + | |
| 43 | + @Override | |
| 44 | + public void updateTestDemo(ToolTestDemoUpdateReqVO updateReqVO) { | |
| 45 | + // 校验存在 | |
| 46 | + this.validateTestDemoExists(updateReqVO.getId()); | |
| 47 | + // 更新 | |
| 48 | + ToolTestDemoDO updateObj = ToolTestDemoConvert.INSTANCE.convert(updateReqVO); | |
| 49 | + testDemoMapper.updateById(updateObj); | |
| 50 | + } | |
| 51 | + | |
| 52 | + @Override | |
| 53 | + public void deleteTestDemo(Long id) { | |
| 54 | + // 校验存在 | |
| 55 | + this.validateTestDemoExists(id); | |
| 56 | + // 更新 | |
| 57 | + testDemoMapper.deleteById(id); | |
| 58 | + } | |
| 59 | + | |
| 60 | + private void validateTestDemoExists(Long id) { | |
| 61 | + if (testDemoMapper.selectById(id) == null) { | |
| 62 | + throw ServiceExceptionUtil.exception(TEST_DEMO_NOT_EXISTS); | |
| 63 | + } | |
| 64 | + } | |
| 65 | + | |
| 66 | + @Override | |
| 67 | + public ToolTestDemoDO getTestDemo(Long id) { | |
| 68 | + return testDemoMapper.selectById(id); | |
| 69 | + } | |
| 70 | + | |
| 71 | + @Override | |
| 72 | + public List<ToolTestDemoDO> getTestDemoList(Collection<Long> ids) { | |
| 73 | + return testDemoMapper.selectBatchIds(ids); | |
| 74 | + } | |
| 75 | + | |
| 76 | + @Override | |
| 77 | + public PageResult<ToolTestDemoDO> getTestDemoPage(ToolTestDemoPageReqVO pageReqVO) { | |
| 78 | + return testDemoMapper.selectPage(pageReqVO); | |
| 79 | + } | |
| 80 | + | |
| 81 | + @Override | |
| 82 | + public List<ToolTestDemoDO> getTestDemoList(ToolTestDemoExportReqVO exportReqVO) { | |
| 83 | + return testDemoMapper.selectList(exportReqVO); | |
| 84 | + } | |
| 85 | + | |
| 86 | +} | ... | ... |
src/main/resources/codegen/java/controller/controller.vm
| ... | ... | @@ -8,12 +8,16 @@ import io.swagger.annotations.*; |
| 8 | 8 | |
| 9 | 9 | import javax.validation.constraints.*; |
| 10 | 10 | import javax.validation.*; |
| 11 | +import javax.servlet.http.*; | |
| 11 | 12 | import java.util.*; |
| 13 | +import java.io.IOException; | |
| 12 | 14 | |
| 13 | 15 | import ${PageResultClassName}; |
| 14 | 16 | import ${CommonResultClassName}; |
| 15 | 17 | import static ${CommonResultClassName}.success; |
| 16 | 18 | |
| 19 | +import ${ExcelUtilsClassName}; | |
| 20 | + | |
| 17 | 21 | import ${basePackage}.${table.moduleName}.controller.${table.businessName}.vo.*; |
| 18 | 22 | import ${basePackage}.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; |
| 19 | 23 | import ${basePackage}.${table.moduleName}.convert.${table.businessName}.${table.className}Convert; |
| ... | ... | @@ -73,6 +77,14 @@ public class ${table.className}Controller { |
| 73 | 77 | return success(${table.className}Convert.INSTANCE.convertPage(pageResult)); |
| 74 | 78 | } |
| 75 | 79 | |
| 76 | - | |
| 80 | + @GetMapping("/export-excel") | |
| 81 | + @ApiOperation("导出${table.classComment} Excel") | |
| 82 | + public void export${simpleClassName}Excel(@Valid ${table.className}ExportReqVO exportReqVO, | |
| 83 | + HttpServletResponse response) throws IOException { | |
| 84 | + List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(exportReqVO); | |
| 85 | + // 导出 Excel | |
| 86 | + List<${table.className}ExcelVO> datas = ${table.className}Convert.INSTANCE.convertList02(list); | |
| 87 | + ExcelUtils.write(response, "${table.classComment}.xls", "数据", ${table.className}ExcelVO.class, datas); | |
| 88 | + } | |
| 77 | 89 | |
| 78 | 90 | } | ... | ... |
src/main/resources/codegen/java/controller/vo/excelRespVO.vm deleted
src/main/resources/codegen/java/controller/vo/excelVO.vm
0 → 100644
| 1 | +package ${basePackage}.${table.moduleName}.controller.${table.businessName}.vo; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | + | |
| 7 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 8 | +#foreach ($column in $columns) | |
| 9 | +#if ("$!column.dictType" != "")## 有设置数据字典 | |
| 10 | +import ${DictFormatClassName}; | |
| 11 | + | |
| 12 | +import static ${SysDictTypeEnumClassName}.*; | |
| 13 | +#break | |
| 14 | +#end | |
| 15 | +#end | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * ${table.classComment} Excel VO | |
| 19 | + * | |
| 20 | + * @author ${table.author} | |
| 21 | + */ | |
| 22 | +@Data | |
| 23 | +public class ${table.className}ExcelVO { | |
| 24 | + | |
| 25 | +#foreach ($column in $columns) | |
| 26 | + #if (${column.listOperationResult})##返回字段 | |
| 27 | + @ExcelProperty("${column.columnComment}") | |
| 28 | + #if ("$!column.dictType" != "")##处理枚举值 | |
| 29 | + @DictFormat(${column.dictType.toUpperCase()}) | |
| 30 | + #end | |
| 31 | + private ${column.javaType} ${column.javaField}; | |
| 32 | + | |
| 33 | + #end | |
| 34 | +#end | |
| 35 | +} | ... | ... |
src/main/resources/codegen/java/controller/vo/excelReqVO.vm renamed to src/main/resources/codegen/java/controller/vo/exportReqVO.vm
| ... | ... | @@ -6,37 +6,37 @@ import io.swagger.annotations.*; |
| 6 | 6 | import ${PageParamClassName}; |
| 7 | 7 | ## 处理 Date 字段的引入 |
| 8 | 8 | #foreach ($column in $columns) |
| 9 | - #if (${column.listOperation} && ${column.javaType} == "Date")## 时间类型 | |
| 10 | - import org.springframework.format.annotation.DateTimeFormat; | |
| 9 | +#if (${column.listOperation} && ${column.javaType} == "Date")## 时间类型 | |
| 10 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 11 | 11 | |
| 12 | - import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 13 | - #break | |
| 14 | - #end | |
| 12 | +import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 13 | +#break | |
| 14 | +#end | |
| 15 | 15 | #end |
| 16 | 16 | ## 字段模板 |
| 17 | 17 | #macro(columnTpl $prefix $prefixStr) |
| 18 | - #if (${column.javaType} == "Date")## 时间类型 | |
| 19 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 20 | - #end | |
| 21 | -@ApiModelProperty(value = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) | |
| 22 | -private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end; | |
| 18 | +#if (${column.javaType} == "Date")## 时间类型 | |
| 19 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 20 | +#end | |
| 21 | + @ApiModelProperty(value = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) | |
| 22 | + private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end; | |
| 23 | 23 | #end |
| 24 | 24 | |
| 25 | 25 | @ApiModel(value = "${table.classComment} Excel 导出 Request VO", description = "参数和 ${table.className}PageReqVO 是一致的") |
| 26 | 26 | @Data |
| 27 | -public class ${table.className}ExcelReqVO { | |
| 27 | +public class ${table.className}ExportReqVO { | |
| 28 | 28 | |
| 29 | 29 | #foreach ($column in $columns) |
| 30 | - #set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写 | |
| 31 | - #if (${column.listOperation})##查询操作 | |
| 32 | - #if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候 | |
| 33 | - #columnTpl('begin', '开始') | |
| 30 | +#set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写 | |
| 31 | +#if (${column.listOperation})##查询操作 | |
| 32 | +#if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候 | |
| 33 | + #columnTpl('begin', '开始') | |
| 34 | 34 | |
| 35 | - #columnTpl('end', '结束') | |
| 36 | - #else##情况二,非 Between 的时间 | |
| 37 | - #columnTpl('', '') | |
| 38 | - #end | |
| 35 | + #columnTpl('end', '结束') | |
| 36 | +#else##情况二,非 Between 的时间 | |
| 37 | + #columnTpl('', '') | |
| 38 | +#end | |
| 39 | 39 | |
| 40 | - #end | |
| 40 | +#end | |
| 41 | 41 | #end |
| 42 | 42 | } | ... | ... |
src/main/resources/codegen/java/convert/convert.vm
| ... | ... | @@ -10,10 +10,10 @@ import ${basePackage}.${table.moduleName}.controller.${table.businessName}.vo.*; |
| 10 | 10 | import ${basePackage}.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; |
| 11 | 11 | |
| 12 | 12 | /** |
| 13 | -* ${table.classComment} Convert | |
| 14 | -* | |
| 15 | -* @author ${table.author} | |
| 16 | -*/ | |
| 13 | + * ${table.classComment} Convert | |
| 14 | + * | |
| 15 | + * @author ${table.author} | |
| 16 | + */ | |
| 17 | 17 | @Mapper |
| 18 | 18 | public interface ${table.className}Convert { |
| 19 | 19 | |
| ... | ... | @@ -29,4 +29,6 @@ public interface ${table.className}Convert { |
| 29 | 29 | |
| 30 | 30 | PageResult<${table.className}RespVO> convertPage(PageResult<${table.className}DO> page); |
| 31 | 31 | |
| 32 | + List<${table.className}ExcelVO> convertList02(List<${table.className}DO> list); | |
| 33 | + | |
| 32 | 34 | } | ... | ... |
src/main/resources/codegen/java/dal/do.vm
| ... | ... | @@ -6,10 +6,10 @@ import com.baomidou.mybatisplus.annotation.*; |
| 6 | 6 | import ${BaseDOClassName}; |
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | -* ${table.classComment} DO | |
| 10 | -* | |
| 11 | -* @author ${table.author} | |
| 12 | -*/ | |
| 9 | + * ${table.classComment} DO | |
| 10 | + * | |
| 11 | + * @author ${table.author} | |
| 12 | + */ | |
| 13 | 13 | @TableName("${table.tableName}") |
| 14 | 14 | @Data |
| 15 | 15 | @EqualsAndHashCode(callSuper = true) | ... | ... |
src/main/resources/codegen/java/dal/mapper.vm
| 1 | 1 | package ${basePackage}.${table.moduleName}.dal.mysql.${table.businessName}; |
| 2 | 2 | |
| 3 | +import java.util.*; | |
| 4 | + | |
| 3 | 5 | import ${PageResultClassName}; |
| 4 | 6 | import ${QueryWrapperClassName}; |
| 5 | 7 | import ${BaseMapperClassName}; |
| 6 | 8 | import ${basePackage}.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; |
| 7 | 9 | import org.apache.ibatis.annotations.Mapper; |
| 8 | -import ${basePackage}.${table.moduleName}.controller.${table.businessName}.vo.${table.className}PageReqVO; | |
| 9 | - | |
| 10 | -/** | |
| 11 | -* ${table.classComment} Mapper | |
| 12 | -* | |
| 13 | -* @author ${table.author} | |
| 14 | -*/ | |
| 15 | -@Mapper | |
| 16 | -public interface ${table.className}Mapper extends BaseMapperX<${table.className}DO> { | |
| 10 | +import ${basePackage}.${table.moduleName}.controller.${table.businessName}.vo.*; | |
| 17 | 11 | |
| 18 | - default PageResult<${table.className}DO> selectPage(${table.className}PageReqVO reqVO) { | |
| 19 | - return selectPage(reqVO, new QueryWrapperX<${table.className}DO>() | |
| 12 | +## 字段模板 | |
| 13 | +#macro(listCondition) | |
| 20 | 14 | #foreach ($column in $columns) |
| 21 | 15 | #if (${column.listOperation}) |
| 22 | 16 | #set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写 |
| 23 | 17 | #if (${column.listOperationCondition} == "=")##情况一,= 的时候 |
| 24 | - .eqIfPresent("${column.columnName}", reqVO.get${JavaField}()) | |
| 18 | + .eqIfPresent("${column.columnName}", reqVO.get${JavaField}()) | |
| 25 | 19 | #end |
| 26 | 20 | #if (${column.listOperationCondition} == "!=")##情况二,!= 的时候 |
| 27 | - .neIfPresent("${column.columnName}", reqVO.get${JavaField}()) | |
| 21 | + .neIfPresent("${column.columnName}", reqVO.get${JavaField}()) | |
| 28 | 22 | #end |
| 29 | 23 | #if (${column.listOperationCondition} == ">")##情况三,> 的时候 |
| 30 | - .gtIfPresent("${column.columnName}", reqVO.get${JavaField}()) | |
| 24 | + .gtIfPresent("${column.columnName}", reqVO.get${JavaField}()) | |
| 31 | 25 | #end |
| 32 | 26 | #if (${column.listOperationCondition} == ">=")##情况四,>= 的时候 |
| 33 | - .geIfPresent("${column.columnName}", reqVO.get${JavaField}()) | |
| 27 | + .geIfPresent("${column.columnName}", reqVO.get${JavaField}()) | |
| 34 | 28 | #end |
| 35 | 29 | #if (${column.listOperationCondition} == "<")##情况五,< 的时候 |
| 36 | - .gtIfPresent("${column.columnName}", reqVO.get${JavaField}()) | |
| 30 | + .gtIfPresent("${column.columnName}", reqVO.get${JavaField}()) | |
| 37 | 31 | #end |
| 38 | 32 | #if (${column.listOperationCondition} == "LIKE")##情况七,Like 的时候 |
| 39 | - .likeIfPresent("${column.columnName}", reqVO.get${JavaField}()) | |
| 33 | + .likeIfPresent("${column.columnName}", reqVO.get${JavaField}()) | |
| 40 | 34 | #end |
| 41 | 35 | #if (${column.listOperationCondition} == "BETWEEN")##情况八,Between 的时候 |
| 42 | - .betweenIfPresent("${column.columnName}", reqVO.getBegin${JavaField}(), reqVO.getEnd${JavaField}()) | |
| 36 | + .betweenIfPresent("${column.columnName}", reqVO.getBegin${JavaField}(), reqVO.getEnd${JavaField}()) | |
| 43 | 37 | #end |
| 44 | 38 | #end |
| 45 | 39 | #end |
| 40 | +#end | |
| 41 | +/** | |
| 42 | + * ${table.classComment} Mapper | |
| 43 | + * | |
| 44 | + * @author ${table.author} | |
| 45 | + */ | |
| 46 | +@Mapper | |
| 47 | +public interface ${table.className}Mapper extends BaseMapperX<${table.className}DO> { | |
| 48 | + | |
| 49 | + default PageResult<${table.className}DO> selectPage(${table.className}PageReqVO reqVO) { | |
| 50 | + return selectPage(reqVO, new QueryWrapperX<${table.className}DO>() | |
| 51 | + #listCondition() | |
| 52 | + ); | |
| 53 | + } | |
| 54 | + | |
| 55 | + default List<${table.className}DO> selectList(${table.className}ExportReqVO reqVO) { | |
| 56 | + return selectList(new QueryWrapperX<${table.className}DO>() | |
| 57 | + #listCondition() | |
| 46 | 58 | ); |
| 47 | 59 | } |
| 48 | 60 | ... | ... |
src/main/resources/codegen/java/enums/errorcode.vm
| 1 | 1 | // ========== ${table.classComment} TODO 补充编号 ========== |
| 2 | -ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS = new ErrorCode(TODO 补充编号, "${table.classComment}不存在}"); | |
| 2 | +ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS = new ErrorCode(TODO 补充编号, "${table.classComment}不存在"); | ... | ... |
src/main/resources/codegen/java/service/service.vm
| ... | ... | @@ -7,10 +7,10 @@ import ${basePackage}.${table.moduleName}.dal.dataobject.${table.businessName}.$ |
| 7 | 7 | import ${PageResultClassName}; |
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | -* ${table.classComment} Service 接口 | |
| 11 | -* | |
| 12 | -* @author ${table.author} | |
| 13 | -*/ | |
| 10 | + * ${table.classComment} Service 接口 | |
| 11 | + * | |
| 12 | + * @author ${table.author} | |
| 13 | + */ | |
| 14 | 14 | public interface ${table.className}Service { |
| 15 | 15 | |
| 16 | 16 | /** |
| ... | ... | @@ -59,4 +59,12 @@ public interface ${table.className}Service { |
| 59 | 59 | */ |
| 60 | 60 | PageResult<${table.className}DO> get${simpleClassName}Page(${table.className}PageReqVO pageReqVO); |
| 61 | 61 | |
| 62 | + /** | |
| 63 | + * 获得${table.classComment}列表, 用于 Excel 导出 | |
| 64 | + * | |
| 65 | + * @param exportReqVO 查询条件 | |
| 66 | + * @return ${table.classComment}分页 | |
| 67 | + */ | |
| 68 | + List<${table.className}DO> get${simpleClassName}List(${table.className}ExportReqVO exportReqVO); | |
| 69 | + | |
| 62 | 70 | } | ... | ... |
src/main/resources/codegen/java/service/serviceImpl.vm
| ... | ... | @@ -19,10 +19,10 @@ import ${ServiceExceptionUtilClassName}; |
| 19 | 19 | import static ${basePackage}.${table.moduleName}.enums.${simpleModuleName_upperFirst}ErrorCodeConstants.*; |
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | -* ${table.classComment} Service 实现类 | |
| 23 | -* | |
| 24 | -* @author ${table.author} | |
| 25 | -*/ | |
| 22 | + * ${table.classComment} Service 实现类 | |
| 23 | + * | |
| 24 | + * @author ${table.author} | |
| 25 | + */ | |
| 26 | 26 | @Service |
| 27 | 27 | @Validated |
| 28 | 28 | public class ${table.className}ServiceImpl implements ${table.className}Service { |
| ... | ... | @@ -77,4 +77,9 @@ public class ${table.className}ServiceImpl implements ${table.className}Service |
| 77 | 77 | return ${classNameVar}Mapper.selectPage(pageReqVO); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | + @Override | |
| 81 | + public List<${table.className}DO> get${simpleClassName}List(${table.className}ExportReqVO exportReqVO) { | |
| 82 | + return ${classNameVar}Mapper.selectList(exportReqVO); | |
| 83 | + } | |
| 84 | + | |
| 80 | 85 | } | ... | ... |