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

/**
 * 宠物类型Controller
 * 
 * @author ruoyi
 * @date 2025-03-08
 */
@RestController
@RequestMapping("/model/AppPetType")
public class AppPetTypeController extends BaseController
{
    @Autowired
    private IAppPetTypeService appPetTypeService;

    /**
     * 查询宠物类型列表
     */
    @PreAuthorize("@ss.hasPermi('model:AppPetType:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppPetType appPetType)
    {
        startPage();
        List<AppPetType> list = appPetTypeService.selectAppPetTypeList(appPetType);
        return getDataTable(list);
    }

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

    /**
     * 获取宠物类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:AppPetType:query')")
    @GetMapping(value = "/{petTypeId}")
    public AjaxResult getInfo(@PathVariable("petTypeId") Long petTypeId)
    {
        return success(appPetTypeService.selectAppPetTypeByPetTypeId(petTypeId));
    }

    /**
     * 新增宠物类型
     */
    @PreAuthorize("@ss.hasPermi('model:AppPetType:add')")
    @Log(title = "宠物类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppPetType appPetType)
    {
        return toAjax(appPetTypeService.insertAppPetType(appPetType));
    }

    /**
     * 修改宠物类型
     */
    @PreAuthorize("@ss.hasPermi('model:AppPetType:edit')")
    @Log(title = "宠物类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppPetType appPetType)
    {
        return toAjax(appPetTypeService.updateAppPetType(appPetType));
    }

    /**
     * 删除宠物类型
     */
    @PreAuthorize("@ss.hasPermi('model:AppPetType:remove')")
    @Log(title = "宠物类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{petTypeIds}")
    public AjaxResult remove(@PathVariable Long[] petTypeIds)
    {
        return toAjax(appPetTypeService.deleteAppPetTypeByPetTypeIds(petTypeIds));
    }
}
