package com.ruoyi.model.controller;

import java.io.IOException;
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.model.domain.AppFeedingFoodType;
import com.ruoyi.model.service.IAppFeedingFoodTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 喂养食品类型Controller
 * 
 * @author ruoyi
 * @date 2025-03-08
 */
@RestController
@RequestMapping("/model/AppFeedingFoodType")
public class AppFeedingFoodTypeController extends BaseController
{
    @Autowired
    private IAppFeedingFoodTypeService appFeedingFoodTypeService;

    /**
     * 查询喂养食品类型列表
     */
    @PreAuthorize("@ss.hasPermi('model:AppFeedingFoodType:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppFeedingFoodType appFeedingFoodType)
    {
        startPage();
        List<AppFeedingFoodType> list = appFeedingFoodTypeService.selectAppFeedingFoodTypeList(appFeedingFoodType);
        return getDataTable(list);
    }

    /**
     * 导出喂养食品类型列表
     */
    @PreAuthorize("@ss.hasPermi('model:AppFeedingFoodType:export')")
    @Log(title = "喂养食品类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppFeedingFoodType appFeedingFoodType) throws IOException {
        List<AppFeedingFoodType> list = appFeedingFoodTypeService.selectAppFeedingFoodTypeList(appFeedingFoodType);
        ExcelUtil<AppFeedingFoodType> util = new ExcelUtil<AppFeedingFoodType>(AppFeedingFoodType.class);
        util.exportExcel(response, list, "喂养食品类型数据");
    }

    /**
     * 获取喂养食品类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:AppFeedingFoodType:query')")
    @GetMapping(value = "/{feedingFoodTypeId}")
    public AjaxResult getInfo(@PathVariable("feedingFoodTypeId") Long feedingFoodTypeId)
    {
        return success(appFeedingFoodTypeService.selectAppFeedingFoodTypeByFeedingFoodTypeId(feedingFoodTypeId));
    }

    /**
     * 新增喂养食品类型
     */
    @PreAuthorize("@ss.hasPermi('model:AppFeedingFoodType:add')")
    @Log(title = "喂养食品类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppFeedingFoodType appFeedingFoodType)
    {
        return toAjax(appFeedingFoodTypeService.insertAppFeedingFoodType(appFeedingFoodType));
    }

    /**
     * 修改喂养食品类型
     */
    @PreAuthorize("@ss.hasPermi('model:AppFeedingFoodType:edit')")
    @Log(title = "喂养食品类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppFeedingFoodType appFeedingFoodType)
    {
        return toAjax(appFeedingFoodTypeService.updateAppFeedingFoodType(appFeedingFoodType));
    }

    /**
     * 删除喂养食品类型
     */
    @PreAuthorize("@ss.hasPermi('model:AppFeedingFoodType:remove')")
    @Log(title = "喂养食品类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{feedingFoodTypeIds}")
    public AjaxResult remove(@PathVariable Long[] feedingFoodTypeIds)
    {
        return toAjax(appFeedingFoodTypeService.deleteAppFeedingFoodTypeByFeedingFoodTypeIds(feedingFoodTypeIds));
    }
}
