package com.ruoyi.frequency.orderpricerecord.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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.frequency.orderpricerecord.entity.OrderPriceRecord;
import com.ruoyi.frequency.orderpricerecord.service.OrderPriceRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单价格明细记录Controller
 * 
 * @author liwenlong
 * @date 2024-01-24
 */
@RestController
@RequestMapping("/frequency/orderpricerecord")
public class OrderPriceRecordController extends BaseController
{
    @Autowired
    private OrderPriceRecordService orderPriceRecordService;

    /**
     * 查询订单价格明细记录列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:orderpricerecord:list')")
    @GetMapping("/list")
    public TableDataInfo<OrderPriceRecord> list(OrderPriceRecord orderPriceRecord)
    {
        startPage();
        List<OrderPriceRecord> list = orderPriceRecordService.selectOrderPriceRecordList(orderPriceRecord);
        return getDataTable(list);
    }

    /**
     * 导出订单价格明细记录列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:orderpricerecord:export')")
    @Log(title = "订单价格明细记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OrderPriceRecord orderPriceRecord)
    {
        List<OrderPriceRecord> list = orderPriceRecordService.selectOrderPriceRecordList(orderPriceRecord);
        ExcelUtil<OrderPriceRecord> util = new ExcelUtil<OrderPriceRecord>(OrderPriceRecord.class);
        return util.exportExcel(list, "订单价格明细记录数据");
    }

    /**
     * 获取订单价格明细记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('frequency:orderpricerecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult<OrderPriceRecord> getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(orderPriceRecordService.selectOrderPriceRecordById(id));
    }

    /**
     * 新增订单价格明细记录
     */
    @PreAuthorize("@ss.hasPermi('frequency:orderpricerecord:add')")
    @Log(title = "订单价格明细记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderPriceRecord orderPriceRecord)
    {
        return toAjax(orderPriceRecordService.insertOrderPriceRecord(orderPriceRecord));
    }

    /**
     * 修改订单价格明细记录
     */
    @PreAuthorize("@ss.hasPermi('frequency:orderpricerecord:edit')")
    @Log(title = "订单价格明细记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderPriceRecord orderPriceRecord)
    {
        return toAjax(orderPriceRecordService.updateOrderPriceRecord(orderPriceRecord));
    }

    /**
     * 删除订单价格明细记录
     */
    @PreAuthorize("@ss.hasPermi('frequency:orderpricerecord:remove')")
    @Log(title = "订单价格明细记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}/{delFlag}")
    public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag)
    {
        return toAjax(orderPriceRecordService.deleteOrderPriceRecordByIds(ids,delFlag));
    }
}
