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.FsUserCourseNoteSaveMapper;
import com.fs.course.domain.FsUserCourseNoteSave;
import com.fs.course.service.IFsUserCourseNoteSaveService;

/**
 * 课堂笔记保存Service业务层处理
 *
 * @author fs
 * @date 2024-06-05
 */
@Service
public class FsUserCourseNoteSaveServiceImpl implements IFsUserCourseNoteSaveService
{
    @Autowired
    private FsUserCourseNoteSaveMapper fsUserCourseNoteSaveMapper;

    /**
     * 查询课堂笔记保存
     *
     * @param saveId 课堂笔记保存主键
     * @return 课堂笔记保存
     */
    @Override
    public FsUserCourseNoteSave selectFsUserCourseNoteSaveBySaveId(Long saveId)
    {
        return fsUserCourseNoteSaveMapper.selectFsUserCourseNoteSaveBySaveId(saveId);
    }

    /**
     * 查询课堂笔记保存列表
     *
     * @param fsUserCourseNoteSave 课堂笔记保存
     * @return 课堂笔记保存
     */
    @Override
    public List<FsUserCourseNoteSave> selectFsUserCourseNoteSaveList(FsUserCourseNoteSave fsUserCourseNoteSave)
    {
        return fsUserCourseNoteSaveMapper.selectFsUserCourseNoteSaveList(fsUserCourseNoteSave);
    }

    /**
     * 新增课堂笔记保存
     *
     * @param fsUserCourseNoteSave 课堂笔记保存
     * @return 结果
     */
    @Override
    public int insertFsUserCourseNoteSave(FsUserCourseNoteSave fsUserCourseNoteSave)
    {
        fsUserCourseNoteSave.setCreateTime(DateUtils.getNowDate());
        return fsUserCourseNoteSaveMapper.insertFsUserCourseNoteSave(fsUserCourseNoteSave);
    }

    /**
     * 修改课堂笔记保存
     *
     * @param fsUserCourseNoteSave 课堂笔记保存
     * @return 结果
     */
    @Override
    public int updateFsUserCourseNoteSave(FsUserCourseNoteSave fsUserCourseNoteSave)
    {
        fsUserCourseNoteSave.setUpdateTime(DateUtils.getNowDate());
        return fsUserCourseNoteSaveMapper.updateFsUserCourseNoteSave(fsUserCourseNoteSave);
    }

    /**
     * 批量删除课堂笔记保存
     *
     * @param saveIds 需要删除的课堂笔记保存主键
     * @return 结果
     */
    @Override
    public int deleteFsUserCourseNoteSaveBySaveIds(Long[] saveIds)
    {
        return fsUserCourseNoteSaveMapper.deleteFsUserCourseNoteSaveBySaveIds(saveIds);
    }

    /**
     * 删除课堂笔记保存信息
     *
     * @param saveId 课堂笔记保存主键
     * @return 结果
     */
    @Override
    public int deleteFsUserCourseNoteSaveBySaveId(Long saveId)
    {
        return fsUserCourseNoteSaveMapper.deleteFsUserCourseNoteSaveBySaveId(saveId);
    }

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

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