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.FsUserCourseLikeMapper;
import com.fs.course.domain.FsUserCourseLike;
import com.fs.course.service.IFsUserCourseLikeService;

/**
 * 课堂点赞Service业务层处理
 *
 * @author fs
 * @date 2024-05-15
 */
@Service
public class FsUserCourseLikeServiceImpl implements IFsUserCourseLikeService
{
    @Autowired
    private FsUserCourseLikeMapper fsUserCourseLikeMapper;

    /**
     * 查询课堂点赞
     *
     * @param id 课堂点赞主键
     * @return 课堂点赞
     */
    @Override
    public FsUserCourseLike selectFsUserCourseLikeById(Long id)
    {
        return fsUserCourseLikeMapper.selectFsUserCourseLikeById(id);
    }

    /**
     * 查询课堂点赞列表
     *
     * @param fsUserCourseLike 课堂点赞
     * @return 课堂点赞
     */
    @Override
    public List<FsUserCourseLike> selectFsUserCourseLikeList(FsUserCourseLike fsUserCourseLike)
    {
        return fsUserCourseLikeMapper.selectFsUserCourseLikeList(fsUserCourseLike);
    }

    /**
     * 新增课堂点赞
     *
     * @param fsUserCourseLike 课堂点赞
     * @return 结果
     */
    @Override
    public int insertFsUserCourseLike(FsUserCourseLike fsUserCourseLike)
    {
        fsUserCourseLike.setCreateTime(DateUtils.getNowDate());
        return fsUserCourseLikeMapper.insertFsUserCourseLike(fsUserCourseLike);
    }

    /**
     * 修改课堂点赞
     *
     * @param fsUserCourseLike 课堂点赞
     * @return 结果
     */
    @Override
    public int updateFsUserCourseLike(FsUserCourseLike fsUserCourseLike)
    {
        fsUserCourseLike.setUpdateTime(DateUtils.getNowDate());
        return fsUserCourseLikeMapper.updateFsUserCourseLike(fsUserCourseLike);
    }

    /**
     * 批量删除课堂点赞
     *
     * @param ids 需要删除的课堂点赞主键
     * @return 结果
     */
    @Override
    public int deleteFsUserCourseLikeByIds(Long[] ids)
    {
        return fsUserCourseLikeMapper.deleteFsUserCourseLikeByIds(ids);
    }

    /**
     * 删除课堂点赞信息
     *
     * @param id 课堂点赞主键
     * @return 结果
     */
    @Override
    public int deleteFsUserCourseLikeById(Long id)
    {
        return fsUserCourseLikeMapper.deleteFsUserCourseLikeById(id);
    }


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

    @Override
    public int deleteLike(Long courseId, long userId) {
        return fsUserCourseLikeMapper.deleteLike(courseId,userId);
    }
}
