package com.ruoyi.tuya.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.tuya.domain.BusSupplierReleaseDay;
import com.ruoyi.tuya.service.IBusSupplierReleaseDayService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 平台报价单明细Controller
 *
 * @author zf
 * @date 2022-07-22
 */
@RestController
@RequestMapping("/tuya/supplierDay")
public class BusSupplierReleaseDayController extends BaseController
{
    @Autowired
    private IBusSupplierReleaseDayService busSupplierReleaseDayService;

    /**
     * 查询平台报价单明细列表
     */
    @PreAuthorize("@ss.hasPermi('tuya:day:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusSupplierReleaseDay busSupplierReleaseDay)
    {
        startPage();
        List<BusSupplierReleaseDay> list = busSupplierReleaseDayService.selectBusSupplierReleaseDayList(busSupplierReleaseDay);
        return getDataTable(list);
    }

    /**
     * 导出平台报价单明细列表
     */
    @PreAuthorize("@ss.hasPermi('tuya:day:export')")
    @Log(title = "平台报价单明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusSupplierReleaseDay busSupplierReleaseDay)
    {
        List<BusSupplierReleaseDay> list = busSupplierReleaseDayService.selectBusSupplierReleaseDayList(busSupplierReleaseDay);
        ExcelUtil<BusSupplierReleaseDay> util = new ExcelUtil<BusSupplierReleaseDay>(BusSupplierReleaseDay.class);
        util.exportExcel(response, list, "平台报价单明细数据");
    }

    /**
     * 获取平台报价单明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('tuya:day:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(busSupplierReleaseDayService.selectBusSupplierReleaseDayById(id));
    }

    /**
     * 新增平台报价单明细
     */
    @PreAuthorize("@ss.hasPermi('tuya:day:add')")
    @Log(title = "平台报价单明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusSupplierReleaseDay busSupplierReleaseDay)
    {
        return toAjax(busSupplierReleaseDayService.insertBusSupplierReleaseDay(busSupplierReleaseDay));
    }

    /**
     * 修改平台报价单明细
     */
    @PreAuthorize("@ss.hasPermi('tuya:day:edit')")
    @Log(title = "平台报价单明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusSupplierReleaseDay busSupplierReleaseDay)
    {
        return toAjax(busSupplierReleaseDayService.updateBusSupplierReleaseDay(busSupplierReleaseDay));
    }

    /**
     * 删除平台报价单明细
     */
    @PreAuthorize("@ss.hasPermi('tuya:day:remove')")
    @Log(title = "平台报价单明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(busSupplierReleaseDayService.deleteBusSupplierReleaseDayByIds(ids));
    }
}
