From edebe3a52a32aa69f6e72e27e7f020bde1bf5543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BD=98=E8=8D=A3=E6=99=9F?= <9691125+pan-rongsheng@user.noreply.gitee.com> Date: Tue, 16 Sep 2025 18:03:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E7=89=88=E6=96=B0=E5=A2=9E=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=85=B3=E8=81=94=E7=9A=84=E7=9B=B8=E5=85=B3=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tmpltp/enums/ErrorCodeConstants.java | 11 ++ .../admin/templtp/TmplItmController.java | 65 ++++++ .../admin/templtp/TmplTpController.java | 131 ++++++++++++ .../admin/templtp/TmplTpFldController.java | 61 ++++++ .../admin/templtp/vo/TmpItmPageReqVO.java | 35 ++++ .../admin/templtp/vo/TmplFldPageReqVO.java | 38 ++++ .../admin/templtp/vo/TmplFldRespVO.java | 43 ++++ .../admin/templtp/vo/TmplItmRespVO.java | 36 ++++ .../admin/templtp/vo/TmplItmSaveReqVO.java | 26 +++ .../admin/templtp/vo/TmplTpFldSaveReqVO.java | 24 +++ .../admin/templtp/vo/TmplTpPageReqVO.java | 37 ++++ .../admin/templtp/vo/TmplTpRespVO.java | 43 ++++ .../admin/templtp/vo/TmplTpSaveReqVO.java | 38 ++++ .../admin/templtp/vo/TmplTpTreeVO.java | 14 ++ .../dal/dataobject/tmpltp/TmplFldRelDO.java | 35 ++++ .../base/dal/dataobject/tmpltp/TmplItmDO.java | 41 ++++ .../dal/dataobject/tmpltp/TmplItmRelDO.java | 35 ++++ .../base/dal/dataobject/tmpltp/TmplTpDO.java | 58 ++++++ .../dal/dataobject/tmpltp/TmplTpFldDO.java | 71 +++++++ .../dal/mysql/tmpltp/TmplFldRelMapper.java | 10 + .../base/dal/mysql/tmpltp/TmplItmMapper.java | 22 +++ .../dal/mysql/tmpltp/TmplItmRelMapper.java | 10 + .../dal/mysql/tmpltp/TmplTpFldMapper.java | 24 +++ .../base/dal/mysql/tmpltp/TmplTpMapper.java | 56 ++++++ .../base/service/tmpltp/TmplItmService.java | 18 ++ .../service/tmpltp/TmplItmServiceImpl.java | 66 +++++++ .../base/service/tmpltp/TmplTpFldService.java | 16 ++ .../service/tmpltp/TmplTpFldServiceImpl.java | 60 ++++++ .../base/service/tmpltp/TmplTpService.java | 72 +++++++ .../service/tmpltp/TmplTpServiceImpl.java | 187 ++++++++++++++++++ 30 files changed, 1383 insertions(+) create mode 100644 yudao-module-base/yudao-module-base-api/src/main/java/cn/iocoder/yudao/module/tmpltp/enums/ErrorCodeConstants.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/TmplItmController.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/TmplTpController.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/TmplTpFldController.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmpItmPageReqVO.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplFldPageReqVO.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplFldRespVO.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplItmRespVO.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplItmSaveReqVO.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplTpFldSaveReqVO.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplTpPageReqVO.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplTpRespVO.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplTpSaveReqVO.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplTpTreeVO.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/dataobject/tmpltp/TmplFldRelDO.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/dataobject/tmpltp/TmplItmDO.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/dataobject/tmpltp/TmplItmRelDO.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/dataobject/tmpltp/TmplTpDO.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/dataobject/tmpltp/TmplTpFldDO.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/mysql/tmpltp/TmplFldRelMapper.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/mysql/tmpltp/TmplItmMapper.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/mysql/tmpltp/TmplItmRelMapper.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/mysql/tmpltp/TmplTpFldMapper.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/mysql/tmpltp/TmplTpMapper.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/service/tmpltp/TmplItmService.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/service/tmpltp/TmplItmServiceImpl.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/service/tmpltp/TmplTpFldService.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/service/tmpltp/TmplTpFldServiceImpl.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/service/tmpltp/TmplTpService.java create mode 100644 yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/service/tmpltp/TmplTpServiceImpl.java diff --git a/yudao-module-base/yudao-module-base-api/src/main/java/cn/iocoder/yudao/module/tmpltp/enums/ErrorCodeConstants.java b/yudao-module-base/yudao-module-base-api/src/main/java/cn/iocoder/yudao/module/tmpltp/enums/ErrorCodeConstants.java new file mode 100644 index 0000000..c9c0246 --- /dev/null +++ b/yudao-module-base/yudao-module-base-api/src/main/java/cn/iocoder/yudao/module/tmpltp/enums/ErrorCodeConstants.java @@ -0,0 +1,11 @@ +package cn.iocoder.yudao.module.tmpltp.enums; + +import cn.iocoder.yudao.framework.common.exception.ErrorCode; + +public interface ErrorCodeConstants { + + // ========== 示例模块 1-001-000-000 ========== + ErrorCode TMPL_TP_NOT_EXISTS = new ErrorCode(1_027_000_500, "模板分类不存在"); + +} + diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/TmplItmController.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/TmplItmController.java new file mode 100644 index 0000000..8a2dc4a --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/TmplItmController.java @@ -0,0 +1,65 @@ +package cn.iocoder.yudao.module.base.controller.admin.templtp; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import cn.iocoder.yudao.framework.business.annotation.FileUploadController; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmpItmPageReqVO; +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplItmRespVO; +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplItmSaveReqVO; +import cn.iocoder.yudao.module.base.dal.dataobject.tmpltp.TmplItmDO; +import cn.iocoder.yudao.module.base.service.tmpltp.TmplItmService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@Tag(name = "管理后台 - 模板条款") +@RestController +@RequestMapping("/base/tmpl-ltm") +@Validated +@FileUploadController(source = "bse.tmplltm") +@RequiredArgsConstructor +public class TmplItmController { + private final TmplItmService tmplItmService; + @RequestMapping("/create") + @Operation(summary = "创建模板条款") + public CommonResult createTmplItm(@Valid @RequestBody TmplItmSaveReqVO createReqVO){ + TmplItmRespVO tmplItm = tmplItmService.createTmplItm(createReqVO); + return success(tmplItm); + } + @RequestMapping("/update") + @Operation(summary = "更新模板条款") + public CommonResult updateTmplItm(@Valid @RequestBody TmplItmSaveReqVO updateReqVO){ + tmplItmService.updateTmplItm(updateReqVO); + return success(true); + } + @RequestMapping("/delete") + @Operation(summary = "删除模板条款") + public CommonResult deleteTmplItm(@RequestBody String ids){ + return success( tmplItmService.deleteTmplItm(ids)); + } + @RequestMapping("/get") + @Operation(summary = "根据id获得模板条款") + public CommonResult getTmplItm(@RequestBody String id){ + return success(BeanUtils.toBean(tmplItmService.getById(id), TmplItmRespVO.class)); + } + @RequestMapping("/list") + + public CommonResult> listTmplItm(){ + return success(BeanUtils.toBean(tmplItmService.list(), TmplItmRespVO.class)); + } + @RequestMapping("/page") + @Operation(summary = "分页获得模板条款") + public CommonResult> pageTmplItm(@Validated TmpItmPageReqVO pageReqVO){ + PageResult pageResult = tmplItmService.pageTmplItm(pageReqVO); + return success(BeanUtils.toBean(pageResult,TmplItmRespVO.class)); + } +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/TmplTpController.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/TmplTpController.java new file mode 100644 index 0000000..92ef571 --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/TmplTpController.java @@ -0,0 +1,131 @@ +package cn.iocoder.yudao.module.base.controller.admin.templtp; + + +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplTpPageReqVO; +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplTpRespVO; +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplTpSaveReqVO; +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplTpTreeVO; +import cn.iocoder.yudao.module.base.dal.dataobject.tmpltp.TmplTpDO; +import cn.iocoder.yudao.module.base.service.tmpltp.TmplTpService; +import org.springframework.web.bind.annotation.*; +import jakarta.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import cn.iocoder.yudao.framework.business.interceptor.BusinessControllerMarker; +import cn.iocoder.yudao.framework.business.annotation.FileUploadController; +import cn.iocoder.yudao.framework.business.controller.AbstractFileUploadController; + +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import jakarta.validation.*; +import jakarta.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.vo.BatchDeleteReqVO; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; + + + +@Tag(name = "管理后台 - 模板分类") +@RestController +@RequestMapping("/base/tmpl-tp") +@Validated +@FileUploadController(source = "bse.tmpltp") +public class TmplTpController extends AbstractFileUploadController implements BusinessControllerMarker{ + + @Resource + private TmplTpService tmplTpService; + + @PostMapping("/create") + @Operation(summary = "创建模板分类") + @PreAuthorize("@ss.hasPermission('bse:tmpl-tp:create')") + public CommonResult createTmplTp(@Valid @RequestBody TmplTpSaveReqVO createReqVO) { + return success(tmplTpService.createTmplTp(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新模板分类") + @PreAuthorize("@ss.hasPermission('bse:tmpl-tp:update')") + public CommonResult updateTmplTp(@Valid @RequestBody TmplTpSaveReqVO updateReqVO) { + tmplTpService.updateTmplTp(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除模板分类") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('bse:tmpl-tp:delete')") + public CommonResult deleteTmplTp(@RequestParam("id") Long id) { + tmplTpService.deleteTmplTp(id); + return success(true); + } + + @DeleteMapping("/delete-list") + @Parameter(name = "ids", description = "编号", required = true) + @Operation(summary = "批量删除模板分类") + @PreAuthorize("@ss.hasPermission('bse:tmpl-tp:delete')") + public CommonResult deleteTmplTpList(@RequestBody BatchDeleteReqVO req) { + tmplTpService.deleteTmplTpListByIds(req.getIds()); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得模板分类") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('bse:tmpl-tp:query')") + public CommonResult getTmplTp(@RequestParam("id") Long id) { + TmplTpDO tmplTp = tmplTpService.getTmplTp(id); + return success(BeanUtils.toBean(tmplTp, TmplTpRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得模板分类分页") + @PreAuthorize("@ss.hasPermission('bse:tmpl-tp:query')") + public CommonResult> getTmplTpPage(@Valid TmplTpPageReqVO pageReqVO) { + PageResult pageResult = tmplTpService.getTmplTpPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, TmplTpRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出模板分类 Excel") + @PreAuthorize("@ss.hasPermission('bse:tmpl-tp:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportTmplTpExcel(@Valid TmplTpPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = tmplTpService.getTmplTpPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "模板分类.xls", "数据", TmplTpRespVO.class, + BeanUtils.toBean(list, TmplTpRespVO.class)); + } + //字段和条款回显 + @GetMapping("/get-field-and-clause") + @Operation(summary = "获得字段和条款") + @PreAuthorize("@ss.hasPermission('bse:tmpl-tp:query')") + public CommonResult> getFieldAndClause(@RequestParam("id") Long id) { + Map map = new HashMap<>(); + map.put("field", tmplTpService.getField(id)); + map.put("clause", tmplTpService.getClause(id)); + return success(map); + } + //获取分类树 + @GetMapping("/tree") + @Operation(summary = "获得分类树") + public CommonResult> getTree() { + List tree = tmplTpService.buildTree(); + return success(tree); + } + +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/TmplTpFldController.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/TmplTpFldController.java new file mode 100644 index 0000000..9672755 --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/TmplTpFldController.java @@ -0,0 +1,61 @@ +package cn.iocoder.yudao.module.base.controller.admin.templtp; + +import cn.iocoder.yudao.framework.business.annotation.FileUploadController; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplFldPageReqVO; +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplFldRespVO; +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplTpFldSaveReqVO; +import cn.iocoder.yudao.module.base.dal.dataobject.tmpltp.TmplTpFldDO; +import cn.iocoder.yudao.module.base.service.tmpltp.TmplTpFldService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - 模板字段") +@RestController +@RequestMapping("/base/tmpl-fld") +@Validated +@FileUploadController(source = "bse.tmplfld") +@RequiredArgsConstructor +public class TmplTpFldController { + private final TmplTpFldService tmplTpFldService; + @RequestMapping("/create") + @PostMapping("/create") + @Operation(summary = "创建模板字段") +// @PreAuthorize("@ss.hasPermission('bse:tmpl-tp:create')") + public CommonResult createTmplFld(@Valid @RequestBody TmplTpFldSaveReqVO tmplTpFldSaveReqVO) { + return success(tmplTpFldService.createTmplFld(tmplTpFldSaveReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新模板字段") + @PreAuthorize("@ss.hasPermission('bse:tmpl-tp:update')") + public CommonResult updateTmplTp(@Valid @RequestBody TmplTpFldSaveReqVO updateReqVO) { + tmplTpFldService.updateTmplFld(updateReqVO); + return success(true); + } + @DeleteMapping("/delete") + @Operation(summary = "删除模板字段") + @PreAuthorize("@ss.hasPermission('bse:tmpl-tp:delete')") + public CommonResult deleteTmplTp(@RequestParam("id") String id) { + tmplTpFldService.removeById(id); + return success(true); + } + @GetMapping("/page") + @Operation(summary = "获得模板字段列表") + @PreAuthorize("@ss.hasPermission('bse:tmpl-tp:list')") + public CommonResult> getTmplTpList( @Valid TmplFldPageReqVO pageReqVO) { + PageResult pageResult = tmplTpFldService.tmplTpFldPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, TmplFldRespVO.class)); + } +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmpItmPageReqVO.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmpItmPageReqVO.java new file mode 100644 index 0000000..e9702c5 --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmpItmPageReqVO.java @@ -0,0 +1,35 @@ +package cn.iocoder.yudao.module.base.controller.admin.templtp.vo; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDate; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + + +@Schema(description = "管理后台 - 模板条款分页 Request VO") +@Data +public class TmpItmPageReqVO extends PageParam { + + @Schema(description = "主键", example = "") + private String id; + + @Schema(description = "条款编号") + private String itmNum; + + @Schema(description = "条款名称", example = "") + private String itmName; + + @Schema(description = "备注") + private String rmk; + + @Schema(description = "条款值") + private String itmVal; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDate[] createTime; +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplFldPageReqVO.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplFldPageReqVO.java new file mode 100644 index 0000000..59bdf12 --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplFldPageReqVO.java @@ -0,0 +1,38 @@ +package cn.iocoder.yudao.module.base.controller.admin.templtp.vo; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDate; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + + +@Schema(description = "管理后台 - 模板字段分页 Request VO") +@Data +public class TmplFldPageReqVO extends PageParam { + + @Schema(description = "字段编码", example = "") + private String fldKy; + + @Schema(description = "字段名称") + private String fldName; + + @Schema(description = "数据类型", example = "") + private String datTp; + + @Schema(description = "字段结构") + private String fldDoc; + + @Schema(description = "备注") + private String rmk; + @Schema(description = "是否必填") + private String isMust; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDate[] createTime; + +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplFldRespVO.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplFldRespVO.java new file mode 100644 index 0000000..b9565a7 --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplFldRespVO.java @@ -0,0 +1,43 @@ +package cn.iocoder.yudao.module.base.controller.admin.templtp.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDate; + +@Schema(description = "管理后台 - 模板分类 Response VO") +@Data +@ExcelIgnoreUnannotated +public class TmplFldRespVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "") + @ExcelProperty("主键") + private Long id; + + @Schema(description = "类型字段编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "") + @ExcelProperty("类型字段编码") + private String fldKy; + + @Schema(description = "字段名称", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("字段名称") + private String fldName; + + @Schema(description = "数据类型", example = "") + @ExcelProperty("数据类型") + private String datTp; + + @Schema(description = "字段结构", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("字段结构") + private String fldDoc; + + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("备注") + private String rmk; + + @Schema(description = "是否必填, 建议值:Y(是)、N(否),需在业务层做枚举校验", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("是否必填") + private String isMust; + +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplItmRespVO.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplItmRespVO.java new file mode 100644 index 0000000..3fbb8d0 --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplItmRespVO.java @@ -0,0 +1,36 @@ +package cn.iocoder.yudao.module.base.controller.admin.templtp.vo; + + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "管理后台 - 模板分类 Response VO") +@Data +@ExcelIgnoreUnannotated +public class TmplItmRespVO { + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "") + @ExcelProperty("主键") + private String id; + + + @Schema(description = "条款编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "") + @ExcelProperty("条款编码") + private String itmNum; + + + @Schema(description = "条款名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "") + @ExcelProperty("条款名称") + private String itmName; + + + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "") + @ExcelProperty("备注") + private String rmk; + + + @Schema(description = "条款结构", requiredMode = Schema.RequiredMode.REQUIRED, example = "") + @ExcelProperty("条款结构") + private String itmVal; +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplItmSaveReqVO.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplItmSaveReqVO.java new file mode 100644 index 0000000..ad2ca2b --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplItmSaveReqVO.java @@ -0,0 +1,26 @@ +package cn.iocoder.yudao.module.base.controller.admin.templtp.vo; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "管理后台 - 模板条款新增/修改 Request VO") +@Data +public class TmplItmSaveReqVO { + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "") + private long id; + + @Schema(description = "条款编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "") + private String itmNum; + + @Schema(description = "条款名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "") + private String itmName; + + @Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "") + private String rmk; + + @Schema(description = "条款值", requiredMode = Schema.RequiredMode.REQUIRED, example = "") + private String itmVal; +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplTpFldSaveReqVO.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplTpFldSaveReqVO.java new file mode 100644 index 0000000..e6fdc1e --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplTpFldSaveReqVO.java @@ -0,0 +1,24 @@ +package cn.iocoder.yudao.module.base.controller.admin.templtp.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "管理后台 - 模板字段新增/修改 Request VO") +@Data +public class TmplTpFldSaveReqVO { + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "20895") + private Long id; + @Schema(description = "字段编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "code") + private String fldKy; + @Schema(description = "字段名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "代码") + private String fldName; + @Schema(description = "字段数据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "string") + private String datTp; + @Schema(description = "字段描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "代码") + private String fldDoc; + @Schema(description = "字段备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "代码") + private String rmk; + @Schema(description = "是否必填", requiredMode = Schema.RequiredMode.REQUIRED, example = "Y") + private String isMust; + +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplTpPageReqVO.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplTpPageReqVO.java new file mode 100644 index 0000000..3284e56 --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplTpPageReqVO.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.module.base.controller.admin.templtp.vo; + +import lombok.*; + +import java.time.LocalDate; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + + +@Schema(description = "管理后台 - 模板分类分页 Request VO") +@Data +public class TmplTpPageReqVO extends PageParam { + + @Schema(description = "类型名称", example = "王五") + private String name; + + @Schema(description = "类型编码") + private String num; + + @Schema(description = "父类型主键;顶级为NULL", example = "20414") + private Long prnId; + + @Schema(description = "同级排序序号") + private Long srt; + + @Schema(description = "状态") + private String sts; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDate[] createTime; + +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplTpRespVO.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplTpRespVO.java new file mode 100644 index 0000000..f6a23f6 --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplTpRespVO.java @@ -0,0 +1,43 @@ +package cn.iocoder.yudao.module.base.controller.admin.templtp.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +import java.time.LocalDate; +import java.util.*; +import com.alibaba.excel.annotation.*; + +@Schema(description = "管理后台 - 模板分类 Response VO") +@Data +@ExcelIgnoreUnannotated +public class TmplTpRespVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "20895") + @ExcelProperty("主键") + private Long id; + + @Schema(description = "类型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") + @ExcelProperty("类型名称") + private String name; + + @Schema(description = "类型编码", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("类型编码") + private String num; + + @Schema(description = "父类型主键;顶级为NULL", example = "20414") + @ExcelProperty("父类型主键;顶级为NULL") + private Long prnId; + + @Schema(description = "同级排序序号", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("同级排序序号") + private Long srt; + + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("状态") + private String sts; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDate createTime; + +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplTpSaveReqVO.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplTpSaveReqVO.java new file mode 100644 index 0000000..b8529ca --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplTpSaveReqVO.java @@ -0,0 +1,38 @@ +package cn.iocoder.yudao.module.base.controller.admin.templtp.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import jakarta.validation.constraints.*; + +@Schema(description = "管理后台 - 模板分类新增/修改 Request VO") +@Data +public class TmplTpSaveReqVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "20895") + private Long id; + + @Schema(description = "类型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") + @NotEmpty(message = "类型名称不能为空") + private String name; + + @Schema(description = "类型编码", requiredMode = Schema.RequiredMode.REQUIRED) + @NotEmpty(message = "类型编码不能为空") + private String num; + + @Schema(description = "父类型主键;顶级为NULL", example = "20414") + private Long prnId; + + @Schema(description = "同级排序序号", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "同级排序序号不能为空") + private Long srt; + + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED) + @NotEmpty(message = "状态不能为空") + private String sts; + @NotEmpty(message = "条款能为空") + private List tmplItmIds ; + @NotEmpty(message = "字段不能为空") + private List tmplTpFldIds; + +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplTpTreeVO.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplTpTreeVO.java new file mode 100644 index 0000000..cc45f5b --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/controller/admin/templtp/vo/TmplTpTreeVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.base.controller.admin.templtp.vo; + +import lombok.Data; + +import java.util.List; +@Data +public class TmplTpTreeVO { + private String tenantId; + private String id; + private String label; + private String value; + private String prnId; + private List children; +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/dataobject/tmpltp/TmplFldRelDO.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/dataobject/tmpltp/TmplFldRelDO.java new file mode 100644 index 0000000..92263aa --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/dataobject/tmpltp/TmplFldRelDO.java @@ -0,0 +1,35 @@ +package cn.iocoder.yudao.module.base.dal.dataobject.tmpltp; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BusinessBaseDO; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@TableName("BSE_TMPL_FLD_REL") +@KeySequence("BSE_TMPL_FLD_REL_SEQ") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TmplFldRelDO extends BusinessBaseDO { + + @TableId(type = IdType.INPUT) + private String id; + + @TableField("TMPL_TP_ID") + private String tmplTpId; + + @TableField("TP_FLD_ID") + private String tpFldId; + +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/dataobject/tmpltp/TmplItmDO.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/dataobject/tmpltp/TmplItmDO.java new file mode 100644 index 0000000..1359e56 --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/dataobject/tmpltp/TmplItmDO.java @@ -0,0 +1,41 @@ +package cn.iocoder.yudao.module.base.dal.dataobject.tmpltp; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BusinessBaseDO; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@TableName("BSE_TMPL_ITM") +@KeySequence("BSE_TMPL_ITM_SEQ") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TmplItmDO extends BusinessBaseDO { + + @TableId(type = IdType.INPUT) + private String id; + + @TableField("ITM_NUM") + private String itmNum; + + @TableField("ITM_NAME") + private String itmName; + + @TableField("RMK") + private String rmk; + + @TableField("ITM_VAL") + private String itmVal; + +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/dataobject/tmpltp/TmplItmRelDO.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/dataobject/tmpltp/TmplItmRelDO.java new file mode 100644 index 0000000..d294476 --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/dataobject/tmpltp/TmplItmRelDO.java @@ -0,0 +1,35 @@ +package cn.iocoder.yudao.module.base.dal.dataobject.tmpltp; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BusinessBaseDO; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.ToString; + +@TableName("BSE_TMPL_ITM_REL") +@KeySequence("BSE_TMPL_ITM_REL_SEQ") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TmplItmRelDO extends BusinessBaseDO { + + @TableId(type = IdType.INPUT) + private String id; + + @TableField("TMPL_TP_ID") + private String tmplTpId; + + @TableField("ITM_FLD_ID") + private String itmFldId; + +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/dataobject/tmpltp/TmplTpDO.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/dataobject/tmpltp/TmplTpDO.java new file mode 100644 index 0000000..45dc95a --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/dataobject/tmpltp/TmplTpDO.java @@ -0,0 +1,58 @@ +package cn.iocoder.yudao.module.base.dal.dataobject.tmpltp; + +import lombok.*; +import java.util.*; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BusinessBaseDO; +/** +* 模板分类 DO +* +* @author 后台管理 +*/ +@TableName("bse_tmpl_tp") +@KeySequence("bse_tmpl_tp_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +/** +* 支持业务基类继承:isBusiness=true 时继承 BusinessBaseDO,否则继承 BaseDO +*/ +public class TmplTpDO extends BusinessBaseDO { + + + + /** + * 主键 + */ + @TableId(type = IdType.ASSIGN_ID) + private Long id; + /** + * 类型名称 + */ + @TableField("NAME") + private String name; + /** + * 类型编码 + */ + @TableField("NUM") + private String num; + /** + * 父类型主键;顶级为NULL + */ + @TableField("PRN_ID") + private Long prnId; + /** + * 同级排序序号 + */ + @TableField("SRT") + private Long srt; + /** + * 状态 + */ + @TableField("STS") + private String sts; + +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/dataobject/tmpltp/TmplTpFldDO.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/dataobject/tmpltp/TmplTpFldDO.java new file mode 100644 index 0000000..176030f --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/dataobject/tmpltp/TmplTpFldDO.java @@ -0,0 +1,71 @@ +package cn.iocoder.yudao.module.base.dal.dataobject.tmpltp; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BusinessBaseDO; +import com.baomidou.mybatisplus.annotation.*; +import lombok.*; + +import java.time.LocalDateTime; + +/** + * 字段库 DO + * 对应数据库表:BIZ_TMPL_TP_FLD + * + * @author 后台管理 + */ +@TableName("BIZ_TMPL_TP_FLD") +@KeySequence("BIZ_TMPL_TP_FLD_SEQ") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TmplTpFldDO extends BusinessBaseDO { // 继承业务基类,自动获取公司/部门/租户等公共字段 + + /** + * 主键(对应表中 ID 字段,VARCHAR2(64) 类型) + * 注意:表中 ID 为字符串类型,此处使用 String 而非 Long,与 TmplTpDO 区分 + */ + @TableId(type = IdType.INPUT) // 手动输入主键(因表中 ID 是 VARCHAR2,非自增 Long) + private String id; + + /** + * 字段编码(对应表中 FLD_KY 字段,VARCHAR2(64) 类型,非空) + */ + @TableField("FLD_KY") + private String fldKy; + + /** + * 字段名称(对应表中 FLD_NAME 字段,VARCHAR2(90) 类型,非空) + */ + @TableField("FLD_NAME") + private String fldName; + + /** + * 数据类型(对应表中 DAT_TP 字段,VARCHAR2(10) 类型,非空) + * 示例值:VARCHAR、INT、DATE、CLOB 等,需与前端/后端数据类型映射 + */ + @TableField("DAT_TP") + private String datTp; + + /** + * 字段结构(对应表中 FLD_DOC 字段,CLOB(900) 类型,可空) + * 存储格式:JSON 字符串(前端传入的字段结构配置),后端可通过 JSON 工具反序列化为对象 + */ + @TableField("FLD_DOC") + private String fldDoc; + + /** + * 备注(对应表中 RMK 字段,CLOB(900) 类型,非空) + * 说明:用于区分同一公司下重复的条款名称 + */ + @TableField("RMK") + private String rmk; // 同 FLD_DOC,用 String 接收 CLOB 内容 + + /** + * 是否必填(对应表中 IS_MUST 字段,VARCHAR2(10) 类型,非空) + * 建议值:Y(是)、N(否),需在业务层做枚举校验 + */ + @TableField("IS_MUST") + private String isMust; +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/mysql/tmpltp/TmplFldRelMapper.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/mysql/tmpltp/TmplFldRelMapper.java new file mode 100644 index 0000000..24153cb --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/mysql/tmpltp/TmplFldRelMapper.java @@ -0,0 +1,10 @@ +package cn.iocoder.yudao.module.base.dal.mysql.tmpltp; + +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; + +import cn.iocoder.yudao.module.base.dal.dataobject.tmpltp.TmplFldRelDO; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface TmplFldRelMapper extends BaseMapperX { +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/mysql/tmpltp/TmplItmMapper.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/mysql/tmpltp/TmplItmMapper.java new file mode 100644 index 0000000..6d6ed2f --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/mysql/tmpltp/TmplItmMapper.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.module.base.dal.mysql.tmpltp; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; + +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmpItmPageReqVO; +import cn.iocoder.yudao.module.base.dal.dataobject.tmpltp.TmplItmDO; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface TmplItmMapper extends BaseMapperX { + default PageResult selectPage(TmpItmPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(TmplItmDO::getItmVal, reqVO.getItmVal()) + .likeIfPresent(TmplItmDO::getItmName, reqVO.getItmName()) + .eqIfPresent(TmplItmDO::getItmNum, reqVO.getItmNum()) + .eqIfPresent(TmplItmDO::getRmk, reqVO.getRmk()) + .betweenIfPresent(TmplItmDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(TmplItmDO::getId)); + } +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/mysql/tmpltp/TmplItmRelMapper.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/mysql/tmpltp/TmplItmRelMapper.java new file mode 100644 index 0000000..0ebb489 --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/mysql/tmpltp/TmplItmRelMapper.java @@ -0,0 +1,10 @@ +package cn.iocoder.yudao.module.base.dal.mysql.tmpltp; + +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; + +import cn.iocoder.yudao.module.base.dal.dataobject.tmpltp.TmplItmRelDO; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface TmplItmRelMapper extends BaseMapperX { +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/mysql/tmpltp/TmplTpFldMapper.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/mysql/tmpltp/TmplTpFldMapper.java new file mode 100644 index 0000000..87112e7 --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/mysql/tmpltp/TmplTpFldMapper.java @@ -0,0 +1,24 @@ +package cn.iocoder.yudao.module.base.dal.mysql.tmpltp; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; + +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplFldPageReqVO; +import cn.iocoder.yudao.module.base.dal.dataobject.tmpltp.TmplTpFldDO; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface TmplTpFldMapper extends BaseMapperX { + + default PageResult selectPage(TmplFldPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(TmplTpFldDO::getFldName, reqVO.getFldName()) + .eqIfPresent(TmplTpFldDO::getFldKy, reqVO.getFldKy()) + .eqIfPresent(TmplTpFldDO::getFldDoc, reqVO.getFldDoc()) + .eqIfPresent(TmplTpFldDO::getIsMust, reqVO.getIsMust()) + .eqIfPresent(TmplTpFldDO::getDatTp, reqVO.getDatTp()) + .betweenIfPresent(TmplTpFldDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(TmplTpFldDO::getId)); + } +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/mysql/tmpltp/TmplTpMapper.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/mysql/tmpltp/TmplTpMapper.java new file mode 100644 index 0000000..3035fbe --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/dal/mysql/tmpltp/TmplTpMapper.java @@ -0,0 +1,56 @@ +package cn.iocoder.yudao.module.base.dal.mysql.tmpltp; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; + + +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplTpPageReqVO; +import cn.iocoder.yudao.module.base.dal.dataobject.tmpltp.TmplTpDO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; +import java.util.Map; + + +/** + * 模板分类 Mapper + * + * @author 后台管理 + */ +@Mapper +public interface TmplTpMapper extends BaseMapperX { + + default PageResult selectPage(TmplTpPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(TmplTpDO::getName, reqVO.getName()) + .eqIfPresent(TmplTpDO::getNum, reqVO.getNum()) + .eqIfPresent(TmplTpDO::getPrnId, reqVO.getPrnId()) + .eqIfPresent(TmplTpDO::getSrt, reqVO.getSrt()) + .eqIfPresent(TmplTpDO::getSts, reqVO.getSts()) + .betweenIfPresent(TmplTpDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(TmplTpDO::getId)); + } + + @Select("select bt.*\n" + + "from bse_tmpl_tp btt\n" + + " inner join bse_tmpl_fld_rel btfr on btt.id = btfr.tmpl_tp_id\n" + + " inner join biz_tmpl_tp_fld bt on bt.id = btfr.tp_fld_id\n" + + "where btt.deleted = 0\n" + + " and btfr.deleted = 0\n" + + " and bt.deleted = 0\n" + + "and btt.id = #{id}") + List> getField(@Param("id") Long id); + + @Select("select bti.*\n" + + "from bse_tmpl_tp btt\n" + + " inner join BSE_TMPL_ITM_REL btir on btt.id = btir.itm_fld_id\n" + + " inner join BSE_TMPL_ITM bti on btir.itm_fld_id = bti.id\n" + + "where btt.deleted = 0\n" + + " and btfr.deleted = 0\n" + + " and bti.deleted = 0\n" + + "and btt.id = #{id}") + List>getClause(@Param("id") Long id); +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/service/tmpltp/TmplItmService.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/service/tmpltp/TmplItmService.java new file mode 100644 index 0000000..858001a --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/service/tmpltp/TmplItmService.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.base.service.tmpltp; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmpItmPageReqVO; +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplItmRespVO; +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplItmSaveReqVO; +import cn.iocoder.yudao.module.base.dal.dataobject.tmpltp.TmplItmDO; +import com.baomidou.mybatisplus.extension.service.IService; + +public interface TmplItmService extends IService { + + TmplItmRespVO createTmplItm(TmplItmSaveReqVO tmplItmSaveReqVO) ; + void updateTmplItm(TmplItmSaveReqVO tmplItmSaveReqVO) ; + boolean deleteTmplItm(String idStr); + + PageResult pageTmplItm(TmpItmPageReqVO pageReqVO); +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/service/tmpltp/TmplItmServiceImpl.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/service/tmpltp/TmplItmServiceImpl.java new file mode 100644 index 0000000..974ae75 --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/service/tmpltp/TmplItmServiceImpl.java @@ -0,0 +1,66 @@ +package cn.iocoder.yudao.module.base.service.tmpltp; + +import cn.hutool.core.collection.CollUtil; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmpItmPageReqVO; +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplItmRespVO; +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplItmSaveReqVO; +import cn.iocoder.yudao.module.base.dal.dataobject.tmpltp.TmplItmDO; +import cn.iocoder.yudao.module.base.dal.mysql.tmpltp.TmplItmMapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; + +import java.util.Arrays; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.tmpltp.enums.ErrorCodeConstants.TMPL_TP_NOT_EXISTS; + +@Service +@Validated +public class TmplItmServiceImpl extends ServiceImpl implements TmplItmService{ + @Override + public TmplItmRespVO createTmplItm(TmplItmSaveReqVO tmplItmSaveReqVO) { + TmplItmDO bean = BeanUtils.toBean(tmplItmSaveReqVO, TmplItmDO.class); + this.save(bean); + return BeanUtils.toBean(bean, TmplItmRespVO.class); + } + + @Override + public void updateTmplItm(TmplItmSaveReqVO tmplItmSaveReqVO) { + validateTmplLtmExists(tmplItmSaveReqVO.getId()); + TmplItmDO bean = BeanUtils.toBean(tmplItmSaveReqVO, TmplItmDO.class); + this.updateById(bean); + } + + + + + private void validateTmplLtmExists(List ids) { + List list = baseMapper.selectByIds(ids); + if (CollUtil.isEmpty(list) || list.size() != ids.size()) { + throw exception(TMPL_TP_NOT_EXISTS); + } + } + + private void validateTmplLtmExists(Long id) { + if (this.getById(id) == null) { + throw exception(TMPL_TP_NOT_EXISTS); + } + } + + @Override + @Transactional + public boolean deleteTmplItm(String idStr) { + return removeBatchByIds(Arrays.asList(idStr.split(","))); + } + + @Override + public PageResult pageTmplItm(TmpItmPageReqVO pageReqVO) { + return baseMapper.selectPage(pageReqVO); + } +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/service/tmpltp/TmplTpFldService.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/service/tmpltp/TmplTpFldService.java new file mode 100644 index 0000000..5e612fa --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/service/tmpltp/TmplTpFldService.java @@ -0,0 +1,16 @@ +package cn.iocoder.yudao.module.base.service.tmpltp; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplFldPageReqVO; +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplFldRespVO; +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplTpFldSaveReqVO; +import cn.iocoder.yudao.module.base.dal.dataobject.tmpltp.TmplTpFldDO; +import com.baomidou.mybatisplus.extension.service.IService; +import jakarta.validation.Valid; + +public interface TmplTpFldService extends IService { + TmplFldRespVO createTmplFld(@Valid TmplTpFldSaveReqVO tmplTpFldSaveReqVO); + void updateTmplFld(@Valid TmplTpFldSaveReqVO tmplTpFldSaveReqVO); + PageResult tmplTpFldPage(@Valid TmplFldPageReqVO pageReqVO); +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/service/tmpltp/TmplTpFldServiceImpl.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/service/tmpltp/TmplTpFldServiceImpl.java new file mode 100644 index 0000000..2940868 --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/service/tmpltp/TmplTpFldServiceImpl.java @@ -0,0 +1,60 @@ +package cn.iocoder.yudao.module.base.service.tmpltp; + +import cn.hutool.core.collection.CollUtil; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplFldPageReqVO; +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplFldRespVO; +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplTpFldSaveReqVO; +import cn.iocoder.yudao.module.base.dal.dataobject.tmpltp.TmplTpFldDO; +import cn.iocoder.yudao.module.base.dal.mysql.tmpltp.TmplTpFldMapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import java.util.List; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.tmpltp.enums.ErrorCodeConstants.TMPL_TP_NOT_EXISTS; + + +@Service +@Validated +public class TmplTpFldServiceImpl extends ServiceImpl implements TmplTpFldService { + @Override + public TmplFldRespVO createTmplFld(TmplTpFldSaveReqVO tmplTpFldSaveReqVO) { + TmplTpFldDO tmplTpFldDO = BeanUtils.toBean(tmplTpFldSaveReqVO, TmplTpFldDO.class); + baseMapper.insert(tmplTpFldDO); + return BeanUtils.toBean(tmplTpFldDO, TmplFldRespVO.class); + } + + @Override + public void updateTmplFld(TmplTpFldSaveReqVO tmplTpFldSaveReqVO) { + // 校验存在 + validateTmplFldExists(tmplTpFldSaveReqVO.getId()); + // 更新 + TmplTpFldDO updateObj = BeanUtils.toBean(tmplTpFldSaveReqVO, TmplTpFldDO.class); + baseMapper.updateById(updateObj); + } + + + + private void validateTmplFldExists(List ids) { + List list = baseMapper.selectByIds(ids); + if (CollUtil.isEmpty(list) || list.size() != ids.size()) { + throw exception(TMPL_TP_NOT_EXISTS); + } + } + + private void validateTmplFldExists(Long id) { + if (this.getById(id) == null) { + throw exception(TMPL_TP_NOT_EXISTS); + } + } + + @Override + public PageResult tmplTpFldPage(TmplFldPageReqVO pageReqVO) { + return baseMapper.selectPage(pageReqVO); + } +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/service/tmpltp/TmplTpService.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/service/tmpltp/TmplTpService.java new file mode 100644 index 0000000..0a44a5d --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/service/tmpltp/TmplTpService.java @@ -0,0 +1,72 @@ +package cn.iocoder.yudao.module.base.service.tmpltp; + +import java.util.*; + + +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplTpPageReqVO; +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplTpRespVO; +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplTpSaveReqVO; +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplTpTreeVO; +import cn.iocoder.yudao.module.base.dal.dataobject.tmpltp.TmplTpDO; +import com.baomidou.mybatisplus.extension.service.IService; +import jakarta.validation.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +/** + * 模板分类 Service 接口 + * + * @author 后台管理 + */ +public interface TmplTpService extends IService { + + /** + * 创建模板分类 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + TmplTpRespVO createTmplTp(@Valid TmplTpSaveReqVO createReqVO); + + /** + * 更新模板分类 + * + * @param updateReqVO 更新信息 + */ + void updateTmplTp(@Valid TmplTpSaveReqVO updateReqVO); + + /** + * 删除模板分类 + * + * @param id 编号 + */ + void deleteTmplTp(Long id); + + /** + * 批量删除模板分类 + * + * @param ids 编号 + */ + void deleteTmplTpListByIds(List ids); + + /** + * 获得模板分类 + * + * @param id 编号 + * @return 模板分类 + */ + TmplTpDO getTmplTp(Long id); + + /** + * 获得模板分类分页 + * + * @param pageReqVO 分页查询 + * @return 模板分类分页 + */ + PageResult getTmplTpPage(TmplTpPageReqVO pageReqVO); + + + List> getField(Long id); + List> getClause(Long id); + List buildTree(); +} diff --git a/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/service/tmpltp/TmplTpServiceImpl.java b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/service/tmpltp/TmplTpServiceImpl.java new file mode 100644 index 0000000..f5e81d5 --- /dev/null +++ b/yudao-module-base/yudao-module-base-server/src/main/java/cn/iocoder/yudao/module/base/service/tmpltp/TmplTpServiceImpl.java @@ -0,0 +1,187 @@ +package cn.iocoder.yudao.module.base.service.tmpltp; + +import cn.hutool.core.collection.CollUtil; + +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplTpPageReqVO; +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplTpRespVO; +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplTpSaveReqVO; + +import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TmplTpTreeVO; +import cn.iocoder.yudao.module.base.dal.dataobject.tmpltp.TmplFldRelDO; +import cn.iocoder.yudao.module.base.dal.dataobject.tmpltp.TmplItmRelDO; +import cn.iocoder.yudao.module.base.dal.dataobject.tmpltp.TmplTpDO; +import cn.iocoder.yudao.module.base.dal.mysql.tmpltp.TmplFldRelMapper; +import cn.iocoder.yudao.module.base.dal.mysql.tmpltp.TmplItmRelMapper; +import cn.iocoder.yudao.module.base.dal.mysql.tmpltp.TmplTpMapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import jakarta.annotation.Resource; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; + +import java.util.*; +import java.util.stream.Collectors; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.tmpltp.enums.ErrorCodeConstants.TMPL_TP_NOT_EXISTS; + +/** + * 模板分类 Service 实现类 + * + * @author 后台管理 + */ +@Service +@Validated +@RequiredArgsConstructor +public class TmplTpServiceImpl extends ServiceImpl implements TmplTpService { + private final TmplFldRelMapper tmplFldRelMapper; + private final TmplItmRelMapper tmplItmRelMapper; + + + @Override + @Transactional + public TmplTpRespVO createTmplTp(TmplTpSaveReqVO createReqVO) { + // 插入 + TmplTpDO tmplTp = BeanUtils.toBean(createReqVO, TmplTpDO.class); + baseMapper.insert(tmplTp); + // 返回 + List tmplFldRelDOS= new ArrayList<>(); + List tmplItmRelDOS= new ArrayList<>(); + createReqVO.getTmplTpFldIds().forEach(tmplItmId -> { + TmplFldRelDO tmplFldRelDO = new TmplFldRelDO(); + tmplFldRelDO.setTmplTpId(String.valueOf(tmplTp.getId())); + tmplFldRelDO.setTpFldId(String.valueOf(tmplItmId)); + tmplFldRelDOS.add(tmplFldRelDO); + }); + createReqVO.getTmplTpFldIds().forEach(tmplFldId -> { + TmplItmRelDO tmplItmRelDO = new TmplItmRelDO(); + tmplItmRelDO.setTmplTpId(String.valueOf(tmplTp.getId())); + tmplItmRelDO.setItmFldId(String.valueOf(tmplFldId)); + tmplItmRelDOS.add(tmplItmRelDO); + }); + tmplFldRelMapper.insertBatch(tmplFldRelDOS); + tmplItmRelMapper.insertBatch(tmplItmRelDOS); + return BeanUtils.toBean(tmplTp, TmplTpRespVO.class); + } + + @Override + public void updateTmplTp(TmplTpSaveReqVO updateReqVO) { + // 校验存在 + validateTmplTpExists(updateReqVO.getId()); + // 更新 + TmplTpDO updateObj = BeanUtils.toBean(updateReqVO, TmplTpDO.class); + baseMapper.updateById(updateObj); + } + + @Override + public void deleteTmplTp(Long id) { + // 校验存在 + validateTmplTpExists(id); + // 删除 + baseMapper.deleteById(id); + } + + @Override + public void deleteTmplTpListByIds(List ids) { + // 校验存在 + validateTmplTpExists(ids); + // 删除 + baseMapper.deleteByIds(ids); + } + + private void validateTmplTpExists(List ids) { + List list = baseMapper.selectByIds(ids); + if (CollUtil.isEmpty(list) || list.size() != ids.size()) { + throw exception(TMPL_TP_NOT_EXISTS); + } + } + + private void validateTmplTpExists(Long id) { + if (this.getById(id) == null) { + throw exception(TMPL_TP_NOT_EXISTS); + } + } + + @Override + public TmplTpDO getTmplTp(Long id) { + return baseMapper.selectById(id); + } + + @Override + public PageResult getTmplTpPage(TmplTpPageReqVO pageReqVO) { + return baseMapper.selectPage(pageReqVO); + } + + @Override + public List> getField(Long id) { + return baseMapper.getField(id); + } + @Override + public List> getClause(Long id) { + return baseMapper.getClause(id); + } + + @Override + public List buildTree() { + // 1. 查询所有数据 + List allNodes = baseMapper.selectList(new QueryWrapper<>()); + + // 2. 转换为树节点VO + List treeNodes = allNodes.stream().map(this::convertToTreeVO).collect(Collectors.toList()); + + // 3. 构建树形结构 + return buildTreeStructure(treeNodes); + } + /** + * 转换实体类到树节点VO + */ + private TmplTpTreeVO convertToTreeVO(TmplTpDO entity) { + TmplTpTreeVO treeVO = new TmplTpTreeVO(); + treeVO.setId(entity.getId().toString()); + treeVO.setPrnId(entity.getPrnId().toString()); + treeVO.setLabel(entity.getName()); // 假设name字段作为显示标签 + treeVO.setValue(entity.getId().toString()); // 假设id作为值 + treeVO.setTenantId(entity.getTenantId().toString()); + return treeVO; + } + + /** + * 构建树形结构 + */ + private List buildTreeStructure(List treeNodes) { + // 1. 分组:将所有节点按父ID分组 + Map> groupByPrnId = treeNodes.stream() + .collect(Collectors.groupingBy(node -> { + // 查找对应的实体来获取prn_id + TmplTpDO entity = findEntityById(treeNodes, node.getId()); + return entity != null && entity.getPrnId() != null ? + entity.getPrnId().toString() : "0"; // 根节点的父ID为0或null + })); + + // 2. 递归设置子节点 + treeNodes.forEach(node -> { + List children = groupByPrnId.get(node.getId()); + if (children != null && !children.isEmpty()) { + node.setChildren(children); + } + }); + + // 3. 返回根节点(父ID为0或null的节点) + return groupByPrnId.getOrDefault("0", new ArrayList<>()); + } + + /** + * 根据ID查找对应的实体(实际项目中可优化) + */ + private TmplTpDO findEntityById(List treeNodes, String id) { + return baseMapper.selectById(Long.valueOf(id)); + } + + +}