Эх сурвалжийг харах

商品参数连表查询成功

Sakana 1 долоо хоног өмнө
parent
commit
0865165777

+ 1 - 1
edu-travel-remote/edu-travel-remote-commodity/src/main/java/edu/travel/remote/vo/ShopParametersVo.java

@@ -34,7 +34,7 @@ public class ShopParametersVo extends BaseEntity {
     /**
      * 国家id
      */
-    private Long countryId;
+    private String countryId;
     /**
      * Map
      */

+ 2 - 2
edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/entity/ShopParameters.java

@@ -29,7 +29,7 @@ public class ShopParameters extends BaseEntity {
      * 商品参数ID
      */
     @TableId(value = "id", type = IdType.ASSIGN_ID)
-    private Long id;
+    private String id;
 
     /**
      * 商品参数名称
@@ -46,7 +46,7 @@ public class ShopParameters extends BaseEntity {
      * 国家id
      */
     @TableField(value = "country_id")
-    private Long countryId;
+    private String countryId;
     /**
      * 连表shopProductParameters表
      */

+ 15 - 12
edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/service/impl/ShopParametersServiceImpl.java

@@ -2,7 +2,6 @@ package edu.travel.commodity.service.impl;
 
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import edu.travel.adapter.service.country.CountryAdapter;
@@ -92,12 +91,12 @@ public class ShopParametersServiceImpl extends SysServiceImpl<ShopParametersMapp
                 .collect(Collectors.toList());
 
         // Step 3: 提取国家服务ID
-        Set<Long> countryServeIds = shopParametersList.stream()
+        Set<String> countryServeIds = shopParametersList.stream()
                 .map(ShopParameters::getCountryId)
                 .collect(Collectors.toSet());
 
         // Step 4: 查询国家信息
-        Map<String, BaseCountryServeVo> countryMap = fetchCountryData(countryServeIds);
+        Map<String, ShopParametersVo> countryMap = fetchCountryData(countryServeIds);
 
         // Step 5: 将国家信息放入参数列表中
         for (ShopParameters shopParameters : shopParametersList) {
@@ -125,7 +124,7 @@ public class ShopParametersServiceImpl extends SysServiceImpl<ShopParametersMapp
     private ShopParameters convertVoToEntity(ShopParametersVo parametersVo) {
         ShopParameters parameters = new ShopParameters();
         // 复制各个属性
-        parameters.setId(Long.valueOf(parametersVo.getId()));
+        parameters.setId(parametersVo.getId());
         parameters.setParametersName(parametersVo.getParametersName());
         parameters.setIsNecessary(parametersVo.getIsNecessary());
         parameters.setProject(parametersVo.getProject());
@@ -141,14 +140,18 @@ public class ShopParametersServiceImpl extends SysServiceImpl<ShopParametersMapp
     /**
      * 提取国家数据
      */
-    private Map<String, BaseCountryServeVo> fetchCountryData(Set<Long> countryServeIds) {
-        Map<String, BaseCountryServeVo> countryMap = new HashMap<>();
-        if (!countryServeIds.isEmpty()) {
-            for (Long countryServeId : countryServeIds) {
-                RPCBaseResponse<BaseCountryServeVo> response = countryAdapter.getFormId(String.valueOf(countryServeId));
-                if (response != null && response.getData() != null) {
-                    countryMap.put(String.valueOf(countryServeId), response.getData());
-                }
+    private Map<String, ShopParametersVo> fetchCountryData(Set<String> countryServeIds) {
+        Map<String, ShopParametersVo> countryMap = new HashMap<>();
+        for (String countryServeId : countryServeIds){
+            BaseCountryServeVo country = countryAdapter.getFormId(countryServeId).getData();
+            if (country != null){
+                ShopParametersVo shopParametersVo = new ShopParametersVo();
+                shopParametersVo.setCountryId(countryServeId);
+                shopParametersVo.setMap(new HashMap<>());
+                shopParametersVo.getMap().put("countryNameZh", country.getCountryNameZh());
+                shopParametersVo.getMap().put("countryNameEn", country.getCountryNameEn());
+                shopParametersVo.getMap().put("countryNameLocal", country.getCountryNameLocal());
+                countryMap.put(countryServeId, shopParametersVo);
             }
         }
         return countryMap;

+ 3 - 3
edu-travel-service/edu-travel-service-commodity/src/main/java/edu/travel/commodity/web/ShopParametersController.java

@@ -87,7 +87,7 @@ public class ShopParametersController extends BaseController<ShopParameters> imp
         ShopParameters shopParameters = parametersRPCBaseResponse.getData();
 
         //提取countryID
-        Long countryId = shopParameters.getCountryId();
+        String countryId = shopParameters.getCountryId();
 
         //调用方法获取国家信息
         RPCBaseResponse<BaseCountryServeVo> countryInfoResponse = countryAdapter.getFormId(countryId.toString());
@@ -174,7 +174,7 @@ public class ShopParametersController extends BaseController<ShopParameters> imp
             for (ShopParameters parameters : shopParametersList) {
                 ShopParametersVo parametersVo = new ShopParametersVo();
                 BeanUtils.copyProperties(parameters, parametersVo);
-                parametersMap.put(parameters.getId(), parametersVo);
+                parametersMap.put(Long.valueOf(parameters.getId()), parametersVo);
 
                 // Step 5: 利用 countryId 查找相关数据并存储到 countryDataMap 中
                 if (parameters.getCountryId() != null) {
@@ -184,7 +184,7 @@ public class ShopParametersController extends BaseController<ShopParameters> imp
                     if (countryResponse != null && countryResponse.getData() != null) {
                         BaseCountryServeVo serveVo = countryResponse.getData();
                         BaseCountryVo countryData = convertToBaseCountryVo(serveVo); // 进行转换
-                        countryDataMap.put(parameters.getCountryId(), countryData);
+                        countryDataMap.put(Long.valueOf(parameters.getCountryId()), countryData);
                     }
                 }
             }

+ 1 - 1
edu-travel-service/edu-travel-service-country/src/main/java/edu/travel/country/service/impl/BaseCountryServeServiceImpl.java

@@ -61,7 +61,7 @@ public RPCBaseResponse<IPage<BaseCountryServe>> getCountryServeCurrencyPageForm(
     public RPCBaseResponse<BaseCountryServeStatusVo> updateServeStatus(BaseCountryServeStatusDto entity) {
     //检查参数是否合法
         if (entity.getId() == null) {
-            return new RPCBaseResponse<>(400, "Currency id is not null", null);
+            return new RPCBaseResponse<>(400, "Country id is not null", null);
         }
         //创建对象,用于更新
         BaseCountryServe baseCountryServe = new BaseCountryServe();