代码生成:增加 crud 单表示例
parent
d83e0413b8
commit
0d49691aa0
@ -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));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@ -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;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -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;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -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;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -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;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -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;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -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;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -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;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -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;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -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;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -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));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -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);
|
||||||
|
|
||||||
|
}
|
||||||
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue