查看购物车业务代码开发
This commit is contained in:
@@ -2,16 +2,16 @@ package com.sky.controller.user;
|
||||
|
||||
|
||||
import com.sky.dto.ShoppingCartDTO;
|
||||
import com.sky.entity.ShoppingCart;
|
||||
import com.sky.result.Result;
|
||||
import com.sky.service.ShoppingCartService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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;
|
||||
|
||||
@RestController
|
||||
@Slf4j
|
||||
@@ -32,4 +32,16 @@ public class ShoppingCartController {
|
||||
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查看购物车
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("查看购物车")
|
||||
public Result<List<ShoppingCart>> list(){
|
||||
List<ShoppingCart> list = shoppingCartService.showShoppingCart();
|
||||
return Result.success(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@ package com.sky.service;
|
||||
|
||||
|
||||
import com.sky.dto.ShoppingCartDTO;
|
||||
import com.sky.entity.ShoppingCart;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ShoppingCartService {
|
||||
|
||||
@@ -11,4 +14,11 @@ public interface ShoppingCartService {
|
||||
* @param shoppingCartDTO
|
||||
*/
|
||||
void addShoppingCart(ShoppingCartDTO shoppingCartDTO);
|
||||
|
||||
|
||||
/**
|
||||
* 查看购物车
|
||||
* @return
|
||||
*/
|
||||
List<ShoppingCart> showShoppingCart();
|
||||
}
|
||||
|
||||
@@ -81,4 +81,19 @@ public class ShoppingCartServiceImpl implements ShoppingCartService {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*查看购物车
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<ShoppingCart> showShoppingCart() {
|
||||
//获取当前微信用户的id
|
||||
Long userId = BaseContext.getCurrentId();
|
||||
ShoppingCart shoppingCart = new ShoppingCart();
|
||||
shoppingCart.setUserId(userId);
|
||||
List<ShoppingCart> list = shoppingCartMapper.list(shoppingCart);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user