package com.yijia.station.controller;

import java.util.List;
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.yijia.common.annotation.Log;
import com.yijia.common.core.controller.BaseController;
import com.yijia.common.core.domain.AjaxResult;
import com.yijia.common.enums.BusinessType;
import com.yijia.station.domain.PayOrder;
import com.yijia.station.service.IPayOrderService;
import com.yijia.common.utils.poi.ExcelUtil;
import com.yijia.common.core.page.TableDataInfo;

/**
 * 订单支付Controller
 *
 * @author yijia
 * @date 2020-12-10
 */
@RestController
@RequestMapping("/station/order")
public class PayOrderController extends BaseController
{
    @Autowired
    private IPayOrderService payOrderService;

    /**
     * 查询订单支付列表
     */
    @PreAuthorize("@ss.hasPermi('station:order:list')")
    @GetMapping("/list")
    public TableDataInfo list(PayOrder payOrder)
    {
        startPage();
        List<PayOrder> list = payOrderService.selectPayOrderList(payOrder);
        return getDataTable(list);
    }

    /**
     * 导出订单支付列表
     */
    @PreAuthorize("@ss.hasPermi('station:order:export')")
    @Log(title = "订单支付", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PayOrder payOrder)
    {
        List<PayOrder> list = payOrderService.selectPayOrderList(payOrder);
        ExcelUtil<PayOrder> util = new ExcelUtil<PayOrder>(PayOrder.class);
        return util.exportExcel(list, "order");
    }

    /**
     * 获取订单支付详细信息
     */
    @PreAuthorize("@ss.hasPermi('station:order:query')")
    @GetMapping(value = "/{orderId}")
    public AjaxResult getInfo(@PathVariable("orderId") Long orderId)
    {
        return AjaxResult.success(payOrderService.selectPayOrderById(orderId));
    }

    /**
     * 新增订单支付
     */
    @PreAuthorize("@ss.hasPermi('station:order:add')")
    @Log(title = "订单支付", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PayOrder payOrder)
    {
        return toAjax(payOrderService.insertPayOrder(payOrder));
    }

    /**
     * 修改订单支付
     */
    @PreAuthorize("@ss.hasPermi('station:order:edit')")
    @Log(title = "订单支付", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PayOrder payOrder)
    {
        return toAjax(payOrderService.updatePayOrder(payOrder));
    }

    /**
     * 删除订单支付
     */
    @PreAuthorize("@ss.hasPermi('station:order:remove')")
    @Log(title = "订单支付", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderIds}")
    public AjaxResult remove(@PathVariable Long[] orderIds)
    {
        return toAjax(payOrderService.deletePayOrderByIds(orderIds));
    }
}
