package com.ruoyi.tuya.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.tuya.domain.BusTravel;
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.BusSupplierRelease;
import com.ruoyi.tuya.service.IBusSupplierReleaseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 平台报价单Controller
 *
 * @author zf
 * @date 2022-07-21
 */
@RestController
@RequestMapping("/tuya/supplierRelease")
public class BusSupplierReleaseController extends BaseController
{
    @Autowired
    private IBusSupplierReleaseService busSupplierReleaseService;

    /**
     * 获取模块下拉列表
     */
    @GetMapping("/selectlist")
    public AjaxResult selectlist(BusSupplierRelease busSupplierRelease)
    {
        return AjaxResult.success(busSupplierReleaseService.selectBusSupplierReleaseList(busSupplierRelease));
    }

    /**
     * 查询平台报价单列表
     */
    @PreAuthorize("@ss.hasPermi('tuya:release:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusSupplierRelease busSupplierRelease)
    {
        startPage();
        List<BusSupplierRelease> list = busSupplierReleaseService.selectBusSupplierReleaseList(busSupplierRelease);
        return getDataTable(list);
    }

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

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

    /**
     * 新增平台报价单
     */
    @PreAuthorize("@ss.hasPermi('tuya:release:add')")
    @Log(title = "平台报价单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusSupplierRelease busSupplierRelease)
    {
        return toAjax(busSupplierReleaseService.insertBusSupplierRelease(busSupplierRelease));
    }

    /**
     * 修改平台报价单
     */
    @PreAuthorize("@ss.hasPermi('tuya:release:edit')")
    @Log(title = "平台报价单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusSupplierRelease busSupplierRelease)
    {
        return toAjax(busSupplierReleaseService.updateBusSupplierRelease(busSupplierRelease));
    }

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

    /**
     * 热门修改
     */
    @PreAuthorize("@ss.hasPermi('tuya:release:changeHotForm')")
    @Log(title = "平台报价单", businessType = BusinessType.UPDATE)
    @PutMapping("/changeHotForm")
    public AjaxResult changeHotForm(@RequestBody BusSupplierRelease busSupplierRelease)
    {
       return toAjax(busSupplierReleaseService.updateHotForm(busSupplierRelease));
    }
}
