Browse Source

training.get only return training entity

xuchaolang 6 years ago
parent
commit
c35e78559c

+ 4 - 1
rankin-product-service/src/main/java/cn/rankin/productservice/service/ProductService.java

@@ -14,6 +14,7 @@ import cn.rankin.data.api.product.entity.Package;
 import cn.rankin.productservice.code.ProductServiceAPICode;
 import cn.rankin.productservice.repository.MerchantProductRepository;
 import cn.rankin.productservice.repository.ProductRepository;
+import cn.rankin.productservice.utils.DTOConverter;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -73,7 +74,9 @@ public class ProductService {
         }else if (ProductTypeEnum.PACKAGE.equals(type)) {
             return packageService.getPackage(productId);
         }else if (ProductTypeEnum.TRAINING.equals(type)) {
-            return trainingService.get(productId);
+            Training entity =  trainingService.get(productId);
+            Product productEntity = DTOConverter.convert(entity);
+            APIResult.ok(productEntity);
         }
 
 

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

@@ -34,16 +34,12 @@ public class TrainingService {
         return APIResult.ok(result);
     }
 
-    public APIResult get(String pid){
+    public Training get(String pid){
         /*
         TODO
          */
         Training entity = repo.find(pid);
-        if (null == entity){
-            return APIResult.error(APICode.NOT_EXISTS);
-        }
-
-        return APIResult.ok(entity);
+        return entity;
     }
 
     @Transactional