|
@@ -0,0 +1,181 @@
|
|
|
+/*
|
|
|
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
|
|
+ *
|
|
|
+ * Redistribution and use in source and binary forms, with or without
|
|
|
+ * modification, are permitted provided that the following conditions are met:
|
|
|
+ *
|
|
|
+ * Redistributions of source code must retain the above copyright notice,
|
|
|
+ * this list of conditions and the following disclaimer.
|
|
|
+ * Redistributions in binary form must reproduce the above copyright
|
|
|
+ * notice, this list of conditions and the following disclaimer in the
|
|
|
+ * documentation and/or other materials provided with the distribution.
|
|
|
+ * Neither the name of the dreamlu.net developer nor the names of its
|
|
|
+ * contributors may be used to endorse or promote products derived from
|
|
|
+ * this software without specific prior written permission.
|
|
|
+ * Author: Chill 庄骞 (smallchill@163.com)
|
|
|
+ */
|
|
|
+package org.springblade.business.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import javax.validation.Valid;
|
|
|
+
|
|
|
+import org.springblade.business.dto.TrialClassificationTreeDTO;
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
+import org.springblade.core.log.exception.ServiceException;
|
|
|
+import org.springblade.core.mp.support.Condition;
|
|
|
+import org.springblade.core.mp.support.Query;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.utils.BeanUtil;
|
|
|
+import org.springblade.core.tool.utils.Func;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import org.springblade.business.entity.TrialClassificationTree;
|
|
|
+import org.springblade.business.vo.TrialClassificationTreeVO;
|
|
|
+import org.springblade.business.service.ITrialClassificationTreeService;
|
|
|
+import org.springblade.core.boot.ctrl.BladeController;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 德飞试验系统检测分类树 控制器
|
|
|
+ *
|
|
|
+ * @author BladeX
|
|
|
+ * @since 2025-08-15
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@AllArgsConstructor
|
|
|
+@RequestMapping("/trialclassificationtree")
|
|
|
+@Api(value = "德飞试验系统检测分类树", tags = "德飞试验系统检测分类树接口")
|
|
|
+public class TrialClassificationTreeController extends BladeController {
|
|
|
+
|
|
|
+ private final ITrialClassificationTreeService trialClassificationTreeService;
|
|
|
+
|
|
|
+// /**
|
|
|
+// * 详情
|
|
|
+// */
|
|
|
+// @GetMapping("/detail")
|
|
|
+// @ApiOperationSupport(order = 1)
|
|
|
+// @ApiOperation(value = "详情", notes = "传入trialClassificationTree")
|
|
|
+// public R<TrialClassificationTree> detail(TrialClassificationTree trialClassificationTree) {
|
|
|
+// TrialClassificationTree detail = trialClassificationTreeService.getOne(Condition.getQueryWrapper(trialClassificationTree));
|
|
|
+// return R.data(detail);
|
|
|
+// }
|
|
|
+//
|
|
|
+ /**
|
|
|
+ * 德飞试验系统检测分类树
|
|
|
+ */
|
|
|
+ @GetMapping("/list")
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
+ @ApiOperation(value = "查询当前节点的子节点", notes = "传入trialClassificationTree")
|
|
|
+ public R<List<TrialClassificationTreeVO>> list(Long id,Long projectId) {
|
|
|
+ if(projectId==null){
|
|
|
+ throw new ServiceException("请选择项目");
|
|
|
+ }
|
|
|
+ List<TrialClassificationTreeVO> list = trialClassificationTreeService.selectAllNode(id,projectId);
|
|
|
+ return R.data(list);
|
|
|
+ }
|
|
|
+
|
|
|
+// /**
|
|
|
+// * 自定义分页 德飞试验系统检测分类树
|
|
|
+// */
|
|
|
+// @GetMapping("/page")
|
|
|
+// @ApiOperationSupport(order = 3)
|
|
|
+// @ApiOperation(value = "分页", notes = "传入trialClassificationTree")
|
|
|
+// public R<IPage<TrialClassificationTreeVO>> page(TrialClassificationTreeVO trialClassificationTree, Query query) {
|
|
|
+// IPage<TrialClassificationTreeVO> pages = trialClassificationTreeService.selectTrialClassificationTreePage(Condition.getPage(query), trialClassificationTree);
|
|
|
+// return R.data(pages);
|
|
|
+// }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增 德飞试验系统检测分类树
|
|
|
+ */
|
|
|
+ @PostMapping("/save")
|
|
|
+ @ApiOperationSupport(order = 4)
|
|
|
+ @ApiOperation(value = "新增", notes = "传入trialClassificationTree")
|
|
|
+ public R save(@Valid @RequestBody TrialClassificationTreeDTO trialClassificationTreeDto) {
|
|
|
+ TrialClassificationTree trialClassificationTree = new TrialClassificationTree();
|
|
|
+ BeanUtil.copy(trialClassificationTreeDto, trialClassificationTree);
|
|
|
+ trialClassificationTree.setId(SnowFlakeUtil.getId());
|
|
|
+ Long parentId = trialClassificationTree.getParentId();
|
|
|
+ StringBuilder classificationAncestors = new StringBuilder();
|
|
|
+ classificationAncestors.append(trialClassificationTree.getId());
|
|
|
+ if(parentId!=0){
|
|
|
+ classificationAncestors.append( ",").append(parentId);
|
|
|
+ }
|
|
|
+ while (parentId!=null&&parentId!=0){
|
|
|
+ parentId = selectAncestors(parentId);
|
|
|
+ if(parentId!=null&&parentId!=0){
|
|
|
+ classificationAncestors.append(parentId).append(",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ trialClassificationTree.setClassificationAncestors(classificationAncestors.toString());
|
|
|
+ trialClassificationTreeService.save(trialClassificationTree);
|
|
|
+ return R.data(trialClassificationTree.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ public Long selectAncestors(Long parentId) {
|
|
|
+ if(parentId==0){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return trialClassificationTreeService.selectAncestors(parentId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改 德飞试验系统检测分类树
|
|
|
+ */
|
|
|
+ @PostMapping("/update")
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
+ @ApiOperation(value = "修改", notes = "传入trialClassificationTree")
|
|
|
+ public R update(Long id,String classificationName) {
|
|
|
+ if(id==null){
|
|
|
+ return R.fail("请选择要修改的分类");
|
|
|
+ }
|
|
|
+ if(Func.isEmpty(classificationName)){
|
|
|
+ return R.fail("请输入分类名称");
|
|
|
+ }
|
|
|
+ TrialClassificationTree trialClassificationTree = new TrialClassificationTree();
|
|
|
+ trialClassificationTree.setId(id);
|
|
|
+ trialClassificationTree.setClassificationName(classificationName);
|
|
|
+ boolean b = trialClassificationTreeService.updateById(trialClassificationTree);
|
|
|
+ return R.status(b);
|
|
|
+ }
|
|
|
+
|
|
|
+// /**
|
|
|
+// * 新增或修改 德飞试验系统检测分类树
|
|
|
+// */
|
|
|
+// @PostMapping("/submit")
|
|
|
+// @ApiOperationSupport(order = 6)
|
|
|
+// @ApiOperation(value = "新增或修改", notes = "传入trialClassificationTree")
|
|
|
+// public R submit(@Valid @RequestBody List<TrialClassificationTree> trialClassificationTrees) {
|
|
|
+// return R.status(trialClassificationTreeService.saveOrUpdateBatch(trialClassificationTrees));
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+// /**
|
|
|
+// * 删除 德飞试验系统检测分类树
|
|
|
+// */
|
|
|
+// @PostMapping("/remove")
|
|
|
+// @ApiOperationSupport(order = 7)
|
|
|
+// @ApiOperation(value = "逻辑删除", notes = "传入ids")
|
|
|
+// public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
|
|
+// return R.status(trialClassificationTreeService.deleteLogic(Func.toLongList(ids)));
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/remove")
|
|
|
+ @ApiOperationSupport(order = 7)
|
|
|
+ @ApiOperation(value = "逻辑删除", notes = "传入id")
|
|
|
+ public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam Long id) {
|
|
|
+ boolean update = trialClassificationTreeService.update(new UpdateWrapper<TrialClassificationTree>().set("is_deleted", 1).in("classification_ancestors", id));
|
|
|
+ return R.status(update);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|