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.TCanteenDaily;
import com.ruoyi.supplier.service.ITCanteenDailyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 供应商日常工作记录Controller
 * 
 * @author ruoyi
 * @date 2025-04-22
 */
@RestController
@RequestMapping("/supplier/daily")
public class TCanteenDailyController extends BaseController
{
    @Autowired
    private ITCanteenDailyService tCanteenDailyService;

    /**
     * 查询供应商日常工作记录列表
     */
    @PreAuthorize("@ss.hasPermi('supplier:daily:list')")
    @GetMapping("/list")
    public TableDataInfo list(TCanteenDaily tCanteenDaily)
    {
        startPage();
        List<TCanteenDaily> list = tCanteenDailyService.selectTCanteenDailyList(tCanteenDaily);
        return getDataTable(list);
    }

    /**
     * 导出供应商日常工作记录列表
     */
    @PreAuthorize("@ss.hasPermi('supplier:daily:export')")
    @Log(title = "供应商日常工作记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TCanteenDaily tCanteenDaily)
    {
        List<TCanteenDaily> list = tCanteenDailyService.selectTCanteenDailyList(tCanteenDaily);
        ExcelUtil<TCanteenDaily> util = new ExcelUtil<TCanteenDaily>(TCanteenDaily.class);
        util.exportExcel(response, list, "供应商日常工作记录数据");
    }

    /**
     * 获取供应商日常工作记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('supplier:daily:query')")
    @GetMapping(value = "/{dailyId}")
    public AjaxResult getInfo(@PathVariable("dailyId") Long dailyId)
    {
        return success(tCanteenDailyService.selectTCanteenDailyByDailyId(dailyId));
    }

    /**
     * 新增供应商日常工作记录
     */
    @PreAuthorize("@ss.hasPermi('supplier:daily:add')")
    @Log(title = "供应商日常工作记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TCanteenDaily tCanteenDaily)
    {
        return toAjax(tCanteenDailyService.insertTCanteenDaily(tCanteenDaily));
    }

    /**
     * 修改供应商日常工作记录
     */
    @PreAuthorize("@ss.hasPermi('supplier:daily:edit')")
    @Log(title = "供应商日常工作记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TCanteenDaily tCanteenDaily)
    {
        return toAjax(tCanteenDailyService.updateTCanteenDaily(tCanteenDaily));
    }

    /**
     * 删除供应商日常工作记录
     */
    @PreAuthorize("@ss.hasPermi('supplier:daily:remove')")
    @Log(title = "供应商日常工作记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dailyIds}")
    public AjaxResult remove(@PathVariable Long[] dailyIds)
    {
        return toAjax(tCanteenDailyService.deleteTCanteenDailyByDailyIds(dailyIds));
    }
}
