| | |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.system.domain.dto.AppBaseBathDto; |
| | | import com.ruoyi.system.domain.dto.AppGoodsInfoGetDto; |
| | | import com.ruoyi.system.domain.dto.AppShoppingCartAddDto; |
| | | import com.ruoyi.system.domain.dto.AppShoppingCartChangeDto; |
| | | import com.ruoyi.system.domain.pojo.member.Member; |
| | | import com.ruoyi.system.domain.vo.AppGoodsInfoVo; |
| | | import com.ruoyi.system.service.goods.GoodsService; |
| | | import com.ruoyi.system.service.member.MemberService; |
| | | import com.ruoyi.system.service.order.ShoppingCartService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | @Autowired |
| | | private MemberService memberService; |
| | | |
| | | @Autowired |
| | | private ShoppingCartService shoppingCartService; |
| | | |
| | | @RequestMapping(value = "/getGoodsInfo", method = RequestMethod.POST) |
| | | @ApiOperation(value = "获取商品详情") |
| | | public R<AppGoodsInfoVo> getGoodsInfo(@RequestBody AppGoodsInfoGetDto appGoodsInfoGetDto) { |
| | |
| | | return R.ok(appGoodsInfoVo); |
| | | } |
| | | |
| | | @RequestMapping(value = "/addShoppingCart", method = RequestMethod.POST) |
| | | @ApiOperation(value = "添加购物车") |
| | | public R addShoppingCart(@RequestBody AppShoppingCartAddDto appShoppingCartAddDto) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if(userId!=null){ |
| | | Member member = memberService.getById(userId); |
| | | appShoppingCartAddDto.setUserId(userId); |
| | | if(member!=null&&member.getRealtionShopId()!=null){ |
| | | appShoppingCartAddDto.setShopId(member.getRealtionShopId()); |
| | | } |
| | | } |
| | | shoppingCartService.addShoppingCart(appShoppingCartAddDto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/changeShoppingCart", method = RequestMethod.POST) |
| | | @ApiOperation(value = "修改购物车") |
| | | public R changeShoppingCart(@RequestBody AppShoppingCartChangeDto appShoppingCartChangeDto) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if(userId!=null){ |
| | | Member member = memberService.getById(userId); |
| | | appShoppingCartChangeDto.setUserId(userId); |
| | | if(member!=null&&member.getRealtionShopId()!=null){ |
| | | appShoppingCartChangeDto.setShopId(member.getRealtionShopId()); |
| | | } |
| | | } |
| | | shoppingCartService.changeShoppingCart(appShoppingCartChangeDto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/deleteShoppingCart", method = RequestMethod.POST) |
| | | @ApiOperation(value = "删除购物车") |
| | | public R changeShoppingCart(@RequestBody AppBaseBathDto appBaseBathDto) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if(userId!=null){ |
| | | Member member = memberService.getById(userId); |
| | | appBaseBathDto.setUserId(userId); |
| | | } |
| | | shoppingCartService.deleteShoppingCart(appBaseBathDto); |
| | | return R.ok(); |
| | | } |
| | | } |