清除多租户功能

This commit is contained in:
2026-02-04 15:41:21 +08:00
parent a2203e4f40
commit 3f65a55c15
189 changed files with 94 additions and 8587 deletions

View File

@@ -15,15 +15,6 @@ public interface ErrorCodeConstants {
ErrorCode CONFIG_CAN_NOT_DELETE_SYSTEM_TYPE = new ErrorCode(1_001_000_003, "不能删除类型为系统内置的参数配置");
ErrorCode CONFIG_GET_VALUE_ERROR_IF_VISIBLE = new ErrorCode(1_001_000_004, "获取参数配置失败,原因:不允许获取不可见配置");
// ========== 定时任务 1-001-001-000 ==========
ErrorCode JOB_NOT_EXISTS = new ErrorCode(1_001_001_000, "定时任务不存在");
ErrorCode JOB_HANDLER_EXISTS = new ErrorCode(1_001_001_001, "定时任务的处理器已经存在");
ErrorCode JOB_CHANGE_STATUS_INVALID = new ErrorCode(1_001_001_002, "只允许修改为开启或者关闭状态");
ErrorCode JOB_CHANGE_STATUS_EQUALS = new ErrorCode(1_001_001_003, "定时任务已经处于该状态,无需修改");
ErrorCode JOB_UPDATE_ONLY_NORMAL_STATUS = new ErrorCode(1_001_001_004, "只有开启状态的任务,才可以修改");
ErrorCode JOB_CRON_EXPRESSION_VALID = new ErrorCode(1_001_001_005, "CRON 表达式不正确");
ErrorCode JOB_HANDLER_BEAN_NOT_EXISTS = new ErrorCode(1_001_001_006, "定时任务的处理器 Bean 不存在,注意 Bean 默认首字母小写");
ErrorCode JOB_HANDLER_BEAN_TYPE_ERROR = new ErrorCode(1_001_001_007, "定时任务的处理器 Bean 类型不正确,未实现 JobHandler 接口");
// ========== API 错误日志 1-001-002-000 ==========
ErrorCode API_ERROR_LOG_NOT_FOUND = new ErrorCode(1_001_002_000, "API 错误日志不存在");
@@ -56,17 +47,6 @@ public interface ErrorCodeConstants {
ErrorCode DATA_SOURCE_CONFIG_NOT_EXISTS = new ErrorCode(1_001_007_000, "数据源配置不存在");
ErrorCode DATA_SOURCE_CONFIG_NOT_OK = new ErrorCode(1_001_007_001, "数据源配置不正确,无法进行连接");
// ========== 学生 1-001-201-000 ==========
ErrorCode DEMO01_CONTACT_NOT_EXISTS = new ErrorCode(1_001_201_000, "示例联系人不存在");
ErrorCode DEMO02_CATEGORY_NOT_EXISTS = new ErrorCode(1_001_201_001, "示例分类不存在");
ErrorCode DEMO02_CATEGORY_EXITS_CHILDREN = new ErrorCode(1_001_201_002, "存在存在子示例分类,无法删除");
ErrorCode DEMO02_CATEGORY_PARENT_NOT_EXITS = new ErrorCode(1_001_201_003,"父级示例分类不存在");
ErrorCode DEMO02_CATEGORY_PARENT_ERROR = new ErrorCode(1_001_201_004, "不能设置自己为父示例分类");
ErrorCode DEMO02_CATEGORY_NAME_DUPLICATE = new ErrorCode(1_001_201_005, "已经存在该名字的示例分类");
ErrorCode DEMO02_CATEGORY_PARENT_IS_CHILD = new ErrorCode(1_001_201_006, "不能设置自己的子示例分类为父示例分类");
ErrorCode DEMO03_STUDENT_NOT_EXISTS = new ErrorCode(1_001_201_007, "学生不存在");
ErrorCode DEMO03_COURSE_NOT_EXISTS = new ErrorCode(1_001_201_008, "学生课程不存在");
ErrorCode DEMO03_GRADE_NOT_EXISTS = new ErrorCode(1_001_201_009, "学生班级不存在");
ErrorCode DEMO03_GRADE_EXISTS = new ErrorCode(1_001_201_010, "学生班级已存在");
}

View File

@@ -32,11 +32,6 @@
<version>${revision}</version>
</dependency>
<!-- 业务组件 -->
<dependency>
<groupId>com.njcn</groupId>
<artifactId>msgpush-spring-boot-starter-biz-tenant</artifactId>
</dependency>
<!-- Web 相关 -->
<dependency>

View File

@@ -1,102 +0,0 @@
package com.njcn.msgpush.module.infra.controller.admin.demo.demo01;
import com.njcn.msgpush.framework.apilog.core.annotation.ApiAccessLog;
import com.njcn.msgpush.framework.common.pojo.CommonResult;
import com.njcn.msgpush.framework.common.pojo.PageParam;
import com.njcn.msgpush.framework.common.pojo.PageResult;
import com.njcn.msgpush.framework.common.util.object.BeanUtils;
import com.njcn.msgpush.framework.excel.core.util.ExcelUtils;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo01.vo.Demo01ContactPageReqVO;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo01.vo.Demo01ContactRespVO;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo01.vo.Demo01ContactSaveReqVO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo01.Demo01ContactDO;
import com.njcn.msgpush.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 jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.List;
import static com.njcn.msgpush.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.njcn.msgpush.framework.common.pojo.CommonResult.success;
@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);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除示例联系人")
@PreAuthorize("@ss.hasPermission('infra:demo01-contact:delete')")
public CommonResult<Boolean> deleteDemo0iContactList(@RequestParam("ids") List<Long> ids) {
demo01ContactService.deleteDemo0iContactList(ids);
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')")
@ApiAccessLog(operateType = 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));
}
}

View File

@@ -1,26 +0,0 @@
package com.njcn.msgpush.module.infra.controller.admin.demo.demo01.vo;
import com.njcn.msgpush.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.njcn.msgpush.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 示例联系人分页 Request VO")
@Data
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;
}

View File

@@ -1,46 +0,0 @@
package com.njcn.msgpush.module.infra.controller.admin.demo.demo01.vo;
import com.njcn.msgpush.framework.excel.core.annotations.DictFormat;
import com.njcn.msgpush.framework.excel.core.convert.DictConvert;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@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;
}

View File

@@ -1,36 +0,0 @@
package com.njcn.msgpush.module.infra.controller.admin.demo.demo01.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
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;
}

View File

@@ -1,90 +0,0 @@
package com.njcn.msgpush.module.infra.controller.admin.demo.demo02;
import com.njcn.msgpush.framework.apilog.core.annotation.ApiAccessLog;
import com.njcn.msgpush.framework.common.pojo.CommonResult;
import com.njcn.msgpush.framework.common.util.object.BeanUtils;
import com.njcn.msgpush.framework.excel.core.util.ExcelUtils;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo02.vo.Demo02CategoryListReqVO;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo02.vo.Demo02CategoryRespVO;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo02.vo.Demo02CategorySaveReqVO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo02.Demo02CategoryDO;
import com.njcn.msgpush.module.infra.service.demo.demo02.Demo02CategoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.List;
import static com.njcn.msgpush.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.njcn.msgpush.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 示例分类")
@RestController
@RequestMapping("/infra/demo02-category")
@Validated
public class Demo02CategoryController {
@Resource
private Demo02CategoryService demo02CategoryService;
@PostMapping("/create")
@Operation(summary = "创建示例分类")
@PreAuthorize("@ss.hasPermission('infra:demo02-category:create')")
public CommonResult<Long> createDemo02Category(@Valid @RequestBody Demo02CategorySaveReqVO createReqVO) {
return success(demo02CategoryService.createDemo02Category(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新示例分类")
@PreAuthorize("@ss.hasPermission('infra:demo02-category:update')")
public CommonResult<Boolean> updateDemo02Category(@Valid @RequestBody Demo02CategorySaveReqVO updateReqVO) {
demo02CategoryService.updateDemo02Category(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除示例分类")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('infra:demo02-category:delete')")
public CommonResult<Boolean> deleteDemo02Category(@RequestParam("id") Long id) {
demo02CategoryService.deleteDemo02Category(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得示例分类")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('infra:demo02-category:query')")
public CommonResult<Demo02CategoryRespVO> getDemo02Category(@RequestParam("id") Long id) {
Demo02CategoryDO demo02Category = demo02CategoryService.getDemo02Category(id);
return success(BeanUtils.toBean(demo02Category, Demo02CategoryRespVO.class));
}
@GetMapping("/list")
@Operation(summary = "获得示例分类列表")
@PreAuthorize("@ss.hasPermission('infra:demo02-category:query')")
public CommonResult<List<Demo02CategoryRespVO>> getDemo02CategoryList(@Valid Demo02CategoryListReqVO listReqVO) {
List<Demo02CategoryDO> list = demo02CategoryService.getDemo02CategoryList(listReqVO);
return success(BeanUtils.toBean(list, Demo02CategoryRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出示例分类 Excel")
@PreAuthorize("@ss.hasPermission('infra:demo02-category:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportDemo02CategoryExcel(@Valid Demo02CategoryListReqVO listReqVO,
HttpServletResponse response) throws IOException {
List<Demo02CategoryDO> list = demo02CategoryService.getDemo02CategoryList(listReqVO);
// 导出 Excel
ExcelUtils.write(response, "示例分类.xls", "数据", Demo02CategoryRespVO.class,
BeanUtils.toBean(list, Demo02CategoryRespVO.class));
}
}

View File

@@ -1,25 +0,0 @@
package com.njcn.msgpush.module.infra.controller.admin.demo.demo02.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.njcn.msgpush.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 示例分类列表 Request VO")
@Data
public class Demo02CategoryListReqVO {
@Schema(description = "名字", example = "芋艿")
private String name;
@Schema(description = "父级编号", example = "6080")
private Long parentId;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@@ -1,31 +0,0 @@
package com.njcn.msgpush.module.infra.controller.admin.demo.demo02.vo;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 示例分类 Response VO")
@Data
@ExcelIgnoreUnannotated
public class Demo02CategoryRespVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10304")
@ExcelProperty("编号")
private Long id;
@Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
@ExcelProperty("名字")
private String name;
@Schema(description = "父级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6080")
@ExcelProperty("父级编号")
private Long parentId;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@@ -1,23 +0,0 @@
package com.njcn.msgpush.module.infra.controller.admin.demo.demo02.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@Schema(description = "管理后台 - 示例分类新增/修改 Request VO")
@Data
public class Demo02CategorySaveReqVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10304")
private Long id;
@Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
@NotEmpty(message = "名字不能为空")
private String name;
@Schema(description = "父级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6080")
@NotNull(message = "父级编号不能为空")
private Long parentId;
}

View File

@@ -1,208 +0,0 @@
package com.njcn.msgpush.module.infra.controller.admin.demo.demo03.erp;
import com.njcn.msgpush.framework.apilog.core.annotation.ApiAccessLog;
import com.njcn.msgpush.framework.common.pojo.CommonResult;
import com.njcn.msgpush.framework.common.pojo.PageParam;
import com.njcn.msgpush.framework.common.pojo.PageResult;
import com.njcn.msgpush.framework.common.util.object.BeanUtils;
import com.njcn.msgpush.framework.excel.core.util.ExcelUtils;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentErpPageReqVO;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentErpRespVO;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentErpSaveReqVO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
import com.njcn.msgpush.module.infra.service.demo.demo03.erp.Demo03StudentErpService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.List;
import static com.njcn.msgpush.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.njcn.msgpush.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 学生")
@RestController
@RequestMapping("/infra/demo03-student-erp")
@Validated
public class Demo03StudentErpController {
@Resource
private Demo03StudentErpService demo03StudentErpService;
@PostMapping("/create")
@Operation(summary = "创建学生")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:create')")
public CommonResult<Long> createDemo03Student(@Valid @RequestBody Demo03StudentErpSaveReqVO createReqVO) {
return success(demo03StudentErpService.createDemo03Student(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新学生")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:update')")
public CommonResult<Boolean> updateDemo03Student(@Valid @RequestBody Demo03StudentErpSaveReqVO updateReqVO) {
demo03StudentErpService.updateDemo03Student(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除学生")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
public CommonResult<Boolean> deleteDemo03Student(@RequestParam("id") Long id) {
demo03StudentErpService.deleteDemo03Student(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除学生")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
public CommonResult<Boolean> deleteDemo03StudentList(@RequestParam("ids") List<Long> ids) {
demo03StudentErpService.deleteDemo03StudentList(ids);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得学生")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
public CommonResult<Demo03StudentErpRespVO> getDemo03Student(@RequestParam("id") Long id) {
Demo03StudentDO demo03Student = demo03StudentErpService.getDemo03Student(id);
return success(BeanUtils.toBean(demo03Student, Demo03StudentErpRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得学生分页")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
public CommonResult<PageResult<Demo03StudentErpRespVO>> getDemo03StudentPage(@Valid Demo03StudentErpPageReqVO pageReqVO) {
PageResult<Demo03StudentDO> pageResult = demo03StudentErpService.getDemo03StudentPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, Demo03StudentErpRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出学生 Excel")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportDemo03StudentExcel(@Valid Demo03StudentErpPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<Demo03StudentDO> list = demo03StudentErpService.getDemo03StudentPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "学生.xls", "数据", Demo03StudentErpRespVO.class,
BeanUtils.toBean(list, Demo03StudentErpRespVO.class));
}
// ==================== 子表(学生课程) ====================
@GetMapping("/demo03-course/page")
@Operation(summary = "获得学生课程分页")
@Parameter(name = "studentId", description = "学生编号")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
public CommonResult<PageResult<Demo03CourseDO>> getDemo03CoursePage(PageParam pageReqVO,
@RequestParam("studentId") Long studentId) {
return success(demo03StudentErpService.getDemo03CoursePage(pageReqVO, studentId));
}
@PostMapping("/demo03-course/create")
@Operation(summary = "创建学生课程")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:create')")
public CommonResult<Long> createDemo03Course(@Valid @RequestBody Demo03CourseDO demo03Course) {
return success(demo03StudentErpService.createDemo03Course(demo03Course));
}
@PutMapping("/demo03-course/update")
@Operation(summary = "更新学生课程")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:update')")
public CommonResult<Boolean> updateDemo03Course(@Valid @RequestBody Demo03CourseDO demo03Course) {
demo03StudentErpService.updateDemo03Course(demo03Course);
return success(true);
}
@DeleteMapping("/demo03-course/delete")
@Parameter(name = "id", description = "编号", required = true)
@Operation(summary = "删除学生课程")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
public CommonResult<Boolean> deleteDemo03Course(@RequestParam("id") Long id) {
demo03StudentErpService.deleteDemo03Course(id);
return success(true);
}
@DeleteMapping("/demo03-course/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除学生课程")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
public CommonResult<Boolean> deleteDemo03CourseList(@RequestParam("ids") List<Long> ids) {
demo03StudentErpService.deleteDemo03CourseList(ids);
return success(true);
}
@GetMapping("/demo03-course/get")
@Operation(summary = "获得学生课程")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
public CommonResult<Demo03CourseDO> getDemo03Course(@RequestParam("id") Long id) {
return success(demo03StudentErpService.getDemo03Course(id));
}
// ==================== 子表(学生班级) ====================
@GetMapping("/demo03-grade/page")
@Operation(summary = "获得学生班级分页")
@Parameter(name = "studentId", description = "学生编号")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
public CommonResult<PageResult<Demo03GradeDO>> getDemo03GradePage(PageParam pageReqVO,
@RequestParam("studentId") Long studentId) {
return success(demo03StudentErpService.getDemo03GradePage(pageReqVO, studentId));
}
@PostMapping("/demo03-grade/create")
@Operation(summary = "创建学生班级")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:create')")
public CommonResult<Long> createDemo03Grade(@Valid @RequestBody Demo03GradeDO demo03Grade) {
return success(demo03StudentErpService.createDemo03Grade(demo03Grade));
}
@PutMapping("/demo03-grade/update")
@Operation(summary = "更新学生班级")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:update')")
public CommonResult<Boolean> updateDemo03Grade(@Valid @RequestBody Demo03GradeDO demo03Grade) {
demo03StudentErpService.updateDemo03Grade(demo03Grade);
return success(true);
}
@DeleteMapping("/demo03-grade/delete")
@Parameter(name = "id", description = "编号", required = true)
@Operation(summary = "删除学生班级")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
public CommonResult<Boolean> deleteDemo03Grade(@RequestParam("id") Long id) {
demo03StudentErpService.deleteDemo03Grade(id);
return success(true);
}
@DeleteMapping("/demo03-grade/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除学生班级")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
public CommonResult<Boolean> deleteDemo03GradeList(@RequestParam("ids") List<Long> ids) {
demo03StudentErpService.deleteDemo03GradeList(ids);
return success(true);
}
@GetMapping("/demo03-grade/get")
@Operation(summary = "获得学生班级")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
public CommonResult<Demo03GradeDO> getDemo03Grade(@RequestParam("id") Long id) {
return success(demo03StudentErpService.getDemo03Grade(id));
}
}

View File

@@ -1,29 +0,0 @@
package com.njcn.msgpush.module.infra.controller.admin.demo.demo03.erp.vo;
import com.njcn.msgpush.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.njcn.msgpush.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 学生分页 Request VO")
@Data
public class Demo03StudentErpPageReqVO extends PageParam {
@Schema(description = "名字", example = "芋艿")
private String name;
@Schema(description = "性别")
private Integer sex;
@Schema(description = "简介", example = "随便")
private String description;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@@ -1,42 +0,0 @@
package com.njcn.msgpush.module.infra.controller.admin.demo.demo03.erp.vo;
import com.njcn.msgpush.framework.excel.core.annotations.DictFormat;
import com.njcn.msgpush.framework.excel.core.convert.DictConvert;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 学生 Response VO")
@Data
@ExcelIgnoreUnannotated
public class Demo03StudentErpRespVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525")
@ExcelProperty("编号")
private Long id;
@Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
@ExcelProperty("名字")
private String name;
@Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED)
@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 = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@@ -1,33 +0,0 @@
package com.njcn.msgpush.module.infra.controller.admin.demo.demo03.erp.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 学生新增/修改 Request VO")
@Data
public class Demo03StudentErpSaveReqVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525")
private Long id;
@Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
@NotEmpty(message = "名字不能为空")
private String name;
@Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED)
@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;
}

View File

@@ -1,124 +0,0 @@
package com.njcn.msgpush.module.infra.controller.admin.demo.demo03.inner;
import com.njcn.msgpush.framework.apilog.core.annotation.ApiAccessLog;
import com.njcn.msgpush.framework.common.pojo.CommonResult;
import com.njcn.msgpush.framework.common.pojo.PageParam;
import com.njcn.msgpush.framework.common.pojo.PageResult;
import com.njcn.msgpush.framework.common.util.object.BeanUtils;
import com.njcn.msgpush.framework.excel.core.util.ExcelUtils;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo03.inner.vo.Demo03StudentInnerPageReqVO;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo03.inner.vo.Demo03StudentInnerRespVO;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo03.inner.vo.Demo03StudentInnerSaveReqVO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
import com.njcn.msgpush.module.infra.service.demo.demo03.inner.Demo03StudentInnerService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.List;
import static com.njcn.msgpush.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.njcn.msgpush.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 学生")
@RestController
@RequestMapping("/infra/demo03-student-inner")
@Validated
public class Demo03StudentInnerController {
@Resource
private Demo03StudentInnerService demo03StudentInnerService;
@PostMapping("/create")
@Operation(summary = "创建学生")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:create')")
public CommonResult<Long> createDemo03Student(@Valid @RequestBody Demo03StudentInnerSaveReqVO createReqVO) {
return success(demo03StudentInnerService.createDemo03Student(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新学生")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:update')")
public CommonResult<Boolean> updateDemo03Student(@Valid @RequestBody Demo03StudentInnerSaveReqVO updateReqVO) {
demo03StudentInnerService.updateDemo03Student(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除学生")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
public CommonResult<Boolean> deleteDemo03Student(@RequestParam("id") Long id) {
demo03StudentInnerService.deleteDemo03Student(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除学生")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
public CommonResult<Boolean> deleteDemo03StudentList(@RequestParam("ids") List<Long> ids) {
demo03StudentInnerService.deleteDemo03StudentList(ids);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得学生")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
public CommonResult<Demo03StudentInnerRespVO> getDemo03Student(@RequestParam("id") Long id) {
Demo03StudentDO demo03Student = demo03StudentInnerService.getDemo03Student(id);
return success(BeanUtils.toBean(demo03Student, Demo03StudentInnerRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得学生分页")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
public CommonResult<PageResult<Demo03StudentInnerRespVO>> getDemo03StudentPage(@Valid Demo03StudentInnerPageReqVO pageReqVO) {
PageResult<Demo03StudentDO> pageResult = demo03StudentInnerService.getDemo03StudentPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, Demo03StudentInnerRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出学生 Excel")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportDemo03StudentExcel(@Valid Demo03StudentInnerPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<Demo03StudentDO> list = demo03StudentInnerService.getDemo03StudentPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "学生.xls", "数据", Demo03StudentInnerRespVO.class,
BeanUtils.toBean(list, Demo03StudentInnerRespVO.class));
}
// ==================== 子表(学生课程) ====================
@GetMapping("/demo03-course/list-by-student-id")
@Operation(summary = "获得学生课程列表")
@Parameter(name = "studentId", description = "学生编号")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
public CommonResult<List<Demo03CourseDO>> getDemo03CourseListByStudentId(@RequestParam("studentId") Long studentId) {
return success(demo03StudentInnerService.getDemo03CourseListByStudentId(studentId));
}
// ==================== 子表(学生班级) ====================
@GetMapping("/demo03-grade/get-by-student-id")
@Operation(summary = "获得学生班级")
@Parameter(name = "studentId", description = "学生编号")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
public CommonResult<Demo03GradeDO> getDemo03GradeByStudentId(@RequestParam("studentId") Long studentId) {
return success(demo03StudentInnerService.getDemo03GradeByStudentId(studentId));
}
}

View File

@@ -1,29 +0,0 @@
package com.njcn.msgpush.module.infra.controller.admin.demo.demo03.inner.vo;
import com.njcn.msgpush.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.njcn.msgpush.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 学生分页 Request VO")
@Data
public class Demo03StudentInnerPageReqVO extends PageParam {
@Schema(description = "名字", example = "芋艿")
private String name;
@Schema(description = "性别")
private Integer sex;
@Schema(description = "简介", example = "随便")
private String description;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@@ -1,42 +0,0 @@
package com.njcn.msgpush.module.infra.controller.admin.demo.demo03.inner.vo;
import com.njcn.msgpush.framework.excel.core.annotations.DictFormat;
import com.njcn.msgpush.framework.excel.core.convert.DictConvert;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 学生 Response VO")
@Data
@ExcelIgnoreUnannotated
public class Demo03StudentInnerRespVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525")
@ExcelProperty("编号")
private Long id;
@Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
@ExcelProperty("名字")
private String name;
@Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED)
@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 = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@@ -1,42 +0,0 @@
package com.njcn.msgpush.module.infra.controller.admin.demo.demo03.inner.vo;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Schema(description = "管理后台 - 学生新增/修改 Request VO")
@Data
public class Demo03StudentInnerSaveReqVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525")
private Long id;
@Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
@NotEmpty(message = "名字不能为空")
private String name;
@Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED)
@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 List<Demo03CourseDO> demo03Courses;
@Schema(description = "学生班级")
private Demo03GradeDO demo03Grade;
}

View File

@@ -1,124 +0,0 @@
package com.njcn.msgpush.module.infra.controller.admin.demo.demo03.normal;
import com.njcn.msgpush.framework.apilog.core.annotation.ApiAccessLog;
import com.njcn.msgpush.framework.common.pojo.CommonResult;
import com.njcn.msgpush.framework.common.pojo.PageParam;
import com.njcn.msgpush.framework.common.pojo.PageResult;
import com.njcn.msgpush.framework.common.util.object.BeanUtils;
import com.njcn.msgpush.framework.excel.core.util.ExcelUtils;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo03.normal.vo.Demo03StudentNormalPageReqVO;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo03.normal.vo.Demo03StudentNormalRespVO;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo03.normal.vo.Demo03StudentNormalSaveReqVO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
import com.njcn.msgpush.module.infra.service.demo.demo03.normal.Demo03StudentNormalService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.List;
import static com.njcn.msgpush.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.njcn.msgpush.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 学生")
@RestController
@RequestMapping("/infra/demo03-student-normal")
@Validated
public class Demo03StudentNormalController {
@Resource
private Demo03StudentNormalService demo03StudentNormalService;
@PostMapping("/create")
@Operation(summary = "创建学生")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:create')")
public CommonResult<Long> createDemo03Student(@Valid @RequestBody Demo03StudentNormalSaveReqVO createReqVO) {
return success(demo03StudentNormalService.createDemo03Student(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新学生")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:update')")
public CommonResult<Boolean> updateDemo03Student(@Valid @RequestBody Demo03StudentNormalSaveReqVO updateReqVO) {
demo03StudentNormalService.updateDemo03Student(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除学生")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
public CommonResult<Boolean> deleteDemo03Student(@RequestParam("id") Long id) {
demo03StudentNormalService.deleteDemo03Student(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除学生")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:delete')")
public CommonResult<Boolean> deleteDemo03StudentList(@RequestParam("ids") List<Long> ids) {
demo03StudentNormalService.deleteDemo03StudentList(ids);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得学生")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
public CommonResult<Demo03StudentNormalRespVO> getDemo03Student(@RequestParam("id") Long id) {
Demo03StudentDO demo03Student = demo03StudentNormalService.getDemo03Student(id);
return success(BeanUtils.toBean(demo03Student, Demo03StudentNormalRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得学生分页")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
public CommonResult<PageResult<Demo03StudentNormalRespVO>> getDemo03StudentPage(@Valid Demo03StudentNormalPageReqVO pageReqVO) {
PageResult<Demo03StudentDO> pageResult = demo03StudentNormalService.getDemo03StudentPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, Demo03StudentNormalRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出学生 Excel")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportDemo03StudentExcel(@Valid Demo03StudentNormalPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<Demo03StudentDO> list = demo03StudentNormalService.getDemo03StudentPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "学生.xls", "数据", Demo03StudentNormalRespVO.class,
BeanUtils.toBean(list, Demo03StudentNormalRespVO.class));
}
// ==================== 子表(学生课程) ====================
@GetMapping("/demo03-course/list-by-student-id")
@Operation(summary = "获得学生课程列表")
@Parameter(name = "studentId", description = "学生编号")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
public CommonResult<List<Demo03CourseDO>> getDemo03CourseListByStudentId(@RequestParam("studentId") Long studentId) {
return success(demo03StudentNormalService.getDemo03CourseListByStudentId(studentId));
}
// ==================== 子表(学生班级) ====================
@GetMapping("/demo03-grade/get-by-student-id")
@Operation(summary = "获得学生班级")
@Parameter(name = "studentId", description = "学生编号")
@PreAuthorize("@ss.hasPermission('infra:demo03-student:query')")
public CommonResult<Demo03GradeDO> getDemo03GradeByStudentId(@RequestParam("studentId") Long studentId) {
return success(demo03StudentNormalService.getDemo03GradeByStudentId(studentId));
}
}

View File

@@ -1,29 +0,0 @@
package com.njcn.msgpush.module.infra.controller.admin.demo.demo03.normal.vo;
import com.njcn.msgpush.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.njcn.msgpush.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 学生分页 Request VO")
@Data
public class Demo03StudentNormalPageReqVO extends PageParam {
@Schema(description = "名字", example = "芋艿")
private String name;
@Schema(description = "性别")
private Integer sex;
@Schema(description = "简介", example = "随便")
private String description;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@@ -1,42 +0,0 @@
package com.njcn.msgpush.module.infra.controller.admin.demo.demo03.normal.vo;
import com.njcn.msgpush.framework.excel.core.annotations.DictFormat;
import com.njcn.msgpush.framework.excel.core.convert.DictConvert;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 学生 Response VO")
@Data
@ExcelIgnoreUnannotated
public class Demo03StudentNormalRespVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525")
@ExcelProperty("编号")
private Long id;
@Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
@ExcelProperty("名字")
private String name;
@Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED)
@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 = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@@ -1,42 +0,0 @@
package com.njcn.msgpush.module.infra.controller.admin.demo.demo03.normal.vo;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Schema(description = "管理后台 - 学生新增/修改 Request VO")
@Data
public class Demo03StudentNormalSaveReqVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "8525")
private Long id;
@Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
@NotEmpty(message = "名字不能为空")
private String name;
@Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED)
@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 List<Demo03CourseDO> demo03Courses;
@Schema(description = "学生班级")
private Demo03GradeDO demo03Grade;
}

View File

@@ -1,8 +0,0 @@
/**
* 代码生成示例
*
* 1. demo01单表增删改查
* 2. demo02单表树形结构
* 3. demo03主子表标准模式+ 主子表ERP 模式)+ 主子表(内嵌模式)
*/
package com.njcn.msgpush.module.infra.controller.admin.demo;

View File

@@ -1,45 +0,0 @@
### 请求 /infra/file-config/create 接口 => 成功
POST {{baseUrl}}/infra/file-config/create
Content-Type: application/json
tenant-id: {{adminTenantId}}
Authorization: Bearer {{token}}
{
"name": "S3 - 七牛云",
"remark": "",
"storage": 20,
"config": {
"accessKey": "b7yvuhBSAGjmtPhMFcn9iMOxUOY_I06cA_p0ZUx8",
"accessSecret": "kXM1l5ia1RvSX3QaOEcwI3RLz3Y2rmNszWonKZtP",
"bucket": "ruoyi-vue-pro",
"endpoint": "s3-cn-south-1.qiniucs.com",
"domain": "http://test.msgpush.iocoder.cn",
"region": "oss-cn-beijing"
}
}
### 请求 /infra/file-config/update 接口 => 成功
PUT {{baseUrl}}/infra/file-config/update
Content-Type: application/json
tenant-id: {{adminTenantId}}
Authorization: Bearer {{token}}
{
"id": 2,
"name": "S3 - 七牛云",
"remark": "",
"config": {
"accessKey": "b7yvuhBSAGjmtPhMFcn9iMOxUOY_I06cA_p0ZUx8",
"accessSecret": "kXM1l5ia1RvSX3QaOEcwI3RLz3Y2rmNszWonKZtP",
"bucket": "ruoyi-vue-pro",
"endpoint": "s3-cn-south-1.qiniucs.com",
"domain": "http://test.msgpush.iocoder.cn",
"region": "oss-cn-beijing"
}
}
### 请求 /infra/file-config/test 接口 => 成功
GET {{baseUrl}}/infra/file-config/test?id=2
Content-Type: application/json
tenant-id: {{adminTenantId}}
Authorization: Bearer {{token}}

View File

@@ -6,7 +6,7 @@ import cn.hutool.core.util.URLUtil;
import com.njcn.msgpush.framework.common.pojo.CommonResult;
import com.njcn.msgpush.framework.common.pojo.PageResult;
import com.njcn.msgpush.framework.common.util.object.BeanUtils;
import com.njcn.msgpush.framework.tenant.core.aop.TenantIgnore;
import com.njcn.msgpush.module.infra.controller.admin.file.vo.file.*;
import com.njcn.msgpush.module.infra.dal.dataobject.file.FileDO;
import com.njcn.msgpush.module.infra.service.file.FileService;
@@ -100,7 +100,6 @@ public class FileController {
@GetMapping("/{configId}/get/**")
@PermitAll
@TenantIgnore
@Operation(summary = "下载文件")
@Parameter(name = "configId", description = "配置编号", required = true)
public void getFileContent(HttpServletRequest request,

View File

@@ -1,4 +0,0 @@
### 请求 /infra/redis/get-monitor-info 接口 => 成功
GET {{baseUrl}}/infra/redis/get-monitor-info
Authorization: Bearer {{token}}
tenant-id: {{adminTenantId}}

View File

@@ -1,7 +1,7 @@
package com.njcn.msgpush.module.infra.dal.dataobject.codegen;
import com.njcn.msgpush.framework.mybatis.core.dataobject.BaseDO;
import com.njcn.msgpush.framework.tenant.core.aop.TenantIgnore;
import com.njcn.msgpush.module.infra.enums.codegen.CodegenColumnHtmlTypeEnum;
import com.njcn.msgpush.module.infra.enums.codegen.CodegenColumnListConditionEnum;
import com.baomidou.mybatisplus.annotation.KeySequence;
@@ -18,7 +18,6 @@ import lombok.Data;
@TableName(value = "infra_codegen_column", autoResultMap = true)
@KeySequence("infra_codegen_column_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@TenantIgnore
public class CodegenColumnDO extends BaseDO {
/**

View File

@@ -1,7 +1,7 @@
package com.njcn.msgpush.module.infra.dal.dataobject.codegen;
import com.njcn.msgpush.framework.mybatis.core.dataobject.BaseDO;
import com.njcn.msgpush.framework.tenant.core.aop.TenantIgnore;
import com.njcn.msgpush.module.infra.dal.dataobject.db.DataSourceConfigDO;
import com.njcn.msgpush.module.infra.enums.codegen.CodegenFrontTypeEnum;
import com.njcn.msgpush.module.infra.enums.codegen.CodegenSceneEnum;
@@ -20,7 +20,6 @@ import lombok.Data;
@TableName(value = "infra_codegen_table", autoResultMap = true)
@KeySequence("infra_codegen_table_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@TenantIgnore
public class CodegenTableDO extends BaseDO {
/**

View File

@@ -1,7 +1,7 @@
package com.njcn.msgpush.module.infra.dal.dataobject.config;
import com.njcn.msgpush.framework.mybatis.core.dataobject.BaseDO;
import com.njcn.msgpush.framework.tenant.core.aop.TenantIgnore;
import com.njcn.msgpush.module.infra.enums.config.ConfigTypeEnum;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
@@ -20,7 +20,6 @@ import lombok.ToString;
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@TenantIgnore
public class ConfigDO extends BaseDO {
/**

View File

@@ -2,7 +2,7 @@ package com.njcn.msgpush.module.infra.dal.dataobject.db;
import com.njcn.msgpush.framework.mybatis.core.dataobject.BaseDO;
import com.njcn.msgpush.framework.mybatis.core.type.EncryptTypeHandler;
import com.njcn.msgpush.framework.tenant.core.aop.TenantIgnore;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
@@ -16,7 +16,6 @@ import lombok.Data;
@TableName(value = "infra_data_source_config", autoResultMap = true)
@KeySequence("infra_data_source_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@TenantIgnore
public class DataSourceConfigDO extends BaseDO {
/**

View File

@@ -1,54 +0,0 @@
package com.njcn.msgpush.module.infra.dal.dataobject.demo.demo01;
import com.njcn.msgpush.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 hongawen
*/
@TableName("msgpush_demo01_contact")
@KeySequence("msgpush_demo01_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Demo01ContactDO extends BaseDO {
/**
* 编号
*/
@TableId
private Long id;
/**
* 名字
*/
private String name;
/**
* 性别
*
* 枚举 {@link TODO system_user_sex 对应的类}
*/
private Integer sex;
/**
* 出生年
*/
private LocalDateTime birthday;
/**
* 简介
*/
private String description;
/**
* 头像
*/
private String avatar;
}

View File

@@ -1,40 +0,0 @@
package com.njcn.msgpush.module.infra.dal.dataobject.demo.demo02;
import com.njcn.msgpush.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.*;
/**
* 示例分类 DO
*
* @author hongawen
*/
@TableName("msgpush_demo02_category")
@KeySequence("msgpush_demo02_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Demo02CategoryDO extends BaseDO {
public static final Long PARENT_ID_ROOT = 0L;
/**
* 编号
*/
@TableId
private Long id;
/**
* 名字
*/
private String name;
/**
* 父级编号
*/
private Long parentId;
}

View File

@@ -1,42 +0,0 @@
package com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03;
import com.njcn.msgpush.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.*;
/**
* 学生课程 DO
*
* @author hongawen
*/
@TableName("msgpush_demo03_course")
@KeySequence("msgpush_demo03_course_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Demo03CourseDO extends BaseDO {
/**
* 编号
*/
@TableId
private Long id;
/**
* 学生编号
*/
private Long studentId;
/**
* 名字
*/
private String name;
/**
* 分数
*/
private Integer score;
}

View File

@@ -1,42 +0,0 @@
package com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03;
import com.njcn.msgpush.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.*;
/**
* 学生班级 DO
*
* @author hongawen
*/
@TableName("msgpush_demo03_grade")
@KeySequence("msgpush_demo03_grade_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Demo03GradeDO extends BaseDO {
/**
* 编号
*/
@TableId
private Long id;
/**
* 学生编号
*/
private Long studentId;
/**
* 名字
*/
private String name;
/**
* 班主任
*/
private String teacher;
}

View File

@@ -1,50 +0,0 @@
package com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03;
import com.njcn.msgpush.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 hongawen
*/
@TableName("msgpush_demo03_student")
@KeySequence("msgpush_demo03_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Demo03StudentDO extends BaseDO {
/**
* 编号
*/
@TableId
private Long id;
/**
* 名字
*/
private String name;
/**
* 性别
*
* 枚举 {@link TODO system_user_sex 对应的类}
*/
private Integer sex;
/**
* 出生日期
*/
private LocalDateTime birthday;
/**
* 简介
*/
private String description;
}

View File

@@ -3,7 +3,7 @@ package com.njcn.msgpush.module.infra.dal.dataobject.file;
import cn.hutool.core.util.StrUtil;
import com.njcn.msgpush.framework.common.util.json.JsonUtils;
import com.njcn.msgpush.framework.mybatis.core.dataobject.BaseDO;
import com.njcn.msgpush.framework.tenant.core.aop.TenantIgnore;
import com.njcn.msgpush.module.infra.framework.file.core.client.FileClientConfig;
import com.njcn.msgpush.module.infra.framework.file.core.client.db.DBFileClientConfig;
import com.njcn.msgpush.module.infra.framework.file.core.client.ftp.FtpFileClientConfig;
@@ -33,7 +33,6 @@ import java.lang.reflect.Field;
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TenantIgnore
public class FileConfigDO extends BaseDO {
/**

View File

@@ -1,7 +1,7 @@
package com.njcn.msgpush.module.infra.dal.dataobject.file;
import com.njcn.msgpush.framework.mybatis.core.dataobject.BaseDO;
import com.njcn.msgpush.framework.tenant.core.aop.TenantIgnore;
import com.njcn.msgpush.module.infra.framework.file.core.client.db.DBFileClient;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
@@ -23,7 +23,6 @@ import lombok.*;
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TenantIgnore
public class FileContentDO extends BaseDO {
/**

View File

@@ -1,7 +1,7 @@
package com.njcn.msgpush.module.infra.dal.dataobject.file;
import com.njcn.msgpush.framework.mybatis.core.dataobject.BaseDO;
import com.njcn.msgpush.framework.tenant.core.aop.TenantIgnore;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
@@ -20,7 +20,6 @@ import lombok.*;
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TenantIgnore
public class FileDO extends BaseDO {
/**

View File

@@ -1,26 +0,0 @@
package com.njcn.msgpush.module.infra.dal.mysql.demo.demo01;
import com.njcn.msgpush.framework.common.pojo.PageResult;
import com.njcn.msgpush.framework.mybatis.core.mapper.BaseMapperX;
import com.njcn.msgpush.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo01.vo.Demo01ContactPageReqVO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo01.Demo01ContactDO;
import org.apache.ibatis.annotations.Mapper;
/**
* 示例联系人 Mapper
*
* @author hongawen
*/
@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));
}
}

View File

@@ -1,35 +0,0 @@
package com.njcn.msgpush.module.infra.dal.mysql.demo.demo02;
import com.njcn.msgpush.framework.mybatis.core.mapper.BaseMapperX;
import com.njcn.msgpush.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo02.vo.Demo02CategoryListReqVO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo02.Demo02CategoryDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 示例分类 Mapper
*
* @author hongawen
*/
@Mapper
public interface Demo02CategoryMapper extends BaseMapperX<Demo02CategoryDO> {
default List<Demo02CategoryDO> selectList(Demo02CategoryListReqVO reqVO) {
return selectList(new LambdaQueryWrapperX<Demo02CategoryDO>()
.likeIfPresent(Demo02CategoryDO::getName, reqVO.getName())
.eqIfPresent(Demo02CategoryDO::getParentId, reqVO.getParentId())
.betweenIfPresent(Demo02CategoryDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(Demo02CategoryDO::getId));
}
default Demo02CategoryDO selectByParentIdAndName(Long parentId, String name) {
return selectOne(Demo02CategoryDO::getParentId, parentId, Demo02CategoryDO::getName, name);
}
default Long selectCountByParentId(Long parentId) {
return selectCount(Demo02CategoryDO::getParentId, parentId);
}
}

View File

@@ -1,34 +0,0 @@
package com.njcn.msgpush.module.infra.dal.mysql.demo.demo03.erp;
import com.njcn.msgpush.framework.common.pojo.PageParam;
import com.njcn.msgpush.framework.common.pojo.PageResult;
import com.njcn.msgpush.framework.mybatis.core.mapper.BaseMapperX;
import com.njcn.msgpush.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 学生课程 Mapper
*
* @author hongawen
*/
@Mapper
public interface Demo03CourseErpMapper extends BaseMapperX<Demo03CourseDO> {
default PageResult<Demo03CourseDO> selectPage(PageParam reqVO, Long studentId) {
return selectPage(reqVO, new LambdaQueryWrapperX<Demo03CourseDO>()
.eq(Demo03CourseDO::getStudentId, studentId)
.orderByDesc(Demo03CourseDO::getId));
}
default int deleteByStudentId(Long studentId) {
return delete(Demo03CourseDO::getStudentId, studentId);
}
default int deleteByStudentIds(List<Long> studentIds) {
return deleteBatch(Demo03CourseDO::getStudentId, studentIds);
}
}

View File

@@ -1,38 +0,0 @@
package com.njcn.msgpush.module.infra.dal.mysql.demo.demo03.erp;
import com.njcn.msgpush.framework.common.pojo.PageParam;
import com.njcn.msgpush.framework.common.pojo.PageResult;
import com.njcn.msgpush.framework.mybatis.core.mapper.BaseMapperX;
import com.njcn.msgpush.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 学生班级 Mapper
*
* @author hongawen
*/
@Mapper
public interface Demo03GradeErpMapper extends BaseMapperX<Demo03GradeDO> {
default PageResult<Demo03GradeDO> selectPage(PageParam reqVO, Long studentId) {
return selectPage(reqVO, new LambdaQueryWrapperX<Demo03GradeDO>()
.eq(Demo03GradeDO::getStudentId, studentId)
.orderByDesc(Demo03GradeDO::getId));
}
default Demo03GradeDO selectByStudentId(Long studentId) {
return selectOne(Demo03GradeDO::getStudentId, studentId);
}
default int deleteByStudentId(Long studentId) {
return delete(Demo03GradeDO::getStudentId, studentId);
}
default int deleteByStudentIds(List<Long> studentIds) {
return deleteBatch(Demo03GradeDO::getStudentId, studentIds);
}
}

View File

@@ -1,27 +0,0 @@
package com.njcn.msgpush.module.infra.dal.mysql.demo.demo03.erp;
import com.njcn.msgpush.framework.common.pojo.PageResult;
import com.njcn.msgpush.framework.mybatis.core.mapper.BaseMapperX;
import com.njcn.msgpush.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentErpPageReqVO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
import org.apache.ibatis.annotations.Mapper;
/**
* 学生 Mapper
*
* @author hongawen
*/
@Mapper
public interface Demo03StudentErpMapper extends BaseMapperX<Demo03StudentDO> {
default PageResult<Demo03StudentDO> selectPage(Demo03StudentErpPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<Demo03StudentDO>()
.likeIfPresent(Demo03StudentDO::getName, reqVO.getName())
.eqIfPresent(Demo03StudentDO::getSex, reqVO.getSex())
.eqIfPresent(Demo03StudentDO::getDescription, reqVO.getDescription())
.betweenIfPresent(Demo03StudentDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(Demo03StudentDO::getId));
}
}

View File

@@ -1,29 +0,0 @@
package com.njcn.msgpush.module.infra.dal.mysql.demo.demo03.inner;
import com.njcn.msgpush.framework.mybatis.core.mapper.BaseMapperX;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 学生课程 Mapper
*
* @author hongawen
*/
@Mapper
public interface Demo03CourseInnerMapper extends BaseMapperX<Demo03CourseDO> {
default List<Demo03CourseDO> selectListByStudentId(Long studentId) {
return selectList(Demo03CourseDO::getStudentId, studentId);
}
default int deleteByStudentId(Long studentId) {
return delete(Demo03CourseDO::getStudentId, studentId);
}
default int deleteByStudentIds(List<Long> studentIds) {
return deleteBatch(Demo03CourseDO::getStudentId, studentIds);
}
}

View File

@@ -1,29 +0,0 @@
package com.njcn.msgpush.module.infra.dal.mysql.demo.demo03.inner;
import com.njcn.msgpush.framework.mybatis.core.mapper.BaseMapperX;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 学生班级 Mapper
*
* @author hongawen
*/
@Mapper
public interface Demo03GradeInnerMapper extends BaseMapperX<Demo03GradeDO> {
default Demo03GradeDO selectByStudentId(Long studentId) {
return selectOne(Demo03GradeDO::getStudentId, studentId);
}
default int deleteByStudentId(Long studentId) {
return delete(Demo03GradeDO::getStudentId, studentId);
}
default int deleteByStudentIds(List<Long> studentIds) {
return deleteBatch(Demo03GradeDO::getStudentId, studentIds);
}
}

View File

@@ -1,27 +0,0 @@
package com.njcn.msgpush.module.infra.dal.mysql.demo.demo03.inner;
import com.njcn.msgpush.framework.common.pojo.PageResult;
import com.njcn.msgpush.framework.mybatis.core.mapper.BaseMapperX;
import com.njcn.msgpush.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo03.inner.vo.Demo03StudentInnerPageReqVO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
import org.apache.ibatis.annotations.Mapper;
/**
* 学生 Mapper
*
* @author hongawen
*/
@Mapper
public interface Demo03StudentInnerMapper extends BaseMapperX<Demo03StudentDO> {
default PageResult<Demo03StudentDO> selectPage(Demo03StudentInnerPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<Demo03StudentDO>()
.likeIfPresent(Demo03StudentDO::getName, reqVO.getName())
.eqIfPresent(Demo03StudentDO::getSex, reqVO.getSex())
.eqIfPresent(Demo03StudentDO::getDescription, reqVO.getDescription())
.betweenIfPresent(Demo03StudentDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(Demo03StudentDO::getId));
}
}

View File

@@ -1,29 +0,0 @@
package com.njcn.msgpush.module.infra.dal.mysql.demo.demo03.normal;
import com.njcn.msgpush.framework.mybatis.core.mapper.BaseMapperX;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 学生课程 Mapper
*
* @author hongawen
*/
@Mapper
public interface Demo03CourseNormalMapper extends BaseMapperX<Demo03CourseDO> {
default List<Demo03CourseDO> selectListByStudentId(Long studentId) {
return selectList(Demo03CourseDO::getStudentId, studentId);
}
default int deleteByStudentId(Long studentId) {
return delete(Demo03CourseDO::getStudentId, studentId);
}
default int deleteByStudentIds(List<Long> studentIds) {
return deleteBatch(Demo03CourseDO::getStudentId, studentIds);
}
}

View File

@@ -1,29 +0,0 @@
package com.njcn.msgpush.module.infra.dal.mysql.demo.demo03.normal;
import com.njcn.msgpush.framework.mybatis.core.mapper.BaseMapperX;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 学生班级 Mapper
*
* @author hongawen
*/
@Mapper
public interface Demo03GradeNormalMapper extends BaseMapperX<Demo03GradeDO> {
default Demo03GradeDO selectByStudentId(Long studentId) {
return selectOne(Demo03GradeDO::getStudentId, studentId);
}
default int deleteByStudentId(Long studentId) {
return delete(Demo03GradeDO::getStudentId, studentId);
}
default int deleteByStudentIds(List<Long> studentIds) {
return deleteBatch(Demo03GradeDO::getStudentId, studentIds);
}
}

View File

@@ -1,27 +0,0 @@
package com.njcn.msgpush.module.infra.dal.mysql.demo.demo03.normal;
import com.njcn.msgpush.framework.common.pojo.PageResult;
import com.njcn.msgpush.framework.mybatis.core.mapper.BaseMapperX;
import com.njcn.msgpush.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo03.normal.vo.Demo03StudentNormalPageReqVO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
import org.apache.ibatis.annotations.Mapper;
/**
* 学生 Mapper
*
* @author hongawen
*/
@Mapper
public interface Demo03StudentNormalMapper extends BaseMapperX<Demo03StudentDO> {
default PageResult<Demo03StudentDO> selectPage(Demo03StudentNormalPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<Demo03StudentDO>()
.likeIfPresent(Demo03StudentDO::getName, reqVO.getName())
.eqIfPresent(Demo03StudentDO::getSex, reqVO.getSex())
.eqIfPresent(Demo03StudentDO::getDescription, reqVO.getDescription())
.betweenIfPresent(Demo03StudentDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(Demo03StudentDO::getId));
}
}

View File

@@ -59,10 +59,7 @@ public class CodegenBuilder {
.put("date", CodegenColumnHtmlTypeEnum.DATETIME)
.build();
/**
* 多租户编号的字段名
*/
public static final String TENANT_ID_FIELD = "tenantId";
/**
* {@link com.njcn.msgpush.framework.mybatis.core.dataobject.BaseDO} 的字段
*/
@@ -86,7 +83,6 @@ public class CodegenBuilder {
static {
Arrays.stream(ReflectUtil.getFields(BaseDO.class)).forEach(field -> BASE_DO_FIELDS.add(field.getName()));
BASE_DO_FIELDS.add(TENANT_ID_FIELD);
// 处理 OPERATION 相关的字段
CREATE_OPERATION_EXCLUDE_COLUMN.addAll(BASE_DO_FIELDS);
UPDATE_OPERATION_EXCLUDE_COLUMN.addAll(BASE_DO_FIELDS);

View File

@@ -1,63 +0,0 @@
package com.njcn.msgpush.module.infra.service.demo.demo01;
import com.njcn.msgpush.framework.common.pojo.PageResult;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo01.vo.Demo01ContactPageReqVO;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo01.vo.Demo01ContactSaveReqVO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo01.Demo01ContactDO;
import jakarta.validation.Valid;
import java.util.List;
/**
* 示例联系人 Service 接口
*
* @author hongawen
*/
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 ids 编号
*/
void deleteDemo0iContactList(List<Long> ids);
/**
* 获得示例联系人
*
* @param id 编号
* @return 示例联系人
*/
Demo01ContactDO getDemo01Contact(Long id);
/**
* 获得示例联系人分页
*
* @param pageReqVO 分页查询
* @return 示例联系人分页
*/
PageResult<Demo01ContactDO> getDemo01ContactPage(Demo01ContactPageReqVO pageReqVO);
}

View File

@@ -1,88 +0,0 @@
package com.njcn.msgpush.module.infra.service.demo.demo01;
import cn.hutool.core.collection.CollUtil;
import com.njcn.msgpush.framework.common.pojo.PageResult;
import com.njcn.msgpush.framework.common.util.object.BeanUtils;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo01.vo.Demo01ContactPageReqVO;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo01.vo.Demo01ContactSaveReqVO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo01.Demo01ContactDO;
import com.njcn.msgpush.module.infra.dal.mysql.demo.demo01.Demo01ContactMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.List;
import static com.njcn.msgpush.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.njcn.msgpush.module.infra.enums.ErrorCodeConstants.DEMO01_CONTACT_NOT_EXISTS;
/**
* 示例联系人 Service 实现类
*
* @author hongawen
*/
@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);
}
@Override
public void deleteDemo0iContactList(List<Long> ids) {
// 校验存在
validateDemo01ContactExists(ids);
// 删除
demo01ContactMapper.deleteByIds(ids);
}
private void validateDemo01ContactExists(List<Long> ids) {
List<Demo01ContactDO> list = demo01ContactMapper.selectByIds(ids);
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
throw exception(DEMO01_CONTACT_NOT_EXISTS);
}
}
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);
}
}

View File

@@ -1,55 +0,0 @@
package com.njcn.msgpush.module.infra.service.demo.demo02;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo02.vo.Demo02CategoryListReqVO;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo02.vo.Demo02CategorySaveReqVO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo02.Demo02CategoryDO;
import jakarta.validation.Valid;
import java.util.List;
/**
* 示例分类 Service 接口
*
* @author hongawen
*/
public interface Demo02CategoryService {
/**
* 创建示例分类
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createDemo02Category(@Valid Demo02CategorySaveReqVO createReqVO);
/**
* 更新示例分类
*
* @param updateReqVO 更新信息
*/
void updateDemo02Category(@Valid Demo02CategorySaveReqVO updateReqVO);
/**
* 删除示例分类
*
* @param id 编号
*/
void deleteDemo02Category(Long id);
/**
* 获得示例分类
*
* @param id 编号
* @return 示例分类
*/
Demo02CategoryDO getDemo02Category(Long id);
/**
* 获得示例分类列表
*
* @param listReqVO 查询条件
* @return 示例分类列表
*/
List<Demo02CategoryDO> getDemo02CategoryList(Demo02CategoryListReqVO listReqVO);
}

View File

@@ -1,134 +0,0 @@
package com.njcn.msgpush.module.infra.service.demo.demo02;
import com.njcn.msgpush.framework.common.util.object.BeanUtils;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo02.vo.Demo02CategoryListReqVO;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo02.vo.Demo02CategorySaveReqVO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo02.Demo02CategoryDO;
import com.njcn.msgpush.module.infra.dal.mysql.demo.demo02.Demo02CategoryMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.List;
import java.util.Objects;
import static com.njcn.msgpush.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.njcn.msgpush.module.infra.enums.ErrorCodeConstants.*;
/**
* 示例分类 Service 实现类
*
* @author hongawen
*/
@Service
@Validated
public class Demo02CategoryServiceImpl implements Demo02CategoryService {
@Resource
private Demo02CategoryMapper demo02CategoryMapper;
@Override
public Long createDemo02Category(Demo02CategorySaveReqVO createReqVO) {
// 校验父级编号的有效性
validateParentDemo02Category(null, createReqVO.getParentId());
// 校验名字的唯一性
validateDemo02CategoryNameUnique(null, createReqVO.getParentId(), createReqVO.getName());
// 插入
Demo02CategoryDO demo02Category = BeanUtils.toBean(createReqVO, Demo02CategoryDO.class);
demo02CategoryMapper.insert(demo02Category);
// 返回
return demo02Category.getId();
}
@Override
public void updateDemo02Category(Demo02CategorySaveReqVO updateReqVO) {
// 校验存在
validateDemo02CategoryExists(updateReqVO.getId());
// 校验父级编号的有效性
validateParentDemo02Category(updateReqVO.getId(), updateReqVO.getParentId());
// 校验名字的唯一性
validateDemo02CategoryNameUnique(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName());
// 更新
Demo02CategoryDO updateObj = BeanUtils.toBean(updateReqVO, Demo02CategoryDO.class);
demo02CategoryMapper.updateById(updateObj);
}
@Override
public void deleteDemo02Category(Long id) {
// 校验存在
validateDemo02CategoryExists(id);
// 校验是否有子示例分类
if (demo02CategoryMapper.selectCountByParentId(id) > 0) {
throw exception(DEMO02_CATEGORY_EXITS_CHILDREN);
}
// 删除
demo02CategoryMapper.deleteById(id);
}
private void validateDemo02CategoryExists(Long id) {
if (demo02CategoryMapper.selectById(id) == null) {
throw exception(DEMO02_CATEGORY_NOT_EXISTS);
}
}
private void validateParentDemo02Category(Long id, Long parentId) {
if (parentId == null || Demo02CategoryDO.PARENT_ID_ROOT.equals(parentId)) {
return;
}
// 1. 不能设置自己为父示例分类
if (Objects.equals(id, parentId)) {
throw exception(DEMO02_CATEGORY_PARENT_ERROR);
}
// 2. 父示例分类不存在
Demo02CategoryDO parentDemo02Category = demo02CategoryMapper.selectById(parentId);
if (parentDemo02Category == null) {
throw exception(DEMO02_CATEGORY_PARENT_NOT_EXITS);
}
// 3. 递归校验父示例分类,如果父示例分类是自己的子示例分类,则报错,避免形成环路
if (id == null) { // id 为空,说明新增,不需要考虑环路
return;
}
for (int i = 0; i < Short.MAX_VALUE; i++) {
// 3.1 校验环路
parentId = parentDemo02Category.getParentId();
if (Objects.equals(id, parentId)) {
throw exception(DEMO02_CATEGORY_PARENT_IS_CHILD);
}
// 3.2 继续递归下一级父示例分类
if (parentId == null || Demo02CategoryDO.PARENT_ID_ROOT.equals(parentId)) {
break;
}
parentDemo02Category = demo02CategoryMapper.selectById(parentId);
if (parentDemo02Category == null) {
break;
}
}
}
private void validateDemo02CategoryNameUnique(Long id, Long parentId, String name) {
Demo02CategoryDO demo02Category = demo02CategoryMapper.selectByParentIdAndName(parentId, name);
if (demo02Category == null) {
return;
}
// 如果 id 为空,说明不用比较是否为相同 id 的示例分类
if (id == null) {
throw exception(DEMO02_CATEGORY_NAME_DUPLICATE);
}
if (!Objects.equals(demo02Category.getId(), id)) {
throw exception(DEMO02_CATEGORY_NAME_DUPLICATE);
}
}
@Override
public Demo02CategoryDO getDemo02Category(Long id) {
return demo02CategoryMapper.selectById(id);
}
@Override
public List<Demo02CategoryDO> getDemo02CategoryList(Demo02CategoryListReqVO listReqVO) {
return demo02CategoryMapper.selectList(listReqVO);
}
}

View File

@@ -1,162 +0,0 @@
package com.njcn.msgpush.module.infra.service.demo.demo03.erp;
import com.njcn.msgpush.framework.common.pojo.PageParam;
import com.njcn.msgpush.framework.common.pojo.PageResult;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentErpPageReqVO;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentErpSaveReqVO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
import jakarta.validation.Valid;
import java.util.List;
/**
* 学生 Service 接口
*
* @author hongawen
*/
public interface Demo03StudentErpService {
/**
* 创建学生
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createDemo03Student(@Valid Demo03StudentErpSaveReqVO createReqVO);
/**
* 更新学生
*
* @param updateReqVO 更新信息
*/
void updateDemo03Student(@Valid Demo03StudentErpSaveReqVO updateReqVO);
/**
* 删除学生
*
* @param id 编号
*/
void deleteDemo03Student(Long id);
/**
* 批量删除学生
*
* @param ids 编号
*/
void deleteDemo03StudentList(List<Long> ids);
/**
* 获得学生
*
* @param id 编号
* @return 学生
*/
Demo03StudentDO getDemo03Student(Long id);
/**
* 获得学生分页
*
* @param pageReqVO 分页查询
* @return 学生分页
*/
PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentErpPageReqVO pageReqVO);
// ==================== 子表(学生课程) ====================
/**
* 获得学生课程分页
*
* @param pageReqVO 分页查询
* @param studentId 学生编号
* @return 学生课程分页
*/
PageResult<Demo03CourseDO> getDemo03CoursePage(PageParam pageReqVO, Long studentId);
/**
* 创建学生课程
*
* @param demo03Course 创建信息
* @return 编号
*/
Long createDemo03Course(@Valid Demo03CourseDO demo03Course);
/**
* 更新学生课程
*
* @param demo03Course 更新信息
*/
void updateDemo03Course(@Valid Demo03CourseDO demo03Course);
/**
* 删除学生课程
*
* @param id 编号
*/
void deleteDemo03Course(Long id);
/**
* 批量删除学生课程
*
* @param ids 编号
*/
void deleteDemo03CourseList(List<Long> ids);
/**
* 获得学生课程
*
* @param id 编号
* @return 学生课程
*/
Demo03CourseDO getDemo03Course(Long id);
// ==================== 子表(学生班级) ====================
/**
* 获得学生班级分页
*
* @param pageReqVO 分页查询
* @param studentId 学生编号
* @return 学生班级分页
*/
PageResult<Demo03GradeDO> getDemo03GradePage(PageParam pageReqVO, Long studentId);
/**
* 创建学生班级
*
* @param demo03Grade 创建信息
* @return 编号
*/
Long createDemo03Grade(@Valid Demo03GradeDO demo03Grade);
/**
* 更新学生班级
*
* @param demo03Grade 更新信息
*/
void updateDemo03Grade(@Valid Demo03GradeDO demo03Grade);
/**
* 删除学生班级
*
* @param id 编号
*/
void deleteDemo03Grade(Long id);
/**
* 批量删除学生班级
*
* @param ids 编号
*/
void deleteDemo03GradeList(List<Long> ids);
/**
* 获得学生班级
*
* @param id 编号
* @return 学生班级
*/
Demo03GradeDO getDemo03Grade(Long id);
}

View File

@@ -1,219 +0,0 @@
package com.njcn.msgpush.module.infra.service.demo.demo03.erp;
import cn.hutool.core.collection.CollUtil;
import com.njcn.msgpush.framework.common.pojo.PageParam;
import com.njcn.msgpush.framework.common.pojo.PageResult;
import com.njcn.msgpush.framework.common.util.object.BeanUtils;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentErpPageReqVO;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo03.erp.vo.Demo03StudentErpSaveReqVO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
import com.njcn.msgpush.module.infra.dal.mysql.demo.demo03.erp.Demo03CourseErpMapper;
import com.njcn.msgpush.module.infra.dal.mysql.demo.demo03.erp.Demo03GradeErpMapper;
import com.njcn.msgpush.module.infra.dal.mysql.demo.demo03.erp.Demo03StudentErpMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.util.List;
import static com.njcn.msgpush.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.njcn.msgpush.module.infra.enums.ErrorCodeConstants.*;
/**
* 学生 Service 实现类
*
* @author hongawen
*/
@Service
@Validated
public class Demo03StudentErpServiceImpl implements Demo03StudentErpService {
@Resource
private Demo03StudentErpMapper demo03StudentErpMapper;
@Resource
private Demo03CourseErpMapper demo03CourseErpMapper;
@Resource
private Demo03GradeErpMapper demo03GradeErpMapper;
@Override
public Long createDemo03Student(Demo03StudentErpSaveReqVO createReqVO) {
// 插入
Demo03StudentDO demo03Student = BeanUtils.toBean(createReqVO, Demo03StudentDO.class);
demo03StudentErpMapper.insert(demo03Student);
// 返回
return demo03Student.getId();
}
@Override
public void updateDemo03Student(Demo03StudentErpSaveReqVO updateReqVO) {
// 校验存在
validateDemo03StudentExists(updateReqVO.getId());
// 更新
Demo03StudentDO updateObj = BeanUtils.toBean(updateReqVO, Demo03StudentDO.class);
demo03StudentErpMapper.updateById(updateObj);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteDemo03Student(Long id) {
// 校验存在
validateDemo03StudentExists(id);
// 删除
demo03StudentErpMapper.deleteById(id);
// 删除子表
deleteDemo03CourseByStudentId(id);
deleteDemo03GradeByStudentId(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteDemo03StudentList(List<Long> ids) {
// 校验存在
validateDemo03StudentExists(ids);
// 删除
demo03StudentErpMapper.deleteByIds(ids);
// 删除子表
deleteDemo03CourseByStudentIds(ids);
deleteDemo03GradeByStudentIds(ids);
}
private void validateDemo03StudentExists(List<Long> ids) {
List<Demo03StudentDO> list = demo03StudentErpMapper.selectByIds(ids);
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
throw exception(DEMO03_STUDENT_NOT_EXISTS);
}
}
private void validateDemo03StudentExists(Long id) {
if (demo03StudentErpMapper.selectById(id) == null) {
throw exception(DEMO03_STUDENT_NOT_EXISTS);
}
}
@Override
public Demo03StudentDO getDemo03Student(Long id) {
return demo03StudentErpMapper.selectById(id);
}
@Override
public PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentErpPageReqVO pageReqVO) {
return demo03StudentErpMapper.selectPage(pageReqVO);
}
// ==================== 子表(学生课程) ====================
@Override
public PageResult<Demo03CourseDO> getDemo03CoursePage(PageParam pageReqVO, Long studentId) {
return demo03CourseErpMapper.selectPage(pageReqVO, studentId);
}
@Override
public Long createDemo03Course(Demo03CourseDO demo03Course) {
demo03CourseErpMapper.insert(demo03Course);
return demo03Course.getId();
}
@Override
public void updateDemo03Course(Demo03CourseDO demo03Course) {
// 校验存在
validateDemo03CourseExists(demo03Course.getId());
// 更新
demo03Course.clean();
demo03CourseErpMapper.updateById(demo03Course);
}
@Override
public void deleteDemo03Course(Long id) {
// 删除
demo03CourseErpMapper.deleteById(id);
}
@Override
public void deleteDemo03CourseList(List<Long> ids) {
// 删除
demo03CourseErpMapper.deleteByIds(ids);
}
@Override
public Demo03CourseDO getDemo03Course(Long id) {
return demo03CourseErpMapper.selectById(id);
}
private void validateDemo03CourseExists(Long id) {
if (demo03CourseErpMapper.selectById(id) == null) {
throw exception(DEMO03_COURSE_NOT_EXISTS);
}
}
private void deleteDemo03CourseByStudentId(Long studentId) {
demo03CourseErpMapper.deleteByStudentId(studentId);
}
private void deleteDemo03CourseByStudentIds(List<Long> studentIds) {
demo03CourseErpMapper.deleteByStudentIds(studentIds);
}
// ==================== 子表(学生班级) ====================
@Override
public PageResult<Demo03GradeDO> getDemo03GradePage(PageParam pageReqVO, Long studentId) {
return demo03GradeErpMapper.selectPage(pageReqVO, studentId);
}
@Override
public Long createDemo03Grade(Demo03GradeDO demo03Grade) {
// 校验是否已经存在
if (demo03GradeErpMapper.selectByStudentId(demo03Grade.getStudentId()) != null) {
throw exception(DEMO03_GRADE_EXISTS);
}
// 插入
demo03GradeErpMapper.insert(demo03Grade);
return demo03Grade.getId();
}
@Override
public void updateDemo03Grade(Demo03GradeDO demo03Grade) {
// 校验存在
validateDemo03GradeExists(demo03Grade.getId());
// 更新
demo03Grade.clean();
demo03GradeErpMapper.updateById(demo03Grade);
}
@Override
public void deleteDemo03Grade(Long id) {
// 删除
demo03GradeErpMapper.deleteById(id);
}
@Override
public void deleteDemo03GradeList(List<Long> ids) {
// 删除
demo03GradeErpMapper.deleteByIds(ids);
}
@Override
public Demo03GradeDO getDemo03Grade(Long id) {
return demo03GradeErpMapper.selectById(id);
}
private void validateDemo03GradeExists(Long id) {
if (demo03GradeErpMapper.selectById(id) == null) {
throw exception(DEMO03_GRADE_NOT_EXISTS);
}
}
private void deleteDemo03GradeByStudentId(Long studentId) {
demo03GradeErpMapper.deleteByStudentId(studentId);
}
private void deleteDemo03GradeByStudentIds(List<Long> studentIds) {
demo03GradeErpMapper.deleteByStudentIds(studentIds);
}
}

View File

@@ -1,85 +0,0 @@
package com.njcn.msgpush.module.infra.service.demo.demo03.inner;
import com.njcn.msgpush.framework.common.pojo.PageResult;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo03.inner.vo.Demo03StudentInnerPageReqVO;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo03.inner.vo.Demo03StudentInnerSaveReqVO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
import jakarta.validation.Valid;
import java.util.List;
/**
* 学生 Service 接口
*
* @author hongawen
*/
public interface Demo03StudentInnerService {
/**
* 创建学生
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createDemo03Student(@Valid Demo03StudentInnerSaveReqVO createReqVO);
/**
* 更新学生
*
* @param updateReqVO 更新信息
*/
void updateDemo03Student(@Valid Demo03StudentInnerSaveReqVO updateReqVO);
/**
* 删除学生
*
* @param id 编号
*/
void deleteDemo03Student(Long id);
/**
* 批量删除学生
*
* @param ids 编号
*/
void deleteDemo03StudentList(List<Long> ids);
/**
* 获得学生
*
* @param id 编号
* @return 学生
*/
Demo03StudentDO getDemo03Student(Long id);
/**
* 获得学生分页
*
* @param pageReqVO 分页查询
* @return 学生分页
*/
PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentInnerPageReqVO pageReqVO);
// ==================== 子表(学生课程) ====================
/**
* 获得学生课程列表
*
* @param studentId 学生编号
* @return 学生课程列表
*/
List<Demo03CourseDO> getDemo03CourseListByStudentId(Long studentId);
// ==================== 子表(学生班级) ====================
/**
* 获得学生班级
*
* @param studentId 学生编号
* @return 学生班级
*/
Demo03GradeDO getDemo03GradeByStudentId(Long studentId);
}

View File

@@ -1,194 +0,0 @@
package com.njcn.msgpush.module.infra.service.demo.demo03.inner;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.njcn.msgpush.framework.common.pojo.PageResult;
import com.njcn.msgpush.framework.common.util.object.BeanUtils;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo03.inner.vo.Demo03StudentInnerPageReqVO;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo03.inner.vo.Demo03StudentInnerSaveReqVO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
import com.njcn.msgpush.module.infra.dal.mysql.demo.demo03.inner.Demo03CourseInnerMapper;
import com.njcn.msgpush.module.infra.dal.mysql.demo.demo03.inner.Demo03GradeInnerMapper;
import com.njcn.msgpush.module.infra.dal.mysql.demo.demo03.inner.Demo03StudentInnerMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.util.List;
import static com.njcn.msgpush.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.njcn.msgpush.framework.common.util.collection.CollectionUtils.convertList;
import static com.njcn.msgpush.framework.common.util.collection.CollectionUtils.diffList;
import static com.njcn.msgpush.module.infra.enums.ErrorCodeConstants.DEMO03_STUDENT_NOT_EXISTS;
/**
* 学生 Service 实现类
*
* @author hongawen
*/
@Service
@Validated
public class Demo03StudentInnerServiceImpl implements Demo03StudentInnerService {
@Resource
private Demo03StudentInnerMapper demo03StudentInnerMapper;
@Resource
private Demo03CourseInnerMapper demo03CourseInnerMapper;
@Resource
private Demo03GradeInnerMapper demo03GradeInnerMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public Long createDemo03Student(Demo03StudentInnerSaveReqVO createReqVO) {
// 插入
Demo03StudentDO demo03Student = BeanUtils.toBean(createReqVO, Demo03StudentDO.class);
demo03StudentInnerMapper.insert(demo03Student);
// 插入子表
createDemo03CourseList(demo03Student.getId(), createReqVO.getDemo03Courses());
createDemo03Grade(demo03Student.getId(), createReqVO.getDemo03Grade());
// 返回
return demo03Student.getId();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateDemo03Student(Demo03StudentInnerSaveReqVO updateReqVO) {
// 校验存在
validateDemo03StudentExists(updateReqVO.getId());
// 更新
Demo03StudentDO updateObj = BeanUtils.toBean(updateReqVO, Demo03StudentDO.class);
demo03StudentInnerMapper.updateById(updateObj);
// 更新子表
updateDemo03CourseList(updateReqVO.getId(), updateReqVO.getDemo03Courses());
updateDemo03Grade(updateReqVO.getId(), updateReqVO.getDemo03Grade());
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteDemo03Student(Long id) {
// 校验存在
validateDemo03StudentExists(id);
// 删除
demo03StudentInnerMapper.deleteById(id);
// 删除子表
deleteDemo03CourseByStudentId(id);
deleteDemo03GradeByStudentId(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteDemo03StudentList(List<Long> ids) {
// 校验存在
validateDemo03StudentExists(ids);
// 删除
demo03StudentInnerMapper.deleteByIds(ids);
// 删除子表
deleteDemo03CourseByStudentIds(ids);
deleteDemo03GradeByStudentIds(ids);
}
private void validateDemo03StudentExists(List<Long> ids) {
List<Demo03StudentDO> list = demo03StudentInnerMapper.selectByIds(ids);
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
throw exception(DEMO03_STUDENT_NOT_EXISTS);
}
}
private void validateDemo03StudentExists(Long id) {
if (demo03StudentInnerMapper.selectById(id) == null) {
throw exception(DEMO03_STUDENT_NOT_EXISTS);
}
}
@Override
public Demo03StudentDO getDemo03Student(Long id) {
return demo03StudentInnerMapper.selectById(id);
}
@Override
public PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentInnerPageReqVO pageReqVO) {
return demo03StudentInnerMapper.selectPage(pageReqVO);
}
// ==================== 子表(学生课程) ====================
@Override
public List<Demo03CourseDO> getDemo03CourseListByStudentId(Long studentId) {
return demo03CourseInnerMapper.selectListByStudentId(studentId);
}
private void createDemo03CourseList(Long studentId, List<Demo03CourseDO> list) {
list.forEach(o -> o.setStudentId(studentId).clean());
demo03CourseInnerMapper.insertBatch(list);
}
private void updateDemo03CourseList(Long studentId, List<Demo03CourseDO> list) {
list.forEach(o -> o.setStudentId(studentId).clean());
List<Demo03CourseDO> oldList = demo03CourseInnerMapper.selectListByStudentId(studentId);
List<List<Demo03CourseDO>> diffList = diffList(oldList, list, (oldVal, newVal) -> {
boolean same = ObjectUtil.equal(oldVal.getId(), newVal.getId());
if (same) {
newVal.setId(oldVal.getId());
}
return same;
});
// 第二步,批量添加、修改、删除
if (CollUtil.isNotEmpty(diffList.get(0))) {
demo03CourseInnerMapper.insertBatch(diffList.get(0));
}
if (CollUtil.isNotEmpty(diffList.get(1))) {
demo03CourseInnerMapper.updateBatch(diffList.get(1));
}
if (CollUtil.isNotEmpty(diffList.get(2))) {
demo03CourseInnerMapper.deleteByIds(convertList(diffList.get(2), Demo03CourseDO::getId));
}
}
private void deleteDemo03CourseByStudentId(Long studentId) {
demo03CourseInnerMapper.deleteByStudentId(studentId);
}
private void deleteDemo03CourseByStudentIds(List<Long> studentIds) {
demo03CourseInnerMapper.deleteByStudentIds(studentIds);
}
// ==================== 子表(学生班级) ====================
@Override
public Demo03GradeDO getDemo03GradeByStudentId(Long studentId) {
return demo03GradeInnerMapper.selectByStudentId(studentId);
}
private void createDemo03Grade(Long studentId, Demo03GradeDO demo03Grade) {
if (demo03Grade == null) {
return;
}
demo03Grade.setStudentId(studentId);
demo03GradeInnerMapper.insert(demo03Grade);
}
private void updateDemo03Grade(Long studentId, Demo03GradeDO demo03Grade) {
if (demo03Grade == null) {
return;
}
demo03Grade.setStudentId(studentId).clean();
demo03GradeInnerMapper.insertOrUpdate(demo03Grade);
}
private void deleteDemo03GradeByStudentId(Long studentId) {
demo03GradeInnerMapper.deleteByStudentId(studentId);
}
private void deleteDemo03GradeByStudentIds(List<Long> studentIds) {
demo03GradeInnerMapper.deleteByStudentIds(studentIds);
}
}

View File

@@ -1,85 +0,0 @@
package com.njcn.msgpush.module.infra.service.demo.demo03.normal;
import com.njcn.msgpush.framework.common.pojo.PageResult;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo03.normal.vo.Demo03StudentNormalPageReqVO;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo03.normal.vo.Demo03StudentNormalSaveReqVO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
import jakarta.validation.Valid;
import java.util.List;
/**
* 学生 Service 接口
*
* @author hongawen
*/
public interface Demo03StudentNormalService {
/**
* 创建学生
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createDemo03Student(@Valid Demo03StudentNormalSaveReqVO createReqVO);
/**
* 更新学生
*
* @param updateReqVO 更新信息
*/
void updateDemo03Student(@Valid Demo03StudentNormalSaveReqVO updateReqVO);
/**
* 删除学生
*
* @param id 编号
*/
void deleteDemo03Student(Long id);
/**
* 批量删除学生
*
* @param ids 编号
*/
void deleteDemo03StudentList(List<Long> ids);
/**
* 获得学生
*
* @param id 编号
* @return 学生
*/
Demo03StudentDO getDemo03Student(Long id);
/**
* 获得学生分页
*
* @param pageReqVO 分页查询
* @return 学生分页
*/
PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentNormalPageReqVO pageReqVO);
// ==================== 子表(学生课程) ====================
/**
* 获得学生课程列表
*
* @param studentId 学生编号
* @return 学生课程列表
*/
List<Demo03CourseDO> getDemo03CourseListByStudentId(Long studentId);
// ==================== 子表(学生班级) ====================
/**
* 获得学生班级
*
* @param studentId 学生编号
* @return 学生班级
*/
Demo03GradeDO getDemo03GradeByStudentId(Long studentId);
}

View File

@@ -1,194 +0,0 @@
package com.njcn.msgpush.module.infra.service.demo.demo03.normal;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.njcn.msgpush.framework.common.pojo.PageResult;
import com.njcn.msgpush.framework.common.util.object.BeanUtils;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo03.normal.vo.Demo03StudentNormalPageReqVO;
import com.njcn.msgpush.module.infra.controller.admin.demo.demo03.normal.vo.Demo03StudentNormalSaveReqVO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03CourseDO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03GradeDO;
import com.njcn.msgpush.module.infra.dal.dataobject.demo.demo03.Demo03StudentDO;
import com.njcn.msgpush.module.infra.dal.mysql.demo.demo03.normal.Demo03CourseNormalMapper;
import com.njcn.msgpush.module.infra.dal.mysql.demo.demo03.normal.Demo03GradeNormalMapper;
import com.njcn.msgpush.module.infra.dal.mysql.demo.demo03.normal.Demo03StudentNormalMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.util.List;
import static com.njcn.msgpush.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.njcn.msgpush.framework.common.util.collection.CollectionUtils.convertList;
import static com.njcn.msgpush.framework.common.util.collection.CollectionUtils.diffList;
import static com.njcn.msgpush.module.infra.enums.ErrorCodeConstants.DEMO03_STUDENT_NOT_EXISTS;
/**
* 学生 Service 实现类
*
* @author hongawen
*/
@Service
@Validated
public class Demo03StudentNormalServiceImpl implements Demo03StudentNormalService {
@Resource
private Demo03StudentNormalMapper demo03StudentNormalMapper;
@Resource
private Demo03CourseNormalMapper demo03CourseNormalMapper;
@Resource
private Demo03GradeNormalMapper demo03GradeNormalMapper;
@Override
@Transactional(rollbackFor = Exception.class)
public Long createDemo03Student(Demo03StudentNormalSaveReqVO createReqVO) {
// 插入
Demo03StudentDO demo03Student = BeanUtils.toBean(createReqVO, Demo03StudentDO.class);
demo03StudentNormalMapper.insert(demo03Student);
// 插入子表
createDemo03CourseList(demo03Student.getId(), createReqVO.getDemo03Courses());
createDemo03Grade(demo03Student.getId(), createReqVO.getDemo03Grade());
// 返回
return demo03Student.getId();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateDemo03Student(Demo03StudentNormalSaveReqVO updateReqVO) {
// 校验存在
validateDemo03StudentExists(updateReqVO.getId());
// 更新
Demo03StudentDO updateObj = BeanUtils.toBean(updateReqVO, Demo03StudentDO.class);
demo03StudentNormalMapper.updateById(updateObj);
// 更新子表
updateDemo03CourseList(updateReqVO.getId(), updateReqVO.getDemo03Courses());
updateDemo03Grade(updateReqVO.getId(), updateReqVO.getDemo03Grade());
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteDemo03Student(Long id) {
// 校验存在
validateDemo03StudentExists(id);
// 删除
demo03StudentNormalMapper.deleteById(id);
// 删除子表
deleteDemo03CourseByStudentId(id);
deleteDemo03GradeByStudentId(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteDemo03StudentList(List<Long> ids) {
// 校验存在
validateDemo03StudentExists(ids);
// 删除
demo03StudentNormalMapper.deleteByIds(ids);
// 删除子表
deleteDemo03CourseByStudentIds(ids);
deleteDemo03GradeByStudentIds(ids);
}
private void validateDemo03StudentExists(List<Long> ids) {
List<Demo03StudentDO> list = demo03StudentNormalMapper.selectByIds(ids);
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
throw exception(DEMO03_STUDENT_NOT_EXISTS);
}
}
private void validateDemo03StudentExists(Long id) {
if (demo03StudentNormalMapper.selectById(id) == null) {
throw exception(DEMO03_STUDENT_NOT_EXISTS);
}
}
@Override
public Demo03StudentDO getDemo03Student(Long id) {
return demo03StudentNormalMapper.selectById(id);
}
@Override
public PageResult<Demo03StudentDO> getDemo03StudentPage(Demo03StudentNormalPageReqVO pageReqVO) {
return demo03StudentNormalMapper.selectPage(pageReqVO);
}
// ==================== 子表(学生课程) ====================
@Override
public List<Demo03CourseDO> getDemo03CourseListByStudentId(Long studentId) {
return demo03CourseNormalMapper.selectListByStudentId(studentId);
}
private void createDemo03CourseList(Long studentId, List<Demo03CourseDO> list) {
list.forEach(o -> o.setStudentId(studentId).clean());
demo03CourseNormalMapper.insertBatch(list);
}
private void updateDemo03CourseList(Long studentId, List<Demo03CourseDO> list) {
list.forEach(o -> o.setStudentId(studentId).clean());
List<Demo03CourseDO> oldList = demo03CourseNormalMapper.selectListByStudentId(studentId);
List<List<Demo03CourseDO>> diffList = diffList(oldList, list, (oldVal, newVal) -> {
boolean same = ObjectUtil.equal(oldVal.getId(), newVal.getId());
if (same) {
newVal.setId(oldVal.getId());
}
return same;
});
// 第二步,批量添加、修改、删除
if (CollUtil.isNotEmpty(diffList.get(0))) {
demo03CourseNormalMapper.insertBatch(diffList.get(0));
}
if (CollUtil.isNotEmpty(diffList.get(1))) {
demo03CourseNormalMapper.updateBatch(diffList.get(1));
}
if (CollUtil.isNotEmpty(diffList.get(2))) {
demo03CourseNormalMapper.deleteByIds(convertList(diffList.get(2), Demo03CourseDO::getId));
}
}
private void deleteDemo03CourseByStudentId(Long studentId) {
demo03CourseNormalMapper.deleteByStudentId(studentId);
}
private void deleteDemo03CourseByStudentIds(List<Long> studentIds) {
demo03CourseNormalMapper.deleteByStudentIds(studentIds);
}
// ==================== 子表(学生班级) ====================
@Override
public Demo03GradeDO getDemo03GradeByStudentId(Long studentId) {
return demo03GradeNormalMapper.selectByStudentId(studentId);
}
private void createDemo03Grade(Long studentId, Demo03GradeDO demo03Grade) {
if (demo03Grade == null) {
return;
}
demo03Grade.setStudentId(studentId);
demo03GradeNormalMapper.insert(demo03Grade);
}
private void updateDemo03Grade(Long studentId, Demo03GradeDO demo03Grade) {
if (demo03Grade == null) {
return;
}
demo03Grade.setStudentId(studentId).clean();
demo03GradeNormalMapper.insertOrUpdate(demo03Grade);
}
private void deleteDemo03GradeByStudentId(Long studentId) {
demo03GradeNormalMapper.deleteByStudentId(studentId);
}
private void deleteDemo03GradeByStudentIds(List<Long> studentIds) {
demo03GradeNormalMapper.deleteByStudentIds(studentIds);
}
}

View File

@@ -4,8 +4,6 @@ import com.njcn.msgpush.framework.common.biz.infra.logger.dto.ApiAccessLogCreate
import com.njcn.msgpush.framework.common.pojo.PageResult;
import com.njcn.msgpush.framework.common.util.object.BeanUtils;
import com.njcn.msgpush.framework.common.util.string.StrUtils;
import com.njcn.msgpush.framework.tenant.core.context.TenantContextHolder;
import com.njcn.msgpush.framework.tenant.core.util.TenantUtils;
import com.njcn.msgpush.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO;
import com.njcn.msgpush.module.infra.dal.dataobject.logger.ApiAccessLogDO;
import com.njcn.msgpush.module.infra.dal.mysql.logger.ApiAccessLogMapper;
@@ -37,12 +35,7 @@ public class ApiAccessLogServiceImpl implements ApiAccessLogService {
ApiAccessLogDO apiAccessLog = BeanUtils.toBean(createDTO, ApiAccessLogDO.class);
apiAccessLog.setRequestParams(StrUtils.maxLength(apiAccessLog.getRequestParams(), REQUEST_PARAMS_MAX_LENGTH));
apiAccessLog.setResultMsg(StrUtils.maxLength(apiAccessLog.getResultMsg(), RESULT_MSG_MAX_LENGTH));
if (TenantContextHolder.getTenantId() != null) {
apiAccessLogMapper.insert(apiAccessLog);
} else {
// 极端情况下,上下文中没有租户时,此时忽略租户上下文,避免插入失败!
TenantUtils.executeIgnore(() -> apiAccessLogMapper.insert(apiAccessLog));
}
apiAccessLogMapper.insert(apiAccessLog);
}
@Override

View File

@@ -4,8 +4,6 @@ import com.njcn.msgpush.framework.common.biz.infra.logger.dto.ApiErrorLogCreateR
import com.njcn.msgpush.framework.common.pojo.PageResult;
import com.njcn.msgpush.framework.common.util.object.BeanUtils;
import com.njcn.msgpush.framework.common.util.string.StrUtils;
import com.njcn.msgpush.framework.tenant.core.context.TenantContextHolder;
import com.njcn.msgpush.framework.tenant.core.util.TenantUtils;
import com.njcn.msgpush.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO;
import com.njcn.msgpush.module.infra.dal.dataobject.logger.ApiErrorLogDO;
import com.njcn.msgpush.module.infra.dal.mysql.logger.ApiErrorLogMapper;
@@ -41,12 +39,7 @@ public class ApiErrorLogServiceImpl implements ApiErrorLogService {
.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus());
apiErrorLog.setRequestParams(StrUtils.maxLength(apiErrorLog.getRequestParams(), REQUEST_PARAMS_MAX_LENGTH));
try {
if (TenantContextHolder.getTenantId() != null) {
apiErrorLogMapper.insert(apiErrorLog);
} else {
// 极端情况下,上下文中没有租户时,此时忽略租户上下文,避免插入失败!
TenantUtils.executeIgnore(() -> apiErrorLogMapper.insert(apiErrorLog));
}
apiErrorLogMapper.insert(apiErrorLog);
} catch (Exception ex) {
// 兜底处理,目前只有 msgpush-cloud 会发生https://gitee.com/msgpushcode/msgpush-cloud-mini/issues/IC1O0A
log.error("[createApiErrorLog][记录时({}) 发生异常]", createDTO, ex);

View File

@@ -107,9 +107,5 @@ msgpush:
vo-type: 10 # VO 的类型,参见 CodegenVOTypeEnum 枚举类
delete-batch-enable: true # 是否生成批量删除接口
unit-test-enable: false # 是否生成单元测试
tenant: # 多租户相关配置项
enable: true
ignore-urls:
ignore-tables:
debug: false

View File

@@ -23,8 +23,6 @@ CREATE TABLE IF NOT EXISTS "${table.tableName.toLowerCase()}" (
"${column.columnName}" ${dataType} DEFAULT '',
#elseif (${column.columnName} == 'deleted')
"deleted" bit NOT NULL DEFAULT FALSE,
#elseif (${column.columnName} == 'tenant_id')
"tenant_id" bigint NOT NULL DEFAULT 0,
#else
"${column.columnName.toLowerCase()}" ${dataType}#if (${column.nullable} == false) NOT NULL#end,
#end

View File

@@ -1,11 +0,0 @@
DELETE FROM "infra_config";
DELETE FROM "infra_file_config";
DELETE FROM "infra_file";
DELETE FROM "infra_job";
DELETE FROM "infra_job_log";
DELETE FROM "infra_api_access_log";
DELETE FROM "infra_api_error_log";
DELETE FROM "infra_file_config";
DELETE FROM "infra_data_source_config";
DELETE FROM "infra_codegen_table";
DELETE FROM "infra_codegen_column";

View File

@@ -1,216 +0,0 @@
CREATE TABLE IF NOT EXISTS "infra_config" (
"id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY COMMENT '编号',
"category" varchar(50) NOT NULL,
"type" tinyint NOT NULL,
"name" varchar(100) NOT NULL DEFAULT '' COMMENT '名字',
"config_key" varchar(100) NOT NULL DEFAULT '',
"value" varchar(500) NOT NULL DEFAULT '',
"visible" bit NOT NULL,
"remark" varchar(500) DEFAULT NULL,
"creator" varchar(64) DEFAULT '',
"create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updater" varchar(64) DEFAULT '',
"update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"deleted" bit NOT NULL DEFAULT FALSE,
PRIMARY KEY ("id")
) COMMENT '参数配置表';
CREATE TABLE IF NOT EXISTS "infra_file_config" (
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"name" varchar(63) NOT NULL,
"storage" tinyint NOT NULL,
"remark" varchar(255),
"master" bit(1) NOT NULL,
"config" varchar(4096) NOT NULL,
"creator" varchar(64) DEFAULT '',
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updater" varchar(64) DEFAULT '',
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
"deleted" bit NOT NULL DEFAULT FALSE,
PRIMARY KEY ("id")
) COMMENT '文件配置表';
CREATE TABLE IF NOT EXISTS "infra_file" (
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"config_id" bigint NOT NULL,
"name" varchar(256),
"path" varchar(512),
"url" varchar(1024),
"type" varchar(63) DEFAULT NULL,
"size" bigint NOT NULL,
"creator" varchar(64) DEFAULT '',
"create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updater" varchar(64) DEFAULT '',
"update_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"deleted" bit NOT NULL DEFAULT FALSE,
"tenant_id" bigint not null default '0',
PRIMARY KEY ("id")
) COMMENT '文件表';
CREATE TABLE IF NOT EXISTS "infra_job" (
"id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY COMMENT '任务编号',
"name" varchar(32) NOT NULL COMMENT '任务名称',
"status" tinyint(4) NOT NULL COMMENT '任务状态',
"handler_name" varchar(64) NOT NULL COMMENT '处理器的名字',
"handler_param" varchar(255) DEFAULT NULL COMMENT '处理器的参数',
"cron_expression" varchar(32) NOT NULL COMMENT 'CRON 表达式',
"retry_count" int(11) NOT NULL DEFAULT '0' COMMENT '重试次数',
"retry_interval" int(11) NOT NULL DEFAULT '0' COMMENT '重试间隔',
"monitor_timeout" int(11) NOT NULL DEFAULT '0' COMMENT '监控超时时间',
"creator" varchar(64) DEFAULT '' COMMENT '创建者',
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
"updater" varchar(64) DEFAULT '' COMMENT '更新者',
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
"deleted" bit NOT NULL DEFAULT FALSE COMMENT '是否删除',
PRIMARY KEY ("id")
) COMMENT='定时任务表';
CREATE TABLE IF NOT EXISTS "infra_job_log" (
"id" bigint(20) NOT NULL GENERATED BY DEFAULT AS IDENTITY COMMENT '日志编号',
"job_id" bigint(20) NOT NULL COMMENT '任务编号',
"handler_name" varchar(64) NOT NULL COMMENT '处理器的名字',
"handler_param" varchar(255) DEFAULT NULL COMMENT '处理器的参数',
"execute_index" tinyint(4) NOT NULL DEFAULT '1' COMMENT '第几次执行',
"begin_time" datetime NOT NULL COMMENT '开始执行时间',
"end_time" datetime DEFAULT NULL COMMENT '结束执行时间',
"duration" int(11) DEFAULT NULL COMMENT '执行时长',
"status" tinyint(4) NOT NULL COMMENT '任务状态',
"result" varchar(4000) DEFAULT '' COMMENT '结果数据',
"creator" varchar(64) DEFAULT '' COMMENT '创建者',
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
"updater" varchar(64) DEFAULT '' COMMENT '更新者',
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
"deleted" bit(1) NOT NULL DEFAULT FALSE COMMENT '是否删除',
PRIMARY KEY ("id")
)COMMENT='定时任务日志表';
CREATE TABLE IF NOT EXISTS "infra_api_access_log" (
"id" bigint not null GENERATED BY DEFAULT AS IDENTITY,
"trace_id" varchar(64) not null default '',
"user_id" bigint not null default '0',
"user_type" tinyint not null default '0',
"application_name" varchar(50) not null,
"request_method" varchar(16) not null default '',
"request_url" varchar(255) not null default '',
"request_params" varchar(8000) not null default '',
"response_body" varchar(8000) not null default '',
"user_ip" varchar(50) not null,
"user_agent" varchar(512) not null,
`operate_module` varchar(50) NOT NULL,
`operate_name` varchar(50) NOT NULL,
`operate_type` bigint(4) NOT NULL DEFAULT '0',
"begin_time" timestamp not null,
"end_time" timestamp not null,
"duration" integer not null,
"result_code" integer not null default '0',
"result_msg" varchar(512) default '',
"creator" varchar(64) default '',
"create_time" timestamp not null default current_timestamp,
"updater" varchar(64) default '',
"update_time" timestamp not null default current_timestamp,
"deleted" bit not null default false,
"tenant_id" bigint not null default '0',
primary key ("id")
) COMMENT 'API 访问日志表';
CREATE TABLE IF NOT EXISTS "infra_api_error_log" (
"id" bigint not null GENERATED BY DEFAULT AS IDENTITY,
"trace_id" varchar(64) not null,
"user_id" bigint not null default '0',
"user_type" tinyint not null default '0',
"application_name" varchar(50) not null,
"request_method" varchar(16) not null,
"request_url" varchar(255) not null,
"request_params" varchar(8000) not null,
"user_ip" varchar(50) not null,
"user_agent" varchar(512) not null,
"exception_time" timestamp not null,
"exception_name" varchar(128) not null default '',
"exception_message" clob not null,
"exception_root_cause_message" clob not null,
"exception_stack_trace" clob not null,
"exception_class_name" varchar(512) not null,
"exception_file_name" varchar(512) not null,
"exception_method_name" varchar(512) not null,
"exception_line_number" integer not null,
"process_status" tinyint not null,
"process_time" timestamp default null,
"process_user_id" bigint default '0',
"creator" varchar(64) default '',
"create_time" timestamp not null default current_timestamp,
"updater" varchar(64) default '',
"update_time" timestamp not null default current_timestamp,
"deleted" bit not null default false,
"tenant_id" bigint not null default '0',
primary key ("id")
) COMMENT '系统异常日志';
CREATE TABLE IF NOT EXISTS "infra_data_source_config" (
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"name" varchar(100) NOT NULL,
"url" varchar(1024) NOT NULL,
"username" varchar(255) NOT NULL,
"password" varchar(255) NOT NULL,
"creator" varchar(64) DEFAULT '',
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updater" varchar(64) DEFAULT '',
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
"deleted" bit NOT NULL DEFAULT FALSE,
PRIMARY KEY ("id")
) COMMENT '数据源配置表';
CREATE TABLE IF NOT EXISTS "infra_codegen_table" (
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"data_source_config_id" bigint not null,
"scene" tinyint not null DEFAULT 1,
"table_name" varchar(200) NOT NULL,
"table_comment" varchar(500) NOT NULL,
"remark" varchar(500) NOT NULL,
"module_name" varchar(30) NOT NULL,
"business_name" varchar(30) NOT NULL,
"class_name" varchar(100) NOT NULL,
"class_comment" varchar(50) NOT NULL,
"author" varchar(50) NOT NULL,
"template_type" tinyint not null DEFAULT 1,
"front_type" tinyint not null,
"parent_menu_id" bigint not null,
"master_table_id" bigint not null,
"sub_join_column_id" bigint not null,
"sub_join_many" bit not null,
"tree_parent_column_id" bigint not null,
"tree_name_column_id" bigint not null,
"creator" varchar(64) DEFAULT '',
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updater" varchar(64) DEFAULT '',
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
"deleted" bit NOT NULL DEFAULT FALSE,
PRIMARY KEY ("id")
) COMMENT '代码生成表定义表';
CREATE TABLE IF NOT EXISTS "infra_codegen_column" (
"id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
"table_id" bigint not null,
"column_name" varchar(200) NOT NULL,
"data_type" varchar(100) NOT NULL,
"column_comment" varchar(500) NOT NULL,
"nullable" tinyint not null,
"primary_key" tinyint not null,
"ordinal_position" int not null,
"java_type" varchar(32) NOT NULL,
"java_field" varchar(64) NOT NULL,
"dict_type" varchar(200) NOT NULL,
"example" varchar(64) NOT NULL,
"create_operation" bit not null,
"update_operation" bit not null,
"list_operation" bit not null,
"list_operation_condition" varchar(32) not null,
"list_operation_result" bit not null,
"html_type" varchar(32) NOT NULL,
"creator" varchar(64) DEFAULT '',
"create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updater" varchar(64) DEFAULT '',
"update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
"deleted" bit NOT NULL DEFAULT FALSE,
PRIMARY KEY ("id")
) COMMENT '代码生成表字段定义表';