Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -6,6 +6,13 @@ public interface ErrorCodeConstants {
|
||||
|
||||
// ========== 示例模块 1-001-000-000 ==========
|
||||
ErrorCode TMPL_TP_NOT_EXISTS = new ErrorCode(1_027_000_500, "模板分类不存在");
|
||||
ErrorCode TMPL_FLD_NOT_EXISTS = new ErrorCode(1_027_000_501, "模板字段不存在");
|
||||
ErrorCode TMPL_FLD_CODE_EXISTS = new ErrorCode(1_027_000_502, "字段编码已存在");
|
||||
ErrorCode TMPL_ITM_NOT_EXISTS = new ErrorCode(1_027_000_503, "模板条款不存在");
|
||||
ErrorCode TEMPLATE_INSTANCE_NOT_EXISTS = new ErrorCode(1_027_000_504, "模板实例不存在");
|
||||
ErrorCode TMPL_TP_SATUS_ERROR = new ErrorCode(1_027_000_506, "状态变更失败");
|
||||
ErrorCode TMPL_TP_DEl_ERROR = new ErrorCode(1_027_000_507, "模版分类删除失败");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package cn.iocoder.yudao.module.tmpltp.enums;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 状态枚举类,定义所有可能的状态及合法的状态转换
|
||||
*/
|
||||
public enum StatusEnum {
|
||||
// 定义所有状态及对应的合法转换目标状态
|
||||
STATUS_1("1", new HashSet<String>() {{
|
||||
add("2");
|
||||
add("4");
|
||||
}}),
|
||||
STATUS_2("2", new HashSet<String>() {{
|
||||
add("3");
|
||||
}}),
|
||||
STATUS_3("3", new HashSet<String>() {{
|
||||
add("4");
|
||||
add("2");
|
||||
}}),
|
||||
STATUS_4("4", new HashSet<>()); // 没有合法的转换目标
|
||||
|
||||
private final String code;
|
||||
private final Set<String> allowedTransitions;
|
||||
|
||||
StatusEnum(String code, Set<String> allowedTransitions) {
|
||||
this.code = code;
|
||||
this.allowedTransitions = allowedTransitions;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据状态码获取对应的枚举实例
|
||||
*/
|
||||
public static StatusEnum fromCode(String code) {
|
||||
for (StatusEnum status : values()) {
|
||||
if (status.code.equals(code)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验状态转换是否合法
|
||||
*/
|
||||
public boolean isTransitionAllowed(String targetStatus) {
|
||||
return allowedTransitions.contains(targetStatus);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package cn.iocoder.yudao.module.base.controller.admin.templtp;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TemplateInstancePageReqVO;
|
||||
import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TemplateInstanceRespVO;
|
||||
import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TemplateInstanceSaveReqVO;
|
||||
import cn.iocoder.yudao.module.base.dal.dataobject.tmpltp.TemplateInstanceDO;
|
||||
import cn.iocoder.yudao.module.base.service.tmpltp.TemplateInstanceService;
|
||||
import cn.iocoder.yudao.module.infra.api.file.FileApi;
|
||||
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.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.constraints.*;
|
||||
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 org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
|
||||
|
||||
@Tag(name = "管理后台 - 模板实例")
|
||||
@RestController
|
||||
@RequestMapping("/base/template-instance")
|
||||
@Validated
|
||||
@FileUploadController(source = "bse.templateinstance")
|
||||
public class TemplateInstanceController extends AbstractFileUploadController {
|
||||
|
||||
static {
|
||||
FileUploadController annotation = TemplateInstanceController.class.getAnnotation(FileUploadController.class);
|
||||
if (annotation != null) {
|
||||
setFileUploadInfo(annotation);
|
||||
}
|
||||
}
|
||||
|
||||
@Resource
|
||||
private TemplateInstanceService templateInstanceService;
|
||||
|
||||
@Resource
|
||||
private FileApi fileApi;
|
||||
|
||||
@PostMapping("/upload-file")
|
||||
@Operation(summary = "上传模板实例文件")
|
||||
public CommonResult<Map<String, String> >upload(MultipartFile file) {
|
||||
Map<String, String> fileMap = new HashMap<>();
|
||||
try {
|
||||
String fileWhitReturn = fileApi.createFile(file.getBytes(), file.getOriginalFilename());
|
||||
fileMap.put("fileUrl", fileWhitReturn);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return success(fileMap);
|
||||
}
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建模板实例")
|
||||
@PreAuthorize("@ss.hasPermission('bse:template-instance:create')")
|
||||
public CommonResult<TemplateInstanceRespVO> createTemplateInstance(@Valid @RequestBody TemplateInstanceSaveReqVO createReqVO) {
|
||||
return success(templateInstanceService.createTemplateInstance(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新模板实例")
|
||||
@PreAuthorize("@ss.hasPermission('bse:template-instance:update')")
|
||||
public CommonResult<Boolean> updateTemplateInstance(@Valid @RequestBody TemplateInstanceSaveReqVO updateReqVO) {
|
||||
templateInstanceService.updateTemplateInstance(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除模板实例")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('bse:template-instance:delete')")
|
||||
public CommonResult<Boolean> deleteTemplateInstance(@RequestParam("id") Long id) {
|
||||
templateInstanceService.deleteTemplateInstance(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除模板实例")
|
||||
@PreAuthorize("@ss.hasPermission('bse:template-instance:delete')")
|
||||
public CommonResult<Boolean> deleteTemplateInstanceList(@RequestBody BatchDeleteReqVO req) {
|
||||
templateInstanceService.deleteTemplateInstanceListByIds(req.getIds());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得模板实例")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('bse:template-instance:query')")
|
||||
public CommonResult<TemplateInstanceRespVO> getTemplateInstance(@RequestParam("id") Long id) {
|
||||
TemplateInstanceDO templateInstance = templateInstanceService.getTemplateInstance(id);
|
||||
return success(BeanUtils.toBean(templateInstance, TemplateInstanceRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得模板实例分页")
|
||||
@PreAuthorize("@ss.hasPermission('bse:template-instance:query')")
|
||||
public CommonResult<PageResult<TemplateInstanceRespVO>> getTemplateInstancePage(@Valid TemplateInstancePageReqVO pageReqVO) {
|
||||
PageResult<TemplateInstanceDO> pageResult = templateInstanceService.getTemplateInstancePage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, TemplateInstanceRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出模板实例 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('bse:template-instance:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportTemplateInstanceExcel(@Valid TemplateInstancePageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<TemplateInstanceDO> list = templateInstanceService.getTemplateInstancePage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "模板实例.xls", "数据", TemplateInstanceRespVO.class,
|
||||
BeanUtils.toBean(list, TemplateInstanceRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ 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.pojo.vo.BatchDeleteReqVO;
|
||||
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;
|
||||
@@ -15,9 +16,7 @@ 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 org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -29,34 +28,33 @@ import java.util.List;
|
||||
@RequiredArgsConstructor
|
||||
public class TmplItmController {
|
||||
private final TmplItmService tmplItmService;
|
||||
@RequestMapping("/create")
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建模板条款")
|
||||
public CommonResult<TmplItmRespVO> createTmplItm(@Valid @RequestBody TmplItmSaveReqVO createReqVO){
|
||||
TmplItmRespVO tmplItm = tmplItmService.createTmplItm(createReqVO);
|
||||
return success(tmplItm);
|
||||
}
|
||||
@RequestMapping("/update")
|
||||
@PutMapping("/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));
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除模板条款", description = "")
|
||||
public CommonResult<Boolean> deleteTmplItm(@RequestBody BatchDeleteReqVO req){
|
||||
return success( tmplItmService.deleteTmplItm(req.getIds()));
|
||||
}
|
||||
@RequestMapping("/get")
|
||||
@GetMapping("/id")
|
||||
@Operation(summary = "根据id获得模板条款")
|
||||
public CommonResult<TmplItmRespVO> getTmplItm(@RequestBody String id){
|
||||
return success(BeanUtils.toBean(tmplItmService.getById(id), TmplItmRespVO.class));
|
||||
}
|
||||
@RequestMapping("/list")
|
||||
|
||||
@GetMapping("/list")
|
||||
public CommonResult<List<TmplItmRespVO>> listTmplItm(){
|
||||
return success(BeanUtils.toBean(tmplItmService.list(), TmplItmRespVO.class));
|
||||
}
|
||||
@RequestMapping("/page")
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "分页获得模板条款")
|
||||
public CommonResult<PageResult<TmplItmRespVO>> pageTmplItm(@Validated TmpItmPageReqVO pageReqVO){
|
||||
PageResult<TmplItmDO> pageResult = tmplItmService.pageTmplItm(pageReqVO);
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
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.controller.admin.templtp.vo.*;
|
||||
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.*;
|
||||
@@ -67,8 +64,8 @@ public class TmplTpController extends AbstractFileUploadController implements Bu
|
||||
@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);
|
||||
public CommonResult<Boolean> deleteTmplTp(@RequestBody BatchDeleteReqVO req) {
|
||||
tmplTpService.deleteTmplTp(req.getIds());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@@ -111,8 +108,8 @@ public class TmplTpController extends AbstractFileUploadController implements Bu
|
||||
BeanUtils.toBean(list, TmplTpRespVO.class));
|
||||
}
|
||||
//字段和条款回显
|
||||
@GetMapping("/get-field-and-clause")
|
||||
@Operation(summary = "获得字段和条款")
|
||||
@GetMapping("/field-and-clause")
|
||||
@Operation(summary = "获得字段和条款",description = "字段和条款回显,传入模版分类的id")
|
||||
@PreAuthorize("@ss.hasPermission('bse:tmpl-tp:query')")
|
||||
public CommonResult<Map<String, Object>> getFieldAndClause(@RequestParam("id") Long id) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
@@ -122,10 +119,19 @@ public class TmplTpController extends AbstractFileUploadController implements Bu
|
||||
}
|
||||
//获取分类树
|
||||
@GetMapping("/tree")
|
||||
@Operation(summary = "获得分类树")
|
||||
@Operation(summary = "获得分类树--上级")
|
||||
public CommonResult<List<TmplTpTreeVO>> getTree() {
|
||||
List<TmplTpTreeVO> tree = tmplTpService.buildTree();
|
||||
return success(tree);
|
||||
}
|
||||
|
||||
//更新类型状态
|
||||
@PutMapping("/updateStatus")
|
||||
@Operation(summary = "更新模板字段状态")
|
||||
@PreAuthorize("@ss.hasPermission('bse:tmpl-tp:update')")
|
||||
public CommonResult<Boolean> updateStatus(@RequestBody TmplTpSaveReqVO updateReqVO) {
|
||||
tmplTpService.updateStatus(updateReqVO.getId(), updateReqVO.getSts());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ 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.pojo.vo.BatchDeleteReqVO;
|
||||
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;
|
||||
@@ -18,6 +19,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@@ -29,31 +31,30 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
@RequiredArgsConstructor
|
||||
public class TmplTpFldController {
|
||||
private final TmplTpFldService tmplTpFldService;
|
||||
@RequestMapping("/create")
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建模板字段")
|
||||
// @PreAuthorize("@ss.hasPermission('bse:tmpl-tp:create')")
|
||||
// @PreAuthorize("@ss.hasPermission('bse:tmpl-tp-fld: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')")
|
||||
@PreAuthorize("@ss.hasPermission('bse:tmpl-tp-fld: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);
|
||||
@PreAuthorize("@ss.hasPermission('bse:tmpl-tp-fld:delete')")
|
||||
public CommonResult<Boolean> deleteTmplTp(@RequestBody BatchDeleteReqVO req) {
|
||||
tmplTpFldService.deleteTmplTpByIds(req.getIds());
|
||||
return success(true);
|
||||
}
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得模板字段列表")
|
||||
@PreAuthorize("@ss.hasPermission('bse:tmpl-tp:list')")
|
||||
@PreAuthorize("@ss.hasPermission('bse:tmpl-tp-fld: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,47 @@
|
||||
package cn.iocoder.yudao.module.base.controller.admin.templtp.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 模板实例分页 Request VO")
|
||||
@Data
|
||||
public class TemplateInstancePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "分类树主键", example = "7804")
|
||||
private Long typeId;
|
||||
|
||||
@Schema(description = "模板名称", example = "王五")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "模板编码")
|
||||
private String coding;
|
||||
|
||||
@Schema(description = "模板描述")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "实例文件内容")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "原始文件内容")
|
||||
private String originalContent;
|
||||
|
||||
@Schema(description = "文件类型", example = "1")
|
||||
private String fileType;
|
||||
|
||||
@Schema(description = "版本号;如v1.0")
|
||||
private String version;
|
||||
|
||||
@Schema(description = "状态", example = "2")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package cn.iocoder.yudao.module.base.controller.admin.templtp.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 模板实例 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class TemplateInstanceRespVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "29024")
|
||||
@ExcelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "分类树主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "7804")
|
||||
@ExcelProperty("分类树主键")
|
||||
private Long typeId;
|
||||
|
||||
@Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
||||
@ExcelProperty("模板名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "模板编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("模板编码")
|
||||
private String coding;
|
||||
|
||||
@Schema(description = "模板描述")
|
||||
@ExcelProperty("模板描述")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "实例文件内容")
|
||||
@ExcelProperty("实例文件内容")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "原始文件内容", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("原始文件内容")
|
||||
private String originalContent;
|
||||
|
||||
@Schema(description = "文件类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("文件类型")
|
||||
private String fileType;
|
||||
|
||||
@Schema(description = "版本号;如v1.0", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("版本号;如v1.0")
|
||||
private String version;
|
||||
|
||||
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@ExcelProperty("状态")
|
||||
private String status;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
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 TemplateInstanceSaveReqVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "29024")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "分类树主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "7804")
|
||||
@NotNull(message = "分类树主键不能为空")
|
||||
private Long typeId;
|
||||
|
||||
@Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
||||
@NotEmpty(message = "模板名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "模板编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "模板编码不能为空")
|
||||
private String coding;
|
||||
|
||||
@Schema(description = "模板描述")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "实例文件内容")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "原始文件内容", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "原始文件内容不能为空")
|
||||
private String originalContent;
|
||||
|
||||
@Schema(description = "文件类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotEmpty(message = "文件类型不能为空")
|
||||
private String fileType;
|
||||
|
||||
@Schema(description = "版本号;如v1.0", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "版本号;如v1.0不能为空")
|
||||
private String version;
|
||||
|
||||
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@NotEmpty(message = "状态不能为空")
|
||||
private String status;
|
||||
|
||||
}
|
||||
@@ -6,6 +6,8 @@ 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
|
||||
@@ -33,4 +35,13 @@ public class TmplItmRespVO {
|
||||
@Schema(description = "条款结构", requiredMode = Schema.RequiredMode.REQUIRED, example = "")
|
||||
@ExcelProperty("条款结构")
|
||||
private String itmVal;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDate createTime;
|
||||
|
||||
|
||||
@Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建人")
|
||||
private String creator;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.base.controller.admin.templtp.vo;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -15,10 +16,10 @@ public class TmplTpFldSaveReqVO {
|
||||
@Schema(description = "字段数据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "string")
|
||||
private String datTp;
|
||||
@Schema(description = "字段描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "代码")
|
||||
private String fldDoc;
|
||||
private JSONObject fldDoc;
|
||||
@Schema(description = "字段备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "代码")
|
||||
private String rmk;
|
||||
@Schema(description = "是否必填", requiredMode = Schema.RequiredMode.REQUIRED, example = "Y")
|
||||
@Schema(description = "是否必填", requiredMode = Schema.RequiredMode.REQUIRED, example = "Y or N")
|
||||
private String isMust;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,33 @@
|
||||
package cn.iocoder.yudao.module.base.controller.admin.templtp.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
@Data
|
||||
public class TmplTpTreeVO {
|
||||
private String tenantId;
|
||||
private String id;
|
||||
private String label;
|
||||
private String value;
|
||||
private String prnId;
|
||||
public class TmplTpTreeVO{
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "20895")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "类型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "类型编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String num;
|
||||
|
||||
@Schema(description = "父类型主键;顶级为NULL", example = "20414")
|
||||
private Long prnId;
|
||||
|
||||
@Schema(description = "同级排序序号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Long srt;
|
||||
|
||||
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String sts;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDate createTime;
|
||||
|
||||
private List<TmplTpTreeVO> children;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
package cn.iocoder.yudao.module.base.dal.dataobject.tmpltp;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
/**
|
||||
* 模板实例 DO
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
@TableName("bse_tmpl_insc")
|
||||
@KeySequence("bse_tmpl_insc_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
/**
|
||||
* 支持业务基类继承:isBusiness=true 时继承 BusinessBaseDO,否则继承 BaseDO
|
||||
*/
|
||||
public class TemplateInstanceDO extends BaseDO {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
/**
|
||||
* 分类树主键
|
||||
*/
|
||||
private Long typeId;
|
||||
/**
|
||||
* 模板名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 模板编码
|
||||
*/
|
||||
private String coding;
|
||||
/**
|
||||
* 模板描述
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 实例文件内容
|
||||
*/
|
||||
private String content;
|
||||
/**
|
||||
* 原始文件内容
|
||||
*/
|
||||
private String originalContent;
|
||||
/**
|
||||
* 文件类型
|
||||
*/
|
||||
private String fileType;
|
||||
/**
|
||||
* 版本号;如v1.0
|
||||
*/
|
||||
private String version;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String status;
|
||||
/**
|
||||
* 公司编号
|
||||
*/
|
||||
private Long companyId;
|
||||
/**
|
||||
* 公司名称
|
||||
*/
|
||||
private String companyName;
|
||||
/**
|
||||
* 部门编号
|
||||
*/
|
||||
private Long deptId;
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
private String deptName;
|
||||
/**
|
||||
* 岗位编号
|
||||
*/
|
||||
private Long postId;
|
||||
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import lombok.ToString;
|
||||
@AllArgsConstructor
|
||||
public class TmplFldRelDO extends BusinessBaseDO {
|
||||
|
||||
@TableId(type = IdType.INPUT)
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@TableField("TMPL_TP_ID")
|
||||
|
||||
@@ -23,7 +23,7 @@ import lombok.ToString;
|
||||
@AllArgsConstructor
|
||||
public class TmplItmDO extends BusinessBaseDO {
|
||||
|
||||
@TableId(type = IdType.INPUT)
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@TableField("ITM_NUM")
|
||||
|
||||
@@ -23,7 +23,7 @@ import lombok.ToString;
|
||||
@AllArgsConstructor
|
||||
public class TmplItmRelDO extends BusinessBaseDO {
|
||||
|
||||
@TableId(type = IdType.INPUT)
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@TableField("TMPL_TP_ID")
|
||||
|
||||
@@ -26,7 +26,7 @@ public class TmplTpFldDO extends BusinessBaseDO { // 继承业务基类,自动
|
||||
* 主键(对应表中 ID 字段,VARCHAR2(64) 类型)
|
||||
* 注意:表中 ID 为字符串类型,此处使用 String 而非 Long,与 TmplTpDO 区分
|
||||
*/
|
||||
@TableId(type = IdType.INPUT) // 手动输入主键(因表中 ID 是 VARCHAR2,非自增 Long)
|
||||
@TableId(type = IdType.ASSIGN_ID) // 手动输入主键(因表中 ID 是 VARCHAR2,非自增 Long)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package cn.iocoder.yudao.module.base.dal.mysql.tmpltp;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
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.TemplateInstancePageReqVO;
|
||||
import cn.iocoder.yudao.module.base.dal.dataobject.tmpltp.TemplateInstanceDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
/**
|
||||
* 模板实例 Mapper
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
@Mapper
|
||||
public interface TemplateInstanceMapper extends BaseMapperX<TemplateInstanceDO> {
|
||||
|
||||
default PageResult<TemplateInstanceDO> selectPage(TemplateInstancePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<TemplateInstanceDO>()
|
||||
.eqIfPresent(TemplateInstanceDO::getTypeId, reqVO.getTypeId())
|
||||
.likeIfPresent(TemplateInstanceDO::getName, reqVO.getName())
|
||||
.eqIfPresent(TemplateInstanceDO::getCoding, reqVO.getCoding())
|
||||
.eqIfPresent(TemplateInstanceDO::getDescription, reqVO.getDescription())
|
||||
.eqIfPresent(TemplateInstanceDO::getContent, reqVO.getContent())
|
||||
.eqIfPresent(TemplateInstanceDO::getOriginalContent, reqVO.getOriginalContent())
|
||||
.eqIfPresent(TemplateInstanceDO::getFileType, reqVO.getFileType())
|
||||
.eqIfPresent(TemplateInstanceDO::getVersion, reqVO.getVersion())
|
||||
.eqIfPresent(TemplateInstanceDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(TemplateInstanceDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(TemplateInstanceDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
package cn.iocoder.yudao.module.base.framework.rpc.config;
|
||||
|
||||
import cn.iocoder.yudao.module.infra.api.file.FileApi;
|
||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(value = "baseRpcConfiguration", proxyBeanMethods = false)
|
||||
@EnableFeignClients(clients = {DeptApi.class})
|
||||
@EnableFeignClients(clients = {DeptApi.class, FileApi.class})
|
||||
public class RpcConfiguration {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package cn.iocoder.yudao.module.base.service.tmpltp;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TemplateInstancePageReqVO;
|
||||
import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TemplateInstanceRespVO;
|
||||
import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TemplateInstanceSaveReqVO;
|
||||
import cn.iocoder.yudao.module.base.dal.dataobject.tmpltp.TemplateInstanceDO;
|
||||
import jakarta.validation.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 模板实例 Service 接口
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
public interface TemplateInstanceService {
|
||||
|
||||
/**
|
||||
* 创建模板实例
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
TemplateInstanceRespVO createTemplateInstance(@Valid TemplateInstanceSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新模板实例
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateTemplateInstance(@Valid TemplateInstanceSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除模板实例
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteTemplateInstance(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除模板实例
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteTemplateInstanceListByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得模板实例
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 模板实例
|
||||
*/
|
||||
TemplateInstanceDO getTemplateInstance(Long id);
|
||||
|
||||
/**
|
||||
* 获得模板实例分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 模板实例分页
|
||||
*/
|
||||
PageResult<TemplateInstanceDO> getTemplateInstancePage(TemplateInstancePageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
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.TemplateInstancePageReqVO;
|
||||
import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TemplateInstanceRespVO;
|
||||
import cn.iocoder.yudao.module.base.controller.admin.templtp.vo.TemplateInstanceSaveReqVO;
|
||||
import cn.iocoder.yudao.module.base.dal.dataobject.tmpltp.TemplateInstanceDO;
|
||||
import cn.iocoder.yudao.module.base.dal.mysql.tmpltp.TemplateInstanceMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
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.TEMPLATE_INSTANCE_NOT_EXISTS;
|
||||
|
||||
|
||||
/**
|
||||
* 模板实例 Service 实现类
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class TemplateInstanceServiceImpl implements TemplateInstanceService {
|
||||
|
||||
@Resource
|
||||
private TemplateInstanceMapper templateInstanceMapper;
|
||||
|
||||
@Override
|
||||
public TemplateInstanceRespVO createTemplateInstance(TemplateInstanceSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
TemplateInstanceDO templateInstance = BeanUtils.toBean(createReqVO, TemplateInstanceDO.class);
|
||||
templateInstanceMapper.insert(templateInstance);
|
||||
// 返回
|
||||
return BeanUtils.toBean(templateInstance, TemplateInstanceRespVO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTemplateInstance(TemplateInstanceSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateTemplateInstanceExists(updateReqVO.getId());
|
||||
// 更新
|
||||
TemplateInstanceDO updateObj = BeanUtils.toBean(updateReqVO, TemplateInstanceDO.class);
|
||||
templateInstanceMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteTemplateInstance(Long id) {
|
||||
// 校验存在
|
||||
validateTemplateInstanceExists(id);
|
||||
// 删除
|
||||
templateInstanceMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteTemplateInstanceListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateTemplateInstanceExists(ids);
|
||||
// 删除
|
||||
templateInstanceMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
private void validateTemplateInstanceExists(List<Long> ids) {
|
||||
List<TemplateInstanceDO> list = templateInstanceMapper.selectByIds(ids);
|
||||
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
||||
throw exception(TEMPLATE_INSTANCE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateTemplateInstanceExists(Long id) {
|
||||
if (templateInstanceMapper.selectById(id) == null) {
|
||||
throw exception(TEMPLATE_INSTANCE_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TemplateInstanceDO getTemplateInstance(Long id) {
|
||||
return templateInstanceMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<TemplateInstanceDO> getTemplateInstancePage(TemplateInstancePageReqVO pageReqVO) {
|
||||
return templateInstanceMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,11 +8,13 @@ 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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TmplItmService extends IService<TmplItmDO> {
|
||||
|
||||
TmplItmRespVO createTmplItm(TmplItmSaveReqVO tmplItmSaveReqVO) ;
|
||||
void updateTmplItm(TmplItmSaveReqVO tmplItmSaveReqVO) ;
|
||||
boolean deleteTmplItm(String idStr);
|
||||
boolean deleteTmplItm(List<Long> ids);
|
||||
|
||||
PageResult<TmplItmDO> pageTmplItm(TmpItmPageReqVO pageReqVO);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ 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;
|
||||
@@ -14,11 +13,10 @@ 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;
|
||||
import static cn.iocoder.yudao.module.tmpltp.enums.ErrorCodeConstants.TMPL_ITM_NOT_EXISTS;
|
||||
|
||||
@Service
|
||||
@Validated
|
||||
@@ -43,20 +41,21 @@ public class TmplItmServiceImpl extends ServiceImpl<TmplItmMapper, TmplItmDO> im
|
||||
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);
|
||||
throw exception(TMPL_ITM_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateTmplLtmExists(Long id) {
|
||||
if (this.getById(id) == null) {
|
||||
throw exception(TMPL_TP_NOT_EXISTS);
|
||||
throw exception(TMPL_ITM_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean deleteTmplItm(String idStr) {
|
||||
return removeBatchByIds(Arrays.asList(idStr.split(",")));
|
||||
public boolean deleteTmplItm(List<Long> ids) {
|
||||
validateTmplLtmExists(ids);
|
||||
return removeBatchByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,8 +9,12 @@ import cn.iocoder.yudao.module.base.dal.dataobject.tmpltp.TmplTpFldDO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TmplTpFldService extends IService<TmplTpFldDO> {
|
||||
TmplFldRespVO createTmplFld(@Valid TmplTpFldSaveReqVO tmplTpFldSaveReqVO);
|
||||
void updateTmplFld(@Valid TmplTpFldSaveReqVO tmplTpFldSaveReqVO);
|
||||
PageResult<TmplTpFldDO> tmplTpFldPage(@Valid TmplFldPageReqVO pageReqVO);
|
||||
void deleteTmplTpByIds(List< Long> ids);
|
||||
|
||||
}
|
||||
|
||||
@@ -3,12 +3,15 @@ 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.framework.security.core.LoginUser;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
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.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -16,7 +19,8 @@ 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;
|
||||
import static cn.iocoder.yudao.module.tmpltp.enums.ErrorCodeConstants.TMPL_FLD_CODE_EXISTS;
|
||||
import static cn.iocoder.yudao.module.tmpltp.enums.ErrorCodeConstants.TMPL_FLD_NOT_EXISTS;
|
||||
|
||||
|
||||
@Service
|
||||
@@ -25,6 +29,7 @@ public class TmplTpFldServiceImpl extends ServiceImpl<TmplTpFldMapper, TmplTpFld
|
||||
@Override
|
||||
public TmplFldRespVO createTmplFld(TmplTpFldSaveReqVO tmplTpFldSaveReqVO) {
|
||||
TmplTpFldDO tmplTpFldDO = BeanUtils.toBean(tmplTpFldSaveReqVO, TmplTpFldDO.class);
|
||||
validateTmplFldCodeExists(tmplTpFldSaveReqVO.getFldKy());
|
||||
baseMapper.insert(tmplTpFldDO);
|
||||
return BeanUtils.toBean(tmplTpFldDO, TmplFldRespVO.class);
|
||||
}
|
||||
@@ -38,18 +43,23 @@ public class TmplTpFldServiceImpl extends ServiceImpl<TmplTpFldMapper, TmplTpFld
|
||||
baseMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
|
||||
private void validateTmplFldCodeExists(String code){
|
||||
Long loginUserCompanyId = SecurityFrameworkUtils.getLoginUserCompanyId();
|
||||
if (baseMapper.selectCount(Wrappers.<TmplTpFldDO>lambdaQuery().eq(TmplTpFldDO::getFldKy, code).eq(TmplTpFldDO::getCompanyId, loginUserCompanyId)) > 0) {
|
||||
throw exception(TMPL_FLD_CODE_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
throw exception(TMPL_FLD_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateTmplFldExists(Long id) {
|
||||
if (this.getById(id) == null) {
|
||||
throw exception(TMPL_TP_NOT_EXISTS);
|
||||
throw exception(TMPL_FLD_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,4 +67,10 @@ public class TmplTpFldServiceImpl extends ServiceImpl<TmplTpFldMapper, TmplTpFld
|
||||
public PageResult<TmplTpFldDO> tmplTpFldPage(TmplFldPageReqVO pageReqVO) {
|
||||
return baseMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteTmplTpByIds(List<Long> ids) {
|
||||
validateTmplFldExists(ids);
|
||||
baseMapper.deleteByIds(ids);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,9 +38,9 @@ public interface TmplTpService extends IService<TmplTpDO> {
|
||||
/**
|
||||
* 删除模板分类
|
||||
*
|
||||
* @param id 编号
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteTmplTp(Long id);
|
||||
void deleteTmplTp(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 批量删除模板分类
|
||||
@@ -69,4 +69,5 @@ public interface TmplTpService extends IService<TmplTpDO> {
|
||||
List<Map<String, Object>> getField(Long id);
|
||||
List<Map<String, Object>> getClause(Long id);
|
||||
List<TmplTpTreeVO> buildTree();
|
||||
void updateStatus(Long id, String status);
|
||||
}
|
||||
|
||||
@@ -10,10 +10,13 @@ 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.dataobject.tmpltp.TmplTpFldDO;
|
||||
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 cn.iocoder.yudao.module.tmpltp.enums.StatusEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -29,7 +32,7 @@ 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;
|
||||
import static cn.iocoder.yudao.module.tmpltp.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 模板分类 Service 实现类
|
||||
@@ -39,7 +42,7 @@ import static cn.iocoder.yudao.module.tmpltp.enums.ErrorCodeConstants.TMPL_TP_NO
|
||||
@Service
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
public class TmplTpServiceImpl extends ServiceImpl<TmplTpMapper, TmplTpDO> implements TmplTpService {
|
||||
public class TmplTpServiceImpl extends ServiceImpl<TmplTpMapper, TmplTpDO> implements TmplTpService {
|
||||
private final TmplFldRelMapper tmplFldRelMapper;
|
||||
private final TmplItmRelMapper tmplItmRelMapper;
|
||||
|
||||
@@ -51,8 +54,8 @@ public class TmplTpServiceImpl extends ServiceImpl<TmplTpMapper, TmplTpDO> imple
|
||||
TmplTpDO tmplTp = BeanUtils.toBean(createReqVO, TmplTpDO.class);
|
||||
baseMapper.insert(tmplTp);
|
||||
// 返回
|
||||
List<TmplFldRelDO> tmplFldRelDOS= new ArrayList<>();
|
||||
List<TmplItmRelDO> tmplItmRelDOS= new ArrayList<>();
|
||||
List<TmplFldRelDO> tmplFldRelDOS = new ArrayList<>();
|
||||
List<TmplItmRelDO> tmplItmRelDOS = new ArrayList<>();
|
||||
createReqVO.getTmplTpFldIds().forEach(tmplItmId -> {
|
||||
TmplFldRelDO tmplFldRelDO = new TmplFldRelDO();
|
||||
tmplFldRelDO.setTmplTpId(String.valueOf(tmplTp.getId()));
|
||||
@@ -80,20 +83,25 @@ public class TmplTpServiceImpl extends ServiceImpl<TmplTpMapper, TmplTpDO> imple
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteTmplTp(Long id) {
|
||||
@Transactional
|
||||
public void deleteTmplTp(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateTmplTpExists(id);
|
||||
validateTmplTpExists(ids);
|
||||
//校验能否进行删除
|
||||
if (!validateStatusCanDelete(ids)){
|
||||
throw exception(TMPL_TP_DEl_ERROR);
|
||||
}
|
||||
// 删除
|
||||
baseMapper.deleteById(id);
|
||||
baseMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteTmplTpListByIds(List<Long> ids) {
|
||||
public void deleteTmplTpListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateTmplTpExists(ids);
|
||||
// 删除
|
||||
baseMapper.deleteByIds(ids);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateTmplTpExists(List<Long> ids) {
|
||||
List<TmplTpDO> list = baseMapper.selectByIds(ids);
|
||||
@@ -122,6 +130,7 @@ public class TmplTpServiceImpl extends ServiceImpl<TmplTpMapper, TmplTpDO> imple
|
||||
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);
|
||||
@@ -133,55 +142,82 @@ public class TmplTpServiceImpl extends ServiceImpl<TmplTpMapper, TmplTpDO> imple
|
||||
List<TmplTpDO> allNodes = baseMapper.selectList(new QueryWrapper<>());
|
||||
|
||||
// 2. 转换为树节点VO
|
||||
List<TmplTpTreeVO> treeNodes = allNodes.stream().map(this::convertToTreeVO).collect(Collectors.toList());
|
||||
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;
|
||||
return BeanUtils.toBean(entity, TmplTpTreeVO.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建树形结构
|
||||
*/
|
||||
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
|
||||
}));
|
||||
.collect(Collectors.groupingBy(node ->
|
||||
node.getPrnId() != null ? node.getPrnId().toString() : "null"));
|
||||
|
||||
// 2. 递归设置子节点
|
||||
// 2. 设置子节点并排序
|
||||
treeNodes.forEach(node -> {
|
||||
List<TmplTpTreeVO> children = groupByPrnId.get(node.getId());
|
||||
List<TmplTpTreeVO> children = groupByPrnId.get(node.getId().toString());
|
||||
if (children != null && !children.isEmpty()) {
|
||||
// 按排序序号升序排列
|
||||
children.sort(Comparator.comparing(TmplTpTreeVO::getSrt));
|
||||
node.setChildren(children);
|
||||
}
|
||||
});
|
||||
|
||||
// 3. 返回根节点(父ID为0或null的节点)
|
||||
// 3. 返回根节点(父ID为NULL的节点)
|
||||
return groupByPrnId.getOrDefault("0", new ArrayList<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查找对应的实体(实际项目中可优化)
|
||||
*/
|
||||
private TmplTpDO findEntityById(List<TmplTpTreeVO> treeNodes, String id) {
|
||||
return baseMapper.selectById(Long.valueOf(id));
|
||||
|
||||
@Override
|
||||
public void updateStatus(Long id, String status) {
|
||||
//验证当前的能否变更为之后的状态
|
||||
if (!validateStatusUpdate(id, status)) {
|
||||
throw exception(TMPL_TP_SATUS_ERROR);
|
||||
}
|
||||
baseMapper.update(Wrappers.<TmplTpDO>lambdaUpdate().set(TmplTpDO::getSts, status).eq(TmplTpDO::getId, id));
|
||||
}
|
||||
|
||||
private boolean validateStatusUpdate(Long id, String status) {
|
||||
TmplTpDO tmplTpDO = this.getById(id);
|
||||
String currentSts = tmplTpDO.getSts();
|
||||
|
||||
// 获取当前状态对应的枚举实例
|
||||
StatusEnum currentStatus = StatusEnum.fromCode(currentSts);
|
||||
|
||||
// 如果当前状态不合法,直接返回false
|
||||
if (currentStatus == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 校验状态转换是否合法
|
||||
return currentStatus.isTransitionAllowed(status);
|
||||
}
|
||||
|
||||
private boolean validateStatusCanDelete(List<Long> ids) {
|
||||
Set<String> sts = listByIds(ids).stream().map(TmplTpDO::getSts).collect(Collectors.toSet());
|
||||
List<Boolean> result=new ArrayList<>();
|
||||
sts.forEach(status -> {
|
||||
StatusEnum currentStatus = StatusEnum.fromCode(status);
|
||||
boolean transitionAllowed = false;
|
||||
if (currentStatus != null) {
|
||||
transitionAllowed = currentStatus.isTransitionAllowed(status);
|
||||
}else {
|
||||
result.add(false);
|
||||
}
|
||||
result.add(transitionAllowed);
|
||||
});
|
||||
return !result.contains(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.base.dal.mysql.tmpltp.TemplateInstanceMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.base.dal.mysql.tmpltp.TmplFldRelMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.base.dal.mysql.tmpltp.TmplItmMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.base.dal.mysql.tmpltp.TmplItmRelMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.base.dal.mysql.tmpltp.TmplTpFldMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.base.dal.mysql.tmpltp.TmplTpMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user