package com.fs.his.controller;

import java.util.List;
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.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.his.domain.FsPackageFavorite;
import com.fs.his.service.IFsPackageFavoriteService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 疗法收藏Controller
 * 
 * @author fs
 * @date 2024-08-24
 */
@RestController
@RequestMapping("/his/packageFavorite")
public class FsPackageFavoriteController extends BaseController
{
    @Autowired
    private IFsPackageFavoriteService fsPackageFavoriteService;

    /**
     * 查询疗法收藏列表
     */
    @PreAuthorize("@ss.hasPermi('his:packageFavorite:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsPackageFavorite fsPackageFavorite)
    {
        startPage();
        List<FsPackageFavorite> list = fsPackageFavoriteService.selectFsPackageFavoriteList(fsPackageFavorite);
        return getDataTable(list);
    }

    /**
     * 导出疗法收藏列表
     */
    @PreAuthorize("@ss.hasPermi('his:packageFavorite:export')")
    @Log(title = "疗法收藏", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsPackageFavorite fsPackageFavorite)
    {
        List<FsPackageFavorite> list = fsPackageFavoriteService.selectFsPackageFavoriteList(fsPackageFavorite);
        ExcelUtil<FsPackageFavorite> util = new ExcelUtil<FsPackageFavorite>(FsPackageFavorite.class);
        return util.exportExcel(list, "疗法收藏数据");
    }

    /**
     * 获取疗法收藏详细信息
     */
    @PreAuthorize("@ss.hasPermi('his:packageFavorite:query')")
    @GetMapping(value = "/{favoriteId}")
    public AjaxResult getInfo(@PathVariable("favoriteId") Long favoriteId)
    {
        return AjaxResult.success(fsPackageFavoriteService.selectFsPackageFavoriteByFavoriteId(favoriteId));
    }

    /**
     * 新增疗法收藏
     */
    @PreAuthorize("@ss.hasPermi('his:packageFavorite:add')")
    @Log(title = "疗法收藏", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsPackageFavorite fsPackageFavorite)
    {
        return toAjax(fsPackageFavoriteService.insertFsPackageFavorite(fsPackageFavorite));
    }

    /**
     * 修改疗法收藏
     */
    @PreAuthorize("@ss.hasPermi('his:packageFavorite:edit')")
    @Log(title = "疗法收藏", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsPackageFavorite fsPackageFavorite)
    {
        return toAjax(fsPackageFavoriteService.updateFsPackageFavorite(fsPackageFavorite));
    }

    /**
     * 删除疗法收藏
     */
    @PreAuthorize("@ss.hasPermi('his:packageFavorite:remove')")
    @Log(title = "疗法收藏", businessType = BusinessType.DELETE)
	@DeleteMapping("/{favoriteIds}")
    public AjaxResult remove(@PathVariable Long[] favoriteIds)
    {
        return toAjax(fsPackageFavoriteService.deleteFsPackageFavoriteByFavoriteIds(favoriteIds));
    }
}
