Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -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, "模板分类不存在");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -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<TmplItmRespVO> createTmplItm(@Valid @RequestBody TmplItmSaveReqVO createReqVO){
|
||||||
|
TmplItmRespVO tmplItm = tmplItmService.createTmplItm(createReqVO);
|
||||||
|
return success(tmplItm);
|
||||||
|
}
|
||||||
|
@RequestMapping("/update")
|
||||||
|
@Operation(summary = "更新模板条款")
|
||||||
|
public CommonResult<Boolean> updateTmplItm(@Valid @RequestBody TmplItmSaveReqVO updateReqVO){
|
||||||
|
tmplItmService.updateTmplItm(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
@RequestMapping("/delete")
|
||||||
|
@Operation(summary = "删除模板条款")
|
||||||
|
public CommonResult<Boolean> deleteTmplItm(@RequestBody String ids){
|
||||||
|
return success( tmplItmService.deleteTmplItm(ids));
|
||||||
|
}
|
||||||
|
@RequestMapping("/get")
|
||||||
|
@Operation(summary = "根据id获得模板条款")
|
||||||
|
public CommonResult<TmplItmRespVO> getTmplItm(@RequestBody String id){
|
||||||
|
return success(BeanUtils.toBean(tmplItmService.getById(id), TmplItmRespVO.class));
|
||||||
|
}
|
||||||
|
@RequestMapping("/list")
|
||||||
|
|
||||||
|
public CommonResult<List<TmplItmRespVO>> listTmplItm(){
|
||||||
|
return success(BeanUtils.toBean(tmplItmService.list(), TmplItmRespVO.class));
|
||||||
|
}
|
||||||
|
@RequestMapping("/page")
|
||||||
|
@Operation(summary = "分页获得模板条款")
|
||||||
|
public CommonResult<PageResult<TmplItmRespVO>> pageTmplItm(@Validated TmpItmPageReqVO pageReqVO){
|
||||||
|
PageResult<TmplItmDO> pageResult = tmplItmService.pageTmplItm(pageReqVO);
|
||||||
|
return success(BeanUtils.toBean(pageResult,TmplItmRespVO.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<TmplTpRespVO> createTmplTp(@Valid @RequestBody TmplTpSaveReqVO createReqVO) {
|
||||||
|
return success(tmplTpService.createTmplTp(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新模板分类")
|
||||||
|
@PreAuthorize("@ss.hasPermission('bse:tmpl-tp:update')")
|
||||||
|
public CommonResult<Boolean> 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<Boolean> 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<Boolean> 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<TmplTpRespVO> 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<PageResult<TmplTpRespVO>> getTmplTpPage(@Valid TmplTpPageReqVO pageReqVO) {
|
||||||
|
PageResult<TmplTpDO> 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<TmplTpDO> 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<Map<String, Object>> getFieldAndClause(@RequestParam("id") Long id) {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("field", tmplTpService.getField(id));
|
||||||
|
map.put("clause", tmplTpService.getClause(id));
|
||||||
|
return success(map);
|
||||||
|
}
|
||||||
|
//获取分类树
|
||||||
|
@GetMapping("/tree")
|
||||||
|
@Operation(summary = "获得分类树")
|
||||||
|
public CommonResult<List<TmplTpTreeVO>> getTree() {
|
||||||
|
List<TmplTpTreeVO> tree = tmplTpService.buildTree();
|
||||||
|
return success(tree);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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<TmplFldRespVO> createTmplFld(@Valid @RequestBody TmplTpFldSaveReqVO tmplTpFldSaveReqVO) {
|
||||||
|
return success(tmplTpFldService.createTmplFld(tmplTpFldSaveReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新模板字段")
|
||||||
|
@PreAuthorize("@ss.hasPermission('bse:tmpl-tp:update')")
|
||||||
|
public CommonResult<Boolean> updateTmplTp(@Valid @RequestBody TmplTpFldSaveReqVO updateReqVO) {
|
||||||
|
tmplTpFldService.updateTmplFld(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除模板字段")
|
||||||
|
@PreAuthorize("@ss.hasPermission('bse:tmpl-tp:delete')")
|
||||||
|
public CommonResult<Boolean> deleteTmplTp(@RequestParam("id") String id) {
|
||||||
|
tmplTpFldService.removeById(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得模板字段列表")
|
||||||
|
@PreAuthorize("@ss.hasPermission('bse:tmpl-tp:list')")
|
||||||
|
public CommonResult<PageResult<TmplFldRespVO>> getTmplTpList( @Valid TmplFldPageReqVO pageReqVO) {
|
||||||
|
PageResult<TmplTpFldDO> pageResult = tmplTpFldService.tmplTpFldPage(pageReqVO);
|
||||||
|
return success(BeanUtils.toBean(pageResult, TmplFldRespVO.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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<String> tmplItmIds ;
|
||||||
|
@NotEmpty(message = "字段不能为空")
|
||||||
|
private List<TmplTpFldSaveReqVO> tmplTpFldIds;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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<TmplTpTreeVO> children;
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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<TmplFldRelDO> {
|
||||||
|
}
|
||||||
@@ -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<TmplItmDO> {
|
||||||
|
default PageResult<TmplItmDO> selectPage(TmpItmPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<TmplItmDO>()
|
||||||
|
.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));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<TmplItmRelDO> {
|
||||||
|
}
|
||||||
@@ -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<TmplTpFldDO> {
|
||||||
|
|
||||||
|
default PageResult<TmplTpFldDO> selectPage(TmplFldPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<TmplTpFldDO>()
|
||||||
|
.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));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<TmplTpDO> {
|
||||||
|
|
||||||
|
default PageResult<TmplTpDO> selectPage(TmplTpPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<TmplTpDO>()
|
||||||
|
.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<Map<String, Object>> 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<Map<String, Object>>getClause(@Param("id") Long id);
|
||||||
|
}
|
||||||
@@ -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<TmplItmDO> {
|
||||||
|
|
||||||
|
TmplItmRespVO createTmplItm(TmplItmSaveReqVO tmplItmSaveReqVO) ;
|
||||||
|
void updateTmplItm(TmplItmSaveReqVO tmplItmSaveReqVO) ;
|
||||||
|
boolean deleteTmplItm(String idStr);
|
||||||
|
|
||||||
|
PageResult<TmplItmDO> pageTmplItm(TmpItmPageReqVO pageReqVO);
|
||||||
|
}
|
||||||
@@ -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<TmplItmMapper, TmplItmDO> 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<Long> ids) {
|
||||||
|
List<TmplItmDO> 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<TmplItmDO> pageTmplItm(TmpItmPageReqVO pageReqVO) {
|
||||||
|
return baseMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<TmplTpFldDO> {
|
||||||
|
TmplFldRespVO createTmplFld(@Valid TmplTpFldSaveReqVO tmplTpFldSaveReqVO);
|
||||||
|
void updateTmplFld(@Valid TmplTpFldSaveReqVO tmplTpFldSaveReqVO);
|
||||||
|
PageResult<TmplTpFldDO> tmplTpFldPage(@Valid TmplFldPageReqVO pageReqVO);
|
||||||
|
}
|
||||||
@@ -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<TmplTpFldMapper, TmplTpFldDO> 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<Long> ids) {
|
||||||
|
List<TmplTpFldDO> 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<TmplTpFldDO> tmplTpFldPage(TmplFldPageReqVO pageReqVO) {
|
||||||
|
return baseMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<TmplTpDO> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建模板分类
|
||||||
|
*
|
||||||
|
* @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<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得模板分类
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 模板分类
|
||||||
|
*/
|
||||||
|
TmplTpDO getTmplTp(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得模板分类分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 模板分类分页
|
||||||
|
*/
|
||||||
|
PageResult<TmplTpDO> getTmplTpPage(TmplTpPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
|
||||||
|
List<Map<String, Object>> getField(Long id);
|
||||||
|
List<Map<String, Object>> getClause(Long id);
|
||||||
|
List<TmplTpTreeVO> buildTree();
|
||||||
|
}
|
||||||
@@ -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<TmplTpMapper, TmplTpDO> 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<TmplFldRelDO> tmplFldRelDOS= new ArrayList<>();
|
||||||
|
List<TmplItmRelDO> 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<Long> ids) {
|
||||||
|
// 校验存在
|
||||||
|
validateTmplTpExists(ids);
|
||||||
|
// 删除
|
||||||
|
baseMapper.deleteByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateTmplTpExists(List<Long> ids) {
|
||||||
|
List<TmplTpDO> 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<TmplTpDO> getTmplTpPage(TmplTpPageReqVO pageReqVO) {
|
||||||
|
return baseMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> getField(Long id) {
|
||||||
|
return baseMapper.getField(id);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public List<Map<String, Object>> getClause(Long id) {
|
||||||
|
return baseMapper.getClause(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TmplTpTreeVO> buildTree() {
|
||||||
|
// 1. 查询所有数据
|
||||||
|
List<TmplTpDO> allNodes = baseMapper.selectList(new QueryWrapper<>());
|
||||||
|
|
||||||
|
// 2. 转换为树节点VO
|
||||||
|
List<TmplTpTreeVO> 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<TmplTpTreeVO> buildTreeStructure(List<TmplTpTreeVO> treeNodes) {
|
||||||
|
// 1. 分组:将所有节点按父ID分组
|
||||||
|
Map<String, List<TmplTpTreeVO>> 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<TmplTpTreeVO> 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<TmplTpTreeVO> treeNodes, String id) {
|
||||||
|
return baseMapper.selectById(Long.valueOf(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user