package com.ruoyi.supplier.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.supplier.domain.TCanteenQualification;
import com.ruoyi.supplier.service.ITCanteenQualificationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 供应商资质Controller
 * 
 * @author ruoyi
 * @date 2025-04-22
 */
@RestController
@RequestMapping("/supplier/qualification")
public class TCanteenQualificationController extends BaseController
{
    @Autowired
    private ITCanteenQualificationService tCanteenQualificationService;

    /**
     * 查询供应商资质列表
     */
    @PreAuthorize("@ss.hasPermi('supplier:qualification:list')")
    @GetMapping("/list")
    public TableDataInfo list(TCanteenQualification tCanteenQualification)
    {
        startPage();
        List<TCanteenQualification> list = tCanteenQualificationService.selectTCanteenQualificationList(tCanteenQualification);
        return getDataTable(list);
    }

    /**
     * 导出供应商资质列表
     */
    @PreAuthorize("@ss.hasPermi('supplier:qualification:export')")
    @Log(title = "供应商资质", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TCanteenQualification tCanteenQualification)
    {
        List<TCanteenQualification> list = tCanteenQualificationService.selectTCanteenQualificationList(tCanteenQualification);
        ExcelUtil<TCanteenQualification> util = new ExcelUtil<TCanteenQualification>(TCanteenQualification.class);
        util.exportExcel(response, list, "供应商资质数据");
    }

    /**
     * 获取供应商资质详细信息
     */
    @PreAuthorize("@ss.hasPermi('supplier:qualification:query')")
    @GetMapping(value = "/{qualificationId}")
    public AjaxResult getInfo(@PathVariable("qualificationId") Long qualificationId)
    {
        return success(tCanteenQualificationService.selectTCanteenQualificationByQualificationId(qualificationId));
    }

    /**
     * 新增供应商资质
     */
    @PreAuthorize("@ss.hasPermi('supplier:qualification:add')")
    @Log(title = "供应商资质", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TCanteenQualification tCanteenQualification)
    {
        return toAjax(tCanteenQualificationService.insertTCanteenQualification(tCanteenQualification));
    }

    /**
     * 修改供应商资质
     */
    @PreAuthorize("@ss.hasPermi('supplier:qualification:edit')")
    @Log(title = "供应商资质", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TCanteenQualification tCanteenQualification)
    {
        return toAjax(tCanteenQualificationService.updateTCanteenQualification(tCanteenQualification));
    }

    /**
     * 删除供应商资质
     */
    @PreAuthorize("@ss.hasPermi('supplier:qualification:remove')")
    @Log(title = "供应商资质", businessType = BusinessType.DELETE)
	@DeleteMapping("/{qualificationIds}")
    public AjaxResult remove(@PathVariable Long[] qualificationIds)
    {
        return toAjax(tCanteenQualificationService.deleteTCanteenQualificationByQualificationIds(qualificationIds));
    }
}
