package com.fs.live.service.impl;

import java.util.List;
import com.fs.common.utils.DateUtils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fs.live.mapper.LiveUserFollowMapper;
import com.fs.live.domain.LiveUserFollow;
import com.fs.live.service.ILiveUserFollowService;

/**
 * 用户直播关注Service业务层处理
 *
 * @author fs
 * @date 2025-07-11
 */
@Service
public class LiveUserFollowServiceImpl implements ILiveUserFollowService {
    @Autowired
    private LiveUserFollowMapper baseMapper;

    /**
     * 查询用户直播关注
     *
     * @param id 用户直播关注主键
     * @return 用户直播关注
     */
    @Override
    public LiveUserFollow selectLiveUserFollowById(Long id)
    {
        return baseMapper.selectLiveUserFollowById(id);
    }

    /**
     * 查询用户直播关注列表
     *
     * @param liveUserFollow 用户直播关注
     * @return 用户直播关注
     */
    @Override
    public List<LiveUserFollow> selectLiveUserFollowList(LiveUserFollow liveUserFollow)
    {
        return baseMapper.selectLiveUserFollowList(liveUserFollow);
    }

    /**
     * 新增用户直播关注
     *
     * @param liveUserFollow 用户直播关注
     * @return 结果
     */
    @Override
    public int insertLiveUserFollow(LiveUserFollow liveUserFollow)
    {
        liveUserFollow.setCreateTime(DateUtils.getNowDate());
        return baseMapper.insertLiveUserFollow(liveUserFollow);
    }

    /**
     * 修改用户直播关注
     *
     * @param liveUserFollow 用户直播关注
     * @return 结果
     */
    @Override
    public int updateLiveUserFollow(LiveUserFollow liveUserFollow)
    {
        liveUserFollow.setUpdateTime(DateUtils.getNowDate());
        return baseMapper.updateLiveUserFollow(liveUserFollow);
    }

    /**
     * 批量删除用户直播关注
     *
     * @param ids 需要删除的用户直播关注主键
     * @return 结果
     */
    @Override
    public int deleteLiveUserFollowByIds(Long[] ids)
    {
        return baseMapper.deleteLiveUserFollowByIds(ids);
    }

    /**
     * 删除用户直播关注信息
     *
     * @param id 用户直播关注主键
     * @return 结果
     */
    @Override
    public int deleteLiveUserFollowById(Long id)
    {
        return baseMapper.deleteLiveUserFollowById(id);
    }

    @Override
    public LiveUserFollow selectLiveUserFollowByLiveIdAndUserId(Long liveId, Long userId) {
        return baseMapper.selectLiveUserFollowByLiveIdAndUserId(liveId, userId);
    }

    @Override
    public void deleteLiveUserFollowByLiveIdAndUserId(Long liveId, Long userId) {
        baseMapper.deleteLiveUserFollowByLiveIdAndUserId(liveId, userId);
    }

    @Override
    public boolean isFollow(Long liveId, Long userId) {
        LiveUserFollow liveUserFollow = baseMapper.selectLiveUserFollowByLiveIdAndUserId(liveId, userId);
        return liveUserFollow != null;
    }
}
