package com.ruoyi.frequency.orderextensionrecord.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.frequency.orderextensionrecord.entity.OrderExtensionRecord;
import com.ruoyi.frequency.orderextensionrecord.service.OrderExtensionRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 订单延期记录Controller
 * 
 * @author liwenlong
 * @date 2023-11-03
 */
@RestController
@RequestMapping("/frequency/orderextensionrecord")
public class OrderExtensionRecordController extends BaseController
{
    @Autowired
    private OrderExtensionRecordService orderExtensionRecordService;

    /**
     * 查询订单延期记录列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:orderextensionrecord:list')")
    @PostMapping("/list")
    public TableDataInfo<OrderExtensionRecord> list(@RequestBody OrderExtensionRecord orderExtensionRecord)
    {
        startPage();
        List<OrderExtensionRecord> list = orderExtensionRecordService.selectOrderExtensionRecordList(orderExtensionRecord);
        return getDataTable(list);
    }

    /**
     * 导出订单延期记录列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:orderextensionrecord:export')")
    @Log(title = "订单延期记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OrderExtensionRecord orderExtensionRecord)
    {
        List<OrderExtensionRecord> list = orderExtensionRecordService.selectOrderExtensionRecordList(orderExtensionRecord);
        ExcelUtil<OrderExtensionRecord> util = new ExcelUtil<OrderExtensionRecord>(OrderExtensionRecord.class);
        return util.exportExcel(list, "订单延期记录数据");
    }

    /**
     * 获取订单延期记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('frequency:orderextensionrecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult<OrderExtensionRecord> getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(orderExtensionRecordService.selectOrderExtensionRecordById(id));
    }

    /**
     * 新增订单延期记录
     */
    @PreAuthorize("@ss.hasPermi('frequency:orderextensionrecord:add')")
    @Log(title = "订单延期记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderExtensionRecord orderExtensionRecord)
    {
        return toAjax(orderExtensionRecordService.insertOrderExtensionRecord(orderExtensionRecord));
    }

    /**
     * 修改订单延期记录
     */
    @PreAuthorize("@ss.hasPermi('frequency:orderextensionrecord:edit')")
    @Log(title = "订单延期记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderExtensionRecord orderExtensionRecord)
    {
        return toAjax(orderExtensionRecordService.updateOrderExtensionRecord(orderExtensionRecord));
    }

    /**
     * 删除订单延期记录
     */
    @PreAuthorize("@ss.hasPermi('frequency:orderextensionrecord:remove')")
    @Log(title = "订单延期记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}/{delFlag}")
    public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFalg)
    {
        return toAjax(orderExtensionRecordService.deleteOrderExtensionRecordByIds(ids,delFalg));
    }
}
