Parcourir la source

产品和产品分类查询

lwhhszx il y a 1 an
Parent
commit
23776a1486

Fichier diff supprimé car celui-ci est trop grand
+ 29690 - 9
logs/pas/pas-debug.log


Fichier diff supprimé car celui-ci est trop grand
+ 52912 - 0
logs/pas/pas-error.log


Fichier diff supprimé car celui-ci est trop grand
+ 3978 - 1242
logs/pas/pas-info.log


+ 5 - 0
pom.xml

@@ -107,6 +107,11 @@
             <!--            <version>${google.code.gson.version}</version>-->
         </dependency>
         <dependency>
+            <groupId>org.mybatis</groupId>
+            <artifactId>mybatis-typehandlers-jsr310</artifactId>
+            <version>1.0.2</version>
+        </dependency>
+        <dependency>
             <groupId>com.baomidou</groupId>
             <artifactId>mybatis-plus-boot-starter</artifactId>
             <version>${mybatisplus.version}</version>

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

@@ -37,4 +37,8 @@ public class ProductDTO {
     private List<String> showPersonIds;
     @Schema(description = "管理人员ids")
     private List<String> adminIds;
+    @Schema(description = "公司名称")
+    private String companyName;
+
+
 }

+ 1 - 0
src/main/java/cn/cslg/pas/common/model/cronModel/SqlObject.java

@@ -19,6 +19,7 @@ public class SqlObject {
      */
     private String field;
     private String sqlField;
+    private String value;
     private String sqlClass;
     private String option;
 

+ 15 - 2
src/main/java/cn/cslg/pas/common/vo/business/ProductVO.java

@@ -3,8 +3,10 @@ package cn.cslg.pas.common.vo.business;
 import cn.cslg.pas.common.model.cronModel.SystemFile;
 import cn.hutool.core.date.DateTime;
 import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
 
 import java.util.Date;
 import java.util.List;
@@ -23,7 +25,10 @@ public class ProductVO {
     @Schema(description = "参考许可费率")
     private Double licenseRate;
     @Schema(description = "上市时间")
-    private DateTime marketTime;
+
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date marketTime;
     @Schema(description = "所属产品类别")
     private Integer categoryId;
     @Schema(description = "可见类型(0所有人可见,1本人可见,2仅选定人可见,3选定人不可见)")
@@ -36,10 +41,18 @@ public class ProductVO {
     private String createId;
     @Schema(description = "创建人")
     private String createName;
+
+
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
     @Schema(description = "创建时间")
-    private DateTime createTime;
+    private Date createTime;
     @Schema(description = "租户id")
     private Integer tenantId;
+
+    @Schema(description = "公司名称")
+    private String companyName;
+
     @Schema(description = "文件信息")
     private List<SystemFile> systemFileList;
 }

+ 0 - 1
src/main/java/cn/cslg/pas/controller/PatentProjectController.java

@@ -1,7 +1,6 @@
 package cn.cslg.pas.controller;
 
 import cn.cslg.pas.common.core.base.Constants;
-import cn.cslg.pas.common.dto.business.EventDTO;
 import cn.cslg.pas.common.dto.business.PatentProjectDTO;
 import cn.cslg.pas.common.dto.business.UpdateEventDTO;
 import cn.cslg.pas.common.model.cronModel.Records;

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

@@ -38,7 +38,7 @@ public class ProductCategoryController {
 
     @Operation(summary = "查询产品类别")
     @PostMapping("/queryProductCategory")
-    public Response queryProductCategory(StringRequest stringRequest) throws Exception {
+    public Response queryProductCategory(@RequestBody  StringRequest stringRequest) throws Exception {
         Business business = businessFactory.getClass("productCategoryService");
         Records records = (Records) business.queryMessage(stringRequest);
         return Response.success(records);

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

@@ -36,8 +36,8 @@ public class ProductController {
 
     @Operation(summary = "查询产品")
     @PostMapping("/queryProduct")
-    public Response queryProduct(StringRequest stringRequest) throws Exception {
-        Business business = businessFactory.getClass("eventService");
+    public Response queryProduct(@RequestBody StringRequest stringRequest) throws Exception {
+        Business business = businessFactory.getClass("productService");
         Records records = (Records) business.queryMessage(stringRequest);
         return Response.success(records);
     }

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

@@ -69,4 +69,11 @@ public class Product extends BaseEntity<Product> {
     @TableField(value = "tenant_id")
     private Integer tenantId;
 
+    /**
+     * 公司名称
+     */
+    @TableField(value = "company_name")
+    private String companyName;
+
+
 }

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

@@ -28,11 +28,6 @@ public class ProductCategory extends BaseEntity<ProductCategory> {
     @TableField(value = "license_rate")
     private Double licenseRate;
     /**
-     * 上市时间
-     */
-    @TableField(value = "market_time")
-    private DateTime marketTime;
-    /**
      * 可见类型(0所有人可见、1本人可见、2仅选定人可见、3选定人不可见)
      */
     @TableField(value = "show_type")

+ 3 - 1
src/main/java/cn/cslg/pas/service/business/ProductCategoryService.java

@@ -421,7 +421,7 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
         //装载信息
         for (ProductCategoryVO productCategoryVO:productCategoryVOS) {
             //装载人员信息
-            Personnel personnel = personnels.stream().filter(item -> item.getGuid().equals(productCategoryVO.getCreateId())).findFirst().orElse(null);
+            Personnel personnel = personnels.stream().filter(item -> item.getId().toString().equals(productCategoryVO.getCreateId())).findFirst().orElse(null);
             if(personnel != null){
                 productCategoryVO.setCreateName(personnel.getPersonnelName());
             } else {
@@ -456,4 +456,6 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
             productCategoryVO.setAdminIds(adminIds);
         }
     }
+
+
 }

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

@@ -403,7 +403,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> implemen
         //装载信息
         for (ProductVO productVO:productVOS) {
             //装载人员信息
-            Personnel personnel = personnels.stream().filter(item -> item.getGuid().equals(productVO.getCreateId())).findFirst().orElse(null);
+            Personnel personnel = personnels.stream().filter(item -> item.getId().toString().equals(productVO.getCreateId())).findFirst().orElse(null);
             if(personnel != null){
                 productVO.setCreateName(personnel.getPersonnelName());
             }

+ 6 - 6
src/main/java/cn/cslg/pas/service/query/FormatQueryService.java

@@ -72,9 +72,9 @@ public class FormatQueryService {
                 String field = Left.ToString();
                 strCode = Left.ToString() + " " + strCode;
                 //判断 参数类型
-                String json = CommonService.readJsonFile("event_sql.json");
+                String json = CommonService.readJsonFile("event.json");
                 List<SqlObject> sqlObjects = JSON.parseArray(json, SqlObject.class);
-                SqlObject sqlObject = sqlObjects.stream().filter(item -> item.getField().equals(field)).findFirst().orElse(null);
+                SqlObject sqlObject = sqlObjects.stream().filter(item -> item.getValue().equals(field)).findFirst().orElse(null);
                 if (sqlObject != null) {
                     getSqlObject = getSqlFactory.getClass(sqlObject.getSqlClass());
                     sqlObject.setOption(optionName);
@@ -110,9 +110,9 @@ public class FormatQueryService {
      * @param dtos
      * @return
      */
-    public String orderToString(List<OrderDTO> dtos) {
+    public String orderToString(List<OrderDTO> dtos,String tableName) {
         //读取排序配置类
-        String json = CommonService.readJsonFile("event.json");
+        String json = CommonService.readJsonFile(tableName+".json");
         List<OrderConfig> configs = JSON.parseArray(json, OrderConfig.class);
         String re = "order by ";
         List<String> orders = new ArrayList<>();
@@ -170,7 +170,7 @@ public class FormatQueryService {
                     //判断 参数类型
                     String json = CommonService.readJsonFile(tableName+".json");
                     List<SqlObject> sqlObjects = JSON.parseArray(json, SqlObject.class);
-                    SqlObject sqlObject = sqlObjects.stream().filter(item -> item.getField().equals(field)).findFirst().orElse(null);
+                    SqlObject sqlObject = sqlObjects.stream().filter(item -> item.getValue().equals(field)).findFirst().orElse(null);
                     if (sqlObject != null) {
                         getSqlObjectLocal = getSqlFactory.getClass(sqlObject.getSqlClass());
                         sqlObject.setOption(optionName);
@@ -265,7 +265,7 @@ public class FormatQueryService {
 
         //格式化排序
         if (queryRequest.getOrderDTOList() != null && queryRequest.getOrderDTOList().size() != 0) {
-            String orderSql = this.orderToString(queryRequest.getOrderDTOList());
+            String orderSql = this.orderToString(queryRequest.getOrderDTOList(),tableName);
             sql2 = orderSql;
 
         }

+ 5 - 5
src/main/resources/jsons/event.json

@@ -1,13 +1,13 @@
 [
   {"name":"Id",
-    "type":"String",
+    "type":"Integer",
     "value":"id",
     "field":"id",
     "sqlField": "id",
     "sqlClass": "getComSql",
-    "orderClass": "getComOrder",
-    "groupClass":"getComGroup",
-    "ifSearch":"false",
+    "orderClass": "",
+    "groupClass":"",
+    "ifSearch":"true",
     "ifGroup": "false",
     "ifShow":"true"
   },
@@ -107,7 +107,7 @@
 
   },
   {"name":"应用场景",
-    "type":"Integer",
+    "type":"Array",
     "value":"scenarioId",
     "field": "scenarioId",
     "sqlField": "scenario_id",

+ 0 - 52
src/main/resources/jsons/event_order.json

@@ -1,52 +0,0 @@
-[
-  {
-    "field": "name",
-    "sqlField": "name",
-    "orderClass": "getComOrder"
-  },
-  {
-    "field": "id",
-    "sqlField": "id",
-    "orderClass": "getComOrder"
-  },
-  {
-    "field": "createName",
-    "sqlField": "create_id",
-    "orderClass": "getCreateNameOrder"
-  },
-  {
-    "field": "clientName",
-    "sqlField": "client_id",
-    "orderClass": "getClientNameOrder"
-  },
-  {
-    "field":"createTime",
-    "sqlField": "create_time",
-    "orderClass": "getComOrder"
-  },
-  {
-    "field":"eventDate",
-    "sqlField": "event_date",
-    "orderClass": "getComOrder"
-  },
-  {
-    "field":"eventDate",
-    "sqlField": "event_date",
-    "orderClass": "getComOrder"
-  },
-  {
-    "field":"scenarioName",
-    "sqlField": "scenario_id",
-    "orderClass": "getScenarioNameOrder"
-  },
-  {
-    "field":"reportProjectNum",
-    "sqlField": "event_id",
-    "orderClass": "getEventReportNumOrder"
-  },
-  {
-    "field":"patentProjectNum",
-    "sqlField": "event_id",
-    "orderClass": "getEventProjectNumOrder"
-  }
-]

+ 0 - 42
src/main/resources/jsons/event_sql.json

@@ -1,42 +0,0 @@
-[
-  {
-    "field": "name",
-    "sqlField": "name",
-    "sqlClass": "getLikeSql"
-  },
-  {
-    "field": "id",
-    "sqlField": "id",
-    "sqlClass": "getComSql"
-  },
-  {
-    "field": "createName",
-    "sqlField": "create_id",
-    "sqlClass": "getCreateNameSql"
-  },
-  {
-    "field": "createTime",
-    "sqlField": "create_time",
-    "sqlClass": "getDateTimeSql"
-  },
-  {
-    "field": "eventDate",
-    "sqlField": "event_Date",
-    "sqlClass": "getDateTimeSql"
-  },
-  {
-    "field": "description",
-    "sqlField": "description",
-    "sqlClass": "getLikeSql"
-  },
-  {
-  "field": "scenarioId",
-  "sqlField": "scenario_id",
-  "sqlClass": "getComSql"
-},
-  {
-    "field": "clientName",
-    "sqlField": "client_id",
-    "sqlClass": "getClientNameSql"
-  }
-]

+ 98 - 37
src/main/resources/jsons/product.json

@@ -1,11 +1,11 @@
 [
-  {"name":"Id",
+  {"name":"产品Id",
     "type":"Integer",
-    "value":"id",
+    "value":"product_id",
     "field":"id",
-    "sqlField": "id",
-    "sqlClass": "",
-    "orderClass": "",
+    "sqlField": "product.id",
+    "sqlClass": "getComSql",
+    "orderClass": "getComOrder",
     "groupClass":"",
     "ifSearch":"true",
     "ifGroup": "false",
@@ -13,23 +13,35 @@
   },
   {"name":"产品名称",
     "type":"String",
-    "value":"name",
+    "value":"product_name",
     "field": "name",
-    "sqlField": "name",
-    "sqlClass": "",
-    "orderClass": "",
+    "sqlField": "product.name",
+    "sqlClass": "getLikeSql",
+    "orderClass": "getComOrder",
     "groupClass":"",
     "ifSearch":"true",
     "ifGroup": "false",
     "ifShow":"true"
   },
-  {"name":"参考许可费率",
+  {"name":"公司名称",
+    "type":"String",
+    "value":"product_companyName",
+    "field": "companyName",
+    "sqlField": "product.company_name",
+    "sqlClass": "",
+    "orderClass": "getComOrder",
+    "groupClass":"",
+    "ifSearch":"false",
+    "ifGroup": "false",
+    "ifShow":"true"
+  },
+  {"name":"产品参考许可费率",
     "type":"Double",
-    "value":"licenseRate",
+    "value":"product_licenseRate",
     "field": "licenseRate",
-    "sqlField": "license_rate",
-    "sqlClass": "",
-    "orderClass": "",
+    "sqlField": "product.license_rate",
+    "sqlClass": "getComSql",
+    "orderClass": "getComOrder",
     "groupClass":"",
     "ifSearch":"true",
     "ifGroup": "false",
@@ -37,69 +49,118 @@
   },
   {"name":"上市时间",
     "type":"DateTime",
-    "value":"marketTime",
+    "value":"product_marketTime",
     "field": "marketTime",
-    "sqlField": "market_time",
-    "orderClass": "",
+    "sqlField": "product.market_time",
+    "sqlClass": "getDateTimeSql",
+    "orderClass": "getComOrder",
     "ifSearch":"true",
     "ifGroup": "false",
     "ifShow":"true"
   },
   {"name":"所属产品类别",
     "type":"Integer",
-    "value":"categoryId",
+    "value":"product_categoryId",
     "field": "categoryId",
-    "sqlField": "category_id",
+    "sqlField": "product.category_id",
     "sqlClass": "",
     "orderClass": "",
     "groupClass":"",
     "ifSearch":"true",
     "ifGroup": "false",
-    "ifShow":"true"
+    "ifShow":"false"
   },
   {"name":"可见类型",
     "type":"Integer",
-    "value":"showType",
+    "value":"product_showType",
     "field": "showType",
-    "sqlField": "show_type",
+    "sqlField": "product.show_type",
     "sqlClass": "",
-    "orderClass": "",
+    "orderClass": "getComOrder",
     "groupClass":"",
-    "ifSearch":"true",
+    "ifSearch":"false",
     "ifGroup": "false",
     "ifShow":"true"
   },
   {"name":"描述",
     "type":"String",
-    "value":"description",
+    "value":"product_description",
     "field": "description",
-    "sqlField": "description",
+    "sqlField": "product.description",
     "sqlClass": "",
-    "orderClass": "",
-    "ifSearch":"true",
+    "orderClass": "getComOrder",
+    "ifSearch":"false",
     "ifGroup": "false",
     "ifShow":"true"
   },
-  {"name":"创建人",
+  {"name":"产品创建人",
     "type":"String",
-    "value":"createName",
+    "value":"product_createName",
     "field": "createName",
-    "sqlField": "createId",
-    "sqlClass": "",
-    "orderClass": "",
+    "sqlField": "product.createId",
+    "sqlClass": "getCreateNameSql",
+    "orderClass": "getCreateNameOrder",
     "ifSearch":"true",
     "ifGroup": "false",
     "ifShow":"true"
   },
   {
-    "name":"创建时间",
+    "name":"产品创建时间",
     "type":"DateTime",
-    "value":"createTime",
+    "value":"product_createTime",
     "field":"createTime",
-    "sqlField": "create_time",
+    "sqlField": "product.create_time",
+    "sqlClass": "getDateTimeSql",
+    "orderClass": "getComOrder",
+    "ifSearch":"true",
+    "ifGroup": "false",
+    "ifShow":"false"
+  },
+  {"name":"产品类别Id",
+    "type":"Integer",
+    "value":"category_id",
+    "field":"category_id",
+    "sqlField": "category.id",
+    "sqlClass": "getComSql",
+    "orderClass": "getComOrder",
+    "groupClass":"",
+    "ifSearch":"true",
+    "ifGroup": "false",
+    "ifShow":"false"
+  },
+  {"name":"产品类别名称",
+    "type":"String",
+    "value":"category_name",
+    "field": "category_name",
+    "sqlField": "category.name",
+    "sqlClass": "getLikeSql",
     "orderClass": "",
+    "groupClass":"",
     "ifSearch":"true",
     "ifGroup": "false",
-    "ifShow":"true"
+    "ifShow":"false"
+  },
+  {"name":"产品类别创建人",
+    "type":"String",
+    "value":"category_createName",
+    "field": "createName",
+    "sqlField": "category.create_id",
+    "sqlClass": "getCreateNameSql",
+    "orderClass": "",
+    "ifSearch":"true",
+    "ifGroup": "false",
+    "ifShow":"false"
+  },
+  {
+    "name":"产品类别创建时间",
+    "type":"DateTime",
+    "value":"category_createTime",
+    "field":"createTime",
+    "sqlField": "category.create_time",
+    "orderClass": "getComOrder",
+    "sqlClass": "getDateTimeSql",
+    "ifSearch":"true",
+    "ifGroup": "false",
+    "ifShow":"false"
   }
 ]

+ 91 - 42
src/main/resources/jsons/productCategory.json

@@ -1,11 +1,11 @@
 [
-  {"name":"Id",
+  {"name":"产品类别Id",
     "type":"Integer",
-    "value":"id",
-    "field":"id",
-    "sqlField": "id",
-    "sqlClass": "",
-    "orderClass": "",
+    "value":"category_id",
+    "field":"category_id",
+    "sqlField": "category.id",
+    "sqlClass": "getComSql",
+    "orderClass": "getComOrder",
     "groupClass":"",
     "ifSearch":"true",
     "ifGroup": "false",
@@ -13,81 +13,130 @@
   },
   {"name":"产品类别名称",
     "type":"String",
-    "value":"name",
+    "value":"category_name",
     "field": "name",
-    "sqlField": "name",
-    "sqlClass": "",
-    "orderClass": "",
+    "sqlField": "category.name",
+    "sqlClass": "getLikeSql",
+    "orderClass": "getComOrder",
     "groupClass":"",
     "ifSearch":"true",
     "ifGroup": "false",
     "ifShow":"true"
   },
-  {"name":"参考许可费率",
+  {"name":"产品类别参考许可费率",
     "type":"Double",
-    "value":"licenseRate",
+    "value":"category_licenseRate",
     "field": "licenseRate",
-    "sqlField": "license_rate",
+    "sqlField": "category.license_rate",
+    "sqlClass": "getComSql",
+    "orderClass": "getComOrder",
+    "groupClass":"",
+    "ifSearch":"false",
+    "ifGroup": "false",
+    "ifShow":"true"
+  },
+  {"name":"可见类型",
+    "type":"Integer",
+    "value":"category_showType",
+    "field": "category_showType",
+    "sqlField": "show_type",
     "sqlClass": "",
-    "orderClass": "",
+    "orderClass": "getComOrder",
     "groupClass":"",
+    "ifSearch":"false",
+    "ifGroup": "false",
+    "ifShow":"true"
+  },
+  {"name":"描述",
+    "type":"String",
+    "value":"category_description",
+    "field": "description",
+    "sqlField": "category.description",
+    "sqlClass": "",
+    "orderClass": "getComOrder",
+    "ifSearch":"false",
+    "ifGroup": "false",
+    "ifShow":"true"
+  },
+  {"name":"产品类别创建人",
+    "type":"String",
+    "value":"category_createName",
+    "field": "createName",
+    "sqlField": "category.create_id",
+    "sqlClass": "getCreateNameSql",
+    "orderClass": "getCreateNameOrder",
     "ifSearch":"true",
     "ifGroup": "false",
     "ifShow":"true"
   },
-  {"name":"上市时间",
+  {
+    "name":"产品类别创建时间",
     "type":"DateTime",
-    "value":"marketTime",
-    "field": "marketTime",
-    "sqlField": "market_time",
-    "orderClass": "",
+    "value":"category_createTime",
+    "field":"createTime",
+    "sqlField": "category.create_time",
+    "orderClass": "getComOrder",
+    "sqlClass": "getDateTimeSql",
     "ifSearch":"true",
     "ifGroup": "false",
     "ifShow":"true"
   },
-  {"name":"可见类型",
+  {"name":"产品Id",
     "type":"Integer",
-    "value":"showType",
-    "field": "showType",
-    "sqlField": "show_type",
-    "sqlClass": "",
+    "value":"product_id",
+    "field":"product_id",
+    "sqlField": "product.id",
+    "sqlClass": "getComSql",
     "orderClass": "",
     "groupClass":"",
     "ifSearch":"true",
     "ifGroup": "false",
-    "ifShow":"true"
+    "ifShow":"false"
   },
-  {"name":"描述",
+  {"name":"产品名称",
     "type":"String",
-    "value":"description",
-    "field": "description",
-    "sqlField": "description",
-    "sqlClass": "",
+    "value":"product_name",
+    "field": "product_name",
+    "sqlField": "product.name",
+    "sqlClass": "getLikeSql",
     "orderClass": "",
+    "groupClass":"",
     "ifSearch":"true",
     "ifGroup": "false",
-    "ifShow":"true"
+    "ifShow":"false"
+  },
+  {"name":"产品上市时间",
+    "type":"DateTime",
+    "value":"product_marketTime",
+    "field": "product_marketTime",
+    "sqlField": "product.market_time",
+    "sqlClass": "getDateTimeSql",
+    "orderClass": "",
+    "ifSearch":"true",
+    "ifGroup": "false",
+    "ifShow":"false"
   },
-  {"name":"创建人",
+  {"name":"产品创建人",
     "type":"String",
-    "value":"createName",
-    "field": "createName",
-    "sqlField": "createId",
-    "sqlClass": "",
+    "value":"product_createName",
+    "field": "product_createName",
+    "sqlField": "product.createId",
+    "sqlClass": "getCreateNameSql",
     "orderClass": "",
     "ifSearch":"true",
     "ifGroup": "false",
-    "ifShow":"true"
+    "ifShow":"false"
   },
   {
-    "name":"创建时间",
+    "name":"产品创建时间",
     "type":"DateTime",
-    "value":"createTime",
-    "field":"createTime",
-    "sqlField": "create_time",
+    "value":"product_createTime",
+    "field":"product_createTime",
+    "sqlField": "product.create_time",
+    "sqlClass": "getDateTimeSql",
     "orderClass": "",
     "ifSearch":"true",
     "ifGroup": "false",
-    "ifShow":"true"
+    "ifShow":"false"
   }
 ]

+ 17 - 11
src/main/resources/mapper/ProductCategoryMapper.xml

@@ -2,12 +2,14 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="cn.cslg.pas.mapper.ProductCategoryMapper">
     <!--namespace根据自己需要创建的的mapper的路径和名称填写-->
-    <select id="getProductCategory"  resultType="cn.cslg.pas.common.vo.business.ProductCategoryVO">
-        select id,name,license_rate as licenseRate,market_time as marketTime,show_type as showType,description,create_id as createId,create_time as createTime, tenant from product_category
-
+    <select id="getProductCategory" resultType="cn.cslg.pas.common.vo.business.ProductCategoryVO">
+        select distinct category.id as id,category.name as name,category.license_rate as licenseRate,category.show_type as
+        showType,category.description,category.create_id as createId,category.create_time as createTime, category.tenant from product_category as category
+        left join product as product
+    on category.id = product.category_id
         <if test="sql1!=''">
 
-            where    ${sql1}
+            where ${sql1}
         </if>
 
 
@@ -15,21 +17,25 @@
     </select>
 
     <select id="getProductCategoryCount" resultType="java.lang.Long">
-        select count(*) from product_category
+       select count(*) from (select distinct category.id as id
+        from product_category as category
+        left join product as product
+        on category.id = product.category_id
         <if test="sql!=''">
 
-            where    ${sql}
+            where ${sql}
         </if>
+        ) as c
     </select>
-    <select id="getGroups"  resultType="java.lang.String">
-        select ${selectField} from  ${tableName}
+    <select id="getGroups" resultType="java.lang.String">
+        select ${selectField} from ${tableName}
         <if test="sqls.get(0)!=''">
-            where    ${sqls.get(0)}
+            where ${sqls.get(0)}
         </if>
-        group by ${groupField} ${sqls.get(1)}  ${sqls.get(2)}
+        group by ${groupField} ${sqls.get(1)} ${sqls.get(2)}
     </select>
 
-    <select id="getGroupsCount"  resultType="java.lang.Long">
+    <select id="getGroupsCount" resultType="java.lang.Long">
         select count(*) from (select ${selectField} from ${tableName}
         <if test="sqls.get(0)!=''">
             where ${sqls.get(0)}

+ 32 - 0
src/main/resources/mapper/ProductMapper.xml

@@ -0,0 +1,32 @@
+<?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.cslg.pas.mapper.ProductMapper">
+    <!--namespace根据自己需要创建的的mapper的路径和名称填写-->
+    <select id="getProduct" resultType="cn.cslg.pas.common.vo.business.ProductVO">
+        select product.id as id ,product.name as name , product.license_rate as licenseRate
+        ,product.category_id as categoryId,product.show_type as showType
+        ,product.description as description,
+        product.create_id as createId, product.tenant_id as tenantId,
+        product.market_time as
+        marketTime,product.create_time as createTime,
+        product.company_name,product.description as description
+        from
+        product as product left join product_category as category
+        on category.id = product.category_id
+        <if test="sql1!=''">
+            where ${sql1}
+        </if>
+        ${sql2} ${sql3}
+    </select>
+
+    <select id="getProductCount" resultType="java.lang.Long">
+        select count(*)
+        from product as product left join product_category as category
+        on category.id = product.category_id
+        <if test="sql!=''">
+
+            where ${sql}
+        </if>
+
+    </select>
+</mapper>

+ 33 - 0
src/test/java/cn/cslg/pas/service/ProductCategoryServiceTests.java

@@ -4,6 +4,8 @@ import cn.cslg.pas.common.model.request.OrderDTO;
 import cn.cslg.pas.common.model.request.StringRequest;
 import cn.cslg.pas.common.utils.Response;
 import cn.cslg.pas.controller.ProductCategoryController;
+import cn.cslg.pas.controller.ProductController;
+import org.junit.Assert;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
@@ -19,6 +21,9 @@ import java.util.List;
 public class ProductCategoryServiceTests {
     @Autowired
     private ProductCategoryController productCategoryController;
+
+    @Autowired
+    private ProductController productController;
     @Test
     void test() throws Exception {
         StringRequest queryRequest = new StringRequest();
@@ -28,4 +33,32 @@ public class ProductCategoryServiceTests {
         Response response = productCategoryController.queryProductCategory(queryRequest);
         System.out.println(response); }
 
+    @Test
+    void query() throws Exception {
+        StringRequest queryRequest = new StringRequest();
+        queryRequest.setSearchQuery("category_id=1");
+        queryRequest.setCurrent(Long.parseLong("1"));
+        queryRequest.setSize(Long.parseLong("10"));
+        Response response = productCategoryController.queryProductCategory(queryRequest);
+        Assert.assertEquals(200,Integer.parseInt(response.getCode().toString()));
+    }
+    @Test
+    void query2() throws Exception {
+        StringRequest queryRequest = new StringRequest();
+        queryRequest.setSearchQuery("product_name = 类别");
+        queryRequest.setCurrent(Long.parseLong("1"));
+        queryRequest.setSize(Long.parseLong("10"));
+        Response response = productCategoryController.queryProductCategory(queryRequest);
+        Assert.assertEquals(200,Integer.parseInt(response.getCode().toString()));
+    }
+
+    @Test
+    void query3() throws Exception {
+        StringRequest queryRequest = new StringRequest();
+        queryRequest.setSearchQuery("");
+        queryRequest.setCurrent(Long.parseLong("1"));
+        queryRequest.setSize(Long.parseLong("10"));
+        Response response = productController.queryProduct(queryRequest);
+        Assert.assertEquals(200,Integer.parseInt(response.getCode().toString()));
+    }
 }