Sfoglia il codice sorgente

代码生成:增加 crud 单表示例

YunaiV 1 anno fa
parent
commit
0d49691aa0
22 ha cambiato i file con 381 aggiunte e 592 eliminazioni
  1. 2 8
      yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants.java
  2. 93 0
      yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/Demo01ContactController.java
  3. 28 0
      yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/vo/Demo01ContactPageReqVO.java
  4. 47 0
      yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/vo/Demo01ContactRespVO.java
  5. 36 0
      yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/vo/Demo01ContactSaveReqVO.java
  6. 10 0
      yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/package-info.java
  7. 12 25
      yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/demo01/Demo01ContactDO.java
  8. 0 68
      yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo01/InfraDemo01StudentDO.java
  9. 0 37
      yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo02/InfraDemoStudentAddressDO.java
  10. 0 37
      yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo02/InfraDemoStudentContactDO.java
  11. 0 29
      yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo02/InfraDemoStudentDO.java
  12. 0 72
      yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo11/InfraDemo11StudentContactDO.java
  13. 0 71
      yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo11/InfraDemo11StudentTeacherDO.java
  14. 0 71
      yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo12/InfraDemo12StudentContactDO.java
  15. 0 67
      yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo12/InfraDemo12StudentDO.java
  16. 0 71
      yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo12/InfraDemo12StudentTeacherDO.java
  17. 26 0
      yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo01/Demo01ContactMapper.java
  18. 55 0
      yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo01/Demo01ContactService.java
  19. 72 0
      yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo01/Demo01ContactServiceImpl.java
  20. 0 12
      yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo01/InfraDemo01StudentMapper.xml
  21. 0 12
      yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo11/InfraDemo11StudentMapper.xml
  22. 0 12
      yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo12/InfraDemo12StudentMapper.xml

+ 2 - 8
yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants.java

@@ -58,13 +58,7 @@ public interface ErrorCodeConstants {
     // ========== 数据源配置 1-001-107-000 ==========
     ErrorCode DEMO_STUDENT_NOT_EXISTS = new ErrorCode(1_001_107_000, "学生不存在");
 
-    // ========== 学生(CodegenTemplateTypeEnum.ONE 示例) 1-001-201-000 ==========
-    ErrorCode DEMO01_STUDENT_NOT_EXISTS = new ErrorCode(1_001_200_000, "学生不存在");
-
-    // ========== 学生(CodegenTemplateTypeEnum.MASTER_NORMAL 示例) 1-001-211-000 ==========
-    ErrorCode DEMO11_STUDENT_NOT_EXISTS = new ErrorCode(1_001_211_000, "学生不存在");
-
-    // ========== 学生(CodegenTemplateTypeEnum.MASTER_INNER 示例) 1-001-213-000 ==========
-    ErrorCode DEMO12_STUDENT_NOT_EXISTS = new ErrorCode(1_001_213_000, "学生不存在");
+    // ========== 学生 1-001-201-000 ==========
+    ErrorCode DEMO01_CONTACT_NOT_EXISTS = new ErrorCode(1_001_201_000, "示例联系人不存在");
 
 }

+ 93 - 0
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/Demo01ContactController.java

@@ -0,0 +1,93 @@
+package cn.iocoder.yudao.module.infra.controller.admin.demo.demo01;
+
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
+import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
+import cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo.Demo01ContactPageReqVO;
+import cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo.Demo01ContactRespVO;
+import cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo.Demo01ContactSaveReqVO;
+import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo01.Demo01ContactDO;
+import cn.iocoder.yudao.module.infra.service.demo.demo01.Demo01ContactService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+import java.io.IOException;
+import java.util.List;
+
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
+
+@Tag(name = "管理后台 - 示例联系人")
+@RestController
+@RequestMapping("/infra/demo01-contact")
+@Validated
+public class Demo01ContactController {
+
+    @Resource
+    private Demo01ContactService demo01ContactService;
+
+    @PostMapping("/create")
+    @Operation(summary = "创建示例联系人")
+    @PreAuthorize("@ss.hasPermission('infra:demo01-contact:create')")
+    public CommonResult<Long> createDemo01Contact(@Valid @RequestBody Demo01ContactSaveReqVO createReqVO) {
+        return success(demo01ContactService.createDemo01Contact(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新示例联系人")
+    @PreAuthorize("@ss.hasPermission('infra:demo01-contact:update')")
+    public CommonResult<Boolean> updateDemo01Contact(@Valid @RequestBody Demo01ContactSaveReqVO updateReqVO) {
+        demo01ContactService.updateDemo01Contact(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除示例联系人")
+    @Parameter(name = "id", description = "编号", required = true)
+    @PreAuthorize("@ss.hasPermission('infra:demo01-contact:delete')")
+    public CommonResult<Boolean> deleteDemo01Contact(@RequestParam("id") Long id) {
+        demo01ContactService.deleteDemo01Contact(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获得示例联系人")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('infra:demo01-contact:query')")
+    public CommonResult<Demo01ContactRespVO> getDemo01Contact(@RequestParam("id") Long id) {
+        Demo01ContactDO demo01Contact = demo01ContactService.getDemo01Contact(id);
+        return success(BeanUtils.toBean(demo01Contact, Demo01ContactRespVO.class));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "获得示例联系人分页")
+    @PreAuthorize("@ss.hasPermission('infra:demo01-contact:query')")
+    public CommonResult<PageResult<Demo01ContactRespVO>> getDemo01ContactPage(@Valid Demo01ContactPageReqVO pageReqVO) {
+        PageResult<Demo01ContactDO> pageResult = demo01ContactService.getDemo01ContactPage(pageReqVO);
+        return success(BeanUtils.toBean(pageResult, Demo01ContactRespVO.class));
+    }
+
+    @GetMapping("/export-excel")
+    @Operation(summary = "导出示例联系人 Excel")
+    @PreAuthorize("@ss.hasPermission('infra:demo01-contact:export')")
+    @OperateLog(type = EXPORT)
+    public void exportDemo01ContactExcel(@Valid Demo01ContactPageReqVO pageReqVO,
+              HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        List<Demo01ContactDO> list = demo01ContactService.getDemo01ContactPage(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "示例联系人.xls", "数据", Demo01ContactRespVO.class,
+                        BeanUtils.toBean(list, Demo01ContactRespVO.class));
+    }
+
+}

+ 28 - 0
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/vo/Demo01ContactPageReqVO.java

@@ -0,0 +1,28 @@
+package cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo;
+
+import lombok.*;
+import java.util.*;
+import io.swagger.v3.oas.annotations.media.Schema;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.time.LocalDateTime;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@Schema(description = "管理后台 - 示例联系人分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class Demo01ContactPageReqVO extends PageParam {
+
+    @Schema(description = "名字", example = "张三")
+    private String name;
+
+    @Schema(description = "性别", example = "1")
+    private Integer sex;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+}

+ 47 - 0
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/vo/Demo01ContactRespVO.java

@@ -0,0 +1,47 @@
+package cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+import java.util.*;
+import java.util.*;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.time.LocalDateTime;
+import com.alibaba.excel.annotation.*;
+import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
+import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
+
+@Schema(description = "管理后台 - 示例联系人 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class Demo01ContactRespVO {
+
+    @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "21555")
+    @ExcelProperty("编号")
+    private Long id;
+
+    @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
+    @ExcelProperty("名字")
+    private String name;
+
+    @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
+    @ExcelProperty(value = "性别", converter = DictConvert.class)
+    @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
+    private Integer sex;
+
+    @Schema(description = "出生年", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("出生年")
+    private LocalDateTime birthday;
+
+    @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对")
+    @ExcelProperty("简介")
+    private String description;
+
+    @Schema(description = "头像")
+    @ExcelProperty("头像")
+    private String avatar;
+
+    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+}

+ 36 - 0
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/vo/Demo01ContactSaveReqVO.java

@@ -0,0 +1,36 @@
+package cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - 示例联系人新增/修改 Request VO")
+@Data
+public class Demo01ContactSaveReqVO {
+
+    @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "21555")
+    private Long id;
+
+    @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
+    @NotEmpty(message = "名字不能为空")
+    private String name;
+
+    @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
+    @NotNull(message = "性别不能为空")
+    private Integer sex;
+
+    @Schema(description = "出生年", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotNull(message = "出生年不能为空")
+    private LocalDateTime birthday;
+
+    @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "你说的对")
+    @NotEmpty(message = "简介不能为空")
+    private String description;
+
+    @Schema(description = "头像")
+    private String avatar;
+
+}

+ 10 - 0
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/package-info.java

@@ -0,0 +1,10 @@
+/**
+ * 代码生成示例
+ *
+ * 1. demo01:单表(增删改查)
+ * 2. demo02:单表(树形结构)
+ * 3.1 demo03/normal:主子表(标准模式)
+ * 3.2 demo03/erp:主子表(ERP 模式)
+ * 3.3 demo03/inner:主子表(内嵌模式)
+ */
+package cn.iocoder.yudao.module.infra.controller.admin.demo;

+ 12 - 25
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo11/InfraDemo11StudentDO.java → yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/demo01/Demo01ContactDO.java

@@ -1,26 +1,27 @@
-package cn.iocoder.yudao.module.infra.dal.dataobject.demo11;
+package cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo01;
 
 import lombok.*;
 import java.util.*;
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
+import java.time.LocalDateTime;
 import com.baomidou.mybatisplus.annotation.*;
 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
 
 /**
- * 学生 DO
+ * 示例联系人 DO
  *
  * @author 芋道源码
  */
-@TableName("infra_demo11_student")
-@KeySequence("infra_demo11_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@TableName("infra_demo01_contact")
+@KeySequence("infra_demo01_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
 @Data
 @EqualsAndHashCode(callSuper = true)
 @ToString(callSuper = true)
 @Builder
 @NoArgsConstructor
 @AllArgsConstructor
-public class InfraDemo11StudentDO extends BaseDO {
+public class Demo01ContactDO extends BaseDO {
 
     /**
      * 编号
@@ -31,14 +32,6 @@ public class InfraDemo11StudentDO extends BaseDO {
      * 名字
      */
     private String name;
-    /**
-     * 简介
-     */
-    private String description;
-    /**
-     * 出生日期
-     */
-    private LocalDateTime birthday;
     /**
      * 性别
      *
@@ -46,22 +39,16 @@ public class InfraDemo11StudentDO extends BaseDO {
      */
     private Integer sex;
     /**
-     * 是否有效
-     *
-     * 枚举 {@link TODO infra_boolean_string 对应的类}
-     */
-    private Boolean enabled;
-    /**
-     * 头像
+     * 出生年
      */
-    private String avatar;
+    private LocalDateTime birthday;
     /**
-     * 附件
+     * 简介
      */
-    private String video;
+    private String description;
     /**
-     * 备注
+     * 头像
      */
-    private String memo;
+    private String avatar;
 
 }

+ 0 - 68
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo01/InfraDemo01StudentDO.java

@@ -1,68 +0,0 @@
-package cn.iocoder.yudao.module.infra.dal.dataobject.demo01;
-
-import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
-import com.baomidou.mybatisplus.annotation.KeySequence;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.*;
-
-import java.time.LocalDateTime;
-
-/**
- * 学生 DO
- *
- * @author 芋道源码
- */
-@TableName("infra_demo01_student")
-@KeySequence("infra_demo01_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
-@Data
-@EqualsAndHashCode(callSuper = true)
-@ToString(callSuper = true)
-@Builder
-@NoArgsConstructor
-@AllArgsConstructor
-public class InfraDemo01StudentDO extends BaseDO {
-
-    /**
-     * 编号
-     */
-    @TableId
-    private Long id;
-    /**
-     * 名字
-     */
-    private String name;
-    /**
-     * 简介
-     */
-    private String description;
-    /**
-     * 出生日期
-     */
-    private LocalDateTime birthday;
-    /**
-     * 性别
-     *
-     * 枚举 {@link TODO system_user_sex 对应的类}
-     */
-    private Integer sex;
-    /**
-     * 是否有效
-     *
-     * 枚举 {@link TODO infra_boolean_string 对应的类}
-     */
-    private Boolean enabled;
-    /**
-     * 头像
-     */
-    private String avatar;
-    /**
-     * 附件
-     */
-    private String video;
-    /**
-     * 备注
-     */
-    private String memo;
-
-}

+ 0 - 37
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo02/InfraDemoStudentAddressDO.java

@@ -1,37 +0,0 @@
-package cn.iocoder.yudao.module.infra.dal.dataobject.demo02;
-
-import lombok.*;
-import java.util.*;
-import com.baomidou.mybatisplus.annotation.*;
-import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
-
-/**
- * 学生地址 DO
- *
- * @author 芋道源码
- */
-@TableName("infra_demo_student_address")
-@KeySequence("infra_demo_student_address_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
-@Data
-@EqualsAndHashCode(callSuper = true)
-@ToString(callSuper = true)
-@Builder
-@NoArgsConstructor
-@AllArgsConstructor
-public class InfraDemoStudentAddressDO extends BaseDO {
-
-    /**
-     * 编号
-     */
-    @TableId
-    private Long id;
-    /**
-     * 学生编号
-     */
-    private Long studentId;
-    /**
-     * 明细
-     */
-    private String detail;
-
-}

+ 0 - 37
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo02/InfraDemoStudentContactDO.java

@@ -1,37 +0,0 @@
-package cn.iocoder.yudao.module.infra.dal.dataobject.demo02;
-
-import lombok.*;
-import java.util.*;
-import com.baomidou.mybatisplus.annotation.*;
-import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
-
-/**
- * 学生联系人 DO
- *
- * @author 芋道源码
- */
-@TableName("infra_demo_student_contact")
-@KeySequence("infra_demo_student_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
-@Data
-@EqualsAndHashCode(callSuper = true)
-@ToString(callSuper = true)
-@Builder
-@NoArgsConstructor
-@AllArgsConstructor
-public class InfraDemoStudentContactDO extends BaseDO {
-
-    /**
-     * 编号
-     */
-    @TableId
-    private Long id;
-    /**
-     * 学生编号
-     */
-    private Long studentId;
-    /**
-     * 名字
-     */
-    private String name;
-
-}

+ 0 - 29
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo02/InfraDemoStudentDO.java

@@ -1,29 +0,0 @@
-package cn.iocoder.yudao.module.infra.dal.dataobject.demo02;
-
-import lombok.*;
-import java.util.*;
-import com.baomidou.mybatisplus.annotation.*;
-import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
-
-/**
- * 学生 DO
- *
- * @author 芋道源码
- */
-@TableName("infra_demo_student")
-@KeySequence("infra_demo_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
-@Data
-@EqualsAndHashCode(callSuper = true)
-@ToString(callSuper = true)
-@Builder
-@NoArgsConstructor
-@AllArgsConstructor
-public class InfraDemoStudentDO extends BaseDO {
-
-    /**
-     * 编号
-     */
-    @TableId
-    private Long id;
-
-}

+ 0 - 72
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo11/InfraDemo11StudentContactDO.java

@@ -1,72 +0,0 @@
-package cn.iocoder.yudao.module.infra.dal.dataobject.demo11;
-
-import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
-import com.baomidou.mybatisplus.annotation.KeySequence;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.*;
-
-import java.time.LocalDateTime;
-
-/**
- * 学生联系人 DO
- *
- * @author 芋道源码
- */
-@TableName("infra_demo11_student_contact")
-@KeySequence("infra_demo11_student_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
-@Data
-@EqualsAndHashCode(callSuper = true)
-@ToString(callSuper = true)
-@Builder
-@NoArgsConstructor
-@AllArgsConstructor
-public class InfraDemo11StudentContactDO extends BaseDO {
-
-    /**
-     * 编号
-     */
-    @TableId
-    private Long id;
-    /**
-     * 学生编号
-     */
-    private Long studentId;
-    /**
-     * 名字
-     */
-    private String name;
-    /**
-     * 简介
-     */
-    private String description;
-    /**
-     * 出生日期
-     */
-    private LocalDateTime birthday;
-    /**
-     * 性别
-     *
-     * 枚举 {@link TODO system_user_sex 对应的类}
-     */
-    private Integer sex;
-    /**
-     * 是否有效
-     *
-     * 枚举 {@link TODO infra_boolean_string 对应的类}
-     */
-    private Boolean enabled;
-    /**
-     * 头像
-     */
-    private String avatar;
-    /**
-     * 附件
-     */
-    private String video;
-    /**
-     * 备注
-     */
-    private String memo;
-
-}

+ 0 - 71
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo11/InfraDemo11StudentTeacherDO.java

@@ -1,71 +0,0 @@
-package cn.iocoder.yudao.module.infra.dal.dataobject.demo11;
-
-import lombok.*;
-import java.util.*;
-import java.time.LocalDateTime;
-import java.time.LocalDateTime;
-import com.baomidou.mybatisplus.annotation.*;
-import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
-
-/**
- * 学生班主任 DO
- *
- * @author 芋道源码
- */
-@TableName("infra_demo11_student_teacher")
-@KeySequence("infra_demo11_student_teacher_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
-@Data
-@EqualsAndHashCode(callSuper = true)
-@ToString(callSuper = true)
-@Builder
-@NoArgsConstructor
-@AllArgsConstructor
-public class InfraDemo11StudentTeacherDO extends BaseDO {
-
-    /**
-     * 编号
-     */
-    @TableId
-    private Long id;
-    /**
-     * 学生编号
-     */
-    private Long studentId;
-    /**
-     * 名字
-     */
-    private String name;
-    /**
-     * 简介
-     */
-    private String description;
-    /**
-     * 出生日期
-     */
-    private LocalDateTime birthday;
-    /**
-     * 性别
-     *
-     * 枚举 {@link TODO system_user_sex 对应的类}
-     */
-    private Integer sex;
-    /**
-     * 是否有效
-     *
-     * 枚举 {@link TODO infra_boolean_string 对应的类}
-     */
-    private Boolean enabled;
-    /**
-     * 头像
-     */
-    private String avatar;
-    /**
-     * 附件
-     */
-    private String video;
-    /**
-     * 备注
-     */
-    private String memo;
-
-}

+ 0 - 71
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo12/InfraDemo12StudentContactDO.java

@@ -1,71 +0,0 @@
-package cn.iocoder.yudao.module.infra.dal.dataobject.demo12;
-
-import lombok.*;
-import java.util.*;
-import java.time.LocalDateTime;
-import java.time.LocalDateTime;
-import com.baomidou.mybatisplus.annotation.*;
-import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
-
-/**
- * 学生联系人 DO
- *
- * @author 芋道源码
- */
-@TableName("infra_demo12_student_contact")
-@KeySequence("infra_demo12_student_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
-@Data
-@EqualsAndHashCode(callSuper = true)
-@ToString(callSuper = true)
-@Builder
-@NoArgsConstructor
-@AllArgsConstructor
-public class InfraDemo12StudentContactDO extends BaseDO {
-
-    /**
-     * 编号
-     */
-    @TableId
-    private Long id;
-    /**
-     * 学生编号
-     */
-    private Long studentId;
-    /**
-     * 名字
-     */
-    private String name;
-    /**
-     * 简介
-     */
-    private String description;
-    /**
-     * 出生日期
-     */
-    private LocalDateTime birthday;
-    /**
-     * 性别
-     *
-     * 枚举 {@link TODO system_user_sex 对应的类}
-     */
-    private Integer sex;
-    /**
-     * 是否有效
-     *
-     * 枚举 {@link TODO infra_boolean_string 对应的类}
-     */
-    private Boolean enabled;
-    /**
-     * 头像
-     */
-    private String avatar;
-    /**
-     * 附件
-     */
-    private String video;
-    /**
-     * 备注
-     */
-    private String memo;
-
-}

+ 0 - 67
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo12/InfraDemo12StudentDO.java

@@ -1,67 +0,0 @@
-package cn.iocoder.yudao.module.infra.dal.dataobject.demo12;
-
-import lombok.*;
-import java.util.*;
-import java.time.LocalDateTime;
-import java.time.LocalDateTime;
-import com.baomidou.mybatisplus.annotation.*;
-import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
-
-/**
- * 学生 DO
- *
- * @author 芋道源码
- */
-@TableName("infra_demo12_student")
-@KeySequence("infra_demo12_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
-@Data
-@EqualsAndHashCode(callSuper = true)
-@ToString(callSuper = true)
-@Builder
-@NoArgsConstructor
-@AllArgsConstructor
-public class InfraDemo12StudentDO extends BaseDO {
-
-    /**
-     * 编号
-     */
-    @TableId
-    private Long id;
-    /**
-     * 名字
-     */
-    private String name;
-    /**
-     * 简介
-     */
-    private String description;
-    /**
-     * 出生日期
-     */
-    private LocalDateTime birthday;
-    /**
-     * 性别
-     *
-     * 枚举 {@link TODO system_user_sex 对应的类}
-     */
-    private Integer sex;
-    /**
-     * 是否有效
-     *
-     * 枚举 {@link TODO infra_boolean_string 对应的类}
-     */
-    private Boolean enabled;
-    /**
-     * 头像
-     */
-    private String avatar;
-    /**
-     * 附件
-     */
-    private String video;
-    /**
-     * 备注
-     */
-    private String memo;
-
-}

+ 0 - 71
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo12/InfraDemo12StudentTeacherDO.java

@@ -1,71 +0,0 @@
-package cn.iocoder.yudao.module.infra.dal.dataobject.demo12;
-
-import lombok.*;
-import java.util.*;
-import java.time.LocalDateTime;
-import java.time.LocalDateTime;
-import com.baomidou.mybatisplus.annotation.*;
-import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
-
-/**
- * 学生班主任 DO
- *
- * @author 芋道源码
- */
-@TableName("infra_demo12_student_teacher")
-@KeySequence("infra_demo12_student_teacher_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
-@Data
-@EqualsAndHashCode(callSuper = true)
-@ToString(callSuper = true)
-@Builder
-@NoArgsConstructor
-@AllArgsConstructor
-public class InfraDemo12StudentTeacherDO extends BaseDO {
-
-    /**
-     * 编号
-     */
-    @TableId
-    private Long id;
-    /**
-     * 学生编号
-     */
-    private Long studentId;
-    /**
-     * 名字
-     */
-    private String name;
-    /**
-     * 简介
-     */
-    private String description;
-    /**
-     * 出生日期
-     */
-    private LocalDateTime birthday;
-    /**
-     * 性别
-     *
-     * 枚举 {@link TODO system_user_sex 对应的类}
-     */
-    private Integer sex;
-    /**
-     * 是否有效
-     *
-     * 枚举 {@link TODO infra_boolean_string 对应的类}
-     */
-    private Boolean enabled;
-    /**
-     * 头像
-     */
-    private String avatar;
-    /**
-     * 附件
-     */
-    private String video;
-    /**
-     * 备注
-     */
-    private String memo;
-
-}

+ 26 - 0
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo01/Demo01ContactMapper.java

@@ -0,0 +1,26 @@
+package cn.iocoder.yudao.module.infra.dal.mysql.demo.demo01;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo.Demo01ContactPageReqVO;
+import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo01.Demo01ContactDO;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 示例联系人 Mapper
+ *
+ * @author 芋道源码
+ */
+@Mapper
+public interface Demo01ContactMapper extends BaseMapperX<Demo01ContactDO> {
+
+    default PageResult<Demo01ContactDO> selectPage(Demo01ContactPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<Demo01ContactDO>()
+                .likeIfPresent(Demo01ContactDO::getName, reqVO.getName())
+                .eqIfPresent(Demo01ContactDO::getSex, reqVO.getSex())
+                .betweenIfPresent(Demo01ContactDO::getCreateTime, reqVO.getCreateTime())
+                .orderByDesc(Demo01ContactDO::getId));
+    }
+
+}

+ 55 - 0
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo01/Demo01ContactService.java

@@ -0,0 +1,55 @@
+package cn.iocoder.yudao.module.infra.service.demo.demo01;
+
+import javax.validation.*;
+
+import cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo.Demo01ContactPageReqVO;
+import cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo.Demo01ContactSaveReqVO;
+import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo01.Demo01ContactDO;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+
+/**
+ * 示例联系人 Service 接口
+ *
+ * @author 芋道源码
+ */
+public interface Demo01ContactService {
+
+    /**
+     * 创建示例联系人
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createDemo01Contact(@Valid Demo01ContactSaveReqVO createReqVO);
+
+    /**
+     * 更新示例联系人
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updateDemo01Contact(@Valid Demo01ContactSaveReqVO updateReqVO);
+
+    /**
+     * 删除示例联系人
+     *
+     * @param id 编号
+     */
+    void deleteDemo01Contact(Long id);
+
+    /**
+     * 获得示例联系人
+     *
+     * @param id 编号
+     * @return 示例联系人
+     */
+    Demo01ContactDO getDemo01Contact(Long id);
+
+    /**
+     * 获得示例联系人分页
+     *
+     * @param pageReqVO 分页查询
+     * @return 示例联系人分页
+     */
+    PageResult<Demo01ContactDO> getDemo01ContactPage(Demo01ContactPageReqVO pageReqVO);
+
+}

+ 72 - 0
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo01/Demo01ContactServiceImpl.java

@@ -0,0 +1,72 @@
+package cn.iocoder.yudao.module.infra.service.demo.demo01;
+
+import cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo.Demo01ContactPageReqVO;
+import cn.iocoder.yudao.module.infra.controller.admin.demo.demo01.vo.Demo01ContactSaveReqVO;
+import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+import org.springframework.validation.annotation.Validated;
+
+import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo01.Demo01ContactDO;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+
+import cn.iocoder.yudao.module.infra.dal.mysql.demo.demo01.Demo01ContactMapper;
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*;
+
+/**
+ * 示例联系人 Service 实现类
+ *
+ * @author 芋道源码
+ */
+@Service
+@Validated
+public class Demo01ContactServiceImpl implements Demo01ContactService {
+
+    @Resource
+    private Demo01ContactMapper demo01ContactMapper;
+
+    @Override
+    public Long createDemo01Contact(Demo01ContactSaveReqVO createReqVO) {
+        // 插入
+        Demo01ContactDO demo01Contact = BeanUtils.toBean(createReqVO, Demo01ContactDO.class);
+        demo01ContactMapper.insert(demo01Contact);
+        // 返回
+        return demo01Contact.getId();
+    }
+
+    @Override
+    public void updateDemo01Contact(Demo01ContactSaveReqVO updateReqVO) {
+        // 校验存在
+        validateDemo01ContactExists(updateReqVO.getId());
+        // 更新
+        Demo01ContactDO updateObj = BeanUtils.toBean(updateReqVO, Demo01ContactDO.class);
+        demo01ContactMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deleteDemo01Contact(Long id) {
+        // 校验存在
+        validateDemo01ContactExists(id);
+        // 删除
+        demo01ContactMapper.deleteById(id);
+    }
+
+    private void validateDemo01ContactExists(Long id) {
+        if (demo01ContactMapper.selectById(id) == null) {
+            throw exception(DEMO01_CONTACT_NOT_EXISTS);
+        }
+    }
+
+    @Override
+    public Demo01ContactDO getDemo01Contact(Long id) {
+        return demo01ContactMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<Demo01ContactDO> getDemo01ContactPage(Demo01ContactPageReqVO pageReqVO) {
+        return demo01ContactMapper.selectPage(pageReqVO);
+    }
+
+}

+ 0 - 12
yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo01/InfraDemo01StudentMapper.xml

@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="cn.iocoder.yudao.module.infra.dal.mysql.demo01.InfraDemo01StudentMapper">
-
-    <!--
-        一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
-        无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
-        代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
-        文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-     -->
-
-</mapper>

+ 0 - 12
yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo11/InfraDemo11StudentMapper.xml

@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="cn.iocoder.yudao.module.infra.dal.mysql.demo11.InfraDemo11StudentMapper">
-
-    <!--
-        一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
-        无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
-        代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
-        文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-     -->
-
-</mapper>

+ 0 - 12
yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo12/InfraDemo12StudentMapper.xml

@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="cn.iocoder.yudao.module.infra.dal.mysql.demo12.InfraDemo12StudentMapper">
-
-    <!--
-        一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
-        无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
-        代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
-        文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-     -->
-
-</mapper>