package com.ruoyi.bid.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.bid.domain.BidInfo;
import com.ruoyi.bid.service.IBidInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 招标信息Controller
 * 
 * @author ruoyi
 * @date 2025-12-09
 */
@RestController
@RequestMapping("/bid/info")
public class BidInfoController extends BaseController
{
    @Autowired
    private IBidInfoService bidInfoService;

    /**
     * 查询招标信息列表
     */
    @PreAuthorize("@ss.hasPermi('bid:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(BidInfo bidInfo)
    {
        startPage();
        List<BidInfo> list = bidInfoService.selectBidInfoList(bidInfo);
        return getDataTable(list);
    }

    /**
     * 导出招标信息列表
     */
    @PreAuthorize("@ss.hasPermi('bid:info:export')")
    @Log(title = "招标信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BidInfo bidInfo)
    {
        List<BidInfo> list = bidInfoService.selectBidInfoList(bidInfo);
        ExcelUtil<BidInfo> util = new ExcelUtil<BidInfo>(BidInfo.class);
        util.exportExcel(response, list, "招标信息数据");
    }

    /**
     * 获取招标信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('bid:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bidInfoService.selectBidInfoById(id));
    }

    /**
     * 新增招标信息
     */
    @PreAuthorize("@ss.hasPermi('bid:info:add')")
    @Log(title = "招标信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BidInfo bidInfo)
    {
        return toAjax(bidInfoService.insertBidInfo(bidInfo));
    }

    /**
     * 修改招标信息
     */
    @PreAuthorize("@ss.hasPermi('bid:info:edit')")
    @Log(title = "招标信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BidInfo bidInfo)
    {
        return toAjax(bidInfoService.updateBidInfo(bidInfo));
    }

    /**
     * 删除招标信息
     */
    @PreAuthorize("@ss.hasPermi('bid:info:remove')")
    @Log(title = "招标信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bidInfoService.deleteBidInfoByIds(ids));
    }
}
