package com.cyl.h5.controller;

import com.cyl.h5.service.H5PetCareService;
import com.cyl.manager.ums.domain.PetCare;
import com.cyl.manager.ums.service.PetCareService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

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

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

    /**
     * 导出宠物服务档案列表
     */
    //@ApiOperation("导出宠物服务档案列表")
    @GetMapping("/export")
    public AjaxResult export(PetCare petCare) {
        List<PetCare> list = petCareService.selectPetCareList(petCare);
        ExcelUtil<PetCare> util = new ExcelUtil<PetCare>(PetCare.class);
        return util.exportExcel(list, "宠物服务档案数据");
    }

    /**
     * 获取宠物服务档案详细信息
     */
    //@ApiOperation("获取宠物服务档案详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(petCareService.selectPetCareByPetId(id));
    }

    /**
     * 新增宠物服务档案
     */
    //@ApiOperation("新增宠物服务档案")
    @PostMapping
    public AjaxResult add(@RequestBody PetCare petCare) {
        return toAjax(petCareService.insertPetCare(petCare));
    }

    /**
     * 修改宠物服务档案
     */
    //@ApiOperation("修改宠物服务档案")
    @PutMapping
    public AjaxResult edit(@RequestBody PetCare petCare) {
        return toAjax(petCareService.updatePetCare(petCare));
    }

    /**
     * 删除宠物服务档案
     */
    //@ApiOperation("删除宠物服务档案")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(petCareService.deletePetCareByIds(ids));
    }
}
