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

/**
 * 个人宠物类型Controller
 * 
 * @author ruoyi
 * @date 2025-03-28
 */
@RestController
@RequestMapping("/model/AppletPetType")
public class AppletPetTypeController extends BaseController
{
    @Autowired
    private IAppletPetTypeService appletPetTypeService;

    /**
     * 查询个人宠物类型列表
     */
    @PreAuthorize("@ss.hasPermi('model:AppletPetType:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppletPetType appletPetType)
    {
        startPage();
        List<AppletPetType> list = appletPetTypeService.selectAppletPetTypeList(appletPetType);
        return getDataTable(list);
    }

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

    /**
     * 获取个人宠物类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:AppletPetType:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appletPetTypeService.selectAppletPetTypeById(id));
    }

    /**
     * 新增个人宠物类型
     */
    @PreAuthorize("@ss.hasPermi('model:AppletPetType:add')")
    @Log(title = "个人宠物类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppletPetType appletPetType)
    {
        return toAjax(appletPetTypeService.insertAppletPetType(appletPetType));
    }

    /**
     * 修改个人宠物类型
     */
    @PreAuthorize("@ss.hasPermi('model:AppletPetType:edit')")
    @Log(title = "个人宠物类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppletPetType appletPetType)
    {
        return toAjax(appletPetTypeService.updateAppletPetType(appletPetType));
    }

    /**
     * 删除个人宠物类型
     */
    @PreAuthorize("@ss.hasPermi('model:AppletPetType:remove')")
    @Log(title = "个人宠物类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appletPetTypeService.deleteAppletPetTypeByIds(ids));
    }
}
