package com.zhongzheng.controller.order;

import java.util.List;
import java.util.Arrays;

import com.zhongzheng.modules.order.bo.OrderGoodsEditBo;
import com.zhongzheng.modules.order.bo.OrderGoodsQueryBo;
import com.zhongzheng.modules.order.service.IOrderGoodsService;
import com.zhongzheng.modules.order.vo.OrderGoodsVo;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
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.RestController;
import com.zhongzheng.common.annotation.Log;
import com.zhongzheng.common.core.controller.BaseController;
import com.zhongzheng.common.core.domain.AjaxResult;
import com.zhongzheng.common.enums.BusinessType;
import com.zhongzheng.common.utils.poi.ExcelUtil;
import com.zhongzheng.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 订单商品Controller
 *
 * @author ruoyi
 * @date 2021-11-12
 */
@Api(value = "订单商品控制器", tags = {"订单商品管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/order/goods")
public class OrderGoodsController extends BaseController {

    private final IOrderGoodsService iOrderGoodsService;

    /**
     * 查询订单商品列表
     */
   /* @ApiOperation("查询订单商品列表")
    @PreAuthorize("@ss.hasPermi('system:goods:list')")
    @GetMapping("/list")
    public TableDataInfo<OrderGoodsVo> list(OrderGoodsQueryBo bo) {
        startPage();
        List<OrderGoodsVo> list = iOrderGoodsService.queryList(bo);
        return getDataTable(list);
    }*/

    /**
     * 导出订单商品列表
     */
   /* @ApiOperation("导出订单商品列表")
    @PreAuthorize("@ss.hasPermi('system:goods:export')")
    @Log(title = "订单商品", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<OrderGoodsVo> export(OrderGoodsQueryBo bo) {
        List<OrderGoodsVo> list = iOrderGoodsService.queryList(bo);
        ExcelUtil<OrderGoodsVo> util = new ExcelUtil<OrderGoodsVo>(OrderGoodsVo.class);
        return util.exportExcel(list, "订单商品");
    }*/

    /**
     * 获取订单商品详细信息
     */
    @ApiOperation("获取订单商品详细信息")
    @PreAuthorize("@ss.hasPermi('system:goods:query')")
    @GetMapping("/info")
    public AjaxResult<OrderGoodsVo> getInfo(OrderGoodsQueryBo bo) {
        return AjaxResult.success(iOrderGoodsService.selectDetail(bo));
    }

    /**
     * 新增订单商品
     */
   /* @ApiOperation("新增订单商品")
    @PreAuthorize("@ss.hasPermi('system:goods:add')")
    @Log(title = "订单商品", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@RequestBody OrderGoodsAddBo bo) {
        return toAjax(iOrderGoodsService.insertByAddBo(bo) ? 1 : 0);
    }*/

    /**
     * 修改订单商品
     */
    @ApiOperation("修改订单商品")
    @PreAuthorize("@ss.hasPermi('system:goods:edit')")
    @Log(title = "订单商品", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult<Void> edit(@RequestBody OrderGoodsEditBo bo) {
        return toAjax(iOrderGoodsService.updateByEditBo(bo) ? 1 : 0);
    }

    /**
     * 删除订单商品
     */
   /* @ApiOperation("删除订单商品")
    @PreAuthorize("@ss.hasPermi('system:goods:remove')")
    @Log(title = "订单商品" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{orderGoodsIds}")
    public AjaxResult<Void> remove(@PathVariable Long[] orderGoodsIds) {
        return toAjax(iOrderGoodsService.deleteWithValidByIds(Arrays.asList(orderGoodsIds), true) ? 1 : 0);
    }*/
}
