|
@@ -8,10 +8,9 @@ import cn.rankin.common.utils.util.JpaSortUtil;
|
|
|
import cn.rankin.data.api.product.dto.CourseDTO;
|
|
|
import cn.rankin.data.api.product.dto.PackageDTO;
|
|
|
import cn.rankin.data.api.product.dto.SupportDTO;
|
|
|
-import cn.rankin.data.api.product.entity.Course;
|
|
|
+import cn.rankin.data.api.product.dto.TrainingDTO;
|
|
|
+import cn.rankin.data.api.product.entity.*;
|
|
|
import cn.rankin.data.api.product.entity.Package;
|
|
|
-import cn.rankin.data.api.product.entity.Product;
|
|
|
-import cn.rankin.data.api.product.entity.Support;
|
|
|
import cn.rankin.productservice.code.ProductServiceAPICode;
|
|
|
import cn.rankin.productservice.repository.MerchantProductRepository;
|
|
|
import cn.rankin.productservice.repository.ProductRepository;
|
|
@@ -42,6 +41,9 @@ public class ProductService {
|
|
|
@Autowired
|
|
|
private PackageService packageService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TrainingService trainingService;
|
|
|
+
|
|
|
public APIResult<Page<Product>> search(Product product, Integer pageNo, Integer pageSize, LinkedHashMap<String, BaseOrderEnum> sort) {
|
|
|
Long count = productRepository.count(product);
|
|
|
Page<Product> page = new Page<>(count, pageNo, pageSize);
|
|
@@ -70,8 +72,11 @@ public class ProductService {
|
|
|
return supportService.getSupport(productId);
|
|
|
}else if (ProductTypeEnum.PACKAGE.equals(type)) {
|
|
|
return packageService.getPackage(productId);
|
|
|
+ }else if (ProductTypeEnum.TRAINING.equals(type)) {
|
|
|
+ return trainingService.get(productId);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
return APIResult.error(ProductServiceAPICode.NOT_EXISTS);
|
|
|
}
|
|
|
|
|
@@ -95,7 +100,9 @@ public class ProductService {
|
|
|
supportService.delete(productId);
|
|
|
}else if (type.equals(ProductTypeEnum.PACKAGE)){
|
|
|
packageService.deletePackage(productId);
|
|
|
- }else {
|
|
|
+ }else if (type.equals(ProductTypeEnum.TRAINING)){
|
|
|
+ trainingService.delete(productId);
|
|
|
+ }else{
|
|
|
}
|
|
|
|
|
|
merchantProductRepository.deleteByPid(productId);
|
|
@@ -147,6 +154,17 @@ public class ProductService {
|
|
|
}
|
|
|
|
|
|
@Transactional
|
|
|
+ public APIResult<Training> create(TrainingDTO trainingDTO) {
|
|
|
+ APIResult<Training> targetAPIResult = trainingService.create(trainingDTO);
|
|
|
+ if (targetAPIResult.getSuccess()) {
|
|
|
+ Product product = convert(targetAPIResult.getData());
|
|
|
+ productRepository.save(product);
|
|
|
+ }
|
|
|
+
|
|
|
+ return targetAPIResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
public APIResult<Support> update(SupportDTO supportDTO) {
|
|
|
APIResult<Support> supportAPIResult = supportService.update(supportDTO);
|
|
|
if (supportAPIResult.getSuccess()) {
|
|
@@ -168,6 +186,17 @@ public class ProductService {
|
|
|
return packageAPIResult;
|
|
|
}
|
|
|
|
|
|
+ @Transactional
|
|
|
+ public APIResult<Training> update(TrainingDTO trainingDTO) {
|
|
|
+ APIResult<Training> targetAPIResult = trainingService.update(trainingDTO);
|
|
|
+ if (targetAPIResult.getSuccess()) {
|
|
|
+ Product product = convert(targetAPIResult.getData());
|
|
|
+ productRepository.update(product);
|
|
|
+ }
|
|
|
+
|
|
|
+ return targetAPIResult;
|
|
|
+ }
|
|
|
+
|
|
|
public APIResult<List<Product>> findByPids(List<String> pidList) {
|
|
|
List<Product> productList = productRepository.findByPids(pidList);
|
|
|
return APIResult.ok(productList);
|