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.FsUserCourseNoteLikeMapper;
import com.fs.course.domain.FsUserCourseNoteLike;
import com.fs.course.service.IFsUserCourseNoteLikeService;

/**
 * 课堂笔记点赞Service业务层处理
 *
 * @author fs
 * @date 2024-05-15
 */
@Service
public class FsUserCourseNoteLikeServiceImpl implements IFsUserCourseNoteLikeService
{
    @Autowired
    private FsUserCourseNoteLikeMapper fsUserCourseNoteLikeMapper;

    /**
     * 查询课堂笔记点赞
     *
     * @param id 课堂笔记点赞主键
     * @return 课堂笔记点赞
     */
    @Override
    public FsUserCourseNoteLike selectFsUserCourseNoteLikeById(Long id)
    {
        return fsUserCourseNoteLikeMapper.selectFsUserCourseNoteLikeById(id);
    }

    /**
     * 查询课堂笔记点赞列表
     *
     * @param fsUserCourseNoteLike 课堂笔记点赞
     * @return 课堂笔记点赞
     */
    @Override
    public List<FsUserCourseNoteLike> selectFsUserCourseNoteLikeList(FsUserCourseNoteLike fsUserCourseNoteLike)
    {
        return fsUserCourseNoteLikeMapper.selectFsUserCourseNoteLikeList(fsUserCourseNoteLike);
    }

    /**
     * 新增课堂笔记点赞
     *
     * @param fsUserCourseNoteLike 课堂笔记点赞
     * @return 结果
     */
    @Override
    public int insertFsUserCourseNoteLike(FsUserCourseNoteLike fsUserCourseNoteLike)
    {
        fsUserCourseNoteLike.setCreateTime(DateUtils.getNowDate());
        return fsUserCourseNoteLikeMapper.insertFsUserCourseNoteLike(fsUserCourseNoteLike);
    }

    /**
     * 修改课堂笔记点赞
     *
     * @param fsUserCourseNoteLike 课堂笔记点赞
     * @return 结果
     */
    @Override
    public int updateFsUserCourseNoteLike(FsUserCourseNoteLike fsUserCourseNoteLike)
    {
        fsUserCourseNoteLike.setUpdateTime(DateUtils.getNowDate());
        return fsUserCourseNoteLikeMapper.updateFsUserCourseNoteLike(fsUserCourseNoteLike);
    }

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

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

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

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