|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import cc.mrbird.febs.common.entity.FebsResponse; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.dto.AddCartDto; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.dto.DelCartGoodsDto; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.dto.GoodsCntDto; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.entity.MallShoppingCart; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.service.IApiMallShoppingCartService; | 
|---|
|  |  |  | import cc.mrbird.febs.mall.vo.ShoppingCartGoodsVo; | 
|---|
|  |  |  | import cn.hutool.core.util.StrUtil; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import io.swagger.annotations.ApiResponse; | 
|---|
|  |  |  | import io.swagger.annotations.ApiResponses; | 
|---|
|  |  |  | import lombok.RequiredArgsConstructor; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.validation.annotation.Validated; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.PostMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestBody; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RestController; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @author wzy | 
|---|
|  |  |  | 
|---|
|  |  |  | private final IApiMallShoppingCartService mallShoppingCartService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "获取购物车商品列表", notes = "获取购物车商品列表") | 
|---|
|  |  |  | @ApiResponses({ | 
|---|
|  |  |  | @ApiResponse(code = 200, message = "success", response = ShoppingCartGoodsVo.class) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @PostMapping(value = "/findCartGoodsList") | 
|---|
|  |  |  | public FebsResponse findCartGoodsList() { | 
|---|
|  |  |  | return new FebsResponse().success().data(mallShoppingCartService.findCartGoodsList()); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "添加商品到购物车", notes = "添加商品到购物车") | 
|---|
|  |  |  | @PostMapping(value = "/addGoodsToCart") | 
|---|
|  |  |  | public FebsResponse addGoodsToCart(@RequestBody AddCartDto addCartDto) { | 
|---|
|  |  |  | public FebsResponse addGoodsToCart(@RequestBody List<AddCartDto> addCartDto) { | 
|---|
|  |  |  | mallShoppingCartService.addGoodsToCart(addCartDto); | 
|---|
|  |  |  | return new FebsResponse().success().data("添加成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "从购物车中删除商品", notes = "从购物车中删除商品") | 
|---|
|  |  |  | @PostMapping(value = "/delGoods") | 
|---|
|  |  |  | public FebsResponse delGoods() { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | public FebsResponse delGoods(@RequestBody DelCartGoodsDto delCartGoodsDto) { | 
|---|
|  |  |  | List<String> ids = StrUtil.split(delCartGoodsDto.getIds(), ','); | 
|---|
|  |  |  | mallShoppingCartService.removeByIds(ids); | 
|---|
|  |  |  | return new FebsResponse().success().data("删除成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "修改购物车商品数量", notes = "修改购物车商品数量") | 
|---|
|  |  |  | @PostMapping(value = "/goodsCnt") | 
|---|
|  |  |  | public FebsResponse goodsCnt(@RequestBody GoodsCntDto goodsCntDto) { | 
|---|
|  |  |  | MallShoppingCart shoppingCart = new MallShoppingCart(); | 
|---|
|  |  |  | shoppingCart.setId(goodsCntDto.getId()); | 
|---|
|  |  |  | shoppingCart.setCnt(goodsCntDto.getCnt()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | mallShoppingCartService.updateById(shoppingCart); | 
|---|
|  |  |  | return new FebsResponse().success(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|