|
@@ -1,21 +1,31 @@
|
|
|
package com.chelvc.cloud.maintain.controller;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+import javax.validation.Valid;
|
|
|
+import javax.validation.constraints.Min;
|
|
|
+import javax.validation.constraints.NotEmpty;
|
|
|
+
|
|
|
import com.chelvc.cloud.maintain.copier.MerchantCopier;
|
|
|
import com.chelvc.cloud.maintain.vo.SimpleMerchantVO;
|
|
|
-import com.chelvc.cloud.vehicle.api.constant.GoodsStatus;
|
|
|
-import com.chelvc.cloud.vehicle.api.dto.BalanceDetailDTO;
|
|
|
-import com.chelvc.cloud.vehicle.api.dto.MerchantDTO;
|
|
|
-import com.chelvc.cloud.vehicle.api.dto.MerchantDetailDTO;
|
|
|
-import com.chelvc.cloud.vehicle.api.dto.MerchantRankDTO;
|
|
|
-import com.chelvc.cloud.vehicle.api.param.*;
|
|
|
-import com.chelvc.cloud.vehicle.api.service.BalanceDetailService;
|
|
|
-import com.chelvc.cloud.vehicle.api.service.FavoriteService;
|
|
|
-import com.chelvc.cloud.vehicle.api.service.GoodsService;
|
|
|
-import com.chelvc.cloud.vehicle.api.service.MerchantService;
|
|
|
+import com.chelvc.cloud.vehicle.client.BalanceDetailClient;
|
|
|
+import com.chelvc.cloud.vehicle.client.FavoriteClient;
|
|
|
+import com.chelvc.cloud.vehicle.client.GoodsClient;
|
|
|
+import com.chelvc.cloud.vehicle.client.MerchantClient;
|
|
|
+import com.chelvc.cloud.vehicle.client.constant.GoodsStatus;
|
|
|
+import com.chelvc.cloud.vehicle.client.dto.BalanceDetailDTO;
|
|
|
+import com.chelvc.cloud.vehicle.client.dto.MerchantDTO;
|
|
|
+import com.chelvc.cloud.vehicle.client.dto.MerchantDetailDTO;
|
|
|
+import com.chelvc.cloud.vehicle.client.dto.MerchantRankDTO;
|
|
|
+import com.chelvc.cloud.vehicle.client.param.LocationQueryParam;
|
|
|
+import com.chelvc.cloud.vehicle.client.param.MerchantQueryParam;
|
|
|
+import com.chelvc.cloud.vehicle.client.param.MerchantRankParam;
|
|
|
+import com.chelvc.cloud.vehicle.client.param.OmsCartItemPagingParam;
|
|
|
+import com.chelvc.cloud.vehicle.client.param.QueryMerchantBalanceParam;
|
|
|
import com.chelvc.framework.base.annotation.ResponseWrapping;
|
|
|
import com.chelvc.framework.base.context.SessionContextHolder;
|
|
|
import com.chelvc.framework.common.model.Pagination;
|
|
|
-import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
@@ -23,11 +33,6 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
-import javax.validation.Valid;
|
|
|
-import javax.validation.constraints.Min;
|
|
|
-import javax.validation.constraints.NotEmpty;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
/**
|
|
|
* 商家接口
|
|
|
*
|
|
@@ -37,17 +42,12 @@ import java.util.List;
|
|
|
@Validated
|
|
|
@RestController
|
|
|
@ResponseWrapping
|
|
|
+@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
|
|
public class MerchantController {
|
|
|
- @DubboReference
|
|
|
- private MerchantService merchantService;
|
|
|
-
|
|
|
- @DubboReference
|
|
|
- private FavoriteService favoriteService;
|
|
|
-
|
|
|
- @DubboReference
|
|
|
- private BalanceDetailService balanceDetailService;
|
|
|
- @DubboReference
|
|
|
- private GoodsService goodsService;
|
|
|
+ private final GoodsClient goodsClient;
|
|
|
+ private final MerchantClient merchantClient;
|
|
|
+ private final FavoriteClient favoriteClient;
|
|
|
+ private final BalanceDetailClient balanceDetailClient;
|
|
|
|
|
|
/**
|
|
|
* 获取商家列表
|
|
@@ -57,7 +57,7 @@ public class MerchantController {
|
|
|
*/
|
|
|
@GetMapping("/merchantSort")
|
|
|
public List<SimpleMerchantVO> listSimpleMerchants(@Valid MerchantQueryParam param) {
|
|
|
- return MerchantCopier.INSTANCE.copying(this.merchantService.listSimpleMerchants(param));
|
|
|
+ return MerchantCopier.INSTANCE.copying(this.merchantClient.listSimpleMerchants(param));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -68,20 +68,20 @@ public class MerchantController {
|
|
|
*/
|
|
|
@GetMapping("/merchants/rank")
|
|
|
public List<MerchantRankDTO> listRankMerchants(@Valid MerchantRankParam param) {
|
|
|
- return this.merchantService.listRankMerchants(param, SessionContextHolder.getId());
|
|
|
+ return this.merchantClient.listUserRankMerchants(param, SessionContextHolder.getId());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取商家详情
|
|
|
*
|
|
|
- * @param id 商家ID
|
|
|
+ * @param id 商家ID
|
|
|
* @param param 查询参数
|
|
|
* @return 商家详情
|
|
|
*/
|
|
|
@GetMapping("/merchant/{id}")
|
|
|
public MerchantDetailDTO getMerchantDetail(@PathVariable("id") @Min(value = 1, message = "商家ID不能小于1") Long id,
|
|
|
@Valid LocationQueryParam param) {
|
|
|
- return this.merchantService.getMerchantDetail(id, param);
|
|
|
+ return this.merchantClient.queryMerchantDetail(id, param);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -92,70 +92,70 @@ public class MerchantController {
|
|
|
*/
|
|
|
@PostMapping("/merchant/{id}/favorite")
|
|
|
public Long addMerchantFavorite(@PathVariable("id") @Min(value = 1, message = "商家ID不能小于1") Long id) {
|
|
|
- return this.favoriteService.addMerchantFavorite(id,"MERCHANT");
|
|
|
+ return this.favoriteClient.addMerchantFavorite(id, "MERCHANT");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询商家余额明细
|
|
|
*
|
|
|
- * @param param 查询条件
|
|
|
+ * @param param 查询条件
|
|
|
* @param pageNum
|
|
|
* @param pageSize
|
|
|
* @return 收藏ID
|
|
|
*/
|
|
|
@GetMapping("/merchant/balance/detail")
|
|
|
- public Pagination<BalanceDetailDTO> queryBalanceDetail(@Validated QueryMerchantBalanceParam param, Integer pageNum, Integer pageSize) {
|
|
|
+ public Pagination<BalanceDetailDTO> queryBalanceDetail(@Validated QueryMerchantBalanceParam param,
|
|
|
+ Integer pageNum, Integer pageSize) {
|
|
|
if (pageNum == null) {
|
|
|
pageNum = 1;
|
|
|
}
|
|
|
if (pageSize == null) {
|
|
|
pageSize = 20;
|
|
|
}
|
|
|
- return this.balanceDetailService.queryByMerchantId(param, pageNum, pageSize, 2);
|
|
|
+ return this.balanceDetailClient.queryByMerchantId(param, pageNum, pageSize, 2);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 我的购物车列表
|
|
|
- *
|
|
|
*/
|
|
|
@GetMapping("/mineCartList")
|
|
|
public Pagination<MerchantDTO> mineCartList(@Valid OmsCartItemPagingParam param) {
|
|
|
- return this.merchantService.getUserMineCartPaging(param);
|
|
|
+ return this.merchantClient.getUserMineCartPaging(param);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 上架商品
|
|
|
*
|
|
|
- * @param goodsIds 商品ID集合
|
|
|
+ * @param goodsIds 商品ID集合
|
|
|
*/
|
|
|
@PutMapping("/merchant/list-goods/{goodsIds}")
|
|
|
public void listGoods(@PathVariable("goodsIds") @NotEmpty(message = "商品ID不能为空") List<Long> goodsIds) {
|
|
|
- this.goodsService.updateGoodsStatus(goodsIds, GoodsStatus.ONLINE);
|
|
|
+ this.goodsClient.updateGoodsStatus(goodsIds, GoodsStatus.ONLINE);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 下架商品
|
|
|
*
|
|
|
- * @param goodsIds 商品ID集合
|
|
|
+ * @param goodsIds 商品ID集合
|
|
|
*/
|
|
|
@PutMapping("/merchant/delist-goods/{goodsIds}")
|
|
|
public void delistGoods(@PathVariable("goodsIds") @NotEmpty(message = "商品ID不能为空") List<Long> goodsIds) {
|
|
|
- this.goodsService.updateGoodsStatus(goodsIds, GoodsStatus.OFFLINE);
|
|
|
+ this.goodsClient.updateGoodsStatus(goodsIds, GoodsStatus.OFFLINE);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 修改商家营业状态
|
|
|
*
|
|
|
- * @param id 商家主键
|
|
|
+ * @param id 商家主键
|
|
|
* @param businessStatus 修改参数 营业状态 0-营业中,1-休息中
|
|
|
*/
|
|
|
@PutMapping("/merchant/updateBusinessStatus/{id}")
|
|
|
public void updateMerchant(@PathVariable("id") @Min(value = 1, message = "商家主键不能小于1") Long id,
|
|
|
String businessStatus) {
|
|
|
- this.merchantService.updateMerchantBusinessStatus(id,businessStatus);
|
|
|
+ this.merchantClient.updateMerchantBusinessStatus(id, businessStatus);
|
|
|
}
|
|
|
|
|
|
}
|