xiexiang 1 anno fa
parent
commit
6efd1c5ab2

+ 56 - 0
src/main/java/cn/cslg/pas/common/dto/business/ProductCategoryDTO.java

@@ -0,0 +1,56 @@
+package cn.cslg.pas.common.dto.business;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import lombok.Data;
+import org.joda.time.DateTime;
+
+/**
+ * @Author xiexiang
+ * @Date 2023/10/24
+ */
+@Data
+/*数据库中的表对应的类
+ */
+public class ProductCategoryDTO {
+    /**
+     * 主键
+     */
+    @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;
+
+    /**
+     * 可见类型(0所有人可见、1本人可见、2仅选定人可见、3选定人不可见)
+     */
+    @TableField(value = "show_type")
+    private Integer showType;
+
+    /**
+     * 描述
+     */
+    @TableField(value = "description")
+    private String description;
+
+    /**
+     * 创建人
+     */
+    @TableField(value = "create_id")
+    private Integer createId;
+}

+ 75 - 0
src/main/java/cn/cslg/pas/controller/ProductCategoryController.java

@@ -0,0 +1,75 @@
+package cn.cslg.pas.controller;
+
+import cn.cslg.pas.common.core.base.Constants;
+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.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/24
+ */
+@Slf4j
+@RequestMapping(Constants.API_XiaoSHI + "/productCategory")
+@RestController
+public class ProductCategoryController {
+    @Autowired
+    private BusinessFactory businessFactory;
+
+    @Operation(summary = "查询产品类别")
+    @PostMapping("/queryProductCategory")
+    public String queryProductCategory(StringRequest stringRequest) throws Exception {
+        Business business = businessFactory.getClass("productCategoryService");
+        business.queryMessage(stringRequest);
+        return "";
+    }
+
+    @Operation(summary = "添加产品类别")
+    @PostMapping("/addProductCategory")
+    public String addProductCategory(String productCategory, List<MultipartFile> files) throws Exception {
+        if (productCategory != null) {
+            ProductCategoryDTO productCategoryDTO = JSONObject.parseObject(productCategory, ProductCategoryDTO.class);
+            Business business = businessFactory.getClass("productCategoryService");
+            business.addMessage(productCategoryDTO,files);
+            return Response.success();
+        } else {
+            return Response.error("网络异常");
+        }
+    }
+
+    @Operation(summary = "更新产品类别")
+    @PostMapping("/updateProductCategory")
+    public String updateProductCategory(String event, List<MultipartFile> files) throws Exception {
+        if (event != null) {
+            ProductCategoryDTO productCategoryDTO = JSONObject.parseObject(event, ProductCategoryDTO.class);
+            Business business = businessFactory.getClass("productCategoryService");
+            business.updateMessage(productCategoryDTO,files);
+            return Response.success();
+        } else {
+            return Response.error("网络异常");
+        }
+    }
+    @Operation(summary = "删除产品类别")
+    @PostMapping("/deleteProductCategory")
+    public String deleteProductCategory(@RequestBody List<Integer> ids) throws Exception {
+        Business business = businessFactory.getClass("productCategoryService");
+        business.deleteMessage(ids);
+        return Response.success();
+    }
+
+}

+ 61 - 0
src/main/java/cn/cslg/pas/domain/business/ProductCategory.java

@@ -0,0 +1,61 @@
+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/24
+ */
+@Data
+@TableName("product_category")
+public class ProductCategory extends BaseEntity<ProductCategory> {
+    /**
+     * 主键
+     */
+    @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;
+
+    /**
+     * 可见类型(0所有人可见、1本人可见、2仅选定人可见、3选定人不可见)
+     */
+    @TableField(value = "show_type")
+    private Integer showType;
+
+    /**
+     * 描述
+     */
+    @TableField(value = "description")
+    private String description;
+
+    /**
+     * 创建人
+     */
+    @TableField(value = "create_id")
+    private Integer createId;
+}

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

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

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

@@ -0,0 +1,61 @@
+package cn.cslg.pas.service.business;
+
+import cn.cslg.pas.common.dto.business.ProductCategoryDTO;
+import cn.cslg.pas.common.model.request.QueryRequest;
+import cn.cslg.pas.domain.business.ProductCategory;
+import cn.cslg.pas.factorys.businessFactory.Business;
+import cn.cslg.pas.mapper.ProductCategoryMapper;
+
+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;
+
+/**
+ * @Author xiexiang
+ * @Date 2023/10/24
+ */
+@Service
+@Slf4j
+public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, ProductCategory> implements Business {
+    @Autowired
+    private ProductCategoryMapper productCategoryMapper;
+
+    @Override
+    public Object queryMessage(QueryRequest queryRequest) throws Exception {
+        return null;
+    }
+
+    @Override
+    public Object addMessage(Object object, List<MultipartFile> files) {
+        //object to productCategory
+        ProductCategoryDTO productCategoryDTO = (ProductCategoryDTO)object;
+        //赋值
+        ProductCategory productCategory = new ProductCategory();
+        BeanUtils.copyProperties(productCategoryDTO, productCategory);
+        //数据入表
+        productCategory.insert();
+        //返回id
+        return productCategory.getId();
+    }
+
+    @Override
+    public Object deleteMessage(List<Integer> ids) {
+        this.removeByIds(ids);
+        return null;
+    }
+
+    @Override
+    public Object updateMessage(Object object, List<MultipartFile> files) {
+        //object to productCategory
+        ProductCategoryDTO productCategoryDTO = (ProductCategoryDTO)object;
+        ProductCategory productCategory = this.getById(productCategoryDTO.getId());
+        BeanUtils.copyProperties(productCategoryDTO, productCategory);
+        productCategory.insert();
+        return null;
+    }
+}