103 lines
2.6 KiB
Java
103 lines
2.6 KiB
Java
package com.peanut.modules.book.controller;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import com.peanut.modules.book.vo.ShopCartVo;
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import com.peanut.modules.book.entity.OrderCartEntity;
|
|
import com.peanut.modules.book.service.OrderCartService;
|
|
import com.peanut.common.utils.PageUtils;
|
|
import com.peanut.common.utils.R;
|
|
|
|
|
|
|
|
/**
|
|
* 购物车
|
|
*
|
|
* @author yl
|
|
* @email yl328572838@163.com
|
|
* @date 2022-08-29 15:27:44
|
|
*/
|
|
@RestController
|
|
@RequestMapping("book/ordercart")
|
|
public class OrderCartController {
|
|
@Autowired
|
|
private OrderCartService orderCartService;
|
|
|
|
/**
|
|
* 列表
|
|
*/
|
|
@RequestMapping("/list")
|
|
// @RequiresPermissions("book:ordercart:list")
|
|
public R list(@RequestParam Map<String, Object> params){
|
|
PageUtils page = orderCartService.queryPage(params);
|
|
|
|
return R.ok().put("page", page);
|
|
}
|
|
|
|
|
|
/**
|
|
* 信息
|
|
*/
|
|
@RequestMapping("/info/{cartId}")
|
|
// @RequiresPermissions("book:ordercart:info")
|
|
public R info(@PathVariable("cartId") Integer cartId){
|
|
OrderCartEntity orderCart = orderCartService.getById(cartId);
|
|
|
|
return R.ok().put("orderCart", orderCart);
|
|
}
|
|
|
|
/**
|
|
* 保存
|
|
*/
|
|
@RequestMapping("/save")
|
|
// @RequiresPermissions("book:ordercart:save")
|
|
public R save(@RequestBody OrderCartEntity orderCart){
|
|
|
|
orderCartService.save(orderCart);
|
|
|
|
return R.ok();
|
|
}
|
|
|
|
/**
|
|
* 修改
|
|
*/
|
|
@RequestMapping("/update")
|
|
// @RequiresPermissions("book:ordercart:update")
|
|
public R update(@RequestBody OrderCartEntity orderCart){
|
|
orderCartService.updateById(orderCart);
|
|
return R.ok();
|
|
}
|
|
|
|
/**
|
|
* 删除
|
|
*/
|
|
@RequestMapping("/delete")
|
|
// @RequiresPermissions("book:ordercart:delete")
|
|
public R delete(@RequestBody Integer[] cartIds){
|
|
orderCartService.removeByIds(Arrays.asList(cartIds));
|
|
|
|
return R.ok();
|
|
}
|
|
|
|
/**
|
|
* 用户获取购物车列表
|
|
*/
|
|
@RequestMapping("/getCartList")
|
|
// @RequiresPermissions("book:ordercart:delete")
|
|
public R getCartList(@RequestParam("userId") Integer userId){
|
|
List<ShopCartVo> cartList = orderCartService.getCartList(userId);
|
|
return R.ok().put("cartList",cartList);
|
|
}
|
|
|
|
}
|