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.FsUserCourseFollowMapper;
import com.fs.course.domain.FsUserCourseFollow;
import com.fs.course.service.IFsUserCourseFollowService;

/**
 * 课堂关注Service业务层处理
 *
 * @author fs
 * @date 2024-05-17
 */
@Service
public class FsUserCourseFollowServiceImpl implements IFsUserCourseFollowService
{
    @Autowired
    private FsUserCourseFollowMapper fsUserCourseFollowMapper;

    /**
     * 查询课堂关注
     *
     * @param id 课堂关注主键
     * @return 课堂关注
     */
    @Override
    public FsUserCourseFollow selectFsUserCourseFollowById(Long id)
    {
        return fsUserCourseFollowMapper.selectFsUserCourseFollowById(id);
    }

    /**
     * 查询课堂关注列表
     *
     * @param fsUserCourseFollow 课堂关注
     * @return 课堂关注
     */
    @Override
    public List<FsUserCourseFollow> selectFsUserCourseFollowList(FsUserCourseFollow fsUserCourseFollow)
    {
        return fsUserCourseFollowMapper.selectFsUserCourseFollowList(fsUserCourseFollow);
    }

    /**
     * 新增课堂关注
     *
     * @param fsUserCourseFollow 课堂关注
     * @return 结果
     */
    @Override
    public int insertFsUserCourseFollow(FsUserCourseFollow fsUserCourseFollow)
    {
        fsUserCourseFollow.setCreateTime(DateUtils.getNowDate());
        return fsUserCourseFollowMapper.insertFsUserCourseFollow(fsUserCourseFollow);
    }

    /**
     * 修改课堂关注
     *
     * @param fsUserCourseFollow 课堂关注
     * @return 结果
     */
    @Override
    public int updateFsUserCourseFollow(FsUserCourseFollow fsUserCourseFollow)
    {
        fsUserCourseFollow.setUpdateTime(DateUtils.getNowDate());
        return fsUserCourseFollowMapper.updateFsUserCourseFollow(fsUserCourseFollow);
    }

    /**
     * 批量删除课堂关注
     *
     * @param ids 需要删除的课堂关注主键
     * @return 结果
     */
    @Override
    public int deleteFsUserCourseFollowByIds(Long[] ids)
    {
        return fsUserCourseFollowMapper.deleteFsUserCourseFollowByIds(ids);
    }

    /**
     * 删除课堂关注信息
     *
     * @param id 课堂关注主键
     * @return 结果
     */
    @Override
    public int deleteFsUserCourseFollowById(Long id)
    {
        return fsUserCourseFollowMapper.deleteFsUserCourseFollowById(id);
    }


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

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