苍穹外卖--查看购物车
This commit is contained in:
@@ -1,16 +1,16 @@
|
|||||||
package com.sky.controller.user;
|
package com.sky.controller.user;
|
||||||
|
|
||||||
import com.sky.dto.ShoppingCartDTO;
|
import com.sky.dto.ShoppingCartDTO;
|
||||||
|
import com.sky.entity.ShoppingCart;
|
||||||
import com.sky.result.Result;
|
import com.sky.result.Result;
|
||||||
import com.sky.service.ShoppingCartService;
|
import com.sky.service.ShoppingCartService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import java.util.List;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@RequestMapping("/user/shoppingCart")
|
@RequestMapping("/user/shoppingCart")
|
||||||
@RestController
|
@RestController
|
||||||
@@ -29,4 +29,11 @@ public class ShoppingCartController {
|
|||||||
shoppingCartService.addShoppingCart(shoppingCartDTO);
|
shoppingCartService.addShoppingCart(shoppingCartDTO);
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
@GetMapping("/list")
|
||||||
|
@ApiOperation("查看购物车")
|
||||||
|
public Result<List<ShoppingCart>> showShoppingCart(){
|
||||||
|
log.info("查看购物车");
|
||||||
|
List<ShoppingCart> list = shoppingCartService.showShoppingCart();
|
||||||
|
return Result.success(list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,18 @@
|
|||||||
package com.sky.service;
|
package com.sky.service;
|
||||||
|
|
||||||
import com.sky.dto.ShoppingCartDTO;
|
import com.sky.dto.ShoppingCartDTO;
|
||||||
|
import com.sky.entity.ShoppingCart;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface ShoppingCartService {
|
public interface ShoppingCartService {
|
||||||
/*
|
/*
|
||||||
添加购物车
|
添加购物车
|
||||||
*/
|
*/
|
||||||
void addShoppingCart(ShoppingCartDTO shoppingCartDTO);
|
void addShoppingCart(ShoppingCartDTO shoppingCartDTO);
|
||||||
|
|
||||||
|
/*
|
||||||
|
查看购物车
|
||||||
|
*/
|
||||||
|
List<ShoppingCart> showShoppingCart();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,4 +92,16 @@ public class ShoppingCartServiceImpl implements ShoppingCartService {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
查看购物车
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<ShoppingCart> showShoppingCart() {
|
||||||
|
ShoppingCart cart = ShoppingCart.builder()
|
||||||
|
.userId(BaseContext.getCurrentId())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
return shoppingCartMapper.list(cart);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user