|
@@ -3,14 +3,25 @@ package com.chelvc.cloud.vehicle.server.service.impl;
|
|
|
import java.util.List;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.chelvc.cloud.vehicle.api.dto.CategoryDTO;
|
|
|
import com.chelvc.cloud.vehicle.api.dto.MerchantDTO;
|
|
|
+import com.chelvc.cloud.vehicle.api.dto.MerchantDetailDTO;
|
|
|
+import com.chelvc.cloud.vehicle.api.param.MerchantQueryParam;
|
|
|
import com.chelvc.cloud.vehicle.api.param.NearbyQueryParam;
|
|
|
import com.chelvc.cloud.vehicle.api.param.PointQueryParam;
|
|
|
+import com.chelvc.cloud.vehicle.server.copier.CategoryCopier;
|
|
|
+import com.chelvc.cloud.vehicle.server.copier.MerchantCopier;
|
|
|
import com.chelvc.cloud.vehicle.server.dao.MerchantMapper;
|
|
|
import com.chelvc.cloud.vehicle.server.entity.Merchant;
|
|
|
+import com.chelvc.cloud.vehicle.server.service.CategoryService;
|
|
|
+import com.chelvc.cloud.vehicle.server.service.GoodsService;
|
|
|
import com.chelvc.cloud.vehicle.server.service.MerchantService;
|
|
|
+import com.chelvc.framework.base.util.ErrorUtils;
|
|
|
+import com.chelvc.framework.base.util.ObjectUtils;
|
|
|
import lombok.NonNull;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
import org.apache.dubbo.config.annotation.DubboService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
/**
|
|
|
* 商家业务操作实现
|
|
@@ -18,9 +29,13 @@ import org.apache.dubbo.config.annotation.DubboService;
|
|
|
* @author Woody
|
|
|
* @date 2023/5/2
|
|
|
*/
|
|
|
+@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
|
|
@DubboService(interfaceClass = com.chelvc.cloud.vehicle.api.service.MerchantService.class)
|
|
|
public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> implements MerchantService,
|
|
|
com.chelvc.cloud.vehicle.api.service.MerchantService {
|
|
|
+ private final GoodsService goodsService;
|
|
|
+ private final CategoryService categoryService;
|
|
|
+
|
|
|
@Override
|
|
|
public List<MerchantDTO> listRecommendMerchants(@NonNull PointQueryParam param, int size) {
|
|
|
return this.baseMapper.listRecommendMerchants(param, size);
|
|
@@ -30,4 +45,23 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> i
|
|
|
public List<MerchantDTO> listNearbyMerchants(@NonNull NearbyQueryParam param, int size) {
|
|
|
return this.baseMapper.listNearbyMerchants(param, size);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<MerchantDTO> listSimpleMerchants(@NonNull MerchantQueryParam param) {
|
|
|
+ return MerchantCopier.INSTANCE.copying(this.list());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public MerchantDetailDTO getMerchantDetail(@NonNull Long id) {
|
|
|
+ // 获取商家信息
|
|
|
+ MerchantDTO merchant = MerchantCopier.INSTANCE.copying(this.getById(id));
|
|
|
+ ErrorUtils.requireResource(merchant, "商家信息不存在");
|
|
|
+
|
|
|
+ // 获取商家商品分类信息
|
|
|
+ List<Long> categoryIds = this.goodsService.listMerchantGoodsCategoryIdentities(id);
|
|
|
+ List<CategoryDTO> categories = CategoryCopier.INSTANCE.copying(
|
|
|
+ ObjectUtils.ifEmpty(categoryIds, this.categoryService::listByIds)
|
|
|
+ );
|
|
|
+ return MerchantDetailDTO.builder().merchant(merchant).categories(categories).build();
|
|
|
+ }
|
|
|
}
|