Commit e67a6a2fe9ae733ec97ba25d4cc79f4354743387
1 parent
07e71e2a
代码生成:1)增加 one 情况下的示例代码;2)修复 vue3 模版现有的 bug
Showing
27 changed files
with
732 additions
and
147 deletions
yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants.java
| ... | ... | @@ -43,9 +43,6 @@ public interface ErrorCodeConstants { |
| 43 | 43 | ErrorCode CODEGEN_TABLE_INFO_TABLE_COMMENT_IS_NULL = new ErrorCode(1_003_001_008, "数据库的表注释未填写"); |
| 44 | 44 | ErrorCode CODEGEN_TABLE_INFO_COLUMN_COMMENT_IS_NULL = new ErrorCode(1_003_001_009, "数据库的表字段({})注释未填写"); |
| 45 | 45 | |
| 46 | - // ========== 字典类型(测试)1-001-005-000 ========== | |
| 47 | - ErrorCode TEST_DEMO_NOT_EXISTS = new ErrorCode(1_001_005_000, "测试示例不存在"); | |
| 48 | - | |
| 49 | 46 | // ========== 文件配置 1-001-006-000 ========== |
| 50 | 47 | ErrorCode FILE_CONFIG_NOT_EXISTS = new ErrorCode(1_001_006_000, "文件配置不存在"); |
| 51 | 48 | ErrorCode FILE_CONFIG_DELETE_FAIL_MASTER = new ErrorCode(1_001_006_001, "该文件配置不允许删除,原因:它是主配置,删除会导致无法上传文件"); |
| ... | ... | @@ -57,4 +54,6 @@ public interface ErrorCodeConstants { |
| 57 | 54 | // ========== 数据源配置 1-001-107-000 ========== |
| 58 | 55 | ErrorCode DEMO_STUDENT_NOT_EXISTS = new ErrorCode(1_001_107_000, "学生不存在"); |
| 59 | 56 | |
| 57 | + // ========== 学生(CodegenTemplateTypeEnum.ONE 示例) 1-001-200-000 ========== | |
| 58 | + ErrorCode DEMO01_STUDENT_NOT_EXISTS = new ErrorCode(1_001_200_000, "学生不存在"); | |
| 60 | 59 | } | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo01/InfraDemo01StudentController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.infra.controller.admin.demo01; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 6 | +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | |
| 7 | +import cn.iocoder.yudao.module.infra.controller.admin.demo01.vo.*; | |
| 8 | +import cn.iocoder.yudao.module.infra.convert.demo01.InfraDemo01StudentConvert; | |
| 9 | +import cn.iocoder.yudao.module.infra.dal.dataobject.demo01.InfraDemo01StudentDO; | |
| 10 | +import cn.iocoder.yudao.module.infra.service.demo01.InfraDemo01StudentService; | |
| 11 | +import io.swagger.v3.oas.annotations.Operation; | |
| 12 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 13 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 14 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 15 | +import org.springframework.validation.annotation.Validated; | |
| 16 | +import org.springframework.web.bind.annotation.*; | |
| 17 | + | |
| 18 | +import javax.annotation.Resource; | |
| 19 | +import javax.servlet.http.HttpServletResponse; | |
| 20 | +import javax.validation.Valid; | |
| 21 | +import java.io.IOException; | |
| 22 | +import java.util.List; | |
| 23 | + | |
| 24 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 25 | +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | |
| 26 | + | |
| 27 | +@Tag(name = "管理后台 - 学生") | |
| 28 | +@RestController | |
| 29 | +@RequestMapping("/infra/demo01-student") | |
| 30 | +@Validated | |
| 31 | +public class InfraDemo01StudentController { | |
| 32 | + | |
| 33 | + @Resource | |
| 34 | + private InfraDemo01StudentService demo01StudentService; | |
| 35 | + | |
| 36 | + @PostMapping("/create") | |
| 37 | + @Operation(summary = "创建学生") | |
| 38 | + @PreAuthorize("@ss.hasPermission('infra:demo01-student:create')") | |
| 39 | + public CommonResult<Long> createDemo01Student(@Valid @RequestBody InfraDemo01StudentCreateReqVO createReqVO) { | |
| 40 | + return success(demo01StudentService.createDemo01Student(createReqVO)); | |
| 41 | + } | |
| 42 | + | |
| 43 | + @PutMapping("/update") | |
| 44 | + @Operation(summary = "更新学生") | |
| 45 | + @PreAuthorize("@ss.hasPermission('infra:demo01-student:update')") | |
| 46 | + public CommonResult<Boolean> updateDemo01Student(@Valid @RequestBody InfraDemo01StudentUpdateReqVO updateReqVO) { | |
| 47 | + demo01StudentService.updateDemo01Student(updateReqVO); | |
| 48 | + return success(true); | |
| 49 | + } | |
| 50 | + | |
| 51 | + @DeleteMapping("/delete") | |
| 52 | + @Operation(summary = "删除学生") | |
| 53 | + @Parameter(name = "id", description = "编号", required = true) | |
| 54 | + @PreAuthorize("@ss.hasPermission('infra:demo01-student:delete')") | |
| 55 | + public CommonResult<Boolean> deleteDemo01Student(@RequestParam("id") Long id) { | |
| 56 | + demo01StudentService.deleteDemo01Student(id); | |
| 57 | + return success(true); | |
| 58 | + } | |
| 59 | + | |
| 60 | + @GetMapping("/get") | |
| 61 | + @Operation(summary = "获得学生") | |
| 62 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 63 | + @PreAuthorize("@ss.hasPermission('infra:demo01-student:query')") | |
| 64 | + public CommonResult<InfraDemo01StudentRespVO> getDemo01Student(@RequestParam("id") Long id) { | |
| 65 | + InfraDemo01StudentDO demo01Student = demo01StudentService.getDemo01Student(id); | |
| 66 | + return success(InfraDemo01StudentConvert.INSTANCE.convert(demo01Student)); | |
| 67 | + } | |
| 68 | + | |
| 69 | + @GetMapping("/page") | |
| 70 | + @Operation(summary = "获得学生分页") | |
| 71 | + @PreAuthorize("@ss.hasPermission('infra:demo01-student:query')") | |
| 72 | + public CommonResult<PageResult<InfraDemo01StudentRespVO>> getDemo01StudentPage(@Valid InfraDemo01StudentPageReqVO pageVO) { | |
| 73 | + PageResult<InfraDemo01StudentDO> pageResult = demo01StudentService.getDemo01StudentPage(pageVO); | |
| 74 | + return success(InfraDemo01StudentConvert.INSTANCE.convertPage(pageResult)); | |
| 75 | + } | |
| 76 | + | |
| 77 | + @GetMapping("/export-excel") | |
| 78 | + @Operation(summary = "导出学生 Excel") | |
| 79 | + @PreAuthorize("@ss.hasPermission('infra:demo01-student:export')") | |
| 80 | + @OperateLog(type = EXPORT) | |
| 81 | + public void exportDemo01StudentExcel(@Valid InfraDemo01StudentExportReqVO exportReqVO, | |
| 82 | + HttpServletResponse response) throws IOException { | |
| 83 | + List<InfraDemo01StudentDO> list = demo01StudentService.getDemo01StudentList(exportReqVO); | |
| 84 | + // 导出 Excel | |
| 85 | + List<InfraDemo01StudentExcelVO> datas = InfraDemo01StudentConvert.INSTANCE.convertList02(list); | |
| 86 | + ExcelUtils.write(response, "学生.xls", "数据", InfraDemo01StudentExcelVO.class, datas); | |
| 87 | + } | |
| 88 | + | |
| 89 | +} | |
| 0 | 90 | \ No newline at end of file | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo01/vo/InfraDemo01StudentBaseVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.infra.controller.admin.demo01.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 6 | + | |
| 7 | +import javax.validation.constraints.NotEmpty; | |
| 8 | +import javax.validation.constraints.NotNull; | |
| 9 | +import java.time.LocalDateTime; | |
| 10 | + | |
| 11 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 学生 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 15 | + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 16 | + */ | |
| 17 | +@Data | |
| 18 | +public class InfraDemo01StudentBaseVO { | |
| 19 | + | |
| 20 | + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋头") | |
| 21 | + @NotEmpty(message = "名字不能为空") | |
| 22 | + private String name; | |
| 23 | + | |
| 24 | + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是介绍") | |
| 25 | + @NotEmpty(message = "简介不能为空") | |
| 26 | + private String description; | |
| 27 | + | |
| 28 | + @Schema(description = "出生日期", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 29 | + @NotNull(message = "出生日期不能为空") | |
| 30 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 31 | + private LocalDateTime birthday; | |
| 32 | + | |
| 33 | + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 34 | + @NotNull(message = "性别不能为空") | |
| 35 | + private Integer sex; | |
| 36 | + | |
| 37 | + @Schema(description = "是否有效", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") | |
| 38 | + @NotNull(message = "是否有效不能为空") | |
| 39 | + private Boolean enabled; | |
| 40 | + | |
| 41 | + @Schema(description = "头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/1.png") | |
| 42 | + @NotEmpty(message = "头像不能为空") | |
| 43 | + private String avatar; | |
| 44 | + | |
| 45 | + @Schema(description = "附件", example = "https://www.iocoder.cn/1.mp4") | |
| 46 | + private String video; | |
| 47 | + | |
| 48 | + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是备注") | |
| 49 | + @NotEmpty(message = "备注不能为空") | |
| 50 | + private String memo; | |
| 51 | + | |
| 52 | +} | |
| 0 | 53 | \ No newline at end of file | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo01/vo/InfraDemo01StudentCreateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.infra.controller.admin.demo01.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +@Schema(description = "管理后台 - 学生创建 Request VO") | |
| 9 | +@Data | |
| 10 | +@EqualsAndHashCode(callSuper = true) | |
| 11 | +@ToString(callSuper = true) | |
| 12 | +public class InfraDemo01StudentCreateReqVO extends InfraDemo01StudentBaseVO { | |
| 13 | + | |
| 14 | +} | |
| 0 | 15 | \ No newline at end of file | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo01/vo/InfraDemo01StudentExcelVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.infra.controller.admin.demo01.vo; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | |
| 4 | +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | |
| 5 | +import com.alibaba.excel.annotation.ExcelProperty; | |
| 6 | +import lombok.Data; | |
| 7 | + | |
| 8 | +import java.time.LocalDateTime; | |
| 9 | + | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 学生 Excel VO | |
| 13 | + * | |
| 14 | + * @author 芋道源码 | |
| 15 | + */ | |
| 16 | +@Data | |
| 17 | +public class InfraDemo01StudentExcelVO { | |
| 18 | + | |
| 19 | + @ExcelProperty("编号") | |
| 20 | + private Long id; | |
| 21 | + | |
| 22 | + @ExcelProperty("名字") | |
| 23 | + private String name; | |
| 24 | + | |
| 25 | + @ExcelProperty("简介") | |
| 26 | + private String description; | |
| 27 | + | |
| 28 | + @ExcelProperty("出生日期") | |
| 29 | + private LocalDateTime birthday; | |
| 30 | + | |
| 31 | + @ExcelProperty(value = "性别", converter = DictConvert.class) | |
| 32 | + @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 | |
| 33 | + private Integer sex; | |
| 34 | + | |
| 35 | + @ExcelProperty(value = "是否有效", converter = DictConvert.class) | |
| 36 | + @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 | |
| 37 | + private Boolean enabled; | |
| 38 | + | |
| 39 | + @ExcelProperty(value = "支付方式", converter = DictConvert.class) | |
| 40 | + @DictFormat("pay_channel_code") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 | |
| 41 | + private String payChannels; | |
| 42 | + | |
| 43 | + @ExcelProperty("头像") | |
| 44 | + private String avatar; | |
| 45 | + | |
| 46 | + @ExcelProperty("附件") | |
| 47 | + private String video; | |
| 48 | + | |
| 49 | + @ExcelProperty("备注") | |
| 50 | + private String memo; | |
| 51 | + | |
| 52 | + @ExcelProperty("创建时间") | |
| 53 | + private LocalDateTime createTime; | |
| 54 | + | |
| 55 | +} | |
| 0 | 56 | \ No newline at end of file | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo01/vo/InfraDemo01StudentExportReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.infra.controller.admin.demo01.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 6 | + | |
| 7 | +import java.time.LocalDateTime; | |
| 8 | + | |
| 9 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 10 | + | |
| 11 | +@Schema(description = "管理后台 - 学生 Excel 导出 Request VO,参数和 InfraDemo01StudentPageReqVO 是一致的") | |
| 12 | +@Data | |
| 13 | +public class InfraDemo01StudentExportReqVO { | |
| 14 | + | |
| 15 | + @Schema(description = "名字", example = "芋头") | |
| 16 | + private String name; | |
| 17 | + | |
| 18 | + @Schema(description = "出生日期") | |
| 19 | + private LocalDateTime birthday; | |
| 20 | + | |
| 21 | + @Schema(description = "性别", example = "1") | |
| 22 | + private Integer sex; | |
| 23 | + | |
| 24 | + @Schema(description = "是否有效", example = "true") | |
| 25 | + private Boolean enabled; | |
| 26 | + | |
| 27 | + @Schema(description = "创建时间") | |
| 28 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 29 | + private LocalDateTime[] createTime; | |
| 30 | + | |
| 31 | +} | |
| 0 | 32 | \ No newline at end of file | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo01/vo/InfraDemo01StudentPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.infra.controller.admin.demo01.vo; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | +import lombok.ToString; | |
| 8 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 9 | + | |
| 10 | +import java.time.LocalDateTime; | |
| 11 | + | |
| 12 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 13 | + | |
| 14 | +@Schema(description = "管理后台 - 学生分页 Request VO") | |
| 15 | +@Data | |
| 16 | +@EqualsAndHashCode(callSuper = true) | |
| 17 | +@ToString(callSuper = true) | |
| 18 | +public class InfraDemo01StudentPageReqVO extends PageParam { | |
| 19 | + | |
| 20 | + @Schema(description = "名字", example = "芋头") | |
| 21 | + private String name; | |
| 22 | + | |
| 23 | + @Schema(description = "出生日期") | |
| 24 | + private LocalDateTime birthday; | |
| 25 | + | |
| 26 | + @Schema(description = "性别", example = "1") | |
| 27 | + private Integer sex; | |
| 28 | + | |
| 29 | + @Schema(description = "是否有效", example = "true") | |
| 30 | + private Boolean enabled; | |
| 31 | + | |
| 32 | + @Schema(description = "创建时间") | |
| 33 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 34 | + private LocalDateTime[] createTime; | |
| 35 | + | |
| 36 | +} | |
| 0 | 37 | \ No newline at end of file | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo01/vo/InfraDemo01StudentRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.infra.controller.admin.demo01.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.*; | |
| 5 | +import java.time.LocalDateTime; | |
| 6 | + | |
| 7 | +@Schema(description = "管理后台 - 学生 Response VO") | |
| 8 | +@Data | |
| 9 | +@EqualsAndHashCode(callSuper = true) | |
| 10 | +@ToString(callSuper = true) | |
| 11 | +public class InfraDemo01StudentRespVO extends InfraDemo01StudentBaseVO { | |
| 12 | + | |
| 13 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 14 | + private Long id; | |
| 15 | + | |
| 16 | + @Schema(description = "创建时间") | |
| 17 | + private LocalDateTime createTime; | |
| 18 | + | |
| 19 | +} | |
| 0 | 20 | \ No newline at end of file | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo01/vo/InfraDemo01StudentUpdateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.infra.controller.admin.demo01.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +import javax.validation.constraints.NotNull; | |
| 9 | + | |
| 10 | +@Schema(description = "管理后台 - 学生更新 Request VO") | |
| 11 | +@Data | |
| 12 | +@EqualsAndHashCode(callSuper = true) | |
| 13 | +@ToString(callSuper = true) | |
| 14 | +public class InfraDemo01StudentUpdateReqVO extends InfraDemo01StudentBaseVO { | |
| 15 | + | |
| 16 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 17 | + @NotNull(message = "编号不能为空") | |
| 18 | + private Long id; | |
| 19 | + | |
| 20 | +} | |
| 0 | 21 | \ No newline at end of file | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/demo01/InfraDemo01StudentConvert.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.infra.convert.demo01; | |
| 2 | + | |
| 3 | +import java.util.*; | |
| 4 | + | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | + | |
| 7 | +import org.mapstruct.Mapper; | |
| 8 | +import org.mapstruct.factory.Mappers; | |
| 9 | +import cn.iocoder.yudao.module.infra.controller.admin.demo01.vo.*; | |
| 10 | +import cn.iocoder.yudao.module.infra.dal.dataobject.demo01.InfraDemo01StudentDO; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 学生 Convert | |
| 14 | + * | |
| 15 | + * @author 芋道源码 | |
| 16 | + */ | |
| 17 | +@Mapper | |
| 18 | +public interface InfraDemo01StudentConvert { | |
| 19 | + | |
| 20 | + InfraDemo01StudentConvert INSTANCE = Mappers.getMapper(InfraDemo01StudentConvert.class); | |
| 21 | + | |
| 22 | + InfraDemo01StudentDO convert(InfraDemo01StudentCreateReqVO bean); | |
| 23 | + | |
| 24 | + InfraDemo01StudentDO convert(InfraDemo01StudentUpdateReqVO bean); | |
| 25 | + | |
| 26 | + InfraDemo01StudentRespVO convert(InfraDemo01StudentDO bean); | |
| 27 | + | |
| 28 | + List<InfraDemo01StudentRespVO> convertList(List<InfraDemo01StudentDO> list); | |
| 29 | + | |
| 30 | + PageResult<InfraDemo01StudentRespVO> convertPage(PageResult<InfraDemo01StudentDO> page); | |
| 31 | + | |
| 32 | + List<InfraDemo01StudentExcelVO> convertList02(List<InfraDemo01StudentDO> list); | |
| 33 | + | |
| 34 | +} | |
| 0 | 35 | \ No newline at end of file | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo01/InfraDemo01StudentDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.infra.dal.dataobject.demo01; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 5 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 7 | +import lombok.*; | |
| 8 | + | |
| 9 | +import java.time.LocalDateTime; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 学生 DO | |
| 13 | + * | |
| 14 | + * @author 芋道源码 | |
| 15 | + */ | |
| 16 | +@TableName("infra_demo01_student") | |
| 17 | +@KeySequence("infra_demo01_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 18 | +@Data | |
| 19 | +@EqualsAndHashCode(callSuper = true) | |
| 20 | +@ToString(callSuper = true) | |
| 21 | +@Builder | |
| 22 | +@NoArgsConstructor | |
| 23 | +@AllArgsConstructor | |
| 24 | +public class InfraDemo01StudentDO extends BaseDO { | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 编号 | |
| 28 | + */ | |
| 29 | + @TableId | |
| 30 | + private Long id; | |
| 31 | + /** | |
| 32 | + * 名字 | |
| 33 | + */ | |
| 34 | + private String name; | |
| 35 | + /** | |
| 36 | + * 简介 | |
| 37 | + */ | |
| 38 | + private String description; | |
| 39 | + /** | |
| 40 | + * 出生日期 | |
| 41 | + */ | |
| 42 | + private LocalDateTime birthday; | |
| 43 | + /** | |
| 44 | + * 性别 | |
| 45 | + * | |
| 46 | + * 枚举 {@link TODO system_user_sex 对应的类} | |
| 47 | + */ | |
| 48 | + private Integer sex; | |
| 49 | + /** | |
| 50 | + * 是否有效 | |
| 51 | + * | |
| 52 | + * 枚举 {@link TODO infra_boolean_string 对应的类} | |
| 53 | + */ | |
| 54 | + private Boolean enabled; | |
| 55 | + /** | |
| 56 | + * 头像 | |
| 57 | + */ | |
| 58 | + private String avatar; | |
| 59 | + /** | |
| 60 | + * 附件 | |
| 61 | + */ | |
| 62 | + private String video; | |
| 63 | + /** | |
| 64 | + * 备注 | |
| 65 | + */ | |
| 66 | + private String memo; | |
| 67 | + | |
| 68 | +} | |
| 0 | 69 | \ No newline at end of file | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo01/InfraDemo01StudentMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.infra.dal.mysql.demo01; | |
| 2 | + | |
| 3 | +import java.util.*; | |
| 4 | + | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 6 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 7 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 8 | +import cn.iocoder.yudao.module.infra.dal.dataobject.demo01.InfraDemo01StudentDO; | |
| 9 | +import org.apache.ibatis.annotations.Mapper; | |
| 10 | +import cn.iocoder.yudao.module.infra.controller.admin.demo01.vo.*; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 学生 Mapper | |
| 14 | + * | |
| 15 | + * @author 芋道源码 | |
| 16 | + */ | |
| 17 | +@Mapper | |
| 18 | +public interface InfraDemo01StudentMapper extends BaseMapperX<InfraDemo01StudentDO> { | |
| 19 | + | |
| 20 | + default PageResult<InfraDemo01StudentDO> selectPage(InfraDemo01StudentPageReqVO reqVO) { | |
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<InfraDemo01StudentDO>() | |
| 22 | + .likeIfPresent(InfraDemo01StudentDO::getName, reqVO.getName()) | |
| 23 | + .eqIfPresent(InfraDemo01StudentDO::getBirthday, reqVO.getBirthday()) | |
| 24 | + .eqIfPresent(InfraDemo01StudentDO::getSex, reqVO.getSex()) | |
| 25 | + .eqIfPresent(InfraDemo01StudentDO::getEnabled, reqVO.getEnabled()) | |
| 26 | + .betweenIfPresent(InfraDemo01StudentDO::getCreateTime, reqVO.getCreateTime()) | |
| 27 | + .orderByDesc(InfraDemo01StudentDO::getId)); | |
| 28 | + } | |
| 29 | + | |
| 30 | + default List<InfraDemo01StudentDO> selectList(InfraDemo01StudentExportReqVO reqVO) { | |
| 31 | + return selectList(new LambdaQueryWrapperX<InfraDemo01StudentDO>() | |
| 32 | + .likeIfPresent(InfraDemo01StudentDO::getName, reqVO.getName()) | |
| 33 | + .eqIfPresent(InfraDemo01StudentDO::getBirthday, reqVO.getBirthday()) | |
| 34 | + .eqIfPresent(InfraDemo01StudentDO::getSex, reqVO.getSex()) | |
| 35 | + .eqIfPresent(InfraDemo01StudentDO::getEnabled, reqVO.getEnabled()) | |
| 36 | + .betweenIfPresent(InfraDemo01StudentDO::getCreateTime, reqVO.getCreateTime()) | |
| 37 | + .orderByDesc(InfraDemo01StudentDO::getId)); | |
| 38 | + } | |
| 39 | + | |
| 40 | +} | |
| 0 | 41 | \ No newline at end of file | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/enums/codegen/CodegenColumnHtmlTypeEnum.java
| ... | ... | @@ -16,8 +16,8 @@ public enum CodegenColumnHtmlTypeEnum { |
| 16 | 16 | RADIO("radio"), // 单选框 |
| 17 | 17 | CHECKBOX("checkbox"), // 复选框 |
| 18 | 18 | DATETIME("datetime"), // 日期控件 |
| 19 | - UPLOAD_IMAGE("upload_image"), // 上传图片 | |
| 20 | - UPLOAD_FILE("upload_file"), // 上传文件 | |
| 19 | + IMAGE_UPLOAD("imageUpload"), // 上传图片 | |
| 20 | + FILE_UPLOAD("fileUpload"), // 上传文件 | |
| 21 | 21 | EDITOR("editor"), // 富文本控件 |
| 22 | 22 | ; |
| 23 | 23 | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenBuilder.java
| ... | ... | @@ -49,8 +49,8 @@ public class CodegenBuilder { |
| 49 | 49 | .put("status", CodegenColumnHtmlTypeEnum.RADIO) |
| 50 | 50 | .put("sex", CodegenColumnHtmlTypeEnum.RADIO) |
| 51 | 51 | .put("type", CodegenColumnHtmlTypeEnum.SELECT) |
| 52 | - .put("image", CodegenColumnHtmlTypeEnum.UPLOAD_IMAGE) | |
| 53 | - .put("file", CodegenColumnHtmlTypeEnum.UPLOAD_FILE) | |
| 52 | + .put("image", CodegenColumnHtmlTypeEnum.IMAGE_UPLOAD) | |
| 53 | + .put("file", CodegenColumnHtmlTypeEnum.FILE_UPLOAD) | |
| 54 | 54 | .put("content", CodegenColumnHtmlTypeEnum.EDITOR) |
| 55 | 55 | .put("description", CodegenColumnHtmlTypeEnum.EDITOR) |
| 56 | 56 | .put("demo", CodegenColumnHtmlTypeEnum.EDITOR) | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngine.java
| ... | ... | @@ -110,21 +110,21 @@ public class CodegenEngine { |
| 110 | 110 | vueFilePath("api/${table.moduleName}/${classNameVar}.js")) |
| 111 | 111 | // Vue3 标准模版 |
| 112 | 112 | .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/index.vue"), |
| 113 | - vue3FilePath("views/${table.moduleName}/${classNameVar}/index.vue")) | |
| 113 | + vue3FilePath("views/${table.moduleName}/${table.businessName}/index.vue")) | |
| 114 | 114 | .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/form.vue"), |
| 115 | - vue3FilePath("views/${table.moduleName}/${classNameVar}/${simpleClassName}Form.vue")) | |
| 115 | + vue3FilePath("views/${table.moduleName}/${table.businessName}/${simpleClassName}Form.vue")) | |
| 116 | 116 | .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/form_sub_normal.vue"), // 特殊:主子表专属逻辑 |
| 117 | - vue3FilePath("views/${table.moduleName}/${classNameVar}/components/${subSimpleClassName}Form.vue")) | |
| 117 | + vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue")) | |
| 118 | 118 | .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/form_sub_inner.vue"), // 特殊:主子表专属逻辑 |
| 119 | - vue3FilePath("views/${table.moduleName}/${classNameVar}/components/${subSimpleClassName}Form.vue")) | |
| 119 | + vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue")) | |
| 120 | 120 | .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/form_sub_erp.vue"), // 特殊:主子表专属逻辑 |
| 121 | - vue3FilePath("views/${table.moduleName}/${classNameVar}/components/${subSimpleClassName}Form.vue")) | |
| 121 | + vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}Form.vue")) | |
| 122 | 122 | .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/list_sub_inner.vue"), // 特殊:主子表专属逻辑 |
| 123 | - vue3FilePath("views/${table.moduleName}/${classNameVar}/components/${subSimpleClassName}List.vue")) | |
| 123 | + vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}List.vue")) | |
| 124 | 124 | .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("views/components/list_sub_erp.vue"), // 特殊:主子表专属逻辑 |
| 125 | - vue3FilePath("views/${table.moduleName}/${classNameVar}/components/${subSimpleClassName}List.vue")) | |
| 125 | + vue3FilePath("views/${table.moduleName}/${table.businessName}/components/${subSimpleClassName}List.vue")) | |
| 126 | 126 | .put(CodegenFrontTypeEnum.VUE3.getType(), vue3TemplatePath("api/api.ts"), |
| 127 | - vue3FilePath("api/${table.moduleName}/${classNameVar}/index.ts")) | |
| 127 | + vue3FilePath("api/${table.moduleName}/${table.businessName}/index.ts")) | |
| 128 | 128 | // Vue3 Schema 模版 |
| 129 | 129 | .put(CodegenFrontTypeEnum.VUE3_SCHEMA.getType(), vue3SchemaTemplatePath("views/data.ts"), |
| 130 | 130 | vue3FilePath("views/${table.moduleName}/${classNameVar}/${classNameVar}.data.ts")) | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo01/InfraDemo01StudentService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.infra.service.demo01; | |
| 2 | + | |
| 3 | +import java.util.*; | |
| 4 | +import javax.validation.*; | |
| 5 | +import cn.iocoder.yudao.module.infra.controller.admin.demo01.vo.*; | |
| 6 | +import cn.iocoder.yudao.module.infra.dal.dataobject.demo01.InfraDemo01StudentDO; | |
| 7 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 学生 Service 接口 | |
| 11 | + * | |
| 12 | + * @author 芋道源码 | |
| 13 | + */ | |
| 14 | +public interface InfraDemo01StudentService { | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 创建学生 | |
| 18 | + * | |
| 19 | + * @param createReqVO 创建信息 | |
| 20 | + * @return 编号 | |
| 21 | + */ | |
| 22 | + Long createDemo01Student(@Valid InfraDemo01StudentCreateReqVO createReqVO); | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * 更新学生 | |
| 26 | + * | |
| 27 | + * @param updateReqVO 更新信息 | |
| 28 | + */ | |
| 29 | + void updateDemo01Student(@Valid InfraDemo01StudentUpdateReqVO updateReqVO); | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * 删除学生 | |
| 33 | + * | |
| 34 | + * @param id 编号 | |
| 35 | + */ | |
| 36 | + void deleteDemo01Student(Long id); | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * 获得学生 | |
| 40 | + * | |
| 41 | + * @param id 编号 | |
| 42 | + * @return 学生 | |
| 43 | + */ | |
| 44 | + InfraDemo01StudentDO getDemo01Student(Long id); | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * 获得学生分页 | |
| 48 | + * | |
| 49 | + * @param pageReqVO 分页查询 | |
| 50 | + * @return 学生分页 | |
| 51 | + */ | |
| 52 | + PageResult<InfraDemo01StudentDO> getDemo01StudentPage(InfraDemo01StudentPageReqVO pageReqVO); | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * 获得学生列表, 用于 Excel 导出 | |
| 56 | + * | |
| 57 | + * @param exportReqVO 查询条件 | |
| 58 | + * @return 学生列表 | |
| 59 | + */ | |
| 60 | + List<InfraDemo01StudentDO> getDemo01StudentList(InfraDemo01StudentExportReqVO exportReqVO); | |
| 61 | + | |
| 62 | +} | |
| 0 | 63 | \ No newline at end of file | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo01/InfraDemo01StudentServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.infra.service.demo01; | |
| 2 | + | |
| 3 | +import org.springframework.stereotype.Service; | |
| 4 | +import javax.annotation.Resource; | |
| 5 | +import org.springframework.validation.annotation.Validated; | |
| 6 | +import org.springframework.transaction.annotation.Transactional; | |
| 7 | + | |
| 8 | +import java.util.*; | |
| 9 | +import cn.iocoder.yudao.module.infra.controller.admin.demo01.vo.*; | |
| 10 | +import cn.iocoder.yudao.module.infra.dal.dataobject.demo01.InfraDemo01StudentDO; | |
| 11 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 12 | + | |
| 13 | +import cn.iocoder.yudao.module.infra.convert.demo01.InfraDemo01StudentConvert; | |
| 14 | +import cn.iocoder.yudao.module.infra.dal.mysql.demo01.InfraDemo01StudentMapper; | |
| 15 | + | |
| 16 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 17 | +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*; | |
| 18 | + | |
| 19 | +import cn.hutool.core.collection.CollUtil; | |
| 20 | +import cn.hutool.core.collection.ListUtil; | |
| 21 | + | |
| 22 | +/** | |
| 23 | + * 学生 Service 实现类 | |
| 24 | + * | |
| 25 | + * @author 芋道源码 | |
| 26 | + */ | |
| 27 | +@Service | |
| 28 | +@Validated | |
| 29 | +public class InfraDemo01StudentServiceImpl implements InfraDemo01StudentService { | |
| 30 | + | |
| 31 | + @Resource | |
| 32 | + private InfraDemo01StudentMapper demo01StudentMapper; | |
| 33 | + | |
| 34 | + @Override | |
| 35 | + public Long createDemo01Student(InfraDemo01StudentCreateReqVO createReqVO) { | |
| 36 | + // 插入 | |
| 37 | + InfraDemo01StudentDO demo01Student = InfraDemo01StudentConvert.INSTANCE.convert(createReqVO); | |
| 38 | + demo01StudentMapper.insert(demo01Student); | |
| 39 | + // 返回 | |
| 40 | + return demo01Student.getId(); | |
| 41 | + } | |
| 42 | + | |
| 43 | + @Override | |
| 44 | + public void updateDemo01Student(InfraDemo01StudentUpdateReqVO updateReqVO) { | |
| 45 | + // 校验存在 | |
| 46 | + validateDemo01StudentExists(updateReqVO.getId()); | |
| 47 | + // 更新 | |
| 48 | + InfraDemo01StudentDO updateObj = InfraDemo01StudentConvert.INSTANCE.convert(updateReqVO); | |
| 49 | + demo01StudentMapper.updateById(updateObj); | |
| 50 | + } | |
| 51 | + | |
| 52 | + @Override | |
| 53 | + public void deleteDemo01Student(Long id) { | |
| 54 | + // 校验存在 | |
| 55 | + validateDemo01StudentExists(id); | |
| 56 | + // 删除 | |
| 57 | + demo01StudentMapper.deleteById(id); | |
| 58 | + } | |
| 59 | + | |
| 60 | + private void validateDemo01StudentExists(Long id) { | |
| 61 | + if (demo01StudentMapper.selectById(id) == null) { | |
| 62 | + throw exception(DEMO01_STUDENT_NOT_EXISTS); | |
| 63 | + } | |
| 64 | + } | |
| 65 | + | |
| 66 | + @Override | |
| 67 | + public InfraDemo01StudentDO getDemo01Student(Long id) { | |
| 68 | + return demo01StudentMapper.selectById(id); | |
| 69 | + } | |
| 70 | + | |
| 71 | + @Override | |
| 72 | + public PageResult<InfraDemo01StudentDO> getDemo01StudentPage(InfraDemo01StudentPageReqVO pageReqVO) { | |
| 73 | + return demo01StudentMapper.selectPage(pageReqVO); | |
| 74 | + } | |
| 75 | + | |
| 76 | + @Override | |
| 77 | + public List<InfraDemo01StudentDO> getDemo01StudentList(InfraDemo01StudentExportReqVO exportReqVO) { | |
| 78 | + return demo01StudentMapper.selectList(exportReqVO); | |
| 79 | + } | |
| 80 | + | |
| 81 | +} | |
| 0 | 82 | \ No newline at end of file | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/sql/sql.vm
| ... | ... | @@ -5,7 +5,7 @@ INSERT INTO system_menu( |
| 5 | 5 | ) |
| 6 | 6 | VALUES ( |
| 7 | 7 | '${table.classComment}管理', '', 2, 0, ${table.parentMenuId}, |
| 8 | - '${simpleClassName_strikeCase}', '', '${table.moduleName}/${classNameVar}/index', 0, '${table.className}' | |
| 8 | + '${simpleClassName_strikeCase}', '', '${table.moduleName}/${table.businessName}/index', 0, '${table.className}' | |
| 9 | 9 | ); |
| 10 | 10 | |
| 11 | 11 | -- 按钮父菜单ID | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/components/form_sub_normal.vue.vm
| ... | ... | @@ -179,15 +179,15 @@ |
| 179 | 179 | <el-input v-model="formData.${javaField}" placeholder="请输入${comment}" /> |
| 180 | 180 | </el-form-item> |
| 181 | 181 | #elseif($column.htmlType == "imageUpload")## 图片上传 |
| 182 | - <el-form-item label="${comment}"> | |
| 182 | + <el-form-item label="${comment}" prop="${javaField}"> | |
| 183 | 183 | <UploadImg v-model="formData.${javaField}" /> |
| 184 | 184 | </el-form-item> |
| 185 | 185 | #elseif($column.htmlType == "fileUpload")## 文件上传 |
| 186 | - <el-form-item label="${comment}"> | |
| 186 | + <el-form-item label="${comment}" prop="${javaField}"> | |
| 187 | 187 | <UploadFile v-model="formData.${javaField}" /> |
| 188 | 188 | </el-form-item> |
| 189 | 189 | #elseif($column.htmlType == "editor")## 文本编辑器 |
| 190 | - <el-form-item label="${comment}"> | |
| 190 | + <el-form-item label="${comment}" prop="${javaField}"> | |
| 191 | 191 | <Editor v-model="formData.${javaField}" height="150px" /> |
| 192 | 192 | </el-form-item> |
| 193 | 193 | #elseif($column.htmlType == "select")## 下拉框 |
| ... | ... | @@ -257,7 +257,7 @@ |
| 257 | 257 | </template> |
| 258 | 258 | <script setup lang="ts"> |
| 259 | 259 | import { getIntDictOptions, getStrDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict' |
| 260 | -import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${classNameVar}' | |
| 260 | +import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}' | |
| 261 | 261 | |
| 262 | 262 | const props = defineProps<{ |
| 263 | 263 | ${subJoinColumn.javaField}: undefined // ${subJoinColumn.columnComment}(主表的关联字段) | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/form.vue.vm
| ... | ... | @@ -31,11 +31,11 @@ |
| 31 | 31 | <UploadImg v-model="formData.${javaField}" /> |
| 32 | 32 | </el-form-item> |
| 33 | 33 | #elseif($column.htmlType == "fileUpload")## 文件上传 |
| 34 | - <el-form-item label="${comment}"> | |
| 34 | + <el-form-item label="${comment}" prop="${javaField}"> | |
| 35 | 35 | <UploadFile v-model="formData.${javaField}" /> |
| 36 | 36 | </el-form-item> |
| 37 | 37 | #elseif($column.htmlType == "editor")## 文本编辑器 |
| 38 | - <el-form-item label="${comment}"> | |
| 38 | + <el-form-item label="${comment}" prop="${javaField}"> | |
| 39 | 39 | <Editor v-model="formData.${javaField}" height="150px" /> |
| 40 | 40 | </el-form-item> |
| 41 | 41 | #elseif($column.htmlType == "select")## 下拉框 |
| ... | ... | @@ -125,7 +125,7 @@ |
| 125 | 125 | </template> |
| 126 | 126 | <script setup lang="ts"> |
| 127 | 127 | import { getIntDictOptions, getStrDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict' |
| 128 | -import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${classNameVar}' | |
| 128 | +import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}' | |
| 129 | 129 | ## 特殊:主子表专属逻辑 |
| 130 | 130 | #foreach ($subSimpleClassName in $subSimpleClassNames) |
| 131 | 131 | import ${subSimpleClassName}Form from './components/${subSimpleClassName}Form.vue' | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/vue3/views/index.vue.vm
| ... | ... | @@ -122,7 +122,7 @@ |
| 122 | 122 | :formatter="dateFormatter" |
| 123 | 123 | width="180px" |
| 124 | 124 | /> |
| 125 | - #elseif("" != $column.dictType)## 数据字典 | |
| 125 | + #elseif($column.dictType && "" != $column.dictType)## 数据字典 | |
| 126 | 126 | <el-table-column label="${comment}" align="center" prop="${javaField}"> |
| 127 | 127 | <template #default="scope"> |
| 128 | 128 | <dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.${column.javaField}" /> |
| ... | ... | @@ -171,7 +171,7 @@ |
| 171 | 171 | import { getIntDictOptions, getStrDictOptions, getBoolDictOptions, DICT_TYPE } from '@/utils/dict' |
| 172 | 172 | import { dateFormatter } from '@/utils/formatTime' |
| 173 | 173 | import download from '@/utils/download' |
| 174 | -import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${classNameVar}' | |
| 174 | +import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}' | |
| 175 | 175 | import ${simpleClassName}Form from './${simpleClassName}Form.vue' |
| 176 | 176 | |
| 177 | 177 | defineOptions({ name: '${table.className}' }) | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo01/InfraDemo01StudentMapper.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |
| 3 | +<mapper namespace="cn.iocoder.yudao.module.infra.dal.mysql.demo01.InfraDemo01StudentMapper"> | |
| 4 | + | |
| 5 | + <!-- | |
| 6 | + 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 | |
| 7 | + 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 | |
| 8 | + 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 | |
| 9 | + 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ | |
| 10 | + --> | |
| 11 | + | |
| 12 | +</mapper> | |
| 0 | 13 | \ No newline at end of file | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenEngineTest.java
| 1 | 1 | package cn.iocoder.yudao.module.infra.service.codegen.inner; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.io.FileUtil; | |
| 4 | +import cn.hutool.core.io.IoUtil; | |
| 3 | 5 | import cn.hutool.core.io.resource.ResourceUtil; |
| 6 | +import cn.hutool.core.util.ZipUtil; | |
| 4 | 7 | import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; |
| 5 | 8 | import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenColumnDO; |
| 6 | 9 | import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenTableDO; |
| ... | ... | @@ -12,8 +15,9 @@ import org.junit.jupiter.api.Test; |
| 12 | 15 | import org.mockito.InjectMocks; |
| 13 | 16 | import org.mockito.Spy; |
| 14 | 17 | |
| 18 | +import java.io.ByteArrayInputStream; | |
| 19 | +import java.io.ByteArrayOutputStream; | |
| 15 | 20 | import java.util.Arrays; |
| 16 | -import java.util.Collections; | |
| 17 | 21 | import java.util.List; |
| 18 | 22 | import java.util.Map; |
| 19 | 23 | |
| ... | ... | @@ -41,84 +45,97 @@ public class CodegenEngineTest extends BaseMockitoUnitTest { |
| 41 | 45 | @Test |
| 42 | 46 | public void testExecute_vue3_crud() { |
| 43 | 47 | // 准备请求参数 |
| 44 | - CodegenTableDO table = new CodegenTableDO().setScene(CodegenSceneEnum.ADMIN.getScene()) | |
| 45 | - .setTableName("system_user").setTableComment("用户表") | |
| 46 | - .setModuleName("system").setBusinessName("user").setClassName("SystemUser") | |
| 47 | - .setClassComment("用户").setAuthor("芋道源码") | |
| 48 | + CodegenTableDO table = new CodegenTableDO().setScene(CodegenSceneEnum.ADMIN.getScene()).setParentMenuId(888L) | |
| 49 | + .setTableName("infra_demo01_student").setTableComment("学生表") | |
| 50 | + .setModuleName("infra").setBusinessName("demo01").setClassName("InfraDemo01Student") | |
| 51 | + .setClassComment("学生").setAuthor("芋道源码") | |
| 48 | 52 | .setTemplateType(CodegenTemplateTypeEnum.ONE.getType()) |
| 49 | - .setFrontType(CodegenFrontTypeEnum.VUE3.getType()) | |
| 50 | - .setParentMenuId(10L); | |
| 53 | + .setFrontType(CodegenFrontTypeEnum.VUE3.getType()); | |
| 51 | 54 | CodegenColumnDO idColumn = new CodegenColumnDO().setColumnName("id").setDataType(JdbcType.BIGINT.name()) |
| 52 | 55 | .setColumnComment("编号").setNullable(false).setPrimaryKey(true).setAutoIncrement(true) |
| 53 | - .setOrdinalPosition(1).setJavaType("Long").setJavaField("id").setExample("1024") | |
| 54 | - .setCreateOperation(false).setUpdateOperation(true).setListOperation(false) | |
| 56 | + .setJavaType("Long").setJavaField("id").setExample("1024") | |
| 57 | + .setCreateOperation(false).setUpdateOperation(true) | |
| 58 | + .setListOperation(false) | |
| 55 | 59 | .setListOperationResult(true); |
| 56 | 60 | CodegenColumnDO nameColumn = new CodegenColumnDO().setColumnName("name").setDataType(JdbcType.VARCHAR.name()) |
| 57 | - .setColumnComment("名字").setNullable(false).setPrimaryKey(false) | |
| 58 | - .setOrdinalPosition(2).setJavaType("String").setJavaField("name").setExample("芋头") | |
| 59 | - .setCreateOperation(true).setUpdateOperation(true).setListOperation(true) | |
| 60 | - .setListOperationCondition(CodegenColumnListConditionEnum.LIKE.getCondition()).setListOperationResult(true) | |
| 61 | - .setHtmlType(CodegenColumnHtmlTypeEnum.INPUT.getType()); | |
| 62 | - CodegenColumnDO avatarColumn = new CodegenColumnDO().setColumnName("avatar").setDataType(JdbcType.VARCHAR.name()) | |
| 63 | - .setColumnComment("头像").setNullable(true).setPrimaryKey(false) | |
| 64 | - .setOrdinalPosition(3).setJavaType("String").setJavaField("avatar").setExample("https://www.iocoder.cn/1.png") | |
| 65 | - .setCreateOperation(true).setUpdateOperation(true).setListOperation(false) | |
| 66 | - .setListOperationResult(true) | |
| 67 | - .setHtmlType(CodegenColumnHtmlTypeEnum.UPLOAD_IMAGE.getType()); | |
| 68 | - CodegenColumnDO videoColumn = new CodegenColumnDO().setColumnName("video").setDataType(JdbcType.VARCHAR.name()) | |
| 69 | - .setColumnComment("视频").setNullable(true).setPrimaryKey(false) | |
| 70 | - .setOrdinalPosition(4).setJavaType("String").setJavaField("video").setExample("https://www.iocoder.cn/1.mp4") | |
| 71 | - .setCreateOperation(true).setUpdateOperation(true).setListOperation(false) | |
| 61 | + .setColumnComment("名字").setNullable(false) | |
| 62 | + .setJavaType("String").setJavaField("name").setExample("芋头") | |
| 63 | + .setCreateOperation(true).setUpdateOperation(true) | |
| 64 | + .setListOperation(true).setListOperationCondition(CodegenColumnListConditionEnum.LIKE.getCondition()) | |
| 72 | 65 | .setListOperationResult(true) |
| 73 | - .setHtmlType(CodegenColumnHtmlTypeEnum.UPLOAD_FILE.getType()); | |
| 66 | + .setHtmlType(CodegenColumnHtmlTypeEnum.INPUT.getType()); | |
| 74 | 67 | CodegenColumnDO descriptionColumn = new CodegenColumnDO().setColumnName("description").setDataType(JdbcType.VARCHAR.name()) |
| 75 | - .setColumnComment("个人简介").setNullable(true).setPrimaryKey(false) | |
| 76 | - .setOrdinalPosition(5).setJavaType("String").setJavaField("description").setExample("我是介绍") | |
| 77 | - .setCreateOperation(true).setUpdateOperation(true).setListOperation(false) | |
| 68 | + .setColumnComment("简介").setNullable(false) | |
| 69 | + .setJavaType("String").setJavaField("description").setExample("我是介绍") | |
| 70 | + .setCreateOperation(true).setUpdateOperation(true) | |
| 71 | + .setListOperation(false) | |
| 78 | 72 | .setListOperationResult(true) |
| 79 | - .setHtmlType(CodegenColumnHtmlTypeEnum.EDITOR.getType()); | |
| 80 | - CodegenColumnDO sex1Column = new CodegenColumnDO().setColumnName("sex1").setDataType(JdbcType.VARCHAR.name()) | |
| 81 | - .setColumnComment("性别 1").setNullable(true).setPrimaryKey(false) | |
| 82 | - .setOrdinalPosition(6).setJavaType("String").setJavaField("sex1").setExample("男") | |
| 83 | - .setCreateOperation(true).setUpdateOperation(true).setListOperation(true) | |
| 84 | - .setListOperationCondition(CodegenColumnListConditionEnum.EQ.getCondition()).setListOperationResult(true) | |
| 85 | - .setHtmlType(CodegenColumnHtmlTypeEnum.SELECT.getType()).setDictType("system_sex1"); | |
| 86 | - CodegenColumnDO sex2Column = new CodegenColumnDO().setColumnName("sex2").setDataType(JdbcType.INTEGER.name()) | |
| 87 | - .setColumnComment("性别 2").setNullable(true).setPrimaryKey(false) | |
| 88 | - .setOrdinalPosition(7).setJavaType("Integer").setJavaField("sex2").setExample("1") | |
| 89 | - .setCreateOperation(true).setUpdateOperation(true).setListOperation(true) | |
| 90 | - .setListOperationCondition(CodegenColumnListConditionEnum.EQ.getCondition()).setListOperationResult(true) | |
| 91 | - .setHtmlType(CodegenColumnHtmlTypeEnum.CHECKBOX.getType()).setDictType("system_sex2"); | |
| 92 | - CodegenColumnDO sex3Column = new CodegenColumnDO().setColumnName("sex3").setDataType(JdbcType.BOOLEAN.name()) | |
| 93 | - .setColumnComment("性别 3").setNullable(true).setPrimaryKey(false) | |
| 94 | - .setOrdinalPosition(8).setJavaType("Boolean").setJavaField("sex3").setExample("true") | |
| 95 | - .setCreateOperation(true).setUpdateOperation(true).setListOperation(true) | |
| 96 | - .setListOperationResult(true) | |
| 97 | - .setHtmlType(CodegenColumnHtmlTypeEnum.RADIO.getType()).setDictType("system_sex3"); | |
| 73 | + .setHtmlType(CodegenColumnHtmlTypeEnum.TEXTAREA.getType()); | |
| 98 | 74 | CodegenColumnDO birthdayColumn = new CodegenColumnDO().setColumnName("birthday").setDataType(JdbcType.DATE.name()) |
| 99 | - .setColumnComment("出生日期").setNullable(true).setPrimaryKey(false) | |
| 100 | - .setOrdinalPosition(9).setJavaType("LocalDateTime").setJavaField("birthday") | |
| 101 | - .setCreateOperation(true).setUpdateOperation(true).setListOperation(true) | |
| 102 | - .setListOperationCondition(CodegenColumnListConditionEnum.EQ.getCondition()).setListOperationResult(true) | |
| 75 | + .setColumnComment("出生日期").setNullable(false) | |
| 76 | + .setJavaType("LocalDateTime").setJavaField("birthday") | |
| 77 | + .setCreateOperation(true).setUpdateOperation(true) | |
| 78 | + .setListOperation(true).setListOperationCondition(CodegenColumnListConditionEnum.EQ.getCondition()) | |
| 79 | + .setListOperationResult(true) | |
| 103 | 80 | .setHtmlType(CodegenColumnHtmlTypeEnum.DATETIME.getType()); |
| 81 | + CodegenColumnDO sexColumn = new CodegenColumnDO().setColumnName("sex").setDataType(JdbcType.INTEGER.name()) | |
| 82 | + .setColumnComment("性别").setNullable(false) | |
| 83 | + .setJavaType("Integer").setJavaField("sex").setExample("1") | |
| 84 | + .setCreateOperation(true).setUpdateOperation(true) | |
| 85 | + .setListOperation(true).setListOperationCondition(CodegenColumnListConditionEnum.EQ.getCondition()) | |
| 86 | + .setListOperationResult(true) | |
| 87 | + .setHtmlType(CodegenColumnHtmlTypeEnum.SELECT.getType()) | |
| 88 | + .setDictType("system_user_sex"); | |
| 89 | + CodegenColumnDO enabledColumn = new CodegenColumnDO().setColumnName("enabled").setDataType(JdbcType.BOOLEAN.name()) | |
| 90 | + .setColumnComment("是否有效").setNullable(false) | |
| 91 | + .setJavaType("Boolean").setJavaField("enabled").setExample("true") | |
| 92 | + .setCreateOperation(true).setUpdateOperation(true) | |
| 93 | + .setListOperation(true).setListOperationCondition(CodegenColumnListConditionEnum.EQ.getCondition()) | |
| 94 | + .setListOperationResult(true) | |
| 95 | + .setHtmlType(CodegenColumnHtmlTypeEnum.RADIO.getType()) | |
| 96 | + .setDictType("infra_boolean_string"); | |
| 97 | + CodegenColumnDO avatarColumn = new CodegenColumnDO().setColumnName("avatar").setDataType(JdbcType.VARCHAR.name()) | |
| 98 | + .setColumnComment("头像").setNullable(false) | |
| 99 | + .setJavaType("String").setJavaField("avatar").setExample("https://www.iocoder.cn/1.png") | |
| 100 | + .setCreateOperation(true).setUpdateOperation(true) | |
| 101 | + .setListOperation(false) | |
| 102 | + .setListOperationResult(true) | |
| 103 | + .setHtmlType(CodegenColumnHtmlTypeEnum.IMAGE_UPLOAD.getType()); | |
| 104 | + CodegenColumnDO videoColumn = new CodegenColumnDO().setColumnName("video").setDataType(JdbcType.VARCHAR.name()) | |
| 105 | + .setColumnComment("附件").setNullable(true) | |
| 106 | + .setJavaType("String").setJavaField("video").setExample("https://www.iocoder.cn/1.mp4") | |
| 107 | + .setCreateOperation(true).setUpdateOperation(true) | |
| 108 | + .setListOperation(false) | |
| 109 | + .setListOperationResult(true) | |
| 110 | + .setHtmlType(CodegenColumnHtmlTypeEnum.FILE_UPLOAD.getType()); | |
| 104 | 111 | CodegenColumnDO memoColumn = new CodegenColumnDO().setColumnName("memo").setDataType(JdbcType.VARCHAR.name()) |
| 105 | - .setColumnComment("备注").setNullable(true).setPrimaryKey(false) | |
| 106 | - .setOrdinalPosition(10).setJavaType("String").setJavaField("memo").setExample("我是备注") | |
| 107 | - .setCreateOperation(true).setUpdateOperation(true).setListOperation(false) | |
| 112 | + .setColumnComment("备注").setNullable(false) | |
| 113 | + .setJavaType("String").setJavaField("memo").setExample("我是备注") | |
| 114 | + .setCreateOperation(true).setUpdateOperation(true) | |
| 115 | + .setListOperation(false) | |
| 108 | 116 | .setListOperationResult(true) |
| 109 | - .setHtmlType(CodegenColumnHtmlTypeEnum.TEXTAREA.getType()); | |
| 117 | + .setHtmlType(CodegenColumnHtmlTypeEnum.EDITOR.getType()); | |
| 110 | 118 | CodegenColumnDO createTimeColumn = new CodegenColumnDO().setColumnName("create_time").setDataType(JdbcType.DATE.name()) |
| 111 | - .setColumnComment("创建时间").setNullable(true).setPrimaryKey(false) | |
| 112 | - .setOrdinalPosition(11).setJavaType("LocalDateTime").setJavaField("createTime") | |
| 113 | - .setCreateOperation(true).setUpdateOperation(true).setListOperation(true) | |
| 114 | - .setListOperationCondition(CodegenColumnListConditionEnum.BETWEEN.getCondition()).setListOperationResult(true) | |
| 119 | + .setColumnComment("创建时间").setNullable(true) | |
| 120 | + .setJavaType("LocalDateTime").setJavaField("createTime") | |
| 121 | + .setCreateOperation(false).setUpdateOperation(false) | |
| 122 | + .setListOperation(true).setListOperationCondition(CodegenColumnListConditionEnum.BETWEEN.getCondition()) | |
| 123 | + .setListOperationResult(true) | |
| 115 | 124 | .setHtmlType(CodegenColumnHtmlTypeEnum.DATETIME.getType()); |
| 116 | - List<CodegenColumnDO> columns = Arrays.asList(idColumn, nameColumn, avatarColumn, videoColumn, descriptionColumn, | |
| 117 | - sex1Column, sex2Column, sex3Column, birthdayColumn, memoColumn, createTimeColumn); | |
| 125 | + List<CodegenColumnDO> columns = Arrays.asList(idColumn, nameColumn, descriptionColumn, birthdayColumn, | |
| 126 | + sexColumn, enabledColumn, avatarColumn, videoColumn, memoColumn, createTimeColumn); | |
| 118 | 127 | |
| 119 | 128 | // 调用 |
| 120 | 129 | Map<String, String> result = codegenEngine.execute(table, columns, null, null); |
| 121 | 130 | |
| 131 | + // 构建 zip 包 | |
| 132 | + String[] paths = result.keySet().toArray(new String[0]); | |
| 133 | + ByteArrayInputStream[] ins = result.values().stream().map(IoUtil::toUtf8Stream).toArray(ByteArrayInputStream[]::new); | |
| 134 | + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); | |
| 135 | + ZipUtil.zip(outputStream, paths, ins); | |
| 136 | + | |
| 137 | + FileUtil.writeBytes(outputStream.toByteArray(), "/Users/yunai/test/demo01.zip"); | |
| 138 | + | |
| 122 | 139 | // 断言 |
| 123 | 140 | assertEquals(21, result.size()); |
| 124 | 141 | // 断言 vo 类 |
| ... | ... | @@ -169,20 +186,7 @@ public class CodegenEngineTest extends BaseMockitoUnitTest { |
| 169 | 186 | public void testExecute_vue3_masterSub() { |
| 170 | 187 | // 准备请求参数 |
| 171 | 188 | // 主表 |
| 172 | - CodegenTableDO table = new CodegenTableDO().setScene(CodegenSceneEnum.ADMIN.getScene()) | |
| 173 | - .setTableName("infra_demo_student").setTableComment("学生表") | |
| 174 | - .setModuleName("infra").setBusinessName("demo02").setClassName("InfraDemoStudent") | |
| 175 | - .setClassComment("学生").setAuthor("芋道源码") | |
| 176 | - .setTemplateType(CodegenTemplateTypeEnum.MASTER_NORMAL.getType()) | |
| 177 | -// .setTemplateType(CodegenTemplateTypeEnum.MASTER_ERP.getType()) | |
| 178 | - .setFrontType(CodegenFrontTypeEnum.VUE3.getType()); | |
| 179 | - CodegenColumnDO idColumn = new CodegenColumnDO().setColumnName("id").setDataType(JdbcType.BIGINT.name()) | |
| 180 | - .setColumnComment("编号").setNullable(false).setPrimaryKey(true).setAutoIncrement(true) | |
| 181 | - .setOrdinalPosition(1).setJavaType("Long").setJavaField("id").setExample("1024") | |
| 182 | - .setCreateOperation(false).setUpdateOperation(true).setListOperation(false) | |
| 183 | - .setListOperationResult(true); | |
| 184 | 189 | |
| 185 | - List<CodegenColumnDO> columns = Collections.singletonList(idColumn); | |
| 186 | 190 | // 子表(联系人) |
| 187 | 191 | CodegenTableDO contactTable = new CodegenTableDO().setScene(CodegenSceneEnum.ADMIN.getScene()) |
| 188 | 192 | .setTableName("infra_demo_student_contact").setTableComment("学生联系人表") |
| ... | ... | @@ -213,13 +217,13 @@ public class CodegenEngineTest extends BaseMockitoUnitTest { |
| 213 | 217 | .setOrdinalPosition(4).setJavaType("String").setJavaField("avatar").setExample("https://www.iocoder.cn/1.png") |
| 214 | 218 | .setCreateOperation(true).setUpdateOperation(true).setListOperation(false) |
| 215 | 219 | .setListOperationResult(true) |
| 216 | - .setHtmlType(CodegenColumnHtmlTypeEnum.UPLOAD_IMAGE.getType()); | |
| 220 | + .setHtmlType(CodegenColumnHtmlTypeEnum.IMAGE_UPLOAD.getType()); | |
| 217 | 221 | CodegenColumnDO contactVideoColumn = new CodegenColumnDO().setColumnName("video").setDataType(JdbcType.VARCHAR.name()) |
| 218 | 222 | .setColumnComment("视频").setNullable(false).setPrimaryKey(false) |
| 219 | 223 | .setOrdinalPosition(5).setJavaType("String").setJavaField("video").setExample("https://www.iocoder.cn/1.mp4") |
| 220 | 224 | .setCreateOperation(true).setUpdateOperation(true).setListOperation(false) |
| 221 | 225 | .setListOperationResult(true) |
| 222 | - .setHtmlType(CodegenColumnHtmlTypeEnum.UPLOAD_FILE.getType()); | |
| 226 | + .setHtmlType(CodegenColumnHtmlTypeEnum.FILE_UPLOAD.getType()); | |
| 223 | 227 | CodegenColumnDO contactDescriptionColumn = new CodegenColumnDO().setColumnName("description").setDataType(JdbcType.VARCHAR.name()) |
| 224 | 228 | .setColumnComment("个人简介").setNullable(false).setPrimaryKey(false) |
| 225 | 229 | .setOrdinalPosition(6).setJavaType("String").setJavaField("description").setExample("我是介绍") |
| ... | ... | @@ -295,13 +299,13 @@ public class CodegenEngineTest extends BaseMockitoUnitTest { |
| 295 | 299 | .setOrdinalPosition(4).setJavaType("String").setJavaField("avatar").setExample("https://www.iocoder.cn/1.png") |
| 296 | 300 | .setCreateOperation(true).setUpdateOperation(true).setListOperation(false) |
| 297 | 301 | .setListOperationResult(true) |
| 298 | - .setHtmlType(CodegenColumnHtmlTypeEnum.UPLOAD_IMAGE.getType()); | |
| 302 | + .setHtmlType(CodegenColumnHtmlTypeEnum.IMAGE_UPLOAD.getType()); | |
| 299 | 303 | CodegenColumnDO addressVideoColumn = new CodegenColumnDO().setColumnName("video").setDataType(JdbcType.VARCHAR.name()) |
| 300 | 304 | .setColumnComment("视频").setNullable(false).setPrimaryKey(false) |
| 301 | 305 | .setOrdinalPosition(5).setJavaType("String").setJavaField("video").setExample("https://www.iocoder.cn/1.mp4") |
| 302 | 306 | .setCreateOperation(true).setUpdateOperation(true).setListOperation(false) |
| 303 | 307 | .setListOperationResult(true) |
| 304 | - .setHtmlType(CodegenColumnHtmlTypeEnum.UPLOAD_FILE.getType()); | |
| 308 | + .setHtmlType(CodegenColumnHtmlTypeEnum.FILE_UPLOAD.getType()); | |
| 305 | 309 | CodegenColumnDO addressDescriptionColumn = new CodegenColumnDO().setColumnName("description").setDataType(JdbcType.VARCHAR.name()) |
| 306 | 310 | .setColumnComment("个人简介").setNullable(false).setPrimaryKey(false) |
| 307 | 311 | .setOrdinalPosition(6).setJavaType("String").setJavaField("description").setExample("我是介绍") |
| ... | ... | @@ -349,7 +353,7 @@ public class CodegenEngineTest extends BaseMockitoUnitTest { |
| 349 | 353 | addressSex1Column, addressSex2Column, addressSex3Column, addressBirthdayColumn, addressMemoColumn, addressCreateTimeColumn); |
| 350 | 354 | |
| 351 | 355 | // 调用 |
| 352 | - Map<String, String> result = codegenEngine.execute(table, columns, | |
| 356 | + Map<String, String> result = codegenEngine.execute(null, null, | |
| 353 | 357 | Arrays.asList(contactTable, addressTable), Arrays.asList(contactColumns, addressColumns)); |
| 354 | 358 | |
| 355 | 359 | // 断言 |
| ... | ... | @@ -362,49 +366,6 @@ public class CodegenEngineTest extends BaseMockitoUnitTest { |
| 362 | 366 | System.out.println(""); |
| 363 | 367 | System.out.println(""); |
| 364 | 368 | } |
| 365 | - | |
| 366 | -// // 断言 vo 类 | |
| 367 | -// for (String vo : new String[]{"SystemUserBaseVO", "SystemUserCreateReqVO", "SystemUserUpdateReqVO", "SystemUserRespVO", | |
| 368 | -// "SystemUserPageReqVO", "SystemUserExportReqVO", "SystemUserExcelVO"}) { | |
| 369 | -// assertPathContentEquals("vue3_crud/java/" + vo, | |
| 370 | -// result, "yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/" + vo + ".java"); | |
| 371 | -// } | |
| 372 | -// // 断言 controller 类 | |
| 373 | -// assertPathContentEquals("vue3_crud/java/SystemUserController", | |
| 374 | -// result, "yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/SystemUserController.java"); | |
| 375 | -// // 断言 service 类 | |
| 376 | -// assertPathContentEquals("vue3_crud/java/SystemUserService", | |
| 377 | -// result, "yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/SystemUserService.java"); | |
| 378 | -// assertPathContentEquals("vue3_crud/java/SystemUserServiceImpl", | |
| 379 | -// result, "yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/SystemUserServiceImpl.java"); | |
| 380 | -// // 断言 convert 类 | |
| 381 | -// assertPathContentEquals("vue3_crud/java/SystemUserConvert", | |
| 382 | -// result, "yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/user/SystemUserConvert.java"); | |
| 383 | -// // 断言 enums 类 | |
| 384 | -// assertPathContentEquals("vue3_crud/java/ErrorCodeConstants", | |
| 385 | -// result, "yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants_手动操作.java"); | |
| 386 | -// // 断言 dal 类 | |
| 387 | -// assertPathContentEquals("vue3_crud/java/SystemUserDO", | |
| 388 | -// result, "yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/user/SystemUserDO.java"); | |
| 389 | -// assertPathContentEquals("vue3_crud/java/SystemUserMapper", | |
| 390 | -// result, "yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/SystemUserMapper.java"); | |
| 391 | -// assertPathContentEquals("vue3_crud/java/SystemUserMapper_xml", | |
| 392 | -// result, "yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/user/SystemUserMapper.xml"); | |
| 393 | -// // 断言 test 类 | |
| 394 | -// assertPathContentEquals("vue3_crud/java/SystemUserServiceImplTest", | |
| 395 | -// result, "yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/user/SystemUserServiceImplTest.java"); | |
| 396 | -// // 断言 sql 语句 | |
| 397 | -// assertPathContentEquals("vue3_crud/sql/h2", | |
| 398 | -// result, "sql/h2.sql"); | |
| 399 | -// assertPathContentEquals("vue3_crud/sql/sql", | |
| 400 | -// result, "sql/sql.sql"); | |
| 401 | -// // 断言 vue 语句 | |
| 402 | -// assertPathContentEquals("vue3_crud/vue/index", | |
| 403 | -// result, "yudao-ui-admin-vue3/src/views/system/user/index.vue"); | |
| 404 | -// assertPathContentEquals("vue3_crud/vue/form", | |
| 405 | -// result, "yudao-ui-admin-vue3/src/views/system/user/UserForm.vue"); | |
| 406 | -// assertPathContentEquals("vue3_crud/vue/api", | |
| 407 | -// result, "yudao-ui-admin-vue3/src/api/system/user/index.ts"); | |
| 408 | 369 | } |
| 409 | 370 | |
| 410 | 371 | private void assertPathContentEquals(String path, Map<String, String> result, String key) { | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/vue3_master_sub/1 renamed to yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/contact.json
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/extension.json
0 → 100644
yudao-module-infra/yudao-module-infra-biz/src/test/resources/codegen/table/student.json
0 → 100644