mirror of
				https://github.com/YunaiV/ruoyi-vue-pro.git
				synced 2025-10-31 18:49:06 +08:00 
			
		
		
		
	代码生成器,增加 businessPackage 字段,用于将多个模块进行归类
This commit is contained in:
		| @ -51,6 +51,18 @@ | ||||
|         </el-form-item> | ||||
|       </el-col> | ||||
|  | ||||
|       <el-col :span="12"> | ||||
|         <el-form-item prop="businessPackage"> | ||||
|           <span slot="label"> | ||||
|             业务包 | ||||
|             <el-tooltip content="业务包,自定义二级目录。例如说,我们希望将 dictType 和 dictData 归类成 dict 业务" placement="top"> | ||||
|               <i class="el-icon-question"></i> | ||||
|             </el-tooltip> | ||||
|           </span> | ||||
|           <el-input v-model="info.businessPackage" /> | ||||
|         </el-form-item> | ||||
|       </el-col> | ||||
|  | ||||
|       <el-col :span="12"> | ||||
|         <el-form-item prop="className"> | ||||
|           <span slot="label"> | ||||
| @ -252,6 +264,9 @@ export default { | ||||
|         businessName: [ | ||||
|           { required: true, message: "请输入生成业务名", trigger: "blur" } | ||||
|         ], | ||||
|         businessPackage: [ | ||||
|           { required: true, message: "请输入生成业务包", trigger: "blur" } | ||||
|         ], | ||||
|         className: [ | ||||
|           { required: true, message: "请输入生成类名称", trigger: "blur" } | ||||
|         ], | ||||
|  | ||||
| @ -1,78 +0,0 @@ | ||||
| package cn.iocoder.dashboard.modules.system.controller.test; | ||||
|  | ||||
| import cn.iocoder.dashboard.common.pojo.CommonResult; | ||||
| import cn.iocoder.dashboard.common.pojo.PageResult; | ||||
| import cn.iocoder.dashboard.modules.system.controller.test.vo.SysTestDemoCreateReqVO; | ||||
| import cn.iocoder.dashboard.modules.system.controller.test.vo.SysTestDemoPageReqVO; | ||||
| import cn.iocoder.dashboard.modules.system.controller.test.vo.SysTestDemoRespVO; | ||||
| import cn.iocoder.dashboard.modules.system.controller.test.vo.SysTestDemoUpdateReqVO; | ||||
| import cn.iocoder.dashboard.modules.system.convert.test.SysTestDemoConvert; | ||||
| import cn.iocoder.dashboard.modules.system.dal.dataobject.test.SysTestDemoDO; | ||||
| import cn.iocoder.dashboard.modules.system.service.test.SysTestDemoService; | ||||
| import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiOperation; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| import javax.annotation.Resource; | ||||
| import javax.validation.Valid; | ||||
| import java.util.Collection; | ||||
| import java.util.List; | ||||
|  | ||||
| import static cn.iocoder.dashboard.common.pojo.CommonResult.success; | ||||
|  | ||||
| @Api(tags = "字典类型") | ||||
| @RestController | ||||
| @RequestMapping("/system/test-demo") | ||||
| @Validated | ||||
| public class SysTestDemoController { | ||||
|  | ||||
|     @Resource | ||||
|     private SysTestDemoService testDemoService; | ||||
|  | ||||
|     @ApiOperation("创建字典类型") | ||||
|     @PostMapping("/create") | ||||
|     public CommonResult<Long> createTestDemo(@Valid SysTestDemoCreateReqVO createReqVO) { | ||||
|         return success(testDemoService.createTestDemo(createReqVO)); | ||||
|     } | ||||
|  | ||||
|     @ApiOperation("更新字典类型") | ||||
|     @PutMapping("/update") | ||||
|     public CommonResult<Boolean> updateTestDemo(@Valid SysTestDemoUpdateReqVO updateReqVO) { | ||||
|         testDemoService.updateTestDemo(updateReqVO); | ||||
|         return success(true); | ||||
|     } | ||||
|  | ||||
| 	@ApiOperation("删除字典类型") | ||||
| 	@DeleteMapping("/delete") | ||||
|     @ApiImplicitParam(name = "id", value = "编号", required = true) | ||||
|     public CommonResult<Boolean> deleteTestDemo(@RequestParam("id") Long id) { | ||||
|         testDemoService.deleteTestDemo(id); | ||||
|         return success(true); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/get") | ||||
|     @ApiOperation("获得字典类型") | ||||
|     @ApiImplicitParam(name = "id", value = "编号", required = true) | ||||
|     public CommonResult<SysTestDemoRespVO> getTestDemo(@RequestParam("id") Long id) { | ||||
|         SysTestDemoDO testDemo = testDemoService.getTestDemo(id); | ||||
|         return success(SysTestDemoConvert.INSTANCE.convert(testDemo)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/list") | ||||
|     @ApiOperation("获得字典类型列表") | ||||
|     @ApiImplicitParam(name = "ids", value = "编号列表", required = true) | ||||
|     public CommonResult<List<SysTestDemoRespVO>> getTestDemoList(@RequestParam("ids") Collection<Long> ids) { | ||||
|         List<SysTestDemoDO> list = testDemoService.getTestDemoList(ids); | ||||
|         return success(SysTestDemoConvert.INSTANCE.convertList(list)); | ||||
|     } | ||||
|  | ||||
|     @ApiOperation("获得字典类型分页") | ||||
|     @GetMapping("/page") | ||||
|     public CommonResult<PageResult<SysTestDemoRespVO>> getTestDemoPage(@Valid SysTestDemoPageReqVO pageVO) { | ||||
|         PageResult<SysTestDemoDO> pageResult = testDemoService.getTestDemoPage(pageVO); | ||||
|         return success(SysTestDemoConvert.INSTANCE.convertPage(pageResult)); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @ -1 +0,0 @@ | ||||
| package cn.iocoder.dashboard.modules.system.controller.test; | ||||
| @ -1,30 +0,0 @@ | ||||
| package cn.iocoder.dashboard.modules.system.controller.test.vo; | ||||
|  | ||||
| import io.swagger.annotations.ApiModelProperty; | ||||
| import lombok.Data; | ||||
|  | ||||
| import javax.validation.constraints.NotNull; | ||||
|  | ||||
| /** | ||||
| * 字典类型 Base VO,提供给添加、修改、详细的子 VO 使用 | ||||
| * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||||
| */ | ||||
| @Data | ||||
| public class SysTestDemoBaseVO { | ||||
|  | ||||
|     @ApiModelProperty(value = "字典名称", required = true, example = "性别额") | ||||
|     @NotNull(message = "字典名称不能为空") | ||||
|     private String name; | ||||
|  | ||||
|     @ApiModelProperty(value = "字典类型", required = true, example = "sys_sex") | ||||
|     @NotNull(message = "字典类型不能为空") | ||||
|     private String dictType; | ||||
|  | ||||
|     @ApiModelProperty(value = "状态", required = true, example = "1") | ||||
|     @NotNull(message = "状态不能为空") | ||||
|     private Integer status; | ||||
|  | ||||
|     @ApiModelProperty(value = "备注", example = "我是备注") | ||||
|     private String remark; | ||||
|  | ||||
| } | ||||
| @ -1,14 +0,0 @@ | ||||
| package cn.iocoder.dashboard.modules.system.controller.test.vo; | ||||
|  | ||||
| import io.swagger.annotations.ApiModel; | ||||
| import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | ||||
|  | ||||
| @ApiModel("字典类型创建 Request VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class SysTestDemoCreateReqVO extends SysTestDemoBaseVO { | ||||
|  | ||||
| } | ||||
| @ -1,41 +0,0 @@ | ||||
| package cn.iocoder.dashboard.modules.system.controller.test.vo; | ||||
|  | ||||
| import cn.iocoder.dashboard.common.pojo.PageParam; | ||||
| import io.swagger.annotations.ApiModel; | ||||
| import io.swagger.annotations.ApiModelProperty; | ||||
| import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
|  | ||||
| import java.util.Date; | ||||
|  | ||||
| import static cn.iocoder.dashboard.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||||
|  | ||||
| @ApiModel("字典类型分页 Request VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class SysTestDemoPageReqVO extends PageParam { | ||||
|  | ||||
|     @ApiModelProperty(value = "字典名称", example = "性别额") | ||||
|     private String name; | ||||
|  | ||||
|     @ApiModelProperty(value = "字典类型", example = "sys_sex") | ||||
|     private String dictType; | ||||
|  | ||||
|     @ApiModelProperty(value = "状态", example = "1") | ||||
|     private Integer status; | ||||
|  | ||||
|     @ApiModelProperty(value = "备注", example = "我是备注") | ||||
|     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.dashboard.modules.system.controller.test.vo; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import io.swagger.annotations.*; | ||||
|  | ||||
| @ApiModel("字典类型 Response VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class SysTestDemoRespVO extends SysTestDemoBaseVO { | ||||
|  | ||||
|     @ApiModelProperty(value = "字典主键", required = true, example = "1") | ||||
|     private Long id; | ||||
|  | ||||
|     @ApiModelProperty(value = "创建时间", required = true) | ||||
|     private Date createTime; | ||||
|  | ||||
| } | ||||
| @ -1,21 +0,0 @@ | ||||
| package cn.iocoder.dashboard.modules.system.controller.test.vo; | ||||
|  | ||||
| import io.swagger.annotations.ApiModel; | ||||
| import io.swagger.annotations.ApiModelProperty; | ||||
| import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | ||||
|  | ||||
| import javax.validation.constraints.NotNull; | ||||
|  | ||||
| @ApiModel("字典类型更新 Request VO") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| public class SysTestDemoUpdateReqVO extends SysTestDemoBaseVO { | ||||
|  | ||||
|     @ApiModelProperty(value = "字典主键", required = true, example = "1") | ||||
|     @NotNull(message = "字典主键不能为空") | ||||
|     private Long id; | ||||
|  | ||||
| } | ||||
| @ -124,7 +124,8 @@ public class SysUserController { | ||||
|     @GetMapping("/export") | ||||
| //    @PreAuthorize("@ss.hasPermi('system:user:export')") , @Validated SysUserExportReqVO reqVO | ||||
| //    @Log(title = "用户管理", businessType = BusinessType.EXPORT) | ||||
|     public void exportUsers(HttpServletResponse response, @Validated SysUserExportReqVO reqVO) throws IOException { | ||||
|     public void exportUsers(@Validated SysUserExportReqVO reqVO, | ||||
|                             HttpServletResponse response) throws IOException { | ||||
|         // 获得用户列表 | ||||
|         List<SysUserDO> users = userService.listUsers(reqVO); | ||||
|  | ||||
| @ -143,8 +144,7 @@ public class SysUserController { | ||||
|         }); | ||||
|  | ||||
|         // 输出 | ||||
|         ExcelUtils.write(response, "用户数据.xls", "用户列表", | ||||
|                 SysUserExcelVO.class, excelUsers); | ||||
|         ExcelUtils.write(response, "用户数据.xls", "用户列表", SysUserExcelVO.class, excelUsers); | ||||
|     } | ||||
|  | ||||
|     @ApiOperation("获得导入用户模板") | ||||
|  | ||||
| @ -25,7 +25,6 @@ public class SysNoticeDO extends BaseDO { | ||||
|     /** | ||||
|      * 公告标题 | ||||
|      */ | ||||
|  | ||||
|     private String title; | ||||
|     /** | ||||
|      * 公告类型 | ||||
|  | ||||
| @ -1,44 +0,0 @@ | ||||
| package cn.iocoder.dashboard.modules.system.dal.dataobject.test; | ||||
|  | ||||
| import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO; | ||||
| import com.baomidou.mybatisplus.annotation.TableId; | ||||
| import com.baomidou.mybatisplus.annotation.TableName; | ||||
| import lombok.*; | ||||
|  | ||||
| /** | ||||
| * 字典类型 DO | ||||
| * | ||||
| * @author 芋艿 | ||||
| */ | ||||
| @TableName("sys_test_demo") | ||||
| @Data | ||||
| @EqualsAndHashCode(callSuper = true) | ||||
| @ToString(callSuper = true) | ||||
| @Builder | ||||
| @NoArgsConstructor | ||||
| @AllArgsConstructor | ||||
| public class SysTestDemoDO extends BaseDO { | ||||
|  | ||||
|     /** | ||||
|     * 字典主键 | ||||
|     */ | ||||
|     @TableId | ||||
|     private Long id; | ||||
|     /** | ||||
|     * 字典名称 | ||||
|     */ | ||||
|     private String name; | ||||
|     /** | ||||
|     * 字典类型 | ||||
|     */ | ||||
|     private String dictType; | ||||
|     /** | ||||
|     * 状态 | ||||
|     */ | ||||
|     private Integer status; | ||||
|     /** | ||||
|     * 备注 | ||||
|     */ | ||||
|     private String remark; | ||||
|  | ||||
| } | ||||
| @ -1,28 +0,0 @@ | ||||
| package cn.iocoder.dashboard.modules.system.dal.mysql.test; | ||||
|  | ||||
| import cn.iocoder.dashboard.common.pojo.PageResult; | ||||
| import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX; | ||||
| import cn.iocoder.dashboard.framework.mybatis.core.mapper.BaseMapperX; | ||||
| import cn.iocoder.dashboard.modules.system.dal.dataobject.test.SysTestDemoDO; | ||||
| import org.apache.ibatis.annotations.Mapper; | ||||
| import cn.iocoder.dashboard.modules.system.controller.test.vo.SysTestDemoPageReqVO; | ||||
|  | ||||
| /** | ||||
| * 字典类型 Mapper | ||||
| * | ||||
| * @author 芋艿 | ||||
| */ | ||||
| @Mapper | ||||
| public interface SysTestDemoMapper extends BaseMapperX<SysTestDemoDO> { | ||||
|  | ||||
|     default PageResult<SysTestDemoDO> selectPage(SysTestDemoPageReqVO reqVO) { | ||||
|         return selectPage(reqVO, new QueryWrapperX<SysTestDemoDO>() | ||||
|             .likeIfPresent("name", reqVO.getName()) | ||||
|             .eqIfPresent("dict_type", reqVO.getDictType()) | ||||
|             .eqIfPresent("status", reqVO.getStatus()) | ||||
|             .eqIfPresent("remark", reqVO.getRemark()) | ||||
|             .betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | ||||
|         ); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @ -1,66 +0,0 @@ | ||||
| package cn.iocoder.dashboard.modules.system.service.test; | ||||
|  | ||||
| import cn.iocoder.dashboard.common.pojo.PageResult; | ||||
| import cn.iocoder.dashboard.modules.system.controller.test.vo.SysTestDemoCreateReqVO; | ||||
| import cn.iocoder.dashboard.modules.system.controller.test.vo.SysTestDemoPageReqVO; | ||||
| import cn.iocoder.dashboard.modules.system.controller.test.vo.SysTestDemoUpdateReqVO; | ||||
| import cn.iocoder.dashboard.modules.system.dal.dataobject.test.SysTestDemoDO; | ||||
|  | ||||
| import javax.validation.Valid; | ||||
| import java.util.Collection; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
| * 字典类型 Service 接口 | ||||
| * | ||||
| * @author 芋艿 | ||||
| */ | ||||
| public interface SysTestDemoService { | ||||
|  | ||||
|     /** | ||||
|      * 创建字典类型 | ||||
|      * | ||||
|      * @param createReqVO 创建信息 | ||||
|      * @return 编号 | ||||
|      */ | ||||
|     Long createTestDemo(@Valid SysTestDemoCreateReqVO createReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 更新字典类型 | ||||
|      * | ||||
|      * @param updateReqVO 更新信息 | ||||
|      */ | ||||
|     void updateTestDemo(@Valid SysTestDemoUpdateReqVO updateReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 删除字典类型 | ||||
|      * | ||||
|      * @param id 编号 | ||||
|      */ | ||||
|     void deleteTestDemo(Long id); | ||||
|  | ||||
|     /** | ||||
|      * 获得字典类型 | ||||
|      * | ||||
|      * @param id 编号 | ||||
|      * @return 字典类型 | ||||
|      */ | ||||
|     SysTestDemoDO getTestDemo(Long id); | ||||
|  | ||||
|     /** | ||||
|      * 获得字典类型列表 | ||||
|      * | ||||
|      * @param ids 编号 | ||||
|      * @return 字典类型列表 | ||||
|      */ | ||||
|     List<SysTestDemoDO> getTestDemoList(Collection<Long> ids); | ||||
|  | ||||
|     /** | ||||
|      * 获得字典类型分页 | ||||
|      * | ||||
|      * @param pageReqVO 分页查询 | ||||
|      * @return 字典类型分页 | ||||
|      */ | ||||
| 	PageResult<SysTestDemoDO> getTestDemoPage(SysTestDemoPageReqVO pageReqVO); | ||||
|  | ||||
| } | ||||
| @ -1,80 +0,0 @@ | ||||
| package cn.iocoder.dashboard.modules.system.service.test.impl; | ||||
|  | ||||
| import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil; | ||||
| import cn.iocoder.dashboard.common.pojo.PageResult; | ||||
| import cn.iocoder.dashboard.modules.system.controller.test.vo.SysTestDemoCreateReqVO; | ||||
| import cn.iocoder.dashboard.modules.system.controller.test.vo.SysTestDemoPageReqVO; | ||||
| import cn.iocoder.dashboard.modules.system.controller.test.vo.SysTestDemoUpdateReqVO; | ||||
| import cn.iocoder.dashboard.modules.system.convert.test.SysTestDemoConvert; | ||||
| import cn.iocoder.dashboard.modules.system.dal.mysql.test.SysTestDemoMapper; | ||||
| import cn.iocoder.dashboard.modules.system.dal.dataobject.test.SysTestDemoDO; | ||||
| import cn.iocoder.dashboard.modules.system.service.test.SysTestDemoService; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
|  | ||||
| import javax.annotation.Resource; | ||||
| import java.util.Collection; | ||||
| import java.util.List; | ||||
|  | ||||
| import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.TEST_DEMO_NOT_EXISTS; | ||||
|  | ||||
| /** | ||||
| * 字典类型 Service 实现类 | ||||
| * | ||||
| * @author 芋艿 | ||||
| */ | ||||
| @Service | ||||
| @Validated | ||||
| public class SysTestDemoServiceImpl implements SysTestDemoService { | ||||
|  | ||||
|     @Resource | ||||
|     private SysTestDemoMapper testDemoMapper; | ||||
|  | ||||
|     @Override | ||||
|     public Long createTestDemo(SysTestDemoCreateReqVO createReqVO) { | ||||
|         // 插入 | ||||
|         SysTestDemoDO testDemo = SysTestDemoConvert.INSTANCE.convert(createReqVO); | ||||
|         testDemoMapper.insert(testDemo); | ||||
|         // 返回 | ||||
|         return testDemo.getId(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void updateTestDemo(SysTestDemoUpdateReqVO updateReqVO) { | ||||
|         // 校验存在 | ||||
|         this.validateTestDemoExists(updateReqVO.getId()); | ||||
|         // 更新 | ||||
|         SysTestDemoDO updateObj = SysTestDemoConvert.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 ServiceExceptionUtil.exception(TEST_DEMO_NOT_EXISTS); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public SysTestDemoDO getTestDemo(Long id) { | ||||
|         return testDemoMapper.selectById(id); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<SysTestDemoDO> getTestDemoList(Collection<Long> ids) { | ||||
|         return testDemoMapper.selectBatchIds(ids); | ||||
|     } | ||||
|  | ||||
| 	@Override | ||||
|     public PageResult<SysTestDemoDO> getTestDemoPage(SysTestDemoPageReqVO pageReqVO) { | ||||
| 		return testDemoMapper.selectPage(pageReqVO); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @ -31,6 +31,10 @@ public class ToolCodegenTableBaseVO { | ||||
|     @NotNull(message = "业务名不能为空") | ||||
|     private String businessName; | ||||
|  | ||||
|     @ApiModelProperty(value = "业务包", required = true, example = "codegen") | ||||
|     @NotNull(message = "业务包不能为空") | ||||
|     private String businessPackage; | ||||
|  | ||||
|     @ApiModelProperty(value = "类名称", required = true, example = "ToolCodegenTable") | ||||
|     @NotNull(message = "类名称不能为空") | ||||
|     private String className; | ||||
|  | ||||
| @ -52,6 +52,14 @@ public class ToolCodegenTableDO extends BaseDO { | ||||
|      * 例如说,user、permission、dict 等等 | ||||
|      */ | ||||
|     private String businessName; | ||||
|     /** | ||||
|      * 业务包,自定义二级目录 | ||||
|      * | ||||
|      * 例如说,我们希望将 dictType 和 dictData 归类成 dict 业务 | ||||
|      * | ||||
|      * 如果不需要的情况下,businessName 和 businessPackage 是等价的 | ||||
|      */ | ||||
|     private String businessPackage; | ||||
|     /** | ||||
|      * 类名称(首字母大写) | ||||
|      * | ||||
|  | ||||
| @ -128,6 +128,7 @@ public class ToolCodegenBuilder { | ||||
|                 '_', false))); // 第一个 _ 前缀的前面,作为 module 名字 | ||||
|         table.setBusinessName(toCamelCase(subAfter(table.getTableName(), | ||||
|                 '_', false))); // 第一步,第一个 _ 前缀的后面,作为 module 名字; 第二步,可能存在多个 _ 的情况,转换成驼峰 | ||||
|         table.setBusinessPackage(table.getBusinessPackage()); | ||||
|         table.setClassName(upperFirst(toCamelCase(table.getTableName()))); // 驼峰 + 首字母大写 | ||||
|         table.setClassComment(subBefore(table.getTableComment(), // 去除结尾的表,作为类描述 | ||||
|                 '表', true)); | ||||
|  | ||||
| @ -73,4 +73,6 @@ public class ${table.className}Controller { | ||||
|         return success(${table.className}Convert.INSTANCE.convertPage(pageResult)); | ||||
|     } | ||||
|  | ||||
|  | ||||
|  | ||||
| } | ||||
|  | ||||
							
								
								
									
										42
									
								
								src/main/resources/codegen/java/controller/vo/excelReqVO.vm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								src/main/resources/codegen/java/controller/vo/excelReqVO.vm
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,42 @@ | ||||
| package ${basePackage}.${table.moduleName}.controller.${table.businessName}.vo; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import io.swagger.annotations.*; | ||||
| import ${PageParamClassName}; | ||||
| ## 处理 Date 字段的引入 | ||||
| #foreach ($column in $columns) | ||||
|     #if (${column.listOperation} && ${column.javaType} == "Date")## 时间类型 | ||||
| 		import org.springframework.format.annotation.DateTimeFormat; | ||||
|  | ||||
| 		import static ${DateUtilsClassName}.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||||
|         #break | ||||
|     #end | ||||
| #end | ||||
| ## 字段模板 | ||||
| #macro(columnTpl $prefix $prefixStr) | ||||
|     #if (${column.javaType} == "Date")## 时间类型 | ||||
| 		@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     #end | ||||
| @ApiModelProperty(value = "${prefixStr}${column.columnComment}"#if ("$!column.example" != ""), example = "${column.example}"#end) | ||||
| private ${column.javaType}#if ("$!prefix" != "") ${prefix}${JavaField}#else ${column.javaField}#end; | ||||
| #end | ||||
|  | ||||
| @ApiModel(value = "${table.classComment} Excel 导出 Request VO", description = "参数和 ${table.className}PageReqVO 是一致的") | ||||
| @Data | ||||
| public class ${table.className}ExcelReqVO { | ||||
|  | ||||
| #foreach ($column in $columns) | ||||
|     #set ($JavaField = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})##首字母大写 | ||||
|     #if (${column.listOperation})##查询操作 | ||||
|         #if (${column.listOperationCondition} == "BETWEEN")## 情况一,Between 的时候 | ||||
|             #columnTpl('begin', '开始') | ||||
|  | ||||
|             #columnTpl('end', '结束') | ||||
|         #else##情况二,非 Between 的时间 | ||||
|             #columnTpl('', '') | ||||
|         #end | ||||
|  | ||||
|     #end | ||||
| #end | ||||
| } | ||||
| @ -22,17 +22,15 @@ public class ${table.className}DO extends BaseDO { | ||||
| #foreach ($column in $columns) | ||||
| #if (!${baseDOFields.contains(${column.javaField})})##排除 BaseDO 的字段 | ||||
|     /** | ||||
|     * ${column.columnComment} | ||||
|     */ | ||||
| #if ("$!column.dictType" != "")##处理枚举值 | ||||
|     // TODO 枚举 ${column.dictType} | ||||
| #end | ||||
| #if (${column.primaryKey} && ${column.javaType} != 'String')##处理主键 + 非 String 的情况 | ||||
|     @TableId | ||||
| #end | ||||
| #if (${column.primaryKey} && ${column.javaType} == 'String')##处理主键 + String 的情况 | ||||
|     @TableId(type = IdType.INPUT) | ||||
| #end | ||||
|      * ${column.columnComment} | ||||
|     #if ("$!column.dictType" != "")##处理枚举值 | ||||
|      * | ||||
|      * 枚举 {@link TODO ${column.dictType} 对应的类} | ||||
|     #end | ||||
|      */ | ||||
|     #if (${column.primaryKey})##处理主键 | ||||
|     @TableId#if (${column.javaType} == 'String')type = IdType.INPUT)#end | ||||
|     #end | ||||
|     private ${column.javaType} ${column.javaField}; | ||||
| #end | ||||
| #end | ||||
|  | ||||
							
								
								
									
										53
									
								
								src/main/resources/codegen/vue/api/api.js.vm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								src/main/resources/codegen/vue/api/api.js.vm
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,53 @@ | ||||
| import request from '@/utils/request' | ||||
|  | ||||
| // 查询${functionName}列表 | ||||
| export function list${BusinessName}(query) { | ||||
|   return request({ | ||||
|     url: '/${moduleName}/${businessName}/list', | ||||
|     method: 'get', | ||||
|     params: query | ||||
|   }) | ||||
| } | ||||
|  | ||||
| // 查询${functionName}详细 | ||||
| export function get${BusinessName}(${pkColumn.javaField}) { | ||||
|   return request({ | ||||
|     url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, | ||||
|     method: 'get' | ||||
|   }) | ||||
| } | ||||
|  | ||||
| // 新增${functionName} | ||||
| export function add${BusinessName}(data) { | ||||
|   return request({ | ||||
|     url: '/${moduleName}/${businessName}', | ||||
|     method: 'post', | ||||
|     data: data | ||||
|   }) | ||||
| } | ||||
|  | ||||
| // 修改${functionName} | ||||
| export function update${BusinessName}(data) { | ||||
|   return request({ | ||||
|     url: '/${moduleName}/${businessName}', | ||||
|     method: 'put', | ||||
|     data: data | ||||
|   }) | ||||
| } | ||||
|  | ||||
| // 删除${functionName} | ||||
| export function del${BusinessName}(${pkColumn.javaField}) { | ||||
|   return request({ | ||||
|     url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, | ||||
|     method: 'delete' | ||||
|   }) | ||||
| } | ||||
|  | ||||
| // 导出${functionName} | ||||
| export function export${BusinessName}(query) { | ||||
|   return request({ | ||||
|     url: '/${moduleName}/${businessName}/export', | ||||
|     method: 'get', | ||||
|     params: query | ||||
|   }) | ||||
| } | ||||
| @ -9,8 +9,6 @@ | ||||
|     #set ($javaField = $column.javaField) | ||||
|     #set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) | ||||
|     #set ($comment=$column.columnComment) | ||||
|     #set ($parentheseIndex=$column.columnComment.indexOf("(")) | ||||
|     #if ($parentheseIndex >= 0) #set($comment=$column.columnComment.substring(0, $parentheseIndex)) #end | ||||
| #if ($column.htmlType == "input") | ||||
|       <el-form-item label="${comment}" prop="${javaField}"> | ||||
|         <el-input v-model="queryParams.${javaField}" placeholder="请输入${comment}" clearable size="small" @keyup.enter.native="handleQuery"/> | ||||
| @ -67,8 +65,6 @@ | ||||
|     #set ($javaField = $column.javaField) | ||||
|     #set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) | ||||
|     #set ($comment=$column.columnComment) | ||||
|     #set ($parentheseIndex=$column.columnComment.indexOf("(")) | ||||
|     #if ($parentheseIndex >= 0) #set($comment=$column.columnComment.substring(0, $parentheseIndex)) #end | ||||
| #if ($column.javaType == "Date")## 时间类型 | ||||
|       <el-table-column label="${comment}" align="center" prop="${javaField}" width="180"> | ||||
|         <template slot-scope="scope"> | ||||
| @ -108,8 +104,6 @@ | ||||
|     #set ($javaField = $column.javaField) | ||||
|     #set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) | ||||
|     #set ($comment = $column.columnComment) | ||||
|     #set ($parentheseIndex = $column.columnComment.indexOf("(")) | ||||
|     #if ($parentheseIndex >= 0) #set($comment = $column.columnComment.substring(0, $parentheseIndex)) #end | ||||
| #if ($column.htmlType == "input") | ||||
|   #if (!$column.primaryKey)## 忽略主键,不用在表单里 | ||||
|         <el-form-item label="${comment}" prop="${javaField}"> | ||||
|  | ||||
| @ -1,10 +1,10 @@ | ||||
| package cn.iocoder.dashboard.modules.tool.service.codegen.impl; | ||||
|  | ||||
| import cn.iocoder.dashboard.TestApplication; | ||||
| import cn.iocoder.dashboard.modules.tool.dal.mysql.coegen.ToolCodegenColumnMapper; | ||||
| import cn.iocoder.dashboard.modules.tool.dal.mysql.coegen.ToolCodegenTableMapper; | ||||
| import cn.iocoder.dashboard.modules.tool.dal.dataobject.codegen.ToolCodegenColumnDO; | ||||
| import cn.iocoder.dashboard.modules.tool.dal.dataobject.codegen.ToolCodegenTableDO; | ||||
| import cn.iocoder.dashboard.modules.tool.dal.mysql.coegen.ToolCodegenColumnMapper; | ||||
| import cn.iocoder.dashboard.modules.tool.dal.mysql.coegen.ToolCodegenTableMapper; | ||||
| import org.junit.jupiter.api.Test; | ||||
| import org.springframework.boot.test.context.SpringBootTest; | ||||
|  | ||||
| @ -25,10 +25,11 @@ public class ToolCodegenEngineTest { | ||||
|  | ||||
|     @Test | ||||
|     public void testExecute() { | ||||
|         ToolCodegenTableDO table = codegenTableMapper.selectById(10); | ||||
|         ToolCodegenTableDO table = codegenTableMapper.selectById(20); | ||||
|         List<ToolCodegenColumnDO> columns = codegenColumnMapper.selectListByTableId(table.getId()); | ||||
|         Map<String, String> result = codegenEngine.execute(table, columns); | ||||
|         System.out.println(result.get("vue/views/system/test/index.vue")); | ||||
|         result.forEach((s, s2) -> System.out.println(s2)); | ||||
| //        System.out.println(result.get("vue/views/system/test/index.vue")); | ||||
|     } | ||||
|  | ||||
| } | ||||
|  | ||||
| @ -14,9 +14,9 @@ class ToolCodegenServiceImplTest { | ||||
|  | ||||
|     @Test | ||||
|     public void tetCreateCodegenTable() { | ||||
| //        toolCodegenService.createCodegenTable("sys_test_demo"); | ||||
|         toolCodegenService.createCodegen("tool_test_demo"); | ||||
| //        toolCodegenService.createCodegenTable("tool_codegen_table"); | ||||
|         toolCodegenService.createCodegen("tool_codegen_column"); | ||||
| //        toolCodegenService.createCodegen("tool_codegen_column"); | ||||
|     } | ||||
|  | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV