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

/**
 * 宠物品种Controller
 * 
 * @author ruoyi
 * @date 2025-03-08
 */
@RestController
@RequestMapping("/model/AppPetsBread")
public class AppPetsBreadController extends BaseController
{
    @Autowired
    private IAppPetsBreadService appPetsBreadService;

    /**
     * 查询宠物品种列表
     */
    @PreAuthorize("@ss.hasPermi('model:AppPetsBread:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppPetsBread appPetsBread)
    {
        startPage();
        List<AppPetsBread> list = appPetsBreadService.selectAppPetsBreadList(appPetsBread);
        return getDataTable(list);
    }

    /**
     * 导出宠物品种列表
     */
    @PreAuthorize("@ss.hasPermi('model:AppPetsBread:export')")
    @Log(title = "宠物品种", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppPetsBread appPetsBread) throws IOException {
        List<AppPetsBread> list = appPetsBreadService.selectAppPetsBreadList(appPetsBread);
        ExcelUtil<AppPetsBread> util = new ExcelUtil<AppPetsBread>(AppPetsBread.class);
        util.exportExcel(response, list, "宠物品种数据");
    }

    /**
     * 获取宠物品种详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:AppPetsBread:query')")
    @GetMapping(value = "/{petBreadId}")
    public AjaxResult getInfo(@PathVariable("petBreadId") Long petBreadId)
    {
        return success(appPetsBreadService.selectAppPetsBreadByPetBreadId(petBreadId));
    }

    /**
     * 新增宠物品种
     */
    @PreAuthorize("@ss.hasPermi('model:AppPetsBread:add')")
    @Log(title = "宠物品种", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppPetsBread appPetsBread)
    {
        return toAjax(appPetsBreadService.insertAppPetsBread(appPetsBread));
    }

    /**
     * 修改宠物品种
     */
    @PreAuthorize("@ss.hasPermi('model:AppPetsBread:edit')")
    @Log(title = "宠物品种", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppPetsBread appPetsBread)
    {
        return toAjax(appPetsBreadService.updateAppPetsBread(appPetsBread));
    }

    /**
     * 删除宠物品种
     */
    @PreAuthorize("@ss.hasPermi('model:AppPetsBread:remove')")
    @Log(title = "宠物品种", businessType = BusinessType.DELETE)
	@DeleteMapping("/{petBreadIds}")
    public AjaxResult remove(@PathVariable Long[] petBreadIds)
    {
        return toAjax(appPetsBreadService.deleteAppPetsBreadByPetBreadIds(petBreadIds));
    }
}
