Commit 5b9879ca8dd2b07fd510ed499e80a55987b9e31a

Authored by YunaiV
1 parent 01a55b93

代码生成:增加 tree 示例

Showing 14 changed files with 459 additions and 4 deletions
yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/enums/ErrorCodeConstants.java
... ... @@ -60,5 +60,10 @@ public interface ErrorCodeConstants {
60 60  
61 61 // ========== 学生 1-001-201-000 ==========
62 62 ErrorCode DEMO01_CONTACT_NOT_EXISTS = new ErrorCode(1_001_201_000, "示例联系人不存在");
63   -
  63 + ErrorCode DEMO02_CATEGORY_NOT_EXISTS = new ErrorCode(1_001_201_001, "示例分类不存在");
  64 + ErrorCode DEMO02_CATEGORY_EXITS_CHILDREN = new ErrorCode(1_001_201_002, "存在存在子示例分类,无法删除");
  65 + ErrorCode DEMO02_CATEGORY_PARENT_NOT_EXITS = new ErrorCode(1_001_201_003,"父级示例分类不存在");
  66 + ErrorCode DEMO02_CATEGORY_PARENT_ERROR = new ErrorCode(1_001_201_004, "不能设置自己为父示例分类");
  67 + ErrorCode DEMO02_CATEGORY_NAME_DUPLICATE = new ErrorCode(1_001_201_005, "已经存在该名字的示例分类");
  68 + ErrorCode DEMO02_CATEGORY_PARENT_IS_CHILD = new ErrorCode(1_001_201_006, "不能设置自己的子示例分类为父示例分类");
64 69 }
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo02/Demo02CategoryController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo02;
  2 +
  3 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo.Demo02CategoryListReqVO;
  4 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo.Demo02CategoryRespVO;
  5 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo.Demo02CategorySaveReqVO;
  6 +import org.springframework.web.bind.annotation.*;
  7 +import javax.annotation.Resource;
  8 +import org.springframework.validation.annotation.Validated;
  9 +import org.springframework.security.access.prepost.PreAuthorize;
  10 +import io.swagger.v3.oas.annotations.tags.Tag;
  11 +import io.swagger.v3.oas.annotations.Parameter;
  12 +import io.swagger.v3.oas.annotations.Operation;
  13 +
  14 +import javax.validation.*;
  15 +import javax.servlet.http.*;
  16 +import java.util.*;
  17 +import java.io.IOException;
  18 +
  19 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  20 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  21 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  22 +
  23 +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
  24 +
  25 +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
  26 +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
  27 +
  28 +import cn.iocoder.yudao.module.infra.controller.admin.demo02.vo.*;
  29 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo02.Demo02CategoryDO;
  30 +import cn.iocoder.yudao.module.infra.service.demo.demo02.Demo02CategoryService;
  31 +
  32 +@Tag(name = "管理后台 - 示例分类")
  33 +@RestController
  34 +@RequestMapping("/infra/demo02-category")
  35 +@Validated
  36 +public class Demo02CategoryController {
  37 +
  38 + @Resource
  39 + private Demo02CategoryService demo02CategoryService;
  40 +
  41 + @PostMapping("/create")
  42 + @Operation(summary = "创建示例分类")
  43 + @PreAuthorize("@ss.hasPermission('infra:demo02-category:create')")
  44 + public CommonResult<Long> createDemo02Category(@Valid @RequestBody Demo02CategorySaveReqVO createReqVO) {
  45 + return success(demo02CategoryService.createDemo02Category(createReqVO));
  46 + }
  47 +
  48 + @PutMapping("/update")
  49 + @Operation(summary = "更新示例分类")
  50 + @PreAuthorize("@ss.hasPermission('infra:demo02-category:update')")
  51 + public CommonResult<Boolean> updateDemo02Category(@Valid @RequestBody Demo02CategorySaveReqVO updateReqVO) {
  52 + demo02CategoryService.updateDemo02Category(updateReqVO);
  53 + return success(true);
  54 + }
  55 +
  56 + @DeleteMapping("/delete")
  57 + @Operation(summary = "删除示例分类")
  58 + @Parameter(name = "id", description = "编号", required = true)
  59 + @PreAuthorize("@ss.hasPermission('infra:demo02-category:delete')")
  60 + public CommonResult<Boolean> deleteDemo02Category(@RequestParam("id") Long id) {
  61 + demo02CategoryService.deleteDemo02Category(id);
  62 + return success(true);
  63 + }
  64 +
  65 + @GetMapping("/get")
  66 + @Operation(summary = "获得示例分类")
  67 + @Parameter(name = "id", description = "编号", required = true, example = "1024")
  68 + @PreAuthorize("@ss.hasPermission('infra:demo02-category:query')")
  69 + public CommonResult<Demo02CategoryRespVO> getDemo02Category(@RequestParam("id") Long id) {
  70 + Demo02CategoryDO demo02Category = demo02CategoryService.getDemo02Category(id);
  71 + return success(BeanUtils.toBean(demo02Category, Demo02CategoryRespVO.class));
  72 + }
  73 +
  74 + @GetMapping("/list")
  75 + @Operation(summary = "获得示例分类列表")
  76 + @PreAuthorize("@ss.hasPermission('infra:demo02-category:query')")
  77 + public CommonResult<List<Demo02CategoryRespVO>> getDemo02CategoryList(@Valid Demo02CategoryListReqVO listReqVO) {
  78 + List<Demo02CategoryDO> list = demo02CategoryService.getDemo02CategoryList(listReqVO);
  79 + return success(BeanUtils.toBean(list, Demo02CategoryRespVO.class));
  80 + }
  81 +
  82 + @GetMapping("/export-excel")
  83 + @Operation(summary = "导出示例分类 Excel")
  84 + @PreAuthorize("@ss.hasPermission('infra:demo02-category:export')")
  85 + @OperateLog(type = EXPORT)
  86 + public void exportDemo02CategoryExcel(@Valid Demo02CategoryListReqVO listReqVO,
  87 + HttpServletResponse response) throws IOException {
  88 + List<Demo02CategoryDO> list = demo02CategoryService.getDemo02CategoryList(listReqVO);
  89 + // 导出 Excel
  90 + ExcelUtils.write(response, "示例分类.xls", "数据", Demo02CategoryRespVO.class,
  91 + BeanUtils.toBean(list, Demo02CategoryRespVO.class));
  92 + }
  93 +
  94 +}
0 95 \ No newline at end of file
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo02/vo/Demo02CategoryListReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.Data;
  5 +import org.springframework.format.annotation.DateTimeFormat;
  6 +
  7 +import java.time.LocalDateTime;
  8 +
  9 +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
  10 +
  11 +@Schema(description = "管理后台 - 示例分类列表 Request VO")
  12 +@Data
  13 +public class Demo02CategoryListReqVO {
  14 +
  15 + @Schema(description = "名字", example = "芋艿")
  16 + private String name;
  17 +
  18 + @Schema(description = "父级编号", example = "6080")
  19 + private Long parentId;
  20 +
  21 + @Schema(description = "创建时间")
  22 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  23 + private LocalDateTime[] createTime;
  24 +
  25 +}
0 26 \ No newline at end of file
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo02/vo/Demo02CategoryRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo;
  2 +
  3 +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
  4 +import com.alibaba.excel.annotation.ExcelProperty;
  5 +import io.swagger.v3.oas.annotations.media.Schema;
  6 +import lombok.Data;
  7 +
  8 +import java.time.LocalDateTime;
  9 +
  10 +@Schema(description = "管理后台 - 示例分类 Response VO")
  11 +@Data
  12 +@ExcelIgnoreUnannotated
  13 +public class Demo02CategoryRespVO {
  14 +
  15 + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10304")
  16 + @ExcelProperty("编号")
  17 + private Long id;
  18 +
  19 + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
  20 + @ExcelProperty("名字")
  21 + private String name;
  22 +
  23 + @Schema(description = "父级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6080")
  24 + @ExcelProperty("父级编号")
  25 + private Long parentId;
  26 +
  27 + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
  28 + @ExcelProperty("创建时间")
  29 + private LocalDateTime createTime;
  30 +
  31 +}
0 32 \ No newline at end of file
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/demo/demo02/vo/Demo02CategorySaveReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.Data;
  5 +
  6 +import javax.validation.constraints.NotEmpty;
  7 +import javax.validation.constraints.NotNull;
  8 +
  9 +@Schema(description = "管理后台 - 示例分类新增/修改 Request VO")
  10 +@Data
  11 +public class Demo02CategorySaveReqVO {
  12 +
  13 + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10304")
  14 + private Long id;
  15 +
  16 + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
  17 + @NotEmpty(message = "名字不能为空")
  18 + private String name;
  19 +
  20 + @Schema(description = "父级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6080")
  21 + @NotNull(message = "父级编号不能为空")
  22 + private Long parentId;
  23 +
  24 +}
0 25 \ No newline at end of file
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/demo02/Demo02CategoryDO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo02;
  2 +
  3 +import lombok.*;
  4 +import java.util.*;
  5 +import java.time.LocalDateTime;
  6 +import java.time.LocalDateTime;
  7 +import com.baomidou.mybatisplus.annotation.*;
  8 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  9 +
  10 +/**
  11 + * 示例分类 DO
  12 + *
  13 + * @author 芋道源码
  14 + */
  15 +@TableName("infra_demo02_category")
  16 +@KeySequence("infra_demo02_category_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
  17 +@Data
  18 +@EqualsAndHashCode(callSuper = true)
  19 +@ToString(callSuper = true)
  20 +@Builder
  21 +@NoArgsConstructor
  22 +@AllArgsConstructor
  23 +public class Demo02CategoryDO extends BaseDO {
  24 +
  25 + public static final Long PARENT_ID_ROOT = 0L;
  26 +
  27 + /**
  28 + * 编号
  29 + */
  30 + @TableId
  31 + private Long id;
  32 + /**
  33 + * 名字
  34 + */
  35 + private String name;
  36 + /**
  37 + * 父级编号
  38 + */
  39 + private Long parentId;
  40 +
  41 +}
0 42 \ No newline at end of file
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/package-info.java deleted
1   -package cn.iocoder.yudao.module.infra.dal.dataobject.demo;
2 0 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo02/Demo02CategoryMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.dal.mysql.demo02;
  2 +
  3 +import java.util.*;
  4 +
  5 +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
  6 +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
  7 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo.Demo02CategoryListReqVO;
  8 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo02.Demo02CategoryDO;
  9 +import org.apache.ibatis.annotations.Mapper;
  10 +
  11 +/**
  12 + * 示例分类 Mapper
  13 + *
  14 + * @author 芋道源码
  15 + */
  16 +@Mapper
  17 +public interface Demo02CategoryMapper extends BaseMapperX<Demo02CategoryDO> {
  18 +
  19 + default List<Demo02CategoryDO> selectList(Demo02CategoryListReqVO reqVO) {
  20 + return selectList(new LambdaQueryWrapperX<Demo02CategoryDO>()
  21 + .likeIfPresent(Demo02CategoryDO::getName, reqVO.getName())
  22 + .eqIfPresent(Demo02CategoryDO::getParentId, reqVO.getParentId())
  23 + .betweenIfPresent(Demo02CategoryDO::getCreateTime, reqVO.getCreateTime())
  24 + .orderByDesc(Demo02CategoryDO::getId));
  25 + }
  26 +
  27 + default Demo02CategoryDO selectByParentIdAndName(Long parentId, String name) {
  28 + return selectOne(Demo02CategoryDO::getParentId, parentId, Demo02CategoryDO::getName, name);
  29 + }
  30 +
  31 + default Long selectCountByParentId(Long parentId) {
  32 + return selectCount(Demo02CategoryDO::getParentId, parentId);
  33 + }
  34 +
  35 +}
0 36 \ No newline at end of file
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo02/Demo02CategoryService.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.service.demo.demo02;
  2 +
  3 +import java.util.*;
  4 +import javax.validation.*;
  5 +
  6 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo.Demo02CategoryListReqVO;
  7 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo.Demo02CategorySaveReqVO;
  8 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo02.Demo02CategoryDO;
  9 +
  10 +/**
  11 + * 示例分类 Service 接口
  12 + *
  13 + * @author 芋道源码
  14 + */
  15 +public interface Demo02CategoryService {
  16 +
  17 + /**
  18 + * 创建示例分类
  19 + *
  20 + * @param createReqVO 创建信息
  21 + * @return 编号
  22 + */
  23 + Long createDemo02Category(@Valid Demo02CategorySaveReqVO createReqVO);
  24 +
  25 + /**
  26 + * 更新示例分类
  27 + *
  28 + * @param updateReqVO 更新信息
  29 + */
  30 + void updateDemo02Category(@Valid Demo02CategorySaveReqVO updateReqVO);
  31 +
  32 + /**
  33 + * 删除示例分类
  34 + *
  35 + * @param id 编号
  36 + */
  37 + void deleteDemo02Category(Long id);
  38 +
  39 + /**
  40 + * 获得示例分类
  41 + *
  42 + * @param id 编号
  43 + * @return 示例分类
  44 + */
  45 + Demo02CategoryDO getDemo02Category(Long id);
  46 +
  47 + /**
  48 + * 获得示例分类列表
  49 + *
  50 + * @param listReqVO 查询条件
  51 + * @return 示例分类列表
  52 + */
  53 + List<Demo02CategoryDO> getDemo02CategoryList(Demo02CategoryListReqVO listReqVO);
  54 +
  55 +}
0 56 \ No newline at end of file
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/demo02/Demo02CategoryServiceImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.service.demo.demo02;
  2 +
  3 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  4 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo.Demo02CategoryListReqVO;
  5 +import cn.iocoder.yudao.module.infra.controller.admin.demo.demo02.vo.Demo02CategorySaveReqVO;
  6 +import cn.iocoder.yudao.module.infra.dal.dataobject.demo.demo02.Demo02CategoryDO;
  7 +import cn.iocoder.yudao.module.infra.dal.mysql.demo02.Demo02CategoryMapper;
  8 +import org.springframework.stereotype.Service;
  9 +import org.springframework.validation.annotation.Validated;
  10 +
  11 +import javax.annotation.Resource;
  12 +import java.util.List;
  13 +import java.util.Objects;
  14 +
  15 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  16 +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*;
  17 +
  18 +/**
  19 + * 示例分类 Service 实现类
  20 + *
  21 + * @author 芋道源码
  22 + */
  23 +@Service
  24 +@Validated
  25 +public class Demo02CategoryServiceImpl implements Demo02CategoryService {
  26 +
  27 + @Resource
  28 + private Demo02CategoryMapper demo02CategoryMapper;
  29 +
  30 + @Override
  31 + public Long createDemo02Category(Demo02CategorySaveReqVO createReqVO) {
  32 + // 校验父级编号的有效性
  33 + validateParentDemo02Category(null, createReqVO.getParentId());
  34 + // 校验名字的唯一性
  35 + validateDemo02CategoryNameUnique(null, createReqVO.getParentId(), createReqVO.getName());
  36 +
  37 + // 插入
  38 + Demo02CategoryDO demo02Category = BeanUtils.toBean(createReqVO, Demo02CategoryDO.class);
  39 + demo02CategoryMapper.insert(demo02Category);
  40 + // 返回
  41 + return demo02Category.getId();
  42 + }
  43 +
  44 + @Override
  45 + public void updateDemo02Category(Demo02CategorySaveReqVO updateReqVO) {
  46 + // 校验存在
  47 + validateDemo02CategoryExists(updateReqVO.getId());
  48 + // 校验父级编号的有效性
  49 + validateParentDemo02Category(updateReqVO.getId(), updateReqVO.getParentId());
  50 + // 校验名字的唯一性
  51 + validateDemo02CategoryNameUnique(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName());
  52 +
  53 + // 更新
  54 + Demo02CategoryDO updateObj = BeanUtils.toBean(updateReqVO, Demo02CategoryDO.class);
  55 + demo02CategoryMapper.updateById(updateObj);
  56 + }
  57 +
  58 + @Override
  59 + public void deleteDemo02Category(Long id) {
  60 + // 校验存在
  61 + validateDemo02CategoryExists(id);
  62 + // 校验是否有子示例分类
  63 + if (demo02CategoryMapper.selectCountByParentId(id) > 0) {
  64 + throw exception(DEMO02_CATEGORY_EXITS_CHILDREN);
  65 + }
  66 + // 删除
  67 + demo02CategoryMapper.deleteById(id);
  68 + }
  69 +
  70 + private void validateDemo02CategoryExists(Long id) {
  71 + if (demo02CategoryMapper.selectById(id) == null) {
  72 + throw exception(DEMO02_CATEGORY_NOT_EXISTS);
  73 + }
  74 + }
  75 +
  76 + private void validateParentDemo02Category(Long id, Long parentId) {
  77 + if (parentId == null || Demo02CategoryDO.PARENT_ID_ROOT.equals(parentId)) {
  78 + return;
  79 + }
  80 + // 1. 不能设置自己为父示例分类
  81 + if (Objects.equals(id, parentId)) {
  82 + throw exception(DEMO02_CATEGORY_PARENT_ERROR);
  83 + }
  84 + // 2. 父示例分类不存在
  85 + Demo02CategoryDO parentDemo02Category = demo02CategoryMapper.selectById(parentId);
  86 + if (parentDemo02Category == null) {
  87 + throw exception(DEMO02_CATEGORY_PARENT_NOT_EXITS);
  88 + }
  89 + // 3. 递归校验父示例分类,如果父示例分类是自己的子示例分类,则报错,避免形成环路
  90 + if (id == null) { // id 为空,说明新增,不需要考虑环路
  91 + return;
  92 + }
  93 + for (int i = 0; i < Short.MAX_VALUE; i++) {
  94 + // 3.1 校验环路
  95 + parentId = parentDemo02Category.getParentId();
  96 + if (Objects.equals(id, parentId)) {
  97 + throw exception(DEMO02_CATEGORY_PARENT_IS_CHILD);
  98 + }
  99 + // 3.2 继续递归下一级父示例分类
  100 + if (parentId == null || Demo02CategoryDO.PARENT_ID_ROOT.equals(parentId)) {
  101 + break;
  102 + }
  103 + parentDemo02Category = demo02CategoryMapper.selectById(parentId);
  104 + if (parentDemo02Category == null) {
  105 + break;
  106 + }
  107 + }
  108 + }
  109 +
  110 + private void validateDemo02CategoryNameUnique(Long id, Long parentId, String name) {
  111 + Demo02CategoryDO demo02Category = demo02CategoryMapper.selectByParentIdAndName(parentId, name);
  112 + if (demo02Category == null) {
  113 + return;
  114 + }
  115 + // 如果 id 为空,说明不用比较是否为相同 id 的示例分类
  116 + if (id == null) {
  117 + throw exception(DEMO02_CATEGORY_NAME_DUPLICATE);
  118 + }
  119 + if (!Objects.equals(demo02Category.getId(), id)) {
  120 + throw exception(DEMO02_CATEGORY_NAME_DUPLICATE);
  121 + }
  122 + }
  123 +
  124 + @Override
  125 + public Demo02CategoryDO getDemo02Category(Long id) {
  126 + return demo02CategoryMapper.selectById(id);
  127 + }
  128 +
  129 + @Override
  130 + public List<Demo02CategoryDO> getDemo02CategoryList(Demo02CategoryListReqVO listReqVO) {
  131 + return demo02CategoryMapper.selectList(listReqVO);
  132 + }
  133 +
  134 +}
0 135 \ No newline at end of file
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/package-info.java deleted
1   -package cn.iocoder.yudao.module.infra.service.demo;
2 0 \ No newline at end of file
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/enums/errorcode.vm
... ... @@ -7,4 +7,5 @@ ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_EXITS_CHILDREN = new Er
7 7 ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_PARENT_NOT_EXITS = new ErrorCode(TODO 补充编号,"父级${table.classComment}不存在");
8 8 ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_PARENT_ERROR = new ErrorCode(TODO 补充编号, "不能设置自己为父${table.classComment}");
9 9 ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_${treeNameColumn_javaField_underlineCase.toUpperCase()}_DUPLICATE = new ErrorCode(TODO 补充编号, "已经存在该${treeNameColumn.columnComment}的${table.classComment}");
  10 +ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_PARENT_IS_CHILD = new ErrorCode(TODO 补充编号, "不能设置自己的子${table.className}为父${table.className}");
10 11 #end
11 12 \ No newline at end of file
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/service/serviceImpl.vm
... ... @@ -207,7 +207,7 @@ public class ${table.className}ServiceImpl implements ${table.className}Service
207 207 if (id == null) {
208 208 throw exception(${simpleClassName_underlineCase.toUpperCase()}_${treeNameColumn_javaField_underlineCase.toUpperCase()}_DUPLICATE);
209 209 }
210   - if (ObjectUtil.notEqual(${classNameVar}.getId(), id)) {
  210 + if (!Objects.equals(${classNameVar}.getId(), id)) {
211 211 throw exception(${simpleClassName_underlineCase.toUpperCase()}_${treeNameColumn_javaField_underlineCase.toUpperCase()}_DUPLICATE);
212 212 }
213 213 }
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/resources/mapper/demo02/Demo02CategoryMapper.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="cn.iocoder.yudao.module.infra.dal.mysql.demo02.Demo02CategoryMapper">
  4 +
  5 + <!--
  6 + 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
  7 + 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
  8 + 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
  9 + 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
  10 + -->
  11 +
  12 +</mapper>
0 13 \ No newline at end of file
... ...