diff --git a/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants.java b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants.java index aaa2a3cfa..caa8cd373 100644 --- a/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants.java +++ b/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, "示例联系人不存在"); } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/Demo01ContactController.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/Demo01ContactController.java new file mode 100644 index 000000000..5ab9d1e97 --- /dev/null +++ b/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 createDemo01Contact(@Valid @RequestBody Demo01ContactSaveReqVO createReqVO) { + return success(demo01ContactService.createDemo01Contact(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新示例联系人") + @PreAuthorize("@ss.hasPermission('infra:demo01-contact:update')") + public CommonResult 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 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 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> getDemo01ContactPage(@Valid Demo01ContactPageReqVO pageReqVO) { + PageResult 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 list = demo01ContactService.getDemo01ContactPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "示例联系人.xls", "数据", Demo01ContactRespVO.class, + BeanUtils.toBean(list, Demo01ContactRespVO.class)); + } + +} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/vo/Demo01ContactPageReqVO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/vo/Demo01ContactPageReqVO.java new file mode 100644 index 000000000..d337d2d7d --- /dev/null +++ b/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; + +} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/vo/Demo01ContactRespVO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/vo/Demo01ContactRespVO.java new file mode 100644 index 000000000..5d176c262 --- /dev/null +++ b/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; + +} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/vo/Demo01ContactSaveReqVO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo01/vo/Demo01ContactSaveReqVO.java new file mode 100644 index 000000000..94157ed4d --- /dev/null +++ b/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; + +} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/package-info.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/package-info.java new file mode 100644 index 000000000..7de5cd338 --- /dev/null +++ b/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; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo11/InfraDemo11StudentDO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/demo01/Demo01ContactDO.java similarity index 64% rename from yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo11/InfraDemo11StudentDO.java rename to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/demo01/Demo01ContactDO.java index 687c0db21..f9294a474 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo11/InfraDemo11StudentDO.java +++ b/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 LocalDateTime birthday; + /** + * 简介 + */ + private String description; /** * 头像 */ private String avatar; - /** - * 附件 - */ - private String video; - /** - * 备注 - */ - private String memo; } \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo01/InfraDemo01StudentDO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo01/InfraDemo01StudentDO.java deleted file mode 100644 index c78f9626e..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo01/InfraDemo01StudentDO.java +++ /dev/null @@ -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; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo02/InfraDemoStudentAddressDO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo02/InfraDemoStudentAddressDO.java deleted file mode 100644 index 0baf4970f..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo02/InfraDemoStudentAddressDO.java +++ /dev/null @@ -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; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo02/InfraDemoStudentContactDO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo02/InfraDemoStudentContactDO.java deleted file mode 100644 index 8d0c9dd39..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo02/InfraDemoStudentContactDO.java +++ /dev/null @@ -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; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo02/InfraDemoStudentDO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo02/InfraDemoStudentDO.java deleted file mode 100644 index 987e97722..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo02/InfraDemoStudentDO.java +++ /dev/null @@ -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; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo11/InfraDemo11StudentContactDO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo11/InfraDemo11StudentContactDO.java deleted file mode 100644 index d11a7d892..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo11/InfraDemo11StudentContactDO.java +++ /dev/null @@ -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; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo11/InfraDemo11StudentTeacherDO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo11/InfraDemo11StudentTeacherDO.java deleted file mode 100644 index fbb631c99..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo11/InfraDemo11StudentTeacherDO.java +++ /dev/null @@ -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; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo12/InfraDemo12StudentContactDO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo12/InfraDemo12StudentContactDO.java deleted file mode 100644 index eda857a8d..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo12/InfraDemo12StudentContactDO.java +++ /dev/null @@ -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; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo12/InfraDemo12StudentDO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo12/InfraDemo12StudentDO.java deleted file mode 100644 index cef77d6cf..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo12/InfraDemo12StudentDO.java +++ /dev/null @@ -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; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo12/InfraDemo12StudentTeacherDO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo12/InfraDemo12StudentTeacherDO.java deleted file mode 100644 index e84ed8d27..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo12/InfraDemo12StudentTeacherDO.java +++ /dev/null @@ -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; - -} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo01/Demo01ContactMapper.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/demo01/Demo01ContactMapper.java new file mode 100644 index 000000000..f5f3cdbbe --- /dev/null +++ b/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 { + + default PageResult selectPage(Demo01ContactPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(Demo01ContactDO::getName, reqVO.getName()) + .eqIfPresent(Demo01ContactDO::getSex, reqVO.getSex()) + .betweenIfPresent(Demo01ContactDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(Demo01ContactDO::getId)); + } + +} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo01/Demo01ContactService.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo01/Demo01ContactService.java new file mode 100644 index 000000000..e3a1b6dd5 --- /dev/null +++ b/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 getDemo01ContactPage(Demo01ContactPageReqVO pageReqVO); + +} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo01/Demo01ContactServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo01/Demo01ContactServiceImpl.java new file mode 100644 index 000000000..cde490638 --- /dev/null +++ b/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 getDemo01ContactPage(Demo01ContactPageReqVO pageReqVO) { + return demo01ContactMapper.selectPage(pageReqVO); + } + +} \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo01/InfraDemo01StudentMapper.xml b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo01/InfraDemo01StudentMapper.xml deleted file mode 100644 index fd3fcfa50..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo01/InfraDemo01StudentMapper.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo11/InfraDemo11StudentMapper.xml b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo11/InfraDemo11StudentMapper.xml deleted file mode 100644 index f8cb8e4aa..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo11/InfraDemo11StudentMapper.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo12/InfraDemo12StudentMapper.xml b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo12/InfraDemo12StudentMapper.xml deleted file mode 100644 index 8f563e8f0..000000000 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo12/InfraDemo12StudentMapper.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - \ No newline at end of file