package com.zhongzheng.controller.order;

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

import com.zhongzheng.modules.order.bo.OrderCouponEditBo;
import com.zhongzheng.modules.order.bo.OrderCouponQueryBo;
import com.zhongzheng.modules.order.domain.OrderCoupon;
import com.zhongzheng.modules.order.domain.OrderGoods;
import com.zhongzheng.modules.order.service.IOrderCouponService;
import com.zhongzheng.modules.order.vo.OrderCouponVo;
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 hjl
 * @date 2021-07-20
 */
@Api(value = "订单优惠券 控制器", tags = {"订单优惠券 管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/order/coupon")
public class OrderCouponController extends BaseController {

    private final IOrderCouponService iOrderCouponService;

    /**
     * 查询订单优惠券 列表
     */
    @ApiOperation("查询订单优惠券 列表")
    @PreAuthorize("@ss.hasPermi('order:coupon:list')")
    @GetMapping("/list")
    public AjaxResult<List<OrderCoupon>>list(OrderCouponQueryBo bo) {
        List<OrderCoupon> list = iOrderCouponService.queryOrderCouponList(bo);
        return AjaxResult.success(list);
    }

    /**
     * 导出订单优惠券 列表
     */
   /* @ApiOperation("导出订单优惠券 列表")
    @PreAuthorize("@ss.hasPermi('system:coupon:export')")
    @Log(title = "订单优惠券 ", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<OrderCouponVo> export(OrderCouponQueryBo bo) {
        List<OrderCouponVo> list = iOrderCouponService.queryList(bo);
        ExcelUtil<OrderCouponVo> util = new ExcelUtil<OrderCouponVo>(OrderCouponVo.class);
        return util.exportExcel(list, "订单优惠券 ");
    }*/

    /**
     * 获取订单优惠券 详细信息
     */
    @ApiOperation("获取订单优惠券 详细信息")
    @PreAuthorize("@ss.hasPermi('order:coupon:query')")
    @GetMapping("/{id}")
    public AjaxResult<OrderCouponVo> getInfo(@PathVariable("id" ) Long id) {
        return AjaxResult.success(iOrderCouponService.queryById(id));
    }



    /**
     * 修改订单优惠券
     */
    @ApiOperation("修改订单优惠券 ")
    @PreAuthorize("@ss.hasPermi('order:coupon:edit')")
    @Log(title = "订单优惠券 ", businessType = BusinessType.UPDATE)
    @PutMapping()
    public AjaxResult<Void> edit(@RequestBody OrderCouponEditBo bo) {
        return toAjax(iOrderCouponService.updateByEditBo(bo) ? 1 : 0);
    }


}
