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.AppFeedingFood;
import com.ruoyi.model.service.IAppFeedingFoodService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 喂养要求Controller
 * 
 * @author ruoyi
 * @date 2025-03-08
 */
@RestController
@RequestMapping("/model/AppFeedingFood")
public class AppFeedingFoodController extends BaseController
{
    @Autowired
    private IAppFeedingFoodService appFeedingFoodService;

    /**
     * 查询喂养要求列表
     */
    @PreAuthorize("@ss.hasPermi('model:AppFeedingFood:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppFeedingFood appFeedingFood)
    {
        startPage();
        List<AppFeedingFood> list = appFeedingFoodService.selectAppFeedingFoodList(appFeedingFood);
        return getDataTable(list);
    }

    /**
     * 导出喂养要求列表
     */
    @PreAuthorize("@ss.hasPermi('model:AppFeedingFood:export')")
    @Log(title = "喂养要求", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppFeedingFood appFeedingFood) throws IOException {
        List<AppFeedingFood> list = appFeedingFoodService.selectAppFeedingFoodList(appFeedingFood);
        ExcelUtil<AppFeedingFood> util = new ExcelUtil<AppFeedingFood>(AppFeedingFood.class);
        util.exportExcel(response, list, "喂养要求数据");
    }

    /**
     * 获取喂养要求详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:AppFeedingFood:query')")
    @GetMapping(value = "/{feedingFoodId}")
    public AjaxResult getInfo(@PathVariable("feedingFoodId") Long feedingFoodId)
    {
        return success(appFeedingFoodService.selectAppFeedingFoodByFeedingFoodId(feedingFoodId));
    }

    /**
     * 新增喂养要求
     */
    @PreAuthorize("@ss.hasPermi('model:AppFeedingFood:add')")
    @Log(title = "喂养要求", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppFeedingFood appFeedingFood)
    {
        return toAjax(appFeedingFoodService.insertAppFeedingFood(appFeedingFood));
    }

    /**
     * 修改喂养要求
     */
    @PreAuthorize("@ss.hasPermi('model:AppFeedingFood:edit')")
    @Log(title = "喂养要求", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppFeedingFood appFeedingFood)
    {
        return toAjax(appFeedingFoodService.updateAppFeedingFood(appFeedingFood));
    }

    /**
     * 删除喂养要求
     */
    @PreAuthorize("@ss.hasPermi('model:AppFeedingFood:remove')")
    @Log(title = "喂养要求", businessType = BusinessType.DELETE)
	@DeleteMapping("/{feedingFoodIds}")
    public AjaxResult remove(@PathVariable Long[] feedingFoodIds)
    {
        return toAjax(appFeedingFoodService.deleteAppFeedingFoodByFeedingFoodIds(feedingFoodIds));
    }
}
