package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.dto.FollowerListDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysUserFollowMapper;
import com.ruoyi.system.domain.SysUserFollow;
import com.ruoyi.system.service.ISysUserFollowService;

/**
 * 用户关注Service业务层处理
 * 
 * @author haotian
 * @date 2024-12-02
 */
@Service
public class SysUserFollowServiceImpl implements ISysUserFollowService 
{
    @Autowired
    private SysUserFollowMapper sysUserFollowMapper;

    /**
     * 查询用户关注
     * 
     * @param id 用户关注主键
     * @return 用户关注
     */
    @Override
    public SysUserFollow selectSysUserFollowById(Long id)
    {
        return sysUserFollowMapper.selectSysUserFollowById(id);
    }

    /**
     * 查询用户关注列表
     * 
     * @param sysUserFollow 用户关注
     * @return 用户关注
     */
    @Override
    public List<SysUserFollow> selectSysUserFollowList(SysUserFollow sysUserFollow)
    {
        return sysUserFollowMapper.selectSysUserFollowList(sysUserFollow);
    }

    /**
     * 新增用户关注
     * 
     * @param sysUserFollow 用户关注
     * @return 结果
     */
    @Override
    public int insertSysUserFollow(SysUserFollow sysUserFollow)
    {
        sysUserFollow.setCreateTime(DateUtils.getNowDate());
        return sysUserFollowMapper.insertSysUserFollow(sysUserFollow);
    }

    /**
     * 修改用户关注
     * 
     * @param sysUserFollow 用户关注
     * @return 结果
     */
    @Override
    public int updateSysUserFollow(SysUserFollow sysUserFollow)
    {
        sysUserFollow.setUpdateTime(DateUtils.getNowDate());
        return sysUserFollowMapper.updateSysUserFollow(sysUserFollow);
    }

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

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

    @Override
    /*
     * 我的--查看我关注了那些人
     * */
    public List<FollowerListDto> getFollowerList(Long userId){
        return sysUserFollowMapper.getFollowerList(userId);
    }

    @Override
    /*
     * 我的--查看那些人关注了我
     * */
    public List<FollowerListDto> getFollowedList(Long userId){
        return sysUserFollowMapper.getFollowedList(userId);
    }

    /*
     * 根据userId和followedUserId删除关注数据
     * */
    @Override
    public int deleteSysUserFollowByUserIdAndFollowedUserId(Long userId,Long followedUserId){
        return sysUserFollowMapper.deleteSysUserFollowByUserIdAndFollowedUserId(userId,followedUserId);
    }

    /*
     * 获取我关注的人数
     * */
    @Override
    public Long getFollowingCount(Long userId){
        return sysUserFollowMapper.getFollowingCount(userId);
    }
    /*
     * 获取关注我的人数
     * */
    @Override
    public Long getFollowedCount(Long userId){
        return sysUserFollowMapper.getFollowedCount(userId);
    }

    /*
     * 获取新增关注列表
     * */
    @Override
    public List<FollowerListDto> getAddFollowerList(Long userId){
        return sysUserFollowMapper.getAddFollowerList(userId);
    }

    /*
     * 设置--注销账号--清除本人关注数据
     * */
    @Override
    public int deleteSysUserFollowUserId(Long userId){
        return sysUserFollowMapper.deleteSysUserFollowUserId(userId);
    }
}
