package com.ruoyi.bid.controller;

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

import com.ruoyi.bid.domain.BidSite;
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.BidZizhi;
import com.ruoyi.bid.service.IBidZizhiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 资质证书Controller
 * 
 * @author ruoyi
 * @date 2025-12-10
 */
@RestController
@RequestMapping("/bid/zizhi")
public class BidZizhiController extends BaseController
{
    @Autowired
    private IBidZizhiService bidZizhiService;

    /**
     * 查询资质证书列表
     */
    @PreAuthorize("@ss.hasPermi('bid:zizhi:list')")
    @GetMapping("/list")
    public TableDataInfo list(BidZizhi bidZizhi)
    {
        startPage();
        List<BidZizhi> list = bidZizhiService.selectBidZizhiList(bidZizhi);
        return getDataTable(list);
    }

    /**
     * 导出资质证书列表
     */
    @PreAuthorize("@ss.hasPermi('bid:zizhi:export')")
    @Log(title = "资质证书", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BidZizhi bidZizhi)
    {
        List<BidZizhi> list = bidZizhiService.selectBidZizhiList(bidZizhi);
        ExcelUtil<BidZizhi> util = new ExcelUtil<BidZizhi>(BidZizhi.class);
        util.exportExcel(response, list, "资质证书数据");
    }

    /**
     * 获取资质证书详细信息
     */
    @PreAuthorize("@ss.hasPermi('bid:zizhi:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bidZizhiService.selectBidZizhiById(id));
    }

    /**
     * 新增资质证书
     */
    @PreAuthorize("@ss.hasPermi('bid:zizhi:add')")
    @Log(title = "资质证书", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BidZizhi bidZizhi)
    {
        return toAjax(bidZizhiService.insertBidZizhi(bidZizhi));
    }

    /**
     * 新增资质证书
     */
    @PreAuthorize("@ss.hasPermi('bid:zizhi:add')")
    @Log(title = "资质证书", businessType = BusinessType.INSERT)
    @PostMapping("/adds")
    public AjaxResult adds(@RequestBody List<BidZizhi> bidZizhis)
    {
        for (BidZizhi bidZizhi : bidZizhis) {
            bidZizhiService.insertBidZizhi(bidZizhi);
        }
        return toAjax(1);
    }

    /**
     * 修改资质证书
     */
    @PreAuthorize("@ss.hasPermi('bid:zizhi:edit')")
    @Log(title = "资质证书", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BidZizhi bidZizhi)
    {
        return toAjax(bidZizhiService.updateBidZizhi(bidZizhi));
    }

    /**
     * 删除资质证书
     */
    @PreAuthorize("@ss.hasPermi('bid:zizhi:remove')")
    @Log(title = "资质证书", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bidZizhiService.deleteBidZizhiByIds(ids));
    }
}
