package com.ruoyi.goods.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.goods.domain.TCanteenClassify;
import com.ruoyi.goods.service.ITCanteenClassifyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 菜单类型Controller
 * 
 * @author ruoyi
 * @date 2025-04-22
 */
@RestController
@RequestMapping("/goods/classify")
public class TCanteenClassifyController extends BaseController
{
    @Autowired
    private ITCanteenClassifyService tCanteenClassifyService;

    /**
     * 查询菜单类型列表
     */
    @PreAuthorize("@ss.hasPermi('goods:classify:list')")
    @GetMapping("/list")
    public TableDataInfo list(TCanteenClassify tCanteenClassify)
    {
        startPage();
        List<TCanteenClassify> list = tCanteenClassifyService.selectTCanteenClassifyList(tCanteenClassify);
        return getDataTable(list);
    }

    /**
     * 导出菜单类型列表
     */
    @PreAuthorize("@ss.hasPermi('goods:classify:export')")
    @Log(title = "菜单类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TCanteenClassify tCanteenClassify)
    {
        List<TCanteenClassify> list = tCanteenClassifyService.selectTCanteenClassifyList(tCanteenClassify);
        ExcelUtil<TCanteenClassify> util = new ExcelUtil<TCanteenClassify>(TCanteenClassify.class);
        util.exportExcel(response, list, "菜单类型数据");
    }

    /**
     * 获取菜单类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('goods:classify:query')")
    @GetMapping(value = "/{classifyId}")
    public AjaxResult getInfo(@PathVariable("classifyId") Long classifyId)
    {
        return success(tCanteenClassifyService.selectTCanteenClassifyByClassifyId(classifyId));
    }

    /**
     * 新增菜单类型
     */
    @PreAuthorize("@ss.hasPermi('goods:classify:add')")
    @Log(title = "菜单类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TCanteenClassify tCanteenClassify)
    {
        return toAjax(tCanteenClassifyService.insertTCanteenClassify(tCanteenClassify));
    }

    /**
     * 修改菜单类型
     */
    @PreAuthorize("@ss.hasPermi('goods:classify:edit')")
    @Log(title = "菜单类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TCanteenClassify tCanteenClassify)
    {
        return toAjax(tCanteenClassifyService.updateTCanteenClassify(tCanteenClassify));
    }

    /**
     * 删除菜单类型
     */
    @PreAuthorize("@ss.hasPermi('goods:classify:remove')")
    @Log(title = "菜单类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{classifyIds}")
    public AjaxResult remove(@PathVariable Long[] classifyIds)
    {
        return toAjax(tCanteenClassifyService.deleteTCanteenClassifyByClassifyIds(classifyIds));
    }
}
