|
@@ -12,11 +12,10 @@ import edu.travel.commodity.entity.*;
|
|
|
import edu.travel.commodity.mapper.ShopProductSpecMapper;
|
|
|
import edu.travel.commodity.service.*;
|
|
|
import edu.travel.commodity.utils.IdUtils;
|
|
|
-import edu.travel.remote.dto.FileDto;
|
|
|
-import edu.travel.remote.dto.InsertProductSpecDto;
|
|
|
-import edu.travel.remote.dto.ProductSpecDto;
|
|
|
-import edu.travel.remote.dto.SpecValueDto;
|
|
|
+import edu.travel.remote.dto.*;
|
|
|
import edu.travel.remote.vo.*;
|
|
|
+import edu.travel.rpc.RPCBaseResponse;
|
|
|
+import edu.travel.service.SysServiceImpl;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -27,8 +26,10 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import static edu.travel.rpc.RPCBaseResponse.error;
|
|
|
+
|
|
|
@Service
|
|
|
-public class ShopProductSpecServiceImpl extends ServiceImpl<ShopProductSpecMapper, ShopProductSpec> implements ShopProductSpecService {
|
|
|
+public class ShopProductSpecServiceImpl extends SysServiceImpl<ShopProductSpecMapper, ShopProductSpec> implements ShopProductSpecService {
|
|
|
@Autowired
|
|
|
private ShopProductService shopProductService;
|
|
|
@Autowired
|
|
@@ -41,6 +42,8 @@ public class ShopProductSpecServiceImpl extends ServiceImpl<ShopProductSpecMappe
|
|
|
private ShopProductSpecService shopProductSpecService;
|
|
|
@Autowired
|
|
|
private ShopProductSpecMapper shopProductSpecMapper;
|
|
|
+ @Autowired
|
|
|
+ private ShopSpecService shopSpecService;
|
|
|
|
|
|
@Override
|
|
|
public ProductSpecVo getShopSpec(ProductSpecDto param) {
|
|
@@ -145,6 +148,73 @@ public class ShopProductSpecServiceImpl extends ServiceImpl<ShopProductSpecMappe
|
|
|
this.saveBatch(list);
|
|
|
return shopSpecValueService.saveBatch(shopSpecValues);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RPCBaseResponse<List<ProductSpecVo>> getShopSpecSortVoList(String specId) {
|
|
|
+
|
|
|
+ LambdaQueryWrapper<ShopProductSpec> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ List<ShopProductSpec> specs = super.getListLink(queryWrapper);
|
|
|
+
|
|
|
+ List<ProductSpecVo> specs1 = BeanUtil.copyToList(specs, ProductSpecVo.class);
|
|
|
+ return new RPCBaseResponse<>(200, "SUCCESS", specs1);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RPCBaseResponse<ProductSpecInsertShopSpecVo> insertOrUpdateProductSpecAndShopSpec(ProductSpecInsertShopSpecDto entity) {
|
|
|
+
|
|
|
+ LambdaQueryWrapper<ShopProductSpec> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(ShopProductSpec::getProductId, entity.getProductId());
|
|
|
+
|
|
|
+
|
|
|
+ List<ShopProductSpec> shopProductSpecs = shopProductSpecMapper.selectList(queryWrapper);
|
|
|
+
|
|
|
+
|
|
|
+ if (shopProductSpecs == null || shopProductSpecs.isEmpty()) {
|
|
|
+ return error("No specifications found for the provided productId");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ SpecDto specDto = new SpecDto();
|
|
|
+ specDto.setSpecId(entity.getSpecId());
|
|
|
+ specDto.setSpecName(entity.getSpecName());
|
|
|
+ specDto.setCountryId(entity.getCountryId());
|
|
|
+
|
|
|
+
|
|
|
+ RPCBaseResponse<ProductSpecInsertShopSpecVo> response = shopSpecService.insertOrUpdate(specDto);
|
|
|
+
|
|
|
+ System.out.println("response = " + response);
|
|
|
+
|
|
|
+ if (response == null || response.getData() == null) {
|
|
|
+ return error("Failed to insert or update shop specification");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ProductSpecInsertShopSpecVo specVo = response.getData();
|
|
|
+ entity.setSpecId(specVo.getId());
|
|
|
+ entity.setSpecName(specVo.getSpecName());
|
|
|
+
|
|
|
+
|
|
|
+ ShopProductSpec newShopProductSpec = new ShopProductSpec();
|
|
|
+ newShopProductSpec.setProductId(Long.valueOf(entity.getProductId()));
|
|
|
+ newShopProductSpec.setSpecId(Long.valueOf(entity.getSpecId()));
|
|
|
+ newShopProductSpec.setSpecName(entity.getSpecName());
|
|
|
+
|
|
|
+
|
|
|
+ int result = shopProductSpecMapper.insert(newShopProductSpec);
|
|
|
+
|
|
|
+
|
|
|
+ if (result <= 0) {
|
|
|
+ return error("Failed to associate product with specification");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return new RPCBaseResponse<>(200, "SUCCESS", specVo);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|