Browse Source

merchant product name change source

guozhaoshun 6 years ago
parent
commit
671925bb7c

+ 3 - 3
rankin-product-service/src/main/java/cn/rankin/productservice/controller/cms/MerchantProductController.java

@@ -86,14 +86,14 @@ public class MerchantProductController {
         return merchantProductService.mountTags(productId, merchantId, tagIdList);
     }
 
-    @RequestMapping(value = "/2/list", method = RequestMethod.POST)
+    @RequestMapping(value = "/list2", method = RequestMethod.POST)
     public APIResult<List<MerchantProduct>> getList(@RequestBody List<String> productIdList, @RequestParam("merchantId") String merchantId) {
-        return merchantProductService.findByPidList(productIdList, merchantId);
+        return merchantProductService.findByPidList_bak(productIdList, merchantId);
     }
 
     @RequestMapping(value = "/list", method = RequestMethod.POST)
     public APIResult<List<MerchantProduct>> getList2(@RequestBody List<String> productIdList, @RequestParam("merchantId") String merchantId) {
-        List<MerchantProduct> merchantProductList = merchantProductService.findByPidList2(productIdList, merchantId);
+        List<MerchantProduct> merchantProductList = merchantProductService.findByPidList(productIdList, merchantId);
         return APIResult.ok(merchantProductList);
     }
 

+ 5 - 0
rankin-product-service/src/main/java/cn/rankin/productservice/repository/CourseRepository.java

@@ -15,6 +15,11 @@ public interface CourseRepository extends BasicJpaRepository<Course, String> {
     @Query(value = "select c from Course c where c.id in (?1) and c.status = ?2")
     List<Course> findByIds(List<String> ids, BaseStatusEnum status);
 
+
+    @Query(value = "select c from Course c where c.id = ?1 ")
+    Course findCourseById(String id);
+
+
     @Modifying
     @Query(value = "update Course c set c.status = 1 where c.id = ?1")
     Integer deleteById(String id);

+ 4 - 0
rankin-product-service/src/main/java/cn/rankin/productservice/repository/PackageRepository.java

@@ -12,4 +12,8 @@ public interface PackageRepository extends BasicJpaRepository<Package, String> {
     @Modifying
     @Query(value = "update Package p set p.status = 1 where p.id = ?1")
     Integer deleteById(String id);
+
+    @Query(value = "select p from  Package p  where p.id = ?1")
+    Package findPackageById(String id);
+
 }

+ 3 - 0
rankin-product-service/src/main/java/cn/rankin/productservice/repository/SupportRepository.java

@@ -17,6 +17,9 @@ public interface SupportRepository extends BasicJpaRepository<Support, String> {
     @Query(value = "select s from Support s where s.id in (:ids) and s.status = :status")
     List<Support> findByIds(@Param("ids") List<String> ids, @Param("status") BaseStatusEnum status);
 
+    @Query(value = "select s from Support s where s.id = :id")
+    Support findSupportById(@Param("id") String id);
+
     @Transactional
     @Modifying
     @Query(value = "update Support s set s.status = 1 where s.id = :id")

+ 2 - 2
rankin-product-service/src/main/java/cn/rankin/productservice/service/CourseService.java

@@ -63,8 +63,8 @@ public class CourseService {
         return APIResult.ok(course);
     }
 
-    public Course getCourse2(String courseId) {
-        Course course = courseRepository.find(courseId);
+    public Course findCourseById(String courseId) {
+        Course course = courseRepository.findCourseById(courseId);
         if (course == null) {
             return null;
         }

+ 3 - 3
rankin-product-service/src/main/java/cn/rankin/productservice/service/MerchantProductService.java

@@ -134,7 +134,7 @@ public class MerchantProductService {
             String productId = product.getPid();
 
             Map<String, Object> productMap = productService.getProduct(productId);
-            merchantProduct.setName(String.valueOf(productMap.get("name")));
+            product.setName(String.valueOf(productMap.get("name")));
 
             String merchantId = product.getMerchantId();
             String key = String.format("%s_%s", productId, merchantId);
@@ -242,7 +242,7 @@ public class MerchantProductService {
         }
     }
 
-    public APIResult<List<MerchantProduct>> findByPidList(List<String> productIdList, String merchantId) {
+    public APIResult<List<MerchantProduct>> findByPidList_bak(List<String> productIdList, String merchantId) {
 
         if (CollectionUtils.isEmpty(productIdList)) {
             return APIResult.ok(new ArrayList<>());
@@ -279,7 +279,7 @@ public class MerchantProductService {
     }
 
 
-    public List<MerchantProduct> findByPidList2(List<String> productIdList, String merchantId) {
+    public List<MerchantProduct> findByPidList(List<String> productIdList, String merchantId) {
 
         if (CollectionUtils.isEmpty(productIdList)) {
             return new ArrayList<>();

+ 2 - 2
rankin-product-service/src/main/java/cn/rankin/productservice/service/PackageService.java

@@ -56,8 +56,8 @@ public class PackageService {
         return APIResult.ok(pkg);
     }
 
-    public Package getPackage2(String pkgId) {
-        Package pkg = packageRepository.find(pkgId);
+    public Package findPackageById(String pkgId) {
+        Package pkg = packageRepository.findPackageById(pkgId);
         if (pkg == null) {
             return null;
         }

+ 6 - 5
rankin-product-service/src/main/java/cn/rankin/productservice/service/ProductService.java

@@ -99,23 +99,23 @@ public class ProductService {
 
         ProductTypeEnum type = product.getType();
         if (ProductTypeEnum.COURSE.equals(type)){
-            Course entity = courseService.getCourse2(productId);
+            Course entity = courseService.findCourseById(productId);
             if(null == entity){
                 return null;
             }
             result = BeanUtil.convertToMap(entity, true);
             result.put("type", ProductTypeEnum.COURSE);
-            result.put("name", result.get("title") +"|"+result.get("subTitle"));
+            result.put("name", result.get("title") +" | "+result.get("subTitle"));
         }else if (ProductTypeEnum.SUPPORT.equals(type)) {
-            Support entity = supportService.getSupport2(productId);
+            Support entity = supportService.findSupportById(productId);
             if(null == entity){
                 return null;
             }
             result = BeanUtil.convertToMap(entity, true);
             result.put("type", ProductTypeEnum.SUPPORT);
-            result.put("name", result.get("title") +"|"+result.get("subTitle"));
+            result.put("name", result.get("title") +" | "+result.get("subTitle"));
         }else if (ProductTypeEnum.PACKAGE.equals(type)) {
-            Package entity = packageService.getPackage2(productId);
+            Package entity = packageService.findPackageById(productId);
             if(null == entity){
                 return null;
             }
@@ -128,6 +128,7 @@ public class ProductService {
             }
             result = BeanUtil.convertToMap(entity, true);
             result.put("type", ProductTypeEnum.TRAINING);
+            result.put("name", result.get("title"));
 
         }
 

+ 2 - 2
rankin-product-service/src/main/java/cn/rankin/productservice/service/SupportService.java

@@ -93,8 +93,8 @@ public class SupportService {
         return APIResult.ok(support);
     }
 
-    public Support getSupport2(String id) {
-        Support support = supportRepository.find(id);
+    public Support findSupportById(String id) {
+        Support support = supportRepository.findSupportById(id);
         if (support == null) {
             return null;
         }