package com.ruoyi.plant.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.plant.domain.TCanteenCard;
import com.ruoyi.plant.service.ITCanteenCardService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 员工卡管理Controller
 * 
 * @author ruoyi
 * @date 2025-04-22
 */
@RestController
@RequestMapping("/plant/card")
public class TCanteenCardController extends BaseController
{
    @Autowired
    private ITCanteenCardService tCanteenCardService;

    /**
     * 查询员工卡管理列表
     */
    @PreAuthorize("@ss.hasPermi('plant:card:list')")
    @GetMapping("/list")
    public TableDataInfo list(TCanteenCard tCanteenCard)
    {
        startPage();
        List<TCanteenCard> list = tCanteenCardService.selectTCanteenCardList(tCanteenCard);
        return getDataTable(list);
    }

    /**
     * 导出员工卡管理列表
     */
    @PreAuthorize("@ss.hasPermi('plant:card:export')")
    @Log(title = "员工卡管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TCanteenCard tCanteenCard)
    {
        List<TCanteenCard> list = tCanteenCardService.selectTCanteenCardList(tCanteenCard);
        ExcelUtil<TCanteenCard> util = new ExcelUtil<TCanteenCard>(TCanteenCard.class);
        util.exportExcel(response, list, "员工卡管理数据");
    }

    /**
     * 获取员工卡管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('plant:card:query')")
    @GetMapping(value = "/{cardId}")
    public AjaxResult getInfo(@PathVariable("cardId") Long cardId)
    {
        return success(tCanteenCardService.selectTCanteenCardByCardId(cardId));
    }

    /**
     * 新增员工卡管理
     */
    @PreAuthorize("@ss.hasPermi('plant:card:add')")
    @Log(title = "员工卡管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TCanteenCard tCanteenCard)
    {
        return toAjax(tCanteenCardService.insertTCanteenCard(tCanteenCard));
    }

    /**
     * 修改员工卡管理
     */
    @PreAuthorize("@ss.hasPermi('plant:card:edit')")
    @Log(title = "员工卡管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TCanteenCard tCanteenCard)
    {
        return toAjax(tCanteenCardService.updateTCanteenCard(tCanteenCard));
    }

    /**
     * 删除员工卡管理
     */
    @PreAuthorize("@ss.hasPermi('plant:card:remove')")
    @Log(title = "员工卡管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cardIds}")
    public AjaxResult remove(@PathVariable Long[] cardIds)
    {
        return toAjax(tCanteenCardService.deleteTCanteenCardByCardIds(cardIds));
    }
}
