Commit 392dfa47c37d00752e10483fd77e05a424e3500d
1 parent
ab09b7c6
代码生成器,增加 businessPackage 字段,用于将多个模块进行归类
Showing
25 changed files
with
144 additions
and
449 deletions
ruoyi-ui/src/views/tool/gen/genInfoForm.vue
| @@ -52,6 +52,18 @@ | @@ -52,6 +52,18 @@ | ||
| 52 | </el-col> | 52 | </el-col> |
| 53 | 53 | ||
| 54 | <el-col :span="12"> | 54 | <el-col :span="12"> |
| 55 | + <el-form-item prop="businessPackage"> | ||
| 56 | + <span slot="label"> | ||
| 57 | + 业务包 | ||
| 58 | + <el-tooltip content="业务包,自定义二级目录。例如说,我们希望将 dictType 和 dictData 归类成 dict 业务" placement="top"> | ||
| 59 | + <i class="el-icon-question"></i> | ||
| 60 | + </el-tooltip> | ||
| 61 | + </span> | ||
| 62 | + <el-input v-model="info.businessPackage" /> | ||
| 63 | + </el-form-item> | ||
| 64 | + </el-col> | ||
| 65 | + | ||
| 66 | + <el-col :span="12"> | ||
| 55 | <el-form-item prop="className"> | 67 | <el-form-item prop="className"> |
| 56 | <span slot="label"> | 68 | <span slot="label"> |
| 57 | 类名称 | 69 | 类名称 |
| @@ -252,6 +264,9 @@ export default { | @@ -252,6 +264,9 @@ export default { | ||
| 252 | businessName: [ | 264 | businessName: [ |
| 253 | { required: true, message: "请输入生成业务名", trigger: "blur" } | 265 | { required: true, message: "请输入生成业务名", trigger: "blur" } |
| 254 | ], | 266 | ], |
| 267 | + businessPackage: [ | ||
| 268 | + { required: true, message: "请输入生成业务包", trigger: "blur" } | ||
| 269 | + ], | ||
| 255 | className: [ | 270 | className: [ |
| 256 | { required: true, message: "请输入生成类名称", trigger: "blur" } | 271 | { required: true, message: "请输入生成类名称", trigger: "blur" } |
| 257 | ], | 272 | ], |
src/main/java/cn/iocoder/dashboard/modules/system/controller/test/SysTestDemoController.java deleted
| 1 | -package cn.iocoder.dashboard.modules.system.controller.test; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.dashboard.common.pojo.CommonResult; | ||
| 4 | -import cn.iocoder.dashboard.common.pojo.PageResult; | ||
| 5 | -import cn.iocoder.dashboard.modules.system.controller.test.vo.SysTestDemoCreateReqVO; | ||
| 6 | -import cn.iocoder.dashboard.modules.system.controller.test.vo.SysTestDemoPageReqVO; | ||
| 7 | -import cn.iocoder.dashboard.modules.system.controller.test.vo.SysTestDemoRespVO; | ||
| 8 | -import cn.iocoder.dashboard.modules.system.controller.test.vo.SysTestDemoUpdateReqVO; | ||
| 9 | -import cn.iocoder.dashboard.modules.system.convert.test.SysTestDemoConvert; | ||
| 10 | -import cn.iocoder.dashboard.modules.system.dal.dataobject.test.SysTestDemoDO; | ||
| 11 | -import cn.iocoder.dashboard.modules.system.service.test.SysTestDemoService; | ||
| 12 | -import io.swagger.annotations.Api; | ||
| 13 | -import io.swagger.annotations.ApiImplicitParam; | ||
| 14 | -import io.swagger.annotations.ApiOperation; | ||
| 15 | -import org.springframework.validation.annotation.Validated; | ||
| 16 | -import org.springframework.web.bind.annotation.*; | ||
| 17 | - | ||
| 18 | -import javax.annotation.Resource; | ||
| 19 | -import javax.validation.Valid; | ||
| 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("/system/test-demo") | ||
| 28 | -@Validated | ||
| 29 | -public class SysTestDemoController { | ||
| 30 | - | ||
| 31 | - @Resource | ||
| 32 | - private SysTestDemoService testDemoService; | ||
| 33 | - | ||
| 34 | - @ApiOperation("创建字典类型") | ||
| 35 | - @PostMapping("/create") | ||
| 36 | - public CommonResult<Long> createTestDemo(@Valid SysTestDemoCreateReqVO createReqVO) { | ||
| 37 | - return success(testDemoService.createTestDemo(createReqVO)); | ||
| 38 | - } | ||
| 39 | - | ||
| 40 | - @ApiOperation("更新字典类型") | ||
| 41 | - @PutMapping("/update") | ||
| 42 | - public CommonResult<Boolean> updateTestDemo(@Valid SysTestDemoUpdateReqVO 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) | ||
| 58 | - public CommonResult<SysTestDemoRespVO> getTestDemo(@RequestParam("id") Long id) { | ||
| 59 | - SysTestDemoDO testDemo = testDemoService.getTestDemo(id); | ||
| 60 | - return success(SysTestDemoConvert.INSTANCE.convert(testDemo)); | ||
| 61 | - } | ||
| 62 | - | ||
| 63 | - @GetMapping("/list") | ||
| 64 | - @ApiOperation("获得字典类型列表") | ||
| 65 | - @ApiImplicitParam(name = "ids", value = "编号列表", required = true) | ||
| 66 | - public CommonResult<List<SysTestDemoRespVO>> getTestDemoList(@RequestParam("ids") Collection<Long> ids) { | ||
| 67 | - List<SysTestDemoDO> list = testDemoService.getTestDemoList(ids); | ||
| 68 | - return success(SysTestDemoConvert.INSTANCE.convertList(list)); | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | - @ApiOperation("获得字典类型分页") | ||
| 72 | - @GetMapping("/page") | ||
| 73 | - public CommonResult<PageResult<SysTestDemoRespVO>> getTestDemoPage(@Valid SysTestDemoPageReqVO pageVO) { | ||
| 74 | - PageResult<SysTestDemoDO> pageResult = testDemoService.getTestDemoPage(pageVO); | ||
| 75 | - return success(SysTestDemoConvert.INSTANCE.convertPage(pageResult)); | ||
| 76 | - } | ||
| 77 | - | ||
| 78 | -} |
src/main/java/cn/iocoder/dashboard/modules/system/controller/test/package-info.java deleted
| 1 | -package cn.iocoder.dashboard.modules.system.controller.test; |
src/main/java/cn/iocoder/dashboard/modules/system/controller/test/vo/SysTestDemoBaseVO.java deleted
| 1 | -package cn.iocoder.dashboard.modules.system.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 SysTestDemoBaseVO { | ||
| 14 | - | ||
| 15 | - @ApiModelProperty(value = "字典名称", required = true, example = "性别额") | ||
| 16 | - @NotNull(message = "字典名称不能为空") | ||
| 17 | - private String name; | ||
| 18 | - | ||
| 19 | - @ApiModelProperty(value = "字典类型", required = true, example = "sys_sex") | ||
| 20 | - @NotNull(message = "字典类型不能为空") | ||
| 21 | - private String dictType; | ||
| 22 | - | ||
| 23 | - @ApiModelProperty(value = "状态", required = true, example = "1") | ||
| 24 | - @NotNull(message = "状态不能为空") | ||
| 25 | - private Integer status; | ||
| 26 | - | ||
| 27 | - @ApiModelProperty(value = "备注", example = "我是备注") | ||
| 28 | - private String remark; | ||
| 29 | - | ||
| 30 | -} |
src/main/java/cn/iocoder/dashboard/modules/system/controller/test/vo/SysTestDemoCreateReqVO.java deleted
| 1 | -package cn.iocoder.dashboard.modules.system.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 SysTestDemoCreateReqVO extends SysTestDemoBaseVO { | ||
| 13 | - | ||
| 14 | -} |
src/main/java/cn/iocoder/dashboard/modules/system/controller/test/vo/SysTestDemoPageReqVO.java deleted
| 1 | -package cn.iocoder.dashboard.modules.system.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 SysTestDemoPageReqVO extends PageParam { | ||
| 20 | - | ||
| 21 | - @ApiModelProperty(value = "字典名称", example = "性别额") | ||
| 22 | - private String name; | ||
| 23 | - | ||
| 24 | - @ApiModelProperty(value = "字典类型", example = "sys_sex") | ||
| 25 | - private String dictType; | ||
| 26 | - | ||
| 27 | - @ApiModelProperty(value = "状态", example = "1") | ||
| 28 | - private Integer status; | ||
| 29 | - | ||
| 30 | - @ApiModelProperty(value = "备注", example = "我是备注") | ||
| 31 | - private String remark; | ||
| 32 | - | ||
| 33 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 34 | - @ApiModelProperty(value = "开始创建时间") | ||
| 35 | - private Date beginCreateTime; | ||
| 36 | - | ||
| 37 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 38 | - @ApiModelProperty(value = "结束创建时间") | ||
| 39 | - private Date endCreateTime; | ||
| 40 | - | ||
| 41 | -} |
src/main/java/cn/iocoder/dashboard/modules/system/controller/test/vo/SysTestDemoRespVO.java deleted
| 1 | -package cn.iocoder.dashboard.modules.system.controller.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 SysTestDemoRespVO extends SysTestDemoBaseVO { | ||
| 12 | - | ||
| 13 | - @ApiModelProperty(value = "字典主键", required = true, example = "1") | ||
| 14 | - private Long id; | ||
| 15 | - | ||
| 16 | - @ApiModelProperty(value = "创建时间", required = true) | ||
| 17 | - private Date createTime; | ||
| 18 | - | ||
| 19 | -} |
src/main/java/cn/iocoder/dashboard/modules/system/controller/test/vo/SysTestDemoUpdateReqVO.java deleted
| 1 | -package cn.iocoder.dashboard.modules.system.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 SysTestDemoUpdateReqVO extends SysTestDemoBaseVO { | ||
| 16 | - | ||
| 17 | - @ApiModelProperty(value = "字典主键", required = true, example = "1") | ||
| 18 | - @NotNull(message = "字典主键不能为空") | ||
| 19 | - private Long id; | ||
| 20 | - | ||
| 21 | -} |
src/main/java/cn/iocoder/dashboard/modules/system/controller/user/SysUserController.java
| @@ -124,7 +124,8 @@ public class SysUserController { | @@ -124,7 +124,8 @@ public class SysUserController { | ||
| 124 | @GetMapping("/export") | 124 | @GetMapping("/export") |
| 125 | // @PreAuthorize("@ss.hasPermi('system:user:export')") , @Validated SysUserExportReqVO reqVO | 125 | // @PreAuthorize("@ss.hasPermi('system:user:export')") , @Validated SysUserExportReqVO reqVO |
| 126 | // @Log(title = "用户管理", businessType = BusinessType.EXPORT) | 126 | // @Log(title = "用户管理", businessType = BusinessType.EXPORT) |
| 127 | - public void exportUsers(HttpServletResponse response, @Validated SysUserExportReqVO reqVO) throws IOException { | 127 | + public void exportUsers(@Validated SysUserExportReqVO reqVO, |
| 128 | + HttpServletResponse response) throws IOException { | ||
| 128 | // 获得用户列表 | 129 | // 获得用户列表 |
| 129 | List<SysUserDO> users = userService.listUsers(reqVO); | 130 | List<SysUserDO> users = userService.listUsers(reqVO); |
| 130 | 131 | ||
| @@ -143,8 +144,7 @@ public class SysUserController { | @@ -143,8 +144,7 @@ public class SysUserController { | ||
| 143 | }); | 144 | }); |
| 144 | 145 | ||
| 145 | // 输出 | 146 | // 输出 |
| 146 | - ExcelUtils.write(response, "用户数据.xls", "用户列表", | ||
| 147 | - SysUserExcelVO.class, excelUsers); | 147 | + ExcelUtils.write(response, "用户数据.xls", "用户列表", SysUserExcelVO.class, excelUsers); |
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | @ApiOperation("获得导入用户模板") | 150 | @ApiOperation("获得导入用户模板") |
src/main/java/cn/iocoder/dashboard/modules/system/dal/dataobject/notice/SysNoticeDO.java
src/main/java/cn/iocoder/dashboard/modules/system/dal/dataobject/test/SysTestDemoDO.java deleted
| 1 | -package cn.iocoder.dashboard.modules.system.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("sys_test_demo") | ||
| 14 | -@Data | ||
| 15 | -@EqualsAndHashCode(callSuper = true) | ||
| 16 | -@ToString(callSuper = true) | ||
| 17 | -@Builder | ||
| 18 | -@NoArgsConstructor | ||
| 19 | -@AllArgsConstructor | ||
| 20 | -public class SysTestDemoDO extends BaseDO { | ||
| 21 | - | ||
| 22 | - /** | ||
| 23 | - * 字典主键 | ||
| 24 | - */ | ||
| 25 | - @TableId | ||
| 26 | - private Long id; | ||
| 27 | - /** | ||
| 28 | - * 字典名称 | ||
| 29 | - */ | ||
| 30 | - private String name; | ||
| 31 | - /** | ||
| 32 | - * 字典类型 | ||
| 33 | - */ | ||
| 34 | - private String dictType; | ||
| 35 | - /** | ||
| 36 | - * 状态 | ||
| 37 | - */ | ||
| 38 | - private Integer status; | ||
| 39 | - /** | ||
| 40 | - * 备注 | ||
| 41 | - */ | ||
| 42 | - private String remark; | ||
| 43 | - | ||
| 44 | -} |
src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/test/SysTestDemoMapper.java deleted
| 1 | -package cn.iocoder.dashboard.modules.system.dal.mysql.test; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.dashboard.common.pojo.PageResult; | ||
| 4 | -import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX; | ||
| 5 | -import cn.iocoder.dashboard.framework.mybatis.core.mapper.BaseMapperX; | ||
| 6 | -import cn.iocoder.dashboard.modules.system.dal.dataobject.test.SysTestDemoDO; | ||
| 7 | -import org.apache.ibatis.annotations.Mapper; | ||
| 8 | -import cn.iocoder.dashboard.modules.system.controller.test.vo.SysTestDemoPageReqVO; | ||
| 9 | - | ||
| 10 | -/** | ||
| 11 | -* 字典类型 Mapper | ||
| 12 | -* | ||
| 13 | -* @author 芋艿 | ||
| 14 | -*/ | ||
| 15 | -@Mapper | ||
| 16 | -public interface SysTestDemoMapper extends BaseMapperX<SysTestDemoDO> { | ||
| 17 | - | ||
| 18 | - default PageResult<SysTestDemoDO> selectPage(SysTestDemoPageReqVO reqVO) { | ||
| 19 | - return selectPage(reqVO, new QueryWrapperX<SysTestDemoDO>() | ||
| 20 | - .likeIfPresent("name", reqVO.getName()) | ||
| 21 | - .eqIfPresent("dict_type", reqVO.getDictType()) | ||
| 22 | - .eqIfPresent("status", reqVO.getStatus()) | ||
| 23 | - .eqIfPresent("remark", reqVO.getRemark()) | ||
| 24 | - .betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | ||
| 25 | - ); | ||
| 26 | - } | ||
| 27 | - | ||
| 28 | -} |
src/main/java/cn/iocoder/dashboard/modules/system/service/test/SysTestDemoService.java deleted
| 1 | -package cn.iocoder.dashboard.modules.system.service.test; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.dashboard.common.pojo.PageResult; | ||
| 4 | -import cn.iocoder.dashboard.modules.system.controller.test.vo.SysTestDemoCreateReqVO; | ||
| 5 | -import cn.iocoder.dashboard.modules.system.controller.test.vo.SysTestDemoPageReqVO; | ||
| 6 | -import cn.iocoder.dashboard.modules.system.controller.test.vo.SysTestDemoUpdateReqVO; | ||
| 7 | -import cn.iocoder.dashboard.modules.system.dal.dataobject.test.SysTestDemoDO; | ||
| 8 | - | ||
| 9 | -import javax.validation.Valid; | ||
| 10 | -import java.util.Collection; | ||
| 11 | -import java.util.List; | ||
| 12 | - | ||
| 13 | -/** | ||
| 14 | -* 字典类型 Service 接口 | ||
| 15 | -* | ||
| 16 | -* @author 芋艿 | ||
| 17 | -*/ | ||
| 18 | -public interface SysTestDemoService { | ||
| 19 | - | ||
| 20 | - /** | ||
| 21 | - * 创建字典类型 | ||
| 22 | - * | ||
| 23 | - * @param createReqVO 创建信息 | ||
| 24 | - * @return 编号 | ||
| 25 | - */ | ||
| 26 | - Long createTestDemo(@Valid SysTestDemoCreateReqVO createReqVO); | ||
| 27 | - | ||
| 28 | - /** | ||
| 29 | - * 更新字典类型 | ||
| 30 | - * | ||
| 31 | - * @param updateReqVO 更新信息 | ||
| 32 | - */ | ||
| 33 | - void updateTestDemo(@Valid SysTestDemoUpdateReqVO updateReqVO); | ||
| 34 | - | ||
| 35 | - /** | ||
| 36 | - * 删除字典类型 | ||
| 37 | - * | ||
| 38 | - * @param id 编号 | ||
| 39 | - */ | ||
| 40 | - void deleteTestDemo(Long id); | ||
| 41 | - | ||
| 42 | - /** | ||
| 43 | - * 获得字典类型 | ||
| 44 | - * | ||
| 45 | - * @param id 编号 | ||
| 46 | - * @return 字典类型 | ||
| 47 | - */ | ||
| 48 | - SysTestDemoDO getTestDemo(Long id); | ||
| 49 | - | ||
| 50 | - /** | ||
| 51 | - * 获得字典类型列表 | ||
| 52 | - * | ||
| 53 | - * @param ids 编号 | ||
| 54 | - * @return 字典类型列表 | ||
| 55 | - */ | ||
| 56 | - List<SysTestDemoDO> getTestDemoList(Collection<Long> ids); | ||
| 57 | - | ||
| 58 | - /** | ||
| 59 | - * 获得字典类型分页 | ||
| 60 | - * | ||
| 61 | - * @param pageReqVO 分页查询 | ||
| 62 | - * @return 字典类型分页 | ||
| 63 | - */ | ||
| 64 | - PageResult<SysTestDemoDO> getTestDemoPage(SysTestDemoPageReqVO pageReqVO); | ||
| 65 | - | ||
| 66 | -} |
src/main/java/cn/iocoder/dashboard/modules/system/service/test/impl/SysTestDemoServiceImpl.java deleted
| 1 | -package cn.iocoder.dashboard.modules.system.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.system.controller.test.vo.SysTestDemoCreateReqVO; | ||
| 6 | -import cn.iocoder.dashboard.modules.system.controller.test.vo.SysTestDemoPageReqVO; | ||
| 7 | -import cn.iocoder.dashboard.modules.system.controller.test.vo.SysTestDemoUpdateReqVO; | ||
| 8 | -import cn.iocoder.dashboard.modules.system.convert.test.SysTestDemoConvert; | ||
| 9 | -import cn.iocoder.dashboard.modules.system.dal.mysql.test.SysTestDemoMapper; | ||
| 10 | -import cn.iocoder.dashboard.modules.system.dal.dataobject.test.SysTestDemoDO; | ||
| 11 | -import cn.iocoder.dashboard.modules.system.service.test.SysTestDemoService; | ||
| 12 | -import org.springframework.stereotype.Service; | ||
| 13 | -import org.springframework.validation.annotation.Validated; | ||
| 14 | - | ||
| 15 | -import javax.annotation.Resource; | ||
| 16 | -import java.util.Collection; | ||
| 17 | -import java.util.List; | ||
| 18 | - | ||
| 19 | -import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.TEST_DEMO_NOT_EXISTS; | ||
| 20 | - | ||
| 21 | -/** | ||
| 22 | -* 字典类型 Service 实现类 | ||
| 23 | -* | ||
| 24 | -* @author 芋艿 | ||
| 25 | -*/ | ||
| 26 | -@Service | ||
| 27 | -@Validated | ||
| 28 | -public class SysTestDemoServiceImpl implements SysTestDemoService { | ||
| 29 | - | ||
| 30 | - @Resource | ||
| 31 | - private SysTestDemoMapper testDemoMapper; | ||
| 32 | - | ||
| 33 | - @Override | ||
| 34 | - public Long createTestDemo(SysTestDemoCreateReqVO createReqVO) { | ||
| 35 | - // 插入 | ||
| 36 | - SysTestDemoDO testDemo = SysTestDemoConvert.INSTANCE.convert(createReqVO); | ||
| 37 | - testDemoMapper.insert(testDemo); | ||
| 38 | - // 返回 | ||
| 39 | - return testDemo.getId(); | ||
| 40 | - } | ||
| 41 | - | ||
| 42 | - @Override | ||
| 43 | - public void updateTestDemo(SysTestDemoUpdateReqVO updateReqVO) { | ||
| 44 | - // 校验存在 | ||
| 45 | - this.validateTestDemoExists(updateReqVO.getId()); | ||
| 46 | - // 更新 | ||
| 47 | - SysTestDemoDO updateObj = SysTestDemoConvert.INSTANCE.convert(updateReqVO); | ||
| 48 | - testDemoMapper.updateById(updateObj); | ||
| 49 | - } | ||
| 50 | - | ||
| 51 | - @Override | ||
| 52 | - public void deleteTestDemo(Long id) { | ||
| 53 | - // 校验存在 | ||
| 54 | - this.validateTestDemoExists(id); | ||
| 55 | - // 更新 | ||
| 56 | - testDemoMapper.deleteById(id); | ||
| 57 | - } | ||
| 58 | - | ||
| 59 | - private void validateTestDemoExists(Long id) { | ||
| 60 | - if (testDemoMapper.selectById(id) == null) { | ||
| 61 | - throw ServiceExceptionUtil.exception(TEST_DEMO_NOT_EXISTS); | ||
| 62 | - } | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | - @Override | ||
| 66 | - public SysTestDemoDO getTestDemo(Long id) { | ||
| 67 | - return testDemoMapper.selectById(id); | ||
| 68 | - } | ||
| 69 | - | ||
| 70 | - @Override | ||
| 71 | - public List<SysTestDemoDO> getTestDemoList(Collection<Long> ids) { | ||
| 72 | - return testDemoMapper.selectBatchIds(ids); | ||
| 73 | - } | ||
| 74 | - | ||
| 75 | - @Override | ||
| 76 | - public PageResult<SysTestDemoDO> getTestDemoPage(SysTestDemoPageReqVO pageReqVO) { | ||
| 77 | - return testDemoMapper.selectPage(pageReqVO); | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | -} |
src/main/java/cn/iocoder/dashboard/modules/tool/controller/codegen/vo/table/ToolCodegenTableBaseVO.java
| @@ -31,6 +31,10 @@ public class ToolCodegenTableBaseVO { | @@ -31,6 +31,10 @@ public class ToolCodegenTableBaseVO { | ||
| 31 | @NotNull(message = "业务名不能为空") | 31 | @NotNull(message = "业务名不能为空") |
| 32 | private String businessName; | 32 | private String businessName; |
| 33 | 33 | ||
| 34 | + @ApiModelProperty(value = "业务包", required = true, example = "codegen") | ||
| 35 | + @NotNull(message = "业务包不能为空") | ||
| 36 | + private String businessPackage; | ||
| 37 | + | ||
| 34 | @ApiModelProperty(value = "类名称", required = true, example = "ToolCodegenTable") | 38 | @ApiModelProperty(value = "类名称", required = true, example = "ToolCodegenTable") |
| 35 | @NotNull(message = "类名称不能为空") | 39 | @NotNull(message = "类名称不能为空") |
| 36 | private String className; | 40 | private String className; |
src/main/java/cn/iocoder/dashboard/modules/tool/dal/dataobject/codegen/ToolCodegenTableDO.java
| @@ -53,6 +53,14 @@ public class ToolCodegenTableDO extends BaseDO { | @@ -53,6 +53,14 @@ public class ToolCodegenTableDO extends BaseDO { | ||
| 53 | */ | 53 | */ |
| 54 | private String businessName; | 54 | private String businessName; |
| 55 | /** | 55 | /** |
| 56 | + * 业务包,自定义二级目录 | ||
| 57 | + * | ||
| 58 | + * 例如说,我们希望将 dictType 和 dictData 归类成 dict 业务 | ||
| 59 | + * | ||
| 60 | + * 如果不需要的情况下,businessName 和 businessPackage 是等价的 | ||
| 61 | + */ | ||
| 62 | + private String businessPackage; | ||
| 63 | + /** | ||
| 56 | * 类名称(首字母大写) | 64 | * 类名称(首字母大写) |
| 57 | * | 65 | * |
| 58 | * 例如说,SysUser、SysMenu、SysDictData 等等 | 66 | * 例如说,SysUser、SysMenu、SysDictData 等等 |
src/main/java/cn/iocoder/dashboard/modules/tool/service/codegen/impl/ToolCodegenBuilder.java
| @@ -128,6 +128,7 @@ public class ToolCodegenBuilder { | @@ -128,6 +128,7 @@ public class ToolCodegenBuilder { | ||
| 128 | '_', false))); // 第一个 _ 前缀的前面,作为 module 名字 | 128 | '_', false))); // 第一个 _ 前缀的前面,作为 module 名字 |
| 129 | table.setBusinessName(toCamelCase(subAfter(table.getTableName(), | 129 | table.setBusinessName(toCamelCase(subAfter(table.getTableName(), |
| 130 | '_', false))); // 第一步,第一个 _ 前缀的后面,作为 module 名字; 第二步,可能存在多个 _ 的情况,转换成驼峰 | 130 | '_', false))); // 第一步,第一个 _ 前缀的后面,作为 module 名字; 第二步,可能存在多个 _ 的情况,转换成驼峰 |
| 131 | + table.setBusinessPackage(table.getBusinessPackage()); | ||
| 131 | table.setClassName(upperFirst(toCamelCase(table.getTableName()))); // 驼峰 + 首字母大写 | 132 | table.setClassName(upperFirst(toCamelCase(table.getTableName()))); // 驼峰 + 首字母大写 |
| 132 | table.setClassComment(subBefore(table.getTableComment(), // 去除结尾的表,作为类描述 | 133 | table.setClassComment(subBefore(table.getTableComment(), // 去除结尾的表,作为类描述 |
| 133 | '表', true)); | 134 | '表', true)); |
src/main/resources/codegen/java/controller/controller.vm
| @@ -73,4 +73,6 @@ public class ${table.className}Controller { | @@ -73,4 +73,6 @@ public class ${table.className}Controller { | ||
| 73 | return success(${table.className}Convert.INSTANCE.convertPage(pageResult)); | 73 | return success(${table.className}Convert.INSTANCE.convertPage(pageResult)); |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | + | ||
| 77 | + | ||
| 76 | } | 78 | } |
src/main/resources/codegen/java/controller/vo/excelReqVO.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 | +import ${PageParamClassName}; | ||
| 7 | +## 处理 Date 字段的引入 | ||
| 8 | +#foreach ($column in $columns) | ||
| 9 | + #if (${column.listOperation} && ${column.javaType} == "Date")## 时间类型 | ||
| 10 | + import org.springframework.format.annotation.DateTimeFormat; | ||
| 11 | + | ||
| 12 | + import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 13 | + #break | ||
| 14 | + #end | ||
| 15 | +#end | ||
| 16 | +## 字段模板 | ||
| 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; | ||
| 23 | +#end | ||
| 24 | + | ||
| 25 | +@ApiModel(value = "${table.classComment} Excel 导出 Request VO", description = "参数和 ${table.className}PageReqVO 是一致的") | ||
| 26 | +@Data | ||
| 27 | +public class ${table.className}ExcelReqVO { | ||
| 28 | + | ||
| 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', '开始') | ||
| 34 | + | ||
| 35 | + #columnTpl('end', '结束') | ||
| 36 | + #else##情况二,非 Between 的时间 | ||
| 37 | + #columnTpl('', '') | ||
| 38 | + #end | ||
| 39 | + | ||
| 40 | + #end | ||
| 41 | +#end | ||
| 42 | +} |
src/main/resources/codegen/java/controller/vo/excelRespVO.vm
0 → 100644
src/main/resources/codegen/java/dal/do.vm
| @@ -22,17 +22,15 @@ public class ${table.className}DO extends BaseDO { | @@ -22,17 +22,15 @@ public class ${table.className}DO extends BaseDO { | ||
| 22 | #foreach ($column in $columns) | 22 | #foreach ($column in $columns) |
| 23 | #if (!${baseDOFields.contains(${column.javaField})})##排除 BaseDO 的字段 | 23 | #if (!${baseDOFields.contains(${column.javaField})})##排除 BaseDO 的字段 |
| 24 | /** | 24 | /** |
| 25 | - * ${column.columnComment} | ||
| 26 | - */ | ||
| 27 | -#if ("$!column.dictType" != "")##处理枚举值 | ||
| 28 | - // TODO 枚举 ${column.dictType} | ||
| 29 | -#end | ||
| 30 | -#if (${column.primaryKey} && ${column.javaType} != 'String')##处理主键 + 非 String 的情况 | ||
| 31 | - @TableId | ||
| 32 | -#end | ||
| 33 | -#if (${column.primaryKey} && ${column.javaType} == 'String')##处理主键 + String 的情况 | ||
| 34 | - @TableId(type = IdType.INPUT) | ||
| 35 | -#end | 25 | + * ${column.columnComment} |
| 26 | + #if ("$!column.dictType" != "")##处理枚举值 | ||
| 27 | + * | ||
| 28 | + * 枚举 {@link TODO ${column.dictType} 对应的类} | ||
| 29 | + #end | ||
| 30 | + */ | ||
| 31 | + #if (${column.primaryKey})##处理主键 | ||
| 32 | + @TableId#if (${column.javaType} == 'String')type = IdType.INPUT)#end | ||
| 33 | + #end | ||
| 36 | private ${column.javaType} ${column.javaField}; | 34 | private ${column.javaType} ${column.javaField}; |
| 37 | #end | 35 | #end |
| 38 | #end | 36 | #end |
src/main/resources/codegen/vue/api/api.js.vm
0 → 100644
| 1 | +import request from '@/utils/request' | ||
| 2 | + | ||
| 3 | +// 查询${functionName}列表 | ||
| 4 | +export function list${BusinessName}(query) { | ||
| 5 | + return request({ | ||
| 6 | + url: '/${moduleName}/${businessName}/list', | ||
| 7 | + method: 'get', | ||
| 8 | + params: query | ||
| 9 | + }) | ||
| 10 | +} | ||
| 11 | + | ||
| 12 | +// 查询${functionName}详细 | ||
| 13 | +export function get${BusinessName}(${pkColumn.javaField}) { | ||
| 14 | + return request({ | ||
| 15 | + url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, | ||
| 16 | + method: 'get' | ||
| 17 | + }) | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +// 新增${functionName} | ||
| 21 | +export function add${BusinessName}(data) { | ||
| 22 | + return request({ | ||
| 23 | + url: '/${moduleName}/${businessName}', | ||
| 24 | + method: 'post', | ||
| 25 | + data: data | ||
| 26 | + }) | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +// 修改${functionName} | ||
| 30 | +export function update${BusinessName}(data) { | ||
| 31 | + return request({ | ||
| 32 | + url: '/${moduleName}/${businessName}', | ||
| 33 | + method: 'put', | ||
| 34 | + data: data | ||
| 35 | + }) | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +// 删除${functionName} | ||
| 39 | +export function del${BusinessName}(${pkColumn.javaField}) { | ||
| 40 | + return request({ | ||
| 41 | + url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, | ||
| 42 | + method: 'delete' | ||
| 43 | + }) | ||
| 44 | +} | ||
| 45 | + | ||
| 46 | +// 导出${functionName} | ||
| 47 | +export function export${BusinessName}(query) { | ||
| 48 | + return request({ | ||
| 49 | + url: '/${moduleName}/${businessName}/export', | ||
| 50 | + method: 'get', | ||
| 51 | + params: query | ||
| 52 | + }) | ||
| 53 | +} | ||
| 0 | \ No newline at end of file | 54 | \ No newline at end of file |
src/main/resources/codegen/vue/views/index.vue.vm
| @@ -9,8 +9,6 @@ | @@ -9,8 +9,6 @@ | ||
| 9 | #set ($javaField = $column.javaField) | 9 | #set ($javaField = $column.javaField) |
| 10 | #set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) | 10 | #set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
| 11 | #set ($comment=$column.columnComment) | 11 | #set ($comment=$column.columnComment) |
| 12 | - #set ($parentheseIndex=$column.columnComment.indexOf("(")) | ||
| 13 | - #if ($parentheseIndex >= 0) #set($comment=$column.columnComment.substring(0, $parentheseIndex)) #end | ||
| 14 | #if ($column.htmlType == "input") | 12 | #if ($column.htmlType == "input") |
| 15 | <el-form-item label="${comment}" prop="${javaField}"> | 13 | <el-form-item label="${comment}" prop="${javaField}"> |
| 16 | <el-input v-model="queryParams.${javaField}" placeholder="请输入${comment}" clearable size="small" @keyup.enter.native="handleQuery"/> | 14 | <el-input v-model="queryParams.${javaField}" placeholder="请输入${comment}" clearable size="small" @keyup.enter.native="handleQuery"/> |
| @@ -67,8 +65,6 @@ | @@ -67,8 +65,6 @@ | ||
| 67 | #set ($javaField = $column.javaField) | 65 | #set ($javaField = $column.javaField) |
| 68 | #set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) | 66 | #set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
| 69 | #set ($comment=$column.columnComment) | 67 | #set ($comment=$column.columnComment) |
| 70 | - #set ($parentheseIndex=$column.columnComment.indexOf("(")) | ||
| 71 | - #if ($parentheseIndex >= 0) #set($comment=$column.columnComment.substring(0, $parentheseIndex)) #end | ||
| 72 | #if ($column.javaType == "Date")## 时间类型 | 68 | #if ($column.javaType == "Date")## 时间类型 |
| 73 | <el-table-column label="${comment}" align="center" prop="${javaField}" width="180"> | 69 | <el-table-column label="${comment}" align="center" prop="${javaField}" width="180"> |
| 74 | <template slot-scope="scope"> | 70 | <template slot-scope="scope"> |
| @@ -108,8 +104,6 @@ | @@ -108,8 +104,6 @@ | ||
| 108 | #set ($javaField = $column.javaField) | 104 | #set ($javaField = $column.javaField) |
| 109 | #set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) | 105 | #set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
| 110 | #set ($comment = $column.columnComment) | 106 | #set ($comment = $column.columnComment) |
| 111 | - #set ($parentheseIndex = $column.columnComment.indexOf("(")) | ||
| 112 | - #if ($parentheseIndex >= 0) #set($comment = $column.columnComment.substring(0, $parentheseIndex)) #end | ||
| 113 | #if ($column.htmlType == "input") | 107 | #if ($column.htmlType == "input") |
| 114 | #if (!$column.primaryKey)## 忽略主键,不用在表单里 | 108 | #if (!$column.primaryKey)## 忽略主键,不用在表单里 |
| 115 | <el-form-item label="${comment}" prop="${javaField}"> | 109 | <el-form-item label="${comment}" prop="${javaField}"> |
src/test/java/cn/iocoder/dashboard/modules/tool/service/codegen/impl/ToolCodegenEngineTest.java
| 1 | package cn.iocoder.dashboard.modules.tool.service.codegen.impl; | 1 | package cn.iocoder.dashboard.modules.tool.service.codegen.impl; |
| 2 | 2 | ||
| 3 | import cn.iocoder.dashboard.TestApplication; | 3 | import cn.iocoder.dashboard.TestApplication; |
| 4 | -import cn.iocoder.dashboard.modules.tool.dal.mysql.coegen.ToolCodegenColumnMapper; | ||
| 5 | -import cn.iocoder.dashboard.modules.tool.dal.mysql.coegen.ToolCodegenTableMapper; | ||
| 6 | import cn.iocoder.dashboard.modules.tool.dal.dataobject.codegen.ToolCodegenColumnDO; | 4 | import cn.iocoder.dashboard.modules.tool.dal.dataobject.codegen.ToolCodegenColumnDO; |
| 7 | import cn.iocoder.dashboard.modules.tool.dal.dataobject.codegen.ToolCodegenTableDO; | 5 | import cn.iocoder.dashboard.modules.tool.dal.dataobject.codegen.ToolCodegenTableDO; |
| 6 | +import cn.iocoder.dashboard.modules.tool.dal.mysql.coegen.ToolCodegenColumnMapper; | ||
| 7 | +import cn.iocoder.dashboard.modules.tool.dal.mysql.coegen.ToolCodegenTableMapper; | ||
| 8 | import org.junit.jupiter.api.Test; | 8 | import org.junit.jupiter.api.Test; |
| 9 | import org.springframework.boot.test.context.SpringBootTest; | 9 | import org.springframework.boot.test.context.SpringBootTest; |
| 10 | 10 | ||
| @@ -25,10 +25,11 @@ public class ToolCodegenEngineTest { | @@ -25,10 +25,11 @@ public class ToolCodegenEngineTest { | ||
| 25 | 25 | ||
| 26 | @Test | 26 | @Test |
| 27 | public void testExecute() { | 27 | public void testExecute() { |
| 28 | - ToolCodegenTableDO table = codegenTableMapper.selectById(10); | 28 | + ToolCodegenTableDO table = codegenTableMapper.selectById(20); |
| 29 | List<ToolCodegenColumnDO> columns = codegenColumnMapper.selectListByTableId(table.getId()); | 29 | List<ToolCodegenColumnDO> columns = codegenColumnMapper.selectListByTableId(table.getId()); |
| 30 | Map<String, String> result = codegenEngine.execute(table, columns); | 30 | Map<String, String> result = codegenEngine.execute(table, columns); |
| 31 | - System.out.println(result.get("vue/views/system/test/index.vue")); | 31 | + result.forEach((s, s2) -> System.out.println(s2)); |
| 32 | +// System.out.println(result.get("vue/views/system/test/index.vue")); | ||
| 32 | } | 33 | } |
| 33 | 34 | ||
| 34 | } | 35 | } |
src/test/java/cn/iocoder/dashboard/modules/tool/service/codegen/impl/ToolCodegenServiceImplTest.java
| @@ -14,9 +14,9 @@ class ToolCodegenServiceImplTest { | @@ -14,9 +14,9 @@ class ToolCodegenServiceImplTest { | ||
| 14 | 14 | ||
| 15 | @Test | 15 | @Test |
| 16 | public void tetCreateCodegenTable() { | 16 | public void tetCreateCodegenTable() { |
| 17 | -// toolCodegenService.createCodegenTable("sys_test_demo"); | 17 | + toolCodegenService.createCodegen("tool_test_demo"); |
| 18 | // toolCodegenService.createCodegenTable("tool_codegen_table"); | 18 | // toolCodegenService.createCodegenTable("tool_codegen_table"); |
| 19 | - toolCodegenService.createCodegen("tool_codegen_column"); | 19 | +// toolCodegenService.createCodegen("tool_codegen_column"); |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | } | 22 | } |