查看购物车
This commit is contained in:
parent
f46e752a40
commit
f84dca1f1c
|
@ -1,17 +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.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 org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/user/shoppingCart")
|
@RequestMapping("/user/shoppingCart")
|
||||||
|
@ -35,4 +34,16 @@ public class ShoppingCartController {
|
||||||
shoppingCartService.addShoppingCart(shoppingCartDTO);
|
shoppingCartService.addShoppingCart(shoppingCartDTO);
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查看购物车
|
||||||
|
*
|
||||||
|
* @return 购物车集合
|
||||||
|
*/
|
||||||
|
@ApiOperation("查看购物车")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Result<List<ShoppingCart>> list() {
|
||||||
|
List<ShoppingCart> list = shoppingCartService.showShoppingCart();
|
||||||
|
return Result.success(list);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
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 {
|
||||||
/**
|
/**
|
||||||
|
@ -9,4 +12,12 @@ public interface ShoppingCartService {
|
||||||
* @param shoppingCartDTO 购物车参数
|
* @param shoppingCartDTO 购物车参数
|
||||||
*/
|
*/
|
||||||
void addShoppingCart(ShoppingCartDTO shoppingCartDTO);
|
void addShoppingCart(ShoppingCartDTO shoppingCartDTO);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查看购物车
|
||||||
|
*
|
||||||
|
* @return 购物车集合
|
||||||
|
*/
|
||||||
|
List<ShoppingCart> showShoppingCart();
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,4 +69,17 @@ public class ShoppingCartServiceImplImpl implements ShoppingCartService {
|
||||||
shoppingCartMapper.insert(shoppingCart);
|
shoppingCartMapper.insert(shoppingCart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查看购物车
|
||||||
|
*
|
||||||
|
* @return 购物车列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<ShoppingCart> showShoppingCart() {
|
||||||
|
// 当前微信用户id
|
||||||
|
Long currentId = BaseContext.getCurrentId();
|
||||||
|
ShoppingCart shoppingCart = ShoppingCart.builder().userId(currentId).build();
|
||||||
|
return shoppingCartMapper.list(shoppingCart);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue