package com.cyl.manager.ums.controller;

import java.io.IOException;
import java.util.List;

import com.cyl.manager.ums.domain.Pet;
import com.cyl.manager.ums.domain.PetCare;
import com.cyl.manager.ums.service.PetCareService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

import javax.servlet.http.HttpServletResponse;

/**
 * 宠物服务档案Controller
 * 
 * @author daixiande
 * @date 2024-05-25
 */
//@Api("宠物服务档案")
@RestController
@RequestMapping("/ums/petCare")
public class PetCareController extends BaseController {
    @Autowired
    private PetCareService petCareService;

    /**
     * 查询宠物服务档案列表
     */
//    @ApiOperation("查询宠物服务档案列表")
    @PreAuthorize("@ss.hasPermi('mall:petCare:list')")
    @GetMapping("/list")
    public TableDataInfo list(PetCare petCare) {
        startPage();
        List<PetCare> list = petCareService.selectPetCareList(petCare);
        return getDataTable(list);
    }

    /**
     * 导出宠物服务档案列表
     */
//    @ApiOperation("导出宠物服务档案列表")
    @PreAuthorize("@ss.hasPermi('ums:petCare:export')")
    @Log(title = "宠物服务档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PetCare petCare) throws IOException {
        List<PetCare> list = petCareService.selectPetCareList(petCare);
        ExcelUtil<PetCare> util = new ExcelUtil<PetCare>(PetCare.class);
        util.exportExcel(response, list, "宠物服务档案数据");
    }



    /**
     * 获取宠物服务档案详细信息
     */
//    @ApiOperation("获取宠物服务档案详细信息")
    @PreAuthorize("@ss.hasPermi('mall:petCare:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(petCareService.selectPetCareById(id));
    }

    /**
     * 新增宠物服务档案
     */
//    @ApiOperation("新增宠物服务档案")
    @PreAuthorize("@ss.hasPermi('mall:petCare:add')")
    @Log(title = "宠物服务档案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PetCare petCare) {
        return toAjax(petCareService.insertPetCare(petCare));
    }

    /**
     * 修改宠物服务档案
     */
//    @ApiOperation("修改宠物服务档案")
    @PreAuthorize("@ss.hasPermi('mall:petCare:edit')")
    @Log(title = "宠物服务档案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PetCare petCare) {
        return toAjax(petCareService.updatePetCare(petCare));
    }

    /**
     * 删除宠物服务档案
     */
//    @ApiOperation("删除宠物服务档案")
    @PreAuthorize("@ss.hasPermi('mall:petCare:remove')")
    @Log(title = "宠物服务档案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(petCareService.deletePetCareByIds(ids));
    }
}
