Parcourir la source

feat: 商品和套餐添加所属公司

xdd il y a 1 mois
Parent
commit
7596c6b79a

+ 1 - 1
fs-service-system/src/main/java/com/fs/company/cache/impl/ICompanyCacheServiceImpl.java

@@ -23,7 +23,7 @@ public class ICompanyCacheServiceImpl implements ICompanyCacheService {
             .build();
     private static final Cache<Long, String> COMPANY_NAME_CACHE = Caffeine.newBuilder()
             .maximumSize(1000)
-            .expireAfterWrite(3, TimeUnit.MINUTES)
+            .expireAfterWrite(7, TimeUnit.DAYS)
             .build();
     @Override
     public Company selectCompanyById(Long companyId) {

+ 32 - 2
fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreProductServiceImpl.java

@@ -14,6 +14,7 @@ import com.fs.common.BeanCopyUtils;
 import com.fs.common.core.domain.R;
 import com.fs.common.exception.CustomException;
 import com.fs.common.utils.DateUtils;
+import com.fs.company.cache.ICompanyCacheService;
 import com.fs.store.domain.*;
 import com.fs.store.dto.ProductArrtDTO;
 import com.fs.store.dto.ProductAttrCountDto;
@@ -54,6 +55,9 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
     private FsStoreProductPackageMapper fsStoreProductPackageMapper;
     @Autowired
     private FsStoreProductGroupMapper fsStoreProductGroupMapper;
+
+    @Autowired
+    private ICompanyCacheService companyCacheService;
     /**
      * 查询商品
      *
@@ -130,12 +134,38 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
 
     @Override
     public List<FsStoreProductListVO> selectFsStoreProductListVO(FsStoreProduct fsStoreProduct) {
-        return fsStoreProductMapper.selectFsStoreProductListVO(fsStoreProduct);
+        List<FsStoreProductListVO> fsStoreProductListVOS = fsStoreProductMapper.selectFsStoreProductListVO(fsStoreProduct);
+        List<String> companyNameList = new ArrayList<>();
+        for (FsStoreProductListVO item : fsStoreProductListVOS) {
+            if(StringUtils.isNotBlank(item.getCompanyIds())){
+                String[] split = item.getCompanyIds().split(",");
+
+                for (String companyId : split) {
+                    String companyName = companyCacheService.selectCompanyNameById(Long.valueOf(companyId));
+                    companyNameList.add(companyName);
+                }
+                item.setCompanyName(String.join(",",companyNameList));
+            }
+        }
+        return fsStoreProductListVOS;
     }
 
     @Override
     public List<FsStoreProductListVO> selectFsStoreProductBarCodeListVO(FsStoreProduct fsStoreProduct) {
-        return fsStoreProductMapper.selectFsStoreProductBarCodeListVO(fsStoreProduct);
+        List<FsStoreProductListVO> fsStoreProductListVOS = fsStoreProductMapper.selectFsStoreProductBarCodeListVO(fsStoreProduct);
+        List<String> companyNameList = new ArrayList<>();
+        for (FsStoreProductListVO item : fsStoreProductListVOS) {
+            if(StringUtils.isNotBlank(item.getCompanyIds())){
+                String[] split = item.getCompanyIds().split(",");
+
+                for (String companyId : split) {
+                    String companyName = companyCacheService.selectCompanyNameById(Long.valueOf(companyId));
+                    companyNameList.add(companyName);
+                }
+                item.setCompanyName(String.join(",",companyNameList));
+            }
+        }
+        return fsStoreProductListVOS;
     }
 
     @Override

+ 10 - 1
fs-service-system/src/main/java/com/fs/store/vo/FsStoreProductListVO.java

@@ -7,7 +7,7 @@ import java.math.BigDecimal;
 @Data
 /**
  * 商品对象 fs_store_product
- * 
+ *
  * @author fs
  * @date 2022-03-15
  */
@@ -69,4 +69,13 @@ public class FsStoreProductListVO  implements Serializable
 
     private String cateName;
 
+    /**
+     * 公司列表
+     */
+    private String companyIds;
+
+    /**
+     * 所属公司
+     */
+    private String companyName;
 }