package com.fs.his.service.impl;

import java.util.List;

import com.fs.common.core.domain.R;
import com.fs.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fs.his.mapper.FsPackageFavoriteMapper;
import com.fs.his.domain.FsPackageFavorite;
import com.fs.his.service.IFsPackageFavoriteService;

/**
 * 疗法收藏Service业务层处理
 *
 * @author fs
 * @date 2024-08-24
 */
@Service
public class FsPackageFavoriteServiceImpl implements IFsPackageFavoriteService
{
    @Autowired
    private FsPackageFavoriteMapper fsPackageFavoriteMapper;

    /**
     * 查询疗法收藏
     *
     * @param favoriteId 疗法收藏主键
     * @return 疗法收藏
     */
    @Override
    public FsPackageFavorite selectFsPackageFavoriteByFavoriteId(Long favoriteId)
    {
        return fsPackageFavoriteMapper.selectFsPackageFavoriteByFavoriteId(favoriteId);
    }

    /**
     * 查询疗法收藏列表
     *
     * @param fsPackageFavorite 疗法收藏
     * @return 疗法收藏
     */
    @Override
    public List<FsPackageFavorite> selectFsPackageFavoriteList(FsPackageFavorite fsPackageFavorite)
    {
        return fsPackageFavoriteMapper.selectFsPackageFavoriteList(fsPackageFavorite);
    }

    /**
     * 新增疗法收藏
     *
     * @param fsPackageFavorite 疗法收藏
     * @return 结果
     */
    @Override
    public int insertFsPackageFavorite(FsPackageFavorite fsPackageFavorite)
    {
        fsPackageFavorite.setCreateTime(DateUtils.getNowDate());
        return fsPackageFavoriteMapper.insertFsPackageFavorite(fsPackageFavorite);
    }

    /**
     * 修改疗法收藏
     *
     * @param fsPackageFavorite 疗法收藏
     * @return 结果
     */
    @Override
    public int updateFsPackageFavorite(FsPackageFavorite fsPackageFavorite)
    {
        fsPackageFavorite.setUpdateTime(DateUtils.getNowDate());
        return fsPackageFavoriteMapper.updateFsPackageFavorite(fsPackageFavorite);
    }

    /**
     * 批量删除疗法收藏
     *
     * @param favoriteIds 需要删除的疗法收藏主键
     * @return 结果
     */
    @Override
    public int deleteFsPackageFavoriteByFavoriteIds(Long[] favoriteIds)
    {
        return fsPackageFavoriteMapper.deleteFsPackageFavoriteByFavoriteIds(favoriteIds);
    }

    /**
     * 删除疗法收藏信息
     *
     * @param favoriteId 疗法收藏主键
     * @return 结果
     */
    @Override
    public int deleteFsPackageFavoriteByFavoriteId(Long favoriteId)
    {
        return fsPackageFavoriteMapper.deleteFsPackageFavoriteByFavoriteId(favoriteId);
    }

    @Override
    public R checkFavorite(Long packageId, long userId) {
        return fsPackageFavoriteMapper.checkFavorite(packageId,userId)>0?R.ok().put("isFavorite",1):R.error().put("isFavorite",0);
    }

    @Override
    public int deleteFavorite(Long packageId, long userId) {
        return fsPackageFavoriteMapper.deleteFavorite(packageId,userId);
    }

}
