chenyu 2 роки тому
батько
коміт
756d168ab8

+ 7 - 7
PAS/src/main/java/cn/cslg/pas/service/impl/ProductServiceImpl.java

@@ -238,13 +238,13 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
             List<ProductGroupVO> productGroupVOS;
             if (groupBy.equals("product_category_id")) {
                 productGroupVOS = productMapper.queryByGroupProductCategoryId(productQueryPageDTO);
-                for (ProductGroupVO productGroupVO : productGroupVOS) {
-                    ProductVO productVO = productGroupVO.getProducts().get(0);
-                    if (productVO != null) {
-                        String productCategoryName = productVO.getProductCategory().getProductCategoryName();
-                        productGroupVO.setProductCategoryName(productCategoryName);
-                    }
-                }
+//                for (ProductGroupVO productGroupVO : productGroupVOS) {
+//                    ProductVO productVO = productGroupVO.getProducts().get(0);
+//                    if (productVO != null) {
+//                        String productCategoryName = productVO.getProductCategory().getProductCategoryName();
+//                        productGroupVO.setProductCategoryName(productCategoryName);
+//                    }
+//                }
             } else {
                 productGroupVOS = productMapper.queryByGroupCompanyName(productQueryPageDTO);
             }

+ 8 - 4
PAS/src/main/resources/mapper/ProductMapper.xml

@@ -162,7 +162,7 @@
                     select="query3" column="p_id">
         </collection>
         <collection property="productCategory" ofType="cn.cslg.pas.common.model.vo.ProductCategoryVO"
-                    select="query4" column="product_category_id">
+                    select="query4" column="{pc_id=product_category_id}">
         </collection>
     </resultMap>
 
@@ -197,7 +197,7 @@
                license_rate,
                create_person_name
         from product_category
-        where id = #{product_category_id}
+        where id = #{pc_id}
     </select>
 
     <resultMap id="query4Map" type="cn.cslg.pas.common.model.vo.ProductCategoryVO">
@@ -229,8 +229,11 @@
     <!--List<ProductGroupVO> queryByGroupProductCategoryId(ProductQueryPageDTO productQueryPageDTO);-->
     <select id="queryByGroupProductCategoryId" resultMap="queryByGroupProductCategoryIdMap">
         select product_category_id pci,
-        #{orderBy} orderBy, #{orderType} orderType
-        from product
+        product_category_name,
+        #{orderBy} orderBy,
+        #{orderType} orderType
+        from product p
+        join product_category pc on p.product_category_id = pc.id
         <where>
             <if test="productName != null">
                 and product_name like '%${productName}%'
@@ -257,6 +260,7 @@
 
     <resultMap id="queryByGroupProductCategoryIdMap" type="cn.cslg.pas.common.model.vo.ProductGroupVO">
         <result column="product_category_id" property="productCategoryId"/>
+        <result column="product_category_name" property="productCategoryName"/>
         <collection property="products" ofType="cn.cslg.pas.common.model.vo.ProductVO"
                     select="queryByGroupProductCategoryId2" column="{pci=pci, orderBy=orderBy, orderType=orderType}">
         </collection>