package com.fs.course.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.course.mapper.FsUserTalentFollowMapper;
import com.fs.course.domain.FsUserTalentFollow;
import com.fs.course.service.IFsUserTalentFollowService;

/**
 * 达人关注Service业务层处理
 *
 * @author fs
 * @date 2024-05-31
 */
@Service
public class FsUserTalentFollowServiceImpl implements IFsUserTalentFollowService
{
    @Autowired
    private FsUserTalentFollowMapper fsUserTalentFollowMapper;

    /**
     * 查询达人关注
     *
     * @param id 达人关注主键
     * @return 达人关注
     */
    @Override
    public FsUserTalentFollow selectFsUserTalentFollowById(Long id)
    {
        return fsUserTalentFollowMapper.selectFsUserTalentFollowById(id);
    }

    /**
     * 查询达人关注列表
     *
     * @param fsUserTalentFollow 达人关注
     * @return 达人关注
     */
    @Override
    public List<FsUserTalentFollow> selectFsUserTalentFollowList(FsUserTalentFollow fsUserTalentFollow)
    {
        return fsUserTalentFollowMapper.selectFsUserTalentFollowList(fsUserTalentFollow);
    }

    /**
     * 新增达人关注
     *
     * @param fsUserTalentFollow 达人关注
     * @return 结果
     */
    @Override
    public int insertFsUserTalentFollow(FsUserTalentFollow fsUserTalentFollow)
    {
        fsUserTalentFollow.setCreateTime(DateUtils.getNowDate());
        return fsUserTalentFollowMapper.insertFsUserTalentFollow(fsUserTalentFollow);
    }

    /**
     * 修改达人关注
     *
     * @param fsUserTalentFollow 达人关注
     * @return 结果
     */
    @Override
    public int updateFsUserTalentFollow(FsUserTalentFollow fsUserTalentFollow)
    {
        fsUserTalentFollow.setUpdateTime(DateUtils.getNowDate());
        return fsUserTalentFollowMapper.updateFsUserTalentFollow(fsUserTalentFollow);
    }

    /**
     * 批量删除达人关注
     *
     * @param ids 需要删除的达人关注主键
     * @return 结果
     */
    @Override
    public int deleteFsUserTalentFollowByIds(Long[] ids)
    {
        return fsUserTalentFollowMapper.deleteFsUserTalentFollowByIds(ids);
    }

    /**
     * 删除达人关注信息
     *
     * @param id 达人关注主键
     * @return 结果
     */
    @Override
    public int deleteFsUserTalentFollowById(Long id)
    {
        return fsUserTalentFollowMapper.deleteFsUserTalentFollowById(id);
    }


    @Override
    public R checkFollow(Long talentId, long userId) {
        return fsUserTalentFollowMapper.checkFollow(talentId,userId)>0?R.ok().put("isFollow",1):R.error().put("isFollow",0);
    }

    @Override
    public int deleteFollow(Long talentId, long userId) {
        return fsUserTalentFollowMapper.deleteFollow(talentId,userId);
    }

}
