|
@@ -1,7 +1,12 @@
|
|
|
package cn.rankin.apiweb.service.collection;
|
|
|
|
|
|
import cn.rankin.apiweb.code.ApiWebCode;
|
|
|
+import cn.rankin.apiweb.service.product.ProductService;
|
|
|
import cn.rankin.common.utils.api.model.APIResult;
|
|
|
+import cn.rankin.common.utils.api.model.BaseCode;
|
|
|
+import cn.rankin.common.utils.enums.BaseStatusEnum;
|
|
|
+import cn.rankin.data.api.product.entity.MerchantProduct;
|
|
|
+import cn.rankin.data.api.user.dto.CollectionDTO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -14,8 +19,28 @@ public class CollectionService {
|
|
|
@Autowired
|
|
|
private CollectionClient collectionClient;
|
|
|
|
|
|
- public APIResult<Boolean> put(String userId, String productId) {
|
|
|
- return null;
|
|
|
+ @Autowired
|
|
|
+ private ProductService productService;
|
|
|
+
|
|
|
+ public APIResult<Boolean> put(String userId, String merchantId, String productId) {
|
|
|
+ APIResult<MerchantProduct> apiResult = productService.getMerchantProduct(productId, merchantId);
|
|
|
+ if (!apiResult.getSuccess()) {
|
|
|
+ return APIResult.error(new BaseCode(apiResult.getCode(), apiResult.getMessage()));
|
|
|
+ }
|
|
|
+
|
|
|
+ MerchantProduct merchantProduct = apiResult.getData();
|
|
|
+ if (merchantProduct == null) {
|
|
|
+ return APIResult.error(ApiWebCode.NOT_EXISTS);
|
|
|
+ }
|
|
|
+
|
|
|
+ CollectionDTO collectionDTO = new CollectionDTO();
|
|
|
+ collectionDTO.setPid(productId);
|
|
|
+ collectionDTO.setUserId(userId);
|
|
|
+ collectionDTO.setType(merchantProduct.getType());
|
|
|
+ collectionDTO.setStatus(BaseStatusEnum.NORMAL);
|
|
|
+
|
|
|
+ return collectionClient.put(collectionDTO);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|