浏览代码

fixed 获取商品列表接口优化

fushengqian 1 月之前
父节点
当前提交
1e3a2522b1

+ 36 - 7
fuint-application/src/main/java/com/fuint/common/service/impl/GoodsServiceImpl.java

@@ -180,6 +180,33 @@ public class GoodsServiceImpl extends ServiceImpl<MtGoodsMapper, MtGoods> implem
         } else {
             lambdaQueryWrapper.orderByAsc(MtGoods::getSort, MtGoods::getId);
         }
+        lambdaQueryWrapper.select(
+                MtGoods::getId,
+                MtGoods::getGoodsNo,
+                MtGoods::getMerchantId,
+                MtGoods::getStoreId,
+                MtGoods::getName,
+                MtGoods::getCanUsePoint,
+                MtGoods::getCateId,
+                MtGoods::getCostPrice,
+                MtGoods::getCouponIds,
+                MtGoods::getCreateTime,
+                MtGoods::getUpdateTime,
+                MtGoods::getInitSale,
+                MtGoods::getIsMemberDiscount,
+                MtGoods::getIsSingleSpec,
+                MtGoods::getPlatform,
+                MtGoods::getPrice,
+                MtGoods::getLinePrice,
+                MtGoods::getImages,
+                MtGoods::getLogo,
+                MtGoods::getCostPrice,
+                MtGoods::getSort,
+                MtGoods::getStatus,
+                MtGoods::getStock,
+                MtGoods::getType,
+                MtGoods::getOperator,
+                MtGoods::getWeight);
         Page<MtGoods> pageHelper = PageHelper.startPage(paginationRequest.getCurrentPage(), paginationRequest.getPageSize());
         List<MtGoods> goodsList = mtGoodsMapper.selectList(lambdaQueryWrapper);
         List<GoodsDto> dataList = new ArrayList<>();
@@ -209,12 +236,12 @@ public class GoodsServiceImpl extends ServiceImpl<MtGoodsMapper, MtGoods> implem
             item.setPrice(mtGoods.getPrice());
             item.setLinePrice(mtGoods.getLinePrice());
             item.setSalePoint(mtGoods.getSalePoint());
-            item.setDescription(mtGoods.getDescription());
             item.setCreateTime(mtGoods.getCreateTime());
             item.setUpdateTime(mtGoods.getUpdateTime());
             item.setStatus(mtGoods.getStatus());
             item.setOperator(mtGoods.getOperator());
             item.setWeight(mtGoods.getWeight());
+            item.setSort(mtGoods.getSort());
             dataList.add(item);
         }
 
@@ -685,12 +712,14 @@ public class GoodsServiceImpl extends ServiceImpl<MtGoodsMapper, MtGoods> implem
         String specIds = goodsSku.getSpecIds();
         String specIdArr[] = specIds.split("-");
         for (String specId : specIdArr) {
-            MtGoodsSpec mtGoodsSpec = mtGoodsSpecMapper.selectById(Integer.parseInt(specId));
-            GoodsSpecValueDto dto = new GoodsSpecValueDto();
-            dto.setSpecValueId(mtGoodsSpec.getId());
-            dto.setSpecName(mtGoodsSpec.getName());
-            dto.setSpecValue(mtGoodsSpec.getValue());
-            result.add(dto);
+             MtGoodsSpec mtGoodsSpec = mtGoodsSpecMapper.selectById(Integer.parseInt(specId));
+             if (mtGoodsSpec != null) {
+                 GoodsSpecValueDto dto = new GoodsSpecValueDto();
+                 dto.setSpecValueId(mtGoodsSpec.getId());
+                 dto.setSpecName(mtGoodsSpec.getName());
+                 dto.setSpecValue(mtGoodsSpec.getValue());
+                 result.add(dto);
+             }
         }
 
         return result;

+ 0 - 1
fuint-repository/src/main/java/com/fuint/repository/mapper/MtGoodsMapper.java

@@ -5,7 +5,6 @@ import com.fuint.repository.bean.GoodsTopBean;
 import com.fuint.repository.model.MtGoods;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
-
 import java.util.Date;
 import java.util.List;
 

+ 7 - 2
fuint-repository/src/main/resources/mapper/MtGoodsMapper.xml

@@ -1,8 +1,13 @@
 <?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="com.fuint.repository.mapper.MtGoodsMapper">
+    <sql id="Base_Column_List">
+        `ID`, `TYPE`, `MERCHANT_ID`, `STORE_ID`, `NAME`, `CATE_ID`, `GOODS_NO`, `PLATFORM`, `IS_SINGLE_SPEC`,
+        `LOGO`, `PRICE`, `LINE_PRICE`, `COST_PRICE`, `STOCK`, `WEIGHT`, `COUPON_IDS`, `INIT_SALE`, `SALE_POINT`,
+        `CAN_USE_POINT`, `IS_MEMBER_DISCOUNT`, `SORT`, `CREATE_TIME`, `UPDATE_TIME`, `OPERATOR`, `STATUS`
+    </sql>
     <select id="getStoreGoodsList" resultType="com.fuint.repository.model.MtGoods">
-        select * from mt_goods t where (t.STORE_ID = #{storeId} or (t.STORE_ID = 0 AND t.id IN( SELECT s.GOODS_ID FROM mt_store_goods s WHERE s.STORE_ID = #{storeId} AND s.STATUS = 'A')))
+        select <include refid="Base_Column_List" /> from mt_goods t where (t.STORE_ID = #{storeId} or (t.STORE_ID = 0 AND t.id IN( SELECT s.GOODS_ID FROM mt_store_goods s WHERE s.STORE_ID = #{storeId} AND s.STATUS = 'A')))
         <if test="cateId != null and cateId > 0">
             AND t.CATE_ID = #{cateId}
         </if>
@@ -18,7 +23,7 @@
     </select>
 
     <select id="searchStoreGoodsList" resultType="com.fuint.repository.model.MtGoods">
-        select * from mt_goods t where t.STATUS = 'A'
+        select <include refid="Base_Column_List" /> from mt_goods t where t.STATUS = 'A'
         <if test="merchantId != null and merchantId > 0">
             AND t.MERCHANT_ID = #{merchantId}
         </if>