New file |
| | |
| | | package com.ruoyi.system.controller.miniapp; |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.member.domain.dto.AppBaseBathDto; |
| | | import com.ruoyi.member.domain.dto.AppGoodsInfoGetDto; |
| | | import com.ruoyi.member.domain.dto.AppShoppingCartAddDto; |
| | | import com.ruoyi.member.domain.dto.AppShoppingCartChangeDto; |
| | | import com.ruoyi.member.domain.pojo.member.Member; |
| | | import com.ruoyi.member.domain.vo.AppGoodsInfoVo; |
| | | import com.ruoyi.member.service.member.MemberService; |
| | | import com.ruoyi.system.service.goods.GoodsService; |
| | | import com.ruoyi.system.service.order.ShoppingCartService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * @author jqs34 |
| | | * @ClassName AppGoodsController |
| | | * @description: TODO |
| | | * @date 2023年04月20日 |
| | | * @version: 1.0 |
| | | */ |
| | | @Api(value = "小程序商品相关接口", tags = "小程序商品相关接口", description = "小程序商品相关接口") |
| | | @RestController |
| | | @RequestMapping("/app/home") |
| | | public class AppGoodsController { |
| | | |
| | | @Autowired |
| | | private GoodsService goodsService; |
| | | |
| | | @Autowired |
| | | private MemberService memberService; |
| | | |
| | | @Autowired |
| | | private ShoppingCartService shoppingCartService; |
| | | |
| | | @RequestMapping(value = "/getGoodsInfo", method = RequestMethod.POST) |
| | | @ApiOperation(value = "获取商品详情") |
| | | public R<AppGoodsInfoVo> getGoodsInfo(@RequestBody AppGoodsInfoGetDto appGoodsInfoGetDto) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if(userId!=null){ |
| | | Member member = memberService.getById(userId); |
| | | if(member!=null&&member.getRealtionShopId()!=null){ |
| | | appGoodsInfoGetDto.setShopId(member.getRealtionShopId()); |
| | | } |
| | | } |
| | | AppGoodsInfoVo appGoodsInfoVo = goodsService.getGoodsInfo(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(); |
| | | } |
| | | } |