package com.ruoyi.frequency.orderreceiving.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.orderreceiving.entity.OrderReceiving;
import com.ruoyi.frequency.orderreceiving.service.OrderReceivingService;
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 zj
 * @date 2023-10-13
 */
@RestController
@RequestMapping("/frequency/orderreceiving")
public class OrderReceivingController extends BaseController
{
    @Autowired
    private OrderReceivingService orderReceivingService;

    /**
     * 查询现师接单列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:orderreceiving:list')")
    @PostMapping("/list")
    public TableDataInfo<OrderReceiving> list(@RequestBody OrderReceiving orderReceiving)
    {
        startPage();
        List<OrderReceiving> list = orderReceivingService.selectOrderReceivingList(orderReceiving);
        return getDataTable(list);
    }

    /**
     * 导出现师接单列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:orderreceiving:export')")
    @Log(title = "现师接单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OrderReceiving orderReceiving)
    {
        List<OrderReceiving> list = orderReceivingService.selectOrderReceivingList(orderReceiving);
        ExcelUtil<OrderReceiving> util = new ExcelUtil<OrderReceiving>(OrderReceiving.class);
        return util.exportExcel(list, "现师接单数据");
    }

    /**
     * 获取现师接单详细信息
     */
    @PreAuthorize("@ss.hasPermi('frequency:orderreceiving:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult<OrderReceiving> getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(orderReceivingService.selectOrderReceivingById(id));
    }

    /**
     * 新增现师接单
     */
    @PreAuthorize("@ss.hasPermi('frequency:orderreceiving:add')")
    @Log(title = "现师接单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderReceiving orderReceiving)
    {
        return toAjax(orderReceivingService.insertOrderReceiving(orderReceiving));
    }

    /**
     * 修改现师接单
     */
    @PreAuthorize("@ss.hasPermi('frequency:orderreceiving:edit')")
    @Log(title = "现师接单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderReceiving orderReceiving)
    {
        return toAjax(orderReceivingService.updateOrderReceiving(orderReceiving));
    }

    /**
     * 删除现师接单
     */
    @PreAuthorize("@ss.hasPermi('frequency:orderreceiving:remove')")
    @Log(title = "现师接单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(orderReceivingService.deleteOrderReceivingByIds(ids));
    }
}
