parent
b5480816ef
commit
001892824c
@ -0,0 +1,61 @@
|
|||||||
|
package cn.iocoder.mall.tradeservice.rpc.cart;
|
||||||
|
|
||||||
|
import cn.iocoder.common.framework.vo.CommonResult;
|
||||||
|
import cn.iocoder.mall.tradeservice.rpc.cart.dto.*;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title:
|
||||||
|
* Description:
|
||||||
|
*
|
||||||
|
* @author zhuyang
|
||||||
|
* @version 1.0 2021/10/9
|
||||||
|
*/
|
||||||
|
@FeignClient(value = "trade-service")
|
||||||
|
public interface CartFeign {
|
||||||
|
/**
|
||||||
|
* 添加商品到购物车
|
||||||
|
*
|
||||||
|
* @param addReqDTO 添加商品信息
|
||||||
|
* @return 成功
|
||||||
|
*/
|
||||||
|
@PostMapping("addCartItem")
|
||||||
|
CommonResult<Boolean> addCartItem(@RequestBody CartItemAddReqDTO addReqDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新购物车商品数量
|
||||||
|
*
|
||||||
|
* @param updateQuantityReqDTO 更新商品数量 DTO
|
||||||
|
* @return 成功
|
||||||
|
*/
|
||||||
|
@PostMapping("updateCartItemQuantity")
|
||||||
|
CommonResult<Boolean> updateCartItemQuantity(@RequestBody CartItemUpdateQuantityReqDTO updateQuantityReqDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新购物车商品是否选中
|
||||||
|
*
|
||||||
|
* @param updateSelectedReqDTO 更新商品是否选中 DTO
|
||||||
|
* @return 成功
|
||||||
|
*/
|
||||||
|
@PostMapping("updateCartItemSelected")
|
||||||
|
CommonResult<Boolean> updateCartItemSelected(@RequestBody CartItemUpdateSelectedReqDTO updateSelectedReqDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除购物车商品列表
|
||||||
|
*
|
||||||
|
* @param deleteListReqDTO 删除商品列表 DTO
|
||||||
|
* @return 成功
|
||||||
|
*/
|
||||||
|
@PostMapping("deleteCartItems")
|
||||||
|
CommonResult<Boolean> deleteCartItems(@RequestBody CartItemDeleteListReqDTO deleteListReqDTO);
|
||||||
|
@GetMapping("/sumCartItemQuantity")
|
||||||
|
public CommonResult<Integer> sumCartItemQuantity(@RequestParam("userId") Integer userId) ;
|
||||||
|
@PostMapping("/listCartItems")
|
||||||
|
public CommonResult<List<CartItemRespDTO>> listCartItems(@RequestBody CartItemListReqDTO listReqDTO) ;
|
||||||
|
}
|
||||||
@ -1,61 +0,0 @@
|
|||||||
package cn.iocoder.mall.tradeservice.rpc.cart;
|
|
||||||
|
|
||||||
import cn.iocoder.common.framework.vo.CommonResult;
|
|
||||||
import cn.iocoder.mall.tradeservice.rpc.cart.dto.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 购物车 Rpc 接口
|
|
||||||
*/
|
|
||||||
public interface CartRpc {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加商品到购物车
|
|
||||||
*
|
|
||||||
* @param addReqDTO 添加商品信息
|
|
||||||
* @return 成功
|
|
||||||
*/
|
|
||||||
CommonResult<Boolean> addCartItem(CartItemAddReqDTO addReqDTO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新购物车商品数量
|
|
||||||
*
|
|
||||||
* @param updateQuantityReqDTO 更新商品数量 DTO
|
|
||||||
* @return 成功
|
|
||||||
*/
|
|
||||||
CommonResult<Boolean> updateCartItemQuantity(CartItemUpdateQuantityReqDTO updateQuantityReqDTO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新购物车商品是否选中
|
|
||||||
*
|
|
||||||
* @param updateSelectedReqDTO 更新商品是否选中 DTO
|
|
||||||
* @return 成功
|
|
||||||
*/
|
|
||||||
CommonResult<Boolean> updateCartItemSelected(CartItemUpdateSelectedReqDTO updateSelectedReqDTO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除购物车商品列表
|
|
||||||
*
|
|
||||||
* @param deleteListReqDTO 删除商品列表 DTO
|
|
||||||
* @return 成功
|
|
||||||
*/
|
|
||||||
CommonResult<Boolean> deleteCartItems(CartItemDeleteListReqDTO deleteListReqDTO);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询用户在购物车中的商品数量
|
|
||||||
*
|
|
||||||
* @param userId 用户编号
|
|
||||||
* @return 商品数量
|
|
||||||
*/
|
|
||||||
CommonResult<Integer> sumCartItemQuantity(Integer userId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询用户在购物车种的商品列表
|
|
||||||
*
|
|
||||||
* @param listReqDTO 查询条件 DTO
|
|
||||||
* @return 购物车中商品列表信息
|
|
||||||
*/
|
|
||||||
CommonResult<List<CartItemRespDTO>> listCartItems(CartItemListReqDTO listReqDTO);
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,74 @@
|
|||||||
|
package cn.iocoder.mall.tradeservice.controller;
|
||||||
|
|
||||||
|
import cn.iocoder.common.framework.vo.CommonResult;
|
||||||
|
import cn.iocoder.mall.tradeservice.rpc.cart.dto.*;
|
||||||
|
import cn.iocoder.mall.tradeservice.service.cart.CartManager;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/trade/cart")
|
||||||
|
public class CartController {
|
||||||
|
@Autowired
|
||||||
|
private CartManager cartManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加商品到购物车
|
||||||
|
*
|
||||||
|
* @param addReqDTO 添加商品信息
|
||||||
|
* @return 成功
|
||||||
|
*/
|
||||||
|
@PostMapping("addCartItem")
|
||||||
|
CommonResult<Boolean> addCartItem(@RequestBody CartItemAddReqDTO addReqDTO){
|
||||||
|
cartManager.addCartItem(addReqDTO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新购物车商品数量
|
||||||
|
*
|
||||||
|
* @param updateQuantityReqDTO 更新商品数量 DTO
|
||||||
|
* @return 成功
|
||||||
|
*/
|
||||||
|
@PostMapping("updateCartItemQuantity")
|
||||||
|
CommonResult<Boolean> updateCartItemQuantity(@RequestBody CartItemUpdateQuantityReqDTO updateQuantityReqDTO){
|
||||||
|
cartManager.updateCartItemSelected(updateQuantityReqDTO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新购物车商品是否选中
|
||||||
|
*
|
||||||
|
* @param updateSelectedReqDTO 更新商品是否选中 DTO
|
||||||
|
* @return 成功
|
||||||
|
*/
|
||||||
|
@PostMapping("updateCartItemSelected")
|
||||||
|
CommonResult<Boolean> updateCartItemSelected(@RequestBody CartItemUpdateSelectedReqDTO updateSelectedReqDTO){
|
||||||
|
cartManager.updateCartItemSelected(updateSelectedReqDTO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除购物车商品列表
|
||||||
|
*
|
||||||
|
* @param deleteListReqDTO 删除商品列表 DTO
|
||||||
|
* @return 成功
|
||||||
|
*/
|
||||||
|
@PostMapping("deleteCartItems")
|
||||||
|
CommonResult<Boolean> deleteCartItems(@RequestBody CartItemDeleteListReqDTO deleteListReqDTO){
|
||||||
|
cartManager.deleteCartItems(deleteListReqDTO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
@GetMapping("/sumCartItemQuantity")
|
||||||
|
public CommonResult<Integer> sumCartItemQuantity(@RequestParam("userId") Integer userId) {
|
||||||
|
return success(cartManager.sumCartItemQuantity(userId));
|
||||||
|
}
|
||||||
|
@PostMapping("/listCartItems")
|
||||||
|
public CommonResult<List<CartItemRespDTO>> listCartItems(@RequestBody CartItemListReqDTO listReqDTO) {
|
||||||
|
return success(cartManager.listCartItems(listReqDTO));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,56 +0,0 @@
|
|||||||
package cn.iocoder.mall.tradeservice.rpc.cart;
|
|
||||||
|
|
||||||
import cn.iocoder.common.framework.vo.CommonResult;
|
|
||||||
import cn.iocoder.mall.tradeservice.service.cart.CartManager;
|
|
||||||
import cn.iocoder.mall.tradeservice.rpc.cart.dto.*;
|
|
||||||
import org.apache.dubbo.config.annotation.DubboService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 购物车 Rpc 实现
|
|
||||||
*/
|
|
||||||
@DubboService
|
|
||||||
public class CartRpcImpl implements CartRpc {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CartManager cartManager;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CommonResult<Boolean> addCartItem(CartItemAddReqDTO addItemReqDTO) {
|
|
||||||
cartManager.addCartItem(addItemReqDTO);
|
|
||||||
return success(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CommonResult<Boolean> updateCartItemQuantity(CartItemUpdateQuantityReqDTO updateQuantityReqDTO) {
|
|
||||||
cartManager.updateCartItemSelected(updateQuantityReqDTO);
|
|
||||||
return success(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CommonResult<Boolean> updateCartItemSelected(CartItemUpdateSelectedReqDTO updateSelectedReqDTO) {
|
|
||||||
cartManager.updateCartItemSelected(updateSelectedReqDTO);
|
|
||||||
return success(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CommonResult<Boolean> deleteCartItems(CartItemDeleteListReqDTO deleteListReqDTO) {
|
|
||||||
cartManager.deleteCartItems(deleteListReqDTO);
|
|
||||||
return success(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CommonResult<Integer> sumCartItemQuantity(Integer userId) {
|
|
||||||
return success(cartManager.sumCartItemQuantity(userId));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CommonResult<List<CartItemRespDTO>> listCartItems(CartItemListReqDTO listReqDTO) {
|
|
||||||
return success(cartManager.listCartItems(listReqDTO));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
package cn.iocoder.mall.tradeservice.rpc.order;
|
|
||||||
|
|
||||||
import cn.iocoder.common.framework.vo.CommonResult;
|
|
||||||
import cn.iocoder.common.framework.vo.PageResult;
|
|
||||||
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderCreateReqDTO;
|
|
||||||
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderPageReqDTO;
|
|
||||||
import cn.iocoder.mall.tradeservice.rpc.order.dto.TradeOrderRespDTO;
|
|
||||||
import cn.iocoder.mall.tradeservice.service.order.TradeOrderService;
|
|
||||||
import org.apache.dubbo.config.annotation.DubboService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 交易订单 Rpc 实现
|
|
||||||
*/
|
|
||||||
@DubboService
|
|
||||||
public class TradeOrderRpcImpl implements TradeOrderRpc {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TradeOrderService tradeOrderService;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CommonResult<Integer> createTradeOrder(TradeOrderCreateReqDTO createReqDTO) {
|
|
||||||
return success(tradeOrderService.createTradeOrder(createReqDTO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CommonResult<TradeOrderRespDTO> getTradeOrder(Integer tradeOrderId, Collection<String> fields) {
|
|
||||||
return success(tradeOrderService.getTradeOrder(tradeOrderId, fields));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CommonResult<PageResult<TradeOrderRespDTO>> pageTradeOrder(TradeOrderPageReqDTO pageDTO) {
|
|
||||||
return success(tradeOrderService.pageTradeOrder(pageDTO));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CommonResult<Boolean> updateTradeOrderPaySuccess(String tradeOrderId, Integer payAmount) {
|
|
||||||
tradeOrderService.updateTradeOrderPaySuccess(Integer.valueOf(tradeOrderId), payAmount);
|
|
||||||
return success(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Loading…
Reference in new issue