Ver código fonte

10/27 xx 产品、产品类别、产品架构、产品类别架构 基本框架搭建

xiexiang 1 ano atrás
pai
commit
6b1910e34c

+ 5 - 5
src/main/java/cn/cslg/pas/common/TreeBuild.java

@@ -29,7 +29,7 @@ public class TreeBuild {
     public List<TreeNode> getRootNode() {
         // 保存所有根节点(所有根节点的数据)
         List<TreeNode> rootNodeList = new ArrayList<>();
-        // treeNode:查询出的每一条数据(节点)
+        // TreeNode:查询出的每一条数据(节点)
         for (TreeNode treeNode : nodeList) {
             // 判断当前节点是否为根节点,此处注意:若parentId类型是String,则要采用equals()方法判断。
             if (treeNode.getParentSorts().contains(-1)) {
@@ -46,16 +46,16 @@ public class TreeBuild {
      * @return 构建整棵树
      */
     public List<TreeNode> buildTree() {
-        // treeNodes:保存一个顶级节点所构建出来的完整树形
-        List<TreeNode> treeNodes = new ArrayList<>();
+        // TreeNodes:保存一个顶级节点所构建出来的完整树形
+        List<TreeNode> TreeNodes = new ArrayList<>();
         // getRootNode():获取所有的根节点
         for (TreeNode treeRootNode : getRootNode()) {
             // 将顶级节点进行构建子树
             treeRootNode = buildChildTree(treeRootNode);
             // 完成一个顶级节点所构建的树形,增加进来
-            treeNodes.add(treeRootNode);
+            TreeNodes.add(treeRootNode);
         }
-        return treeNodes;
+        return TreeNodes;
     }
 
     /**

+ 0 - 41
src/main/java/cn/cslg/pas/common/TreeNode.java

@@ -1,41 +0,0 @@
-package cn.cslg.pas.common;
-
-import lombok.Data;
-import lombok.experimental.Accessors;
-
-import java.util.List;
-
-/**
- * 树结构类
- *
- * @author chenyu
- * @date 2023/8/31
- */
-@Accessors(chain = true)
-@Data
-public class TreeNode {
-    /**
-     * 节点ID(权要排序号)
-     */
-    private Integer sort;
-    /**
-     * 父节点ID:顶级节点为-1(父级权要排序号)
-     */
-    private List<Integer> parentSorts;
-    /**
-     * 节点名称(权要内容)
-     */
-    private String content;
-    /**
-     * 子节点(当前权要的所有子级权要)
-     */
-    private List<TreeNode> children;
-
-    public TreeNode(Integer sort, List<Integer> parentSorts, String content) {
-        this.sort = sort;
-        this.parentSorts = parentSorts;
-        this.content = content;
-    }
-
-
-}

+ 1 - 2
src/main/java/cn/cslg/pas/common/dto/business/ProductCategoryDTO.java

@@ -5,12 +5,11 @@ import lombok.Data;
 import org.joda.time.DateTime;
 
 /**
+ * 产品类别的DTO
  * @Author xiexiang
  * @Date 2023/10/24
  */
 @Data
-/*数据库中的表对应的类
- */
 public class ProductCategoryDTO {
     /**
      * 主键

+ 49 - 0
src/main/java/cn/cslg/pas/common/dto/business/ProductDTO.java

@@ -0,0 +1,49 @@
+package cn.cslg.pas.common.dto.business;
+
+import cn.hutool.core.date.DateTime;
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.Data;
+
+/**
+ * 产品的DTO
+ * @Author xiexiang
+ * @Date 2023/10/26
+ */
+@Data
+public class ProductDTO {
+    /**
+     * 主键
+     */
+    private Integer id;
+
+    /**
+     * 产品名称
+     */
+    private String name;
+
+    /**
+     * 参考许可费率
+     */
+    private Double licenseRate;
+
+    /**
+     * 上市时间
+     */
+    private DateTime marketTime;
+
+    /**
+     * 所属产品类别
+     */
+    private Integer categoryId;
+
+    /**
+     * 可见类型(0所有人可见,1本人可见,2仅选定人可见,3选定人不可见)
+     */
+    private Integer showType;
+
+    /**
+     * 描述
+     */
+    private String description;
+
+}

+ 51 - 0
src/main/java/cn/cslg/pas/common/dto/business/TreeNodeDTO.java

@@ -0,0 +1,51 @@
+package cn.cslg.pas.common.dto.business;
+
+import cn.hutool.core.date.DateTime;
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.Data;
+
+/**
+ * 架构的DTO
+ * @Author xiexiang
+ * @Date 2023/10/26
+ */
+@Data
+public class TreeNodeDTO {
+    /**
+     * 主键
+     */
+    private Integer id;
+
+    /**
+     * 节点名称
+     */
+    private String name;
+
+    /**
+     * 类型
+     * (1产品类别,2产品,3技术分类,4自定义树)
+     */
+    private Integer type;
+
+    /**
+     * 父id
+     */
+    private Integer parentId;
+
+    /**
+     * 抽象id
+     * (所属产品/产品类别/自定义树/技术分类)
+     */
+    private Integer typeId;
+
+    /**
+     * 路径
+     */
+    private String path;
+
+    /**
+     * 层级
+     */
+    private Integer level;
+
+}

+ 14 - 6
src/main/java/cn/cslg/pas/controller/ProductCategoryController.java

@@ -5,6 +5,7 @@ import cn.cslg.pas.common.dto.business.ProductCategoryDTO;
 import cn.cslg.pas.common.model.request.StringRequest;
 import cn.cslg.pas.common.utils.Response;
 
+import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.factorys.businessFactory.Business;
 import cn.cslg.pas.factorys.businessFactory.BusinessFactory;
 import com.alibaba.fastjson.JSONObject;
@@ -45,8 +46,15 @@ public class ProductCategoryController {
         if (productCategory != null) {
             ProductCategoryDTO productCategoryDTO = JSONObject.parseObject(productCategory, ProductCategoryDTO.class);
             Business business = businessFactory.getClass("productCategoryService");
-            business.addMessage(productCategoryDTO,files);
-            return Response.success(1);
+            Integer id = null;
+            try {
+                id = (Integer) business.addMessage(productCategoryDTO, files);
+            } catch (Exception e){
+                if(e instanceof XiaoShiException) {
+                    return Response.error(e.getMessage());
+                }
+            }
+            return Response.success(id);
         } else {
             return Response.error("网络异常");
         }
@@ -54,14 +62,14 @@ public class ProductCategoryController {
 
     @Operation(summary = "更新产品类别")
     @PostMapping("/updateProductCategory")
-    public Response updateProductCategory(String event, List<MultipartFile> files) throws Exception {
-        if (event != null) {
-            ProductCategoryDTO productCategoryDTO = JSONObject.parseObject(event, ProductCategoryDTO.class);
+    public Response updateProductCategory(String productCategory, List<MultipartFile> files) throws Exception {
+        if (productCategory != null) {
+            ProductCategoryDTO productCategoryDTO = JSONObject.parseObject(productCategory, ProductCategoryDTO.class);
             Business business = businessFactory.getClass("productCategoryService");
             business.updateMessage(productCategoryDTO,files);
             return Response.success(1);
         } else {
-            return Response.error("a");
+            return Response.error("网络异常");
         }
     }
     @Operation(summary = "删除产品类别")

+ 84 - 0
src/main/java/cn/cslg/pas/controller/ProductController.java

@@ -0,0 +1,84 @@
+package cn.cslg.pas.controller;
+
+import cn.cslg.pas.common.core.base.Constants;
+import cn.cslg.pas.common.dto.business.ProductDTO;
+import cn.cslg.pas.common.model.request.StringRequest;
+import cn.cslg.pas.common.utils.Response;
+import cn.cslg.pas.exception.XiaoShiException;
+import cn.cslg.pas.factorys.businessFactory.Business;
+import cn.cslg.pas.factorys.businessFactory.BusinessFactory;
+import com.alibaba.fastjson.JSONObject;
+import io.swagger.v3.oas.annotations.Operation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+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.multipart.MultipartFile;
+
+import java.util.List;
+
+/**
+ * 产品的controller层
+ * @Author xiexiang
+ * @Date 2023/10/27
+ */
+@Slf4j
+@RequestMapping(Constants.API_XiaoSHI + "/product")
+@RestController
+public class ProductController {
+    @Autowired
+    private BusinessFactory businessFactory;
+
+    @Operation(summary = "查询产品")
+    @PostMapping("/queryProduct")
+    public Response queryProduct(StringRequest stringRequest) throws Exception {
+        Business business = businessFactory.getClass("eventService");
+        business.queryMessage(stringRequest);
+        return null;
+    }
+
+    @Operation(summary = "添加产品")
+    @PostMapping("/addProduct")
+    public Response addProduct(String product, List<MultipartFile> files) throws Exception {
+        if (product != null) {
+            ProductDTO productDTO = JSONObject.parseObject(product, ProductDTO.class);
+            Business business = businessFactory.getClass("productService");
+            Integer id = null;
+            try {
+                id = (Integer) business.addMessage(productDTO, files);
+            } catch (Exception e){
+                if(e instanceof XiaoShiException){
+                    return Response.error(e.getMessage());
+                }
+            }
+            return Response.success(id);
+        } else {
+            return  Response.error("网络异常");
+        }
+    }
+
+    @Operation(summary = "更新产品")
+    @PostMapping("/updateProduct")
+    public Response updateProduct(String product, List<MultipartFile> files) throws Exception {
+        if(product != null){
+            ProductDTO productDTO = JSONObject.parseObject(product, ProductDTO.class);
+            Business business = businessFactory.getClass("productService");
+            business.updateMessage(productDTO, files);
+            return Response.success(1);
+        } else {
+            return Response.error("网络异常");
+        }
+    }
+
+    @Operation(summary = "删除产品")
+    @PostMapping("/deleteProduct")
+    public String deleteProduct(@RequestBody List<Integer> ids) throws Exception {
+        Business business = businessFactory.getClass("productService");
+        business.deleteMessage(ids);
+        return Response.success();
+    }
+
+
+}

+ 81 - 0
src/main/java/cn/cslg/pas/controller/TreeNodeController.java

@@ -0,0 +1,81 @@
+package cn.cslg.pas.controller;
+
+import cn.cslg.pas.common.core.base.Constants;
+import cn.cslg.pas.common.dto.business.TreeNodeDTO;
+import cn.cslg.pas.common.model.request.StringRequest;
+import cn.cslg.pas.common.utils.Response;
+import cn.cslg.pas.exception.XiaoShiException;
+import cn.cslg.pas.factorys.businessFactory.Business;
+import cn.cslg.pas.factorys.businessFactory.BusinessFactory;
+import io.swagger.v3.oas.annotations.Operation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+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.multipart.MultipartFile;
+
+import java.util.List;
+
+/**
+ * 架构的Controller层
+ * @Author xiexiang
+ * @Date 2023/10/26
+ */
+@Slf4j
+@RequestMapping(Constants.API_XiaoSHI + "/treeNode")
+@RestController
+public class TreeNodeController {
+    @Autowired
+    private BusinessFactory businessFactory;
+
+    @Operation(summary = "查询架构")
+    @PostMapping("/queryTreeNode")
+    public String queryTreeNode(StringRequest stringRequest) throws Exception {
+        Business business = businessFactory.getClass("treeNodeService");
+        business.queryMessage(stringRequest);
+        return "";
+    }
+
+    @Operation(summary = "新增架构")
+    @PostMapping("/addTreeNode")
+    public Response addTreeNode(String treeNode, List<MultipartFile> files) throws Exception {
+        if(treeNode != null){
+            TreeNodeDTO treeNodeDTO = new TreeNodeDTO();
+            Business business = businessFactory.getClass("treeNodeService");
+            Integer id = null;
+            try {
+                id = (Integer) business.addMessage(treeNodeDTO, files);
+            } catch (Exception e){
+                if(e instanceof XiaoShiException) {
+                    return Response.error(e.getMessage());
+                }
+            }
+            return Response.success(id);
+        } else {
+            return Response.error("网络异常");
+        }
+    }
+
+    @Operation(summary = "更新架构")
+    @PostMapping("/updateTreeNode")
+    public Response updateTreeNode(String treeNode, List<MultipartFile> files) throws Exception {
+        if (treeNode != null) {
+            TreeNodeDTO treeNodeDTO = new TreeNodeDTO();
+            Business business = businessFactory.getClass("treeNodeService");
+            business.updateMessage(treeNodeDTO, files);
+            return Response.success(1);
+        } else {
+            return Response.error("网络异常");
+        }
+    }
+
+    @Operation(summary = "删除架构")
+    @PostMapping("/deleteTreeNode")
+    public String deleteTreeNode(@RequestBody List<Integer> ids) throws Exception {
+        Business business = businessFactory.getClass("treeNodeService");
+        business.deleteMessage(ids);
+        return Response.success();
+    }
+}

+ 31 - 0
src/main/java/cn/cslg/pas/domain/business/AssoProductFile.java

@@ -0,0 +1,31 @@
+package cn.cslg.pas.domain.business;
+
+import cn.cslg.pas.domain.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import org.joda.time.DateTime;
+
+/**
+ * <p>
+ *     产品文件关联表
+ * </p>
+ * @Author xiexiang
+ * @Date 2023/10/27
+ */
+@Data
+@TableName("asso_product_file")
+/* 数据库中的表对应的类
+ */
+public class AssoProductFile extends BaseEntity<AssoProductFile> {
+    @TableField(value = "id")
+    private Integer id;
+    @TableField(value = "product_id")
+    private Integer productId;
+    @TableField(value = "file_guid")
+    private String fileGuid;
+    @TableField(value = "create_id")
+    private Integer createId;
+    @TableField(value = "create_time")
+    private DateTime createTime;
+}

+ 77 - 0
src/main/java/cn/cslg/pas/domain/business/Product.java

@@ -0,0 +1,77 @@
+package cn.cslg.pas.domain.business;
+
+import cn.cslg.pas.domain.BaseEntity;
+import cn.hutool.core.date.DateTime;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+/**
+ * 产品实体类
+ * @Author xiexiang
+ * @Date 2023/10/26
+ */
+@Data
+@TableName("product")
+public class Product extends BaseEntity<Product> {
+    /**
+     * 主键
+     */
+    @TableField(value = "id")
+    private Integer id;
+
+    /**
+     * 产品名称
+     */
+    @TableField(value = "name")
+    private String name;
+
+    /**
+     * 参考许可费率
+     */
+    @TableField(value = "license_rate")
+    private Double licenseRate;
+
+    /**
+     * 上市时间
+     */
+    @TableField(value = "market_time")
+    private DateTime marketTime;
+
+    /**
+     * 所属产品类别
+     */
+    @TableField(value = "category_id")
+    private Integer categoryId;
+
+    /**
+     * 可见类型(0所有人可见,1本人可见,2仅选定人可见,3选定人不可见)
+     */
+    @TableField(value = "show_type")
+    private Integer showType;
+
+    /**
+     * 描述
+     */
+    @TableField(value = "description")
+    private String description;
+
+    /**
+     * 创建人
+     */
+    @TableField(value = "create_id")
+    private Integer createId;
+
+    /**
+     * 创建时间
+     */
+    @TableField(value = "create_time")
+    private DateTime createTime;
+
+    /**
+     * 租户id
+     */
+    @TableField(value = "tenant_id")
+    private Integer tenantId;
+
+}

+ 75 - 0
src/main/java/cn/cslg/pas/domain/business/TreeNode.java

@@ -0,0 +1,75 @@
+package cn.cslg.pas.domain.business;
+
+import cn.cslg.pas.domain.BaseEntity;
+import cn.hutool.core.date.DateTime;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+/**
+ * <p>
+ *  架构实体类
+ * </p>
+ * @Author xiexiang
+ * @Date 2023/10/26
+ */
+@Data
+@TableName("tree_node")
+public class TreeNode extends BaseEntity<TreeNode> {
+    /**
+     * 主键
+     */
+    @TableField(value = "id")
+    private Integer id;
+
+    /**
+     * 节点名称
+     */
+    @TableField(value = "name")
+    private String name;
+
+    /**
+     * 类型
+     * (1产品类别,2产品,3技术分类,4自定义树)
+     */
+    @TableField(value = "type")
+    private Integer type;
+
+    /**
+     * 父id
+     */
+    @TableField(value = "parent_id")
+    private Integer parentId;
+
+    /**
+     * 抽象id
+     * (所属产品/产品类别/自定义树/技术分类)
+     */
+    @TableField(value = "type_id")
+    private Integer typeId;
+
+    /**
+     * 路径
+     */
+    @TableField(value = "path")
+    private String path;
+
+    /**
+     * 层级
+     */
+    @TableField(value = "level")
+    private Integer level;
+
+    /**
+     * 创建人
+     */
+    @TableField(value = "create_id")
+    private Integer createId;
+
+    /**
+     * 创建时间
+     */
+    @TableField(value = "create_time")
+    private DateTime createTime;
+
+}

+ 13 - 0
src/main/java/cn/cslg/pas/mapper/AssoProductFileMapper.java

@@ -0,0 +1,13 @@
+package cn.cslg.pas.mapper;
+
+import cn.cslg.pas.domain.business.AssoProductFile;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @Author xiexiang
+ * @Date 2023/10/27
+ */
+@Repository
+public interface AssoProductFileMapper extends BaseMapper<AssoProductFile> {
+}

+ 14 - 0
src/main/java/cn/cslg/pas/mapper/ProductMapper.java

@@ -0,0 +1,14 @@
+package cn.cslg.pas.mapper;
+
+import cn.cslg.pas.domain.business.Product;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springframework.stereotype.Repository;
+
+/**
+ * 产品的Mapper层
+ * @Author xiexiang
+ * @Date 2023/10/26
+ */
+@Repository
+public interface ProductMapper extends BaseMapper<Product> {
+}

+ 15 - 0
src/main/java/cn/cslg/pas/mapper/TreeNodeMapper.java

@@ -0,0 +1,15 @@
+package cn.cslg.pas.mapper;
+
+import cn.cslg.pas.domain.business.TreeNode;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springframework.stereotype.Repository;
+
+/**
+ * 架构的Mapper层
+ * @Author xiexiang
+ * @Date 2023/10/26
+ */
+@Repository
+public interface TreeNodeMapper extends BaseMapper<TreeNode> {
+
+}

+ 14 - 0
src/main/java/cn/cslg/pas/service/business/AssoProductFileService.java

@@ -0,0 +1,14 @@
+package cn.cslg.pas.service.business;
+
+import cn.cslg.pas.domain.business.AssoProductFile;
+import cn.cslg.pas.mapper.AssoProductFileMapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Author xiexiang
+ * @Date 2023/10/27
+ */
+@Service
+public class AssoProductFileService extends ServiceImpl<AssoProductFileMapper, AssoProductFile> {
+}

+ 13 - 0
src/main/java/cn/cslg/pas/service/business/ProductCategoryService.java

@@ -5,9 +5,11 @@ import cn.cslg.pas.common.model.cronModel.GroupVO;
 import cn.cslg.pas.common.model.request.GroupRequest;
 import cn.cslg.pas.common.model.request.QueryRequest;
 import cn.cslg.pas.domain.business.ProductCategory;
+import cn.cslg.pas.exception.XiaoShiException;
 import cn.cslg.pas.factorys.businessFactory.Business;
 import cn.cslg.pas.mapper.ProductCategoryMapper;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
@@ -18,6 +20,7 @@ import org.springframework.web.multipart.MultipartFile;
 import java.util.List;
 
 /**
+ * 产品类别的Service层
  * @Author xiexiang
  * @Date 2023/10/24
  */
@@ -36,11 +39,21 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
     public Object addMessage(Object object, List<MultipartFile> files) {
         //object to productCategory
         ProductCategoryDTO productCategoryDTO = (ProductCategoryDTO)object;
+        //检测名成
+        productCategoryDTO.setName(productCategoryDTO.getName().trim());
+        String name = productCategoryDTO.getName();
+        LambdaQueryWrapper<ProductCategory> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(ProductCategory::getName, name);
+        List<ProductCategory> productCategories = this.list(queryWrapper);
+        if(productCategories != null && productCategories.size() != 0){
+            throw new XiaoShiException("参数错误");
+        }
         //赋值
         ProductCategory productCategory = new ProductCategory();
         BeanUtils.copyProperties(productCategoryDTO, productCategory);
         //数据入表
         productCategory.insert();
+
         //返回id
         return productCategory.getId();
     }

+ 144 - 0
src/main/java/cn/cslg/pas/service/business/ProductService.java

@@ -0,0 +1,144 @@
+package cn.cslg.pas.service.business;
+
+import cn.cslg.pas.common.dto.business.ProductDTO;
+import cn.cslg.pas.common.model.cronModel.GroupVO;
+import cn.cslg.pas.common.model.request.GroupRequest;
+import cn.cslg.pas.common.model.request.QueryRequest;
+import cn.cslg.pas.domain.business.AssoProductFile;
+import cn.cslg.pas.domain.business.Product;
+import cn.cslg.pas.exception.XiaoShiException;
+import cn.cslg.pas.factorys.businessFactory.Business;
+import cn.cslg.pas.mapper.ProductMapper;
+import cn.cslg.pas.service.common.FileManagerService;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 产品的Service层
+ * @Author xiexiang
+ * @Date 2023/10/26
+ */
+@Service
+@Slf4j
+public class ProductService extends ServiceImpl<ProductMapper, Product> implements Business {
+
+    @Autowired
+    private FileManagerService fileManagerService;
+
+    @Autowired
+    private AssoProductFileService assoProductFileService;
+
+    @Override
+    public Object queryMessage(QueryRequest queryRequest) throws Exception {
+        return null;
+    }
+
+    @Override
+    public Integer addMessage(Object object, List<MultipartFile> files) {
+        ProductDTO productDTO = (ProductDTO) object;
+        //根据名称查询是否重复
+        productDTO.setName(productDTO.getName().trim());
+        String name = productDTO.getName();
+        LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(Product::getName, name);
+        List<Product> products = this.list(queryWrapper);
+        if (products != null && products.size() != 0) {
+            throw new XiaoShiException("参数错误");
+        }
+        //产品入库
+        Product product = new Product();
+        BeanUtils.copyProperties(productDTO, product);
+        product.insert();
+        if(files != null && files.size() != 0) {
+            try {
+                List<String> guids = fileManagerService.uploadFileGetGuid(files);
+                List<AssoProductFile> assoProductFiles = new ArrayList<>();
+                guids.forEach(item -> {
+                    AssoProductFile assoProductFile = new AssoProductFile();
+                    assoProductFile.setProductId(product.getId());
+                    assoProductFile.setFileGuid(item);
+                    assoProductFile.setCreateId(1);
+                    assoProductFiles.add(assoProductFile);
+                });
+                if (assoProductFiles != null && assoProductFiles.size() != 0) {
+                    assoProductFileService.saveBatch(assoProductFiles);
+                }
+            } catch (Exception e) {
+
+            }
+        }
+        return product.getId();
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Object deleteMessage(List<Integer> ids) {
+        //根据产品id删除产品
+        this.removeBatchByIds(ids);
+        //根据产品id删除产品和文件关联
+        LambdaQueryWrapper<AssoProductFile> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.in(AssoProductFile::getProductId, ids);
+        List<AssoProductFile> assoProductFiles = assoProductFileService.list(queryWrapper);
+        List<String> guids = assoProductFiles.stream().map(AssoProductFile::getFileGuid).collect(Collectors.toList());
+        //TODO 根据guid删除文件
+        try {
+            fileManagerService.deleteFileFromFMS(guids);
+        } catch (Exception e) {
+            throw new XiaoShiException("调用删除接口错误");
+        }
+        //删除产品和文件关联表
+        assoProductFiles.remove(queryWrapper);
+        return ids;
+    }
+
+    @Override
+    public Object updateMessage(Object object, List<MultipartFile> files) {
+        //object to productDTO
+        ProductDTO productDTO = (ProductDTO) object;
+        productDTO.setName(productDTO.getName().trim());
+        String name = productDTO.getName();
+        LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(Product::getName, name);
+        List<Product> products = this.list(queryWrapper);
+        if(products == null || products.size() == 0){
+            return null;
+        }
+        Product product = new Product();
+        BeanUtils.copyProperties(productDTO, product);
+        product.insert();
+        if (files != null && files.size() != 0) {
+            try {
+                List<String> guids = fileManagerService.uploadFileGetGuid(files);
+                List<AssoProductFile> assoProductFiles = new ArrayList<>();
+                guids.forEach(item -> {
+                    AssoProductFile assoProductFile = new AssoProductFile();
+                    assoProductFile.setProductId(product.getId());
+                    assoProductFile.setFileGuid(item);
+                    assoProductFile.setCreateId(1);
+                    assoProductFiles.add(assoProductFile);
+                });
+                if (assoProductFiles != null && assoProductFiles.size() != 0) {
+                    assoProductFileService.saveBatch(assoProductFiles);
+                }
+            } catch (Exception e) {
+
+            }
+        }
+        return product.getId();
+    }
+
+    @Override
+    public GroupVO getGroup(GroupRequest groupRequest) throws Exception {
+        return null;
+    }
+}

+ 68 - 0
src/main/java/cn/cslg/pas/service/business/TreeNodeService.java

@@ -0,0 +1,68 @@
+package cn.cslg.pas.service.business;
+
+import cn.cslg.pas.common.dto.business.TreeNodeDTO;
+import cn.cslg.pas.common.model.cronModel.GroupVO;
+import cn.cslg.pas.common.model.request.GroupRequest;
+import cn.cslg.pas.common.model.request.QueryRequest;
+import cn.cslg.pas.domain.business.TreeNode;
+import cn.cslg.pas.factorys.businessFactory.Business;
+import cn.cslg.pas.mapper.TreeNodeMapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+/**
+ * 架构的Service层
+ * @Author xiexiang
+ * @Date 2023/10/26
+ */
+@Service
+@Slf4j
+public class TreeNodeService extends ServiceImpl<TreeNodeMapper, TreeNode> implements Business {
+    @Autowired
+    private TreeNodeMapper treeNodeMapper;
+
+    @Override
+    public Object queryMessage(QueryRequest queryRequest) throws Exception {
+        return null;
+    }
+
+    @Override
+    public Object addMessage(Object object, List<MultipartFile> files) {
+        //object to treeNode
+        TreeNodeDTO treeNodeDTO = (TreeNodeDTO)object;
+        //赋值
+        TreeNode treeNode = new TreeNode();
+        BeanUtils.copyProperties(treeNodeDTO, treeNode);
+        //数据入表
+        treeNode.insert();
+        //返回id
+        return treeNode.getId();
+    }
+
+    @Override
+    public Object deleteMessage(List<Integer> ids) {
+        this.removeByIds(ids);
+        return null;
+    }
+
+    @Override
+    public Object updateMessage(Object object, List<MultipartFile> files) {
+        //object to treeNode
+        TreeNodeDTO treeNodeDTO = (TreeNodeDTO) object;
+        TreeNode treeNode = this.getById(treeNodeDTO.getId());
+        BeanUtils.copyProperties(treeNodeDTO, treeNode);
+        treeNode.insert();
+        return null;
+    }
+
+    @Override
+    public GroupVO getGroup(GroupRequest groupRequest) throws Exception {
+        return null;
+    }
+}