package com.ltkj.web.controller.mall;
|
|
import java.util.List;
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletResponse;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.ltkj.common.core.domain.R;
|
import com.ltkj.hosp.domain.Wxuser;
|
import com.ltkj.hosp.service.ITjPackageService;
|
import com.ltkj.hosp.service.IWxuserService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiParam;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
import com.ltkj.common.annotation.Log;
|
import com.ltkj.common.core.controller.BaseController;
|
import com.ltkj.common.core.domain.AjaxResult;
|
import com.ltkj.common.enums.BusinessType;
|
import com.ltkj.mall.domain.MallCart;
|
import com.ltkj.mall.service.IMallCartService;
|
import com.ltkj.common.utils.poi.ExcelUtil;
|
import com.ltkj.common.core.page.TableDataInfo;
|
|
/**
|
* 购物车商品Controller
|
*
|
* @author ltkj_赵佳豪&李格
|
* @date 2023-07-12
|
*/
|
@RestController
|
@RequestMapping("/mall/cart")
|
@Api(tags = "mall购物车")
|
public class MallCartController extends BaseController {
|
@Autowired
|
private IMallCartService mallCartService;
|
@Autowired
|
private IWxuserService wxuserService;
|
@Resource
|
private ITjPackageService packageService;
|
|
/**
|
* 查询购物车商品列表
|
*/
|
@PreAuthorize("@ss.hasPermi('mall:cart:list')")
|
@GetMapping("/list")
|
@ApiOperation(value = "查询购物车商品列表")
|
public TableDataInfo list(MallCart mallCart) {
|
startPage();
|
List<MallCart> list = mallCartService.selectMallCartList(mallCart);
|
if(null !=list && list.size()>0){
|
for (MallCart cart : list) {
|
Wxuser wxuser = wxuserService.getById(cart.getUserId());
|
cart.setPhone(wxuser.getPhone());
|
cart.setPacProName(packageService.getTjPacProNames(String.valueOf(cart.getGoodsId())));
|
}
|
}
|
return getDataTable(list);
|
}
|
|
|
|
/**
|
* 导出购物车商品列表
|
*/
|
@PreAuthorize("@ss.hasPermi('mall:cart:export')")
|
@Log(title = "购物车商品", businessType = BusinessType.EXPORT)
|
@PostMapping("/export")
|
@ApiOperation(value = "导出购物车商品列表")
|
public void export(HttpServletResponse response, MallCart mallCart) {
|
List<MallCart> list = mallCartService.selectMallCartList(mallCart);
|
ExcelUtil<MallCart> util = new ExcelUtil<MallCart>(MallCart.class);
|
util.exportExcel(response, list, "购物车商品数据");
|
}
|
|
/**
|
* 获取购物车商品详细信息
|
*/
|
@PreAuthorize("@ss.hasPermi('mall:cart:query')")
|
@GetMapping(value = "/{id}")
|
@ApiOperation(value = "获取购物车商品详细信息")
|
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
return success(mallCartService.selectMallCartById(id));
|
}
|
|
/**
|
* 新增购物车商品
|
*/
|
@PreAuthorize("@ss.hasPermi('mall:cart:add')")
|
@Log(title = "购物车商品", businessType = BusinessType.INSERT)
|
@PostMapping
|
@ApiOperation(value = "新增购物车商品")
|
public AjaxResult add(@RequestBody MallCart mallCart) {
|
return toAjax(mallCartService.insertMallCart(mallCart));
|
}
|
|
/**
|
* 修改购物车商品
|
*/
|
@PreAuthorize("@ss.hasPermi('mall:cart:edit')")
|
@Log(title = "购物车商品", businessType = BusinessType.UPDATE)
|
@PutMapping
|
@ApiOperation(value = "修改购物车商品")
|
public AjaxResult edit(@RequestBody MallCart mallCart) {
|
return toAjax(mallCartService.updateMallCart(mallCart));
|
}
|
|
/**
|
* 删除购物车商品
|
*/
|
@PreAuthorize("@ss.hasPermi('mall:cart:remove')")
|
@Log(title = "购物车商品", businessType = BusinessType.DELETE)
|
@DeleteMapping("/{ids}")
|
@ApiOperation(value = "删除购物车商品")
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
return toAjax(mallCartService.deleteMallCartByIds(ids));
|
}
|
}
|