package com.fs.course.service.impl;

import java.util.List;
import com.fs.common.utils.DateUtils;
import com.fs.course.param.FsUserCourseListUParam;
import com.fs.course.param.FsUserCourseNoteUParam;
import com.fs.course.vo.FsUserCourseMyNoteListUVO;
import com.fs.course.vo.FsUserCourseNoteListUVO;
import com.fs.course.vo.FsUserCourseNoteUVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fs.course.mapper.FsUserCourseNoteMapper;
import com.fs.course.domain.FsUserCourseNote;
import com.fs.course.service.IFsUserCourseNoteService;

/**
 * 课堂笔记Service业务层处理
 *
 * @author fs
 * @date 2024-05-15
 */
@Service
public class FsUserCourseNoteServiceImpl implements IFsUserCourseNoteService
{
    @Autowired
    private FsUserCourseNoteMapper fsUserCourseNoteMapper;

    /**
     * 查询课堂笔记
     *
     * @param noteId 课堂笔记主键
     * @return 课堂笔记
     */
    @Override
    public FsUserCourseNote selectFsUserCourseNoteByNoteId(Long noteId)
    {
        return fsUserCourseNoteMapper.selectFsUserCourseNoteByNoteId(noteId);
    }

    /**
     * 查询课堂笔记列表
     *
     * @param fsUserCourseNote 课堂笔记
     * @return 课堂笔记
     */
    @Override
    public List<FsUserCourseNote> selectFsUserCourseNoteList(FsUserCourseNote fsUserCourseNote)
    {
        return fsUserCourseNoteMapper.selectFsUserCourseNoteList(fsUserCourseNote);
    }

    /**
     * 新增课堂笔记
     *
     * @param fsUserCourseNote 课堂笔记
     * @return 结果
     */
    @Override
    public int insertFsUserCourseNote(FsUserCourseNote fsUserCourseNote)
    {
        fsUserCourseNote.setCreateTime(DateUtils.getNowDate());
        return fsUserCourseNoteMapper.insertFsUserCourseNote(fsUserCourseNote);
    }

    /**
     * 修改课堂笔记
     *
     * @param fsUserCourseNote 课堂笔记
     * @return 结果
     */
    @Override
    public int updateFsUserCourseNote(FsUserCourseNote fsUserCourseNote)
    {
        fsUserCourseNote.setUpdateTime(DateUtils.getNowDate());
        return fsUserCourseNoteMapper.updateFsUserCourseNote(fsUserCourseNote);
    }

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

    /**
     * 删除课堂笔记信息
     *
     * @param noteId 课堂笔记主键
     * @return 结果
     */
    @Override
    public int deleteFsUserCourseNoteByNoteId(Long noteId)
    {
        return fsUserCourseNoteMapper.deleteFsUserCourseNoteByNoteId(noteId);
    }

    @Override
    public List<FsUserCourseMyNoteListUVO> selectFsUserCourseMyNoteListUVO(FsUserCourseNoteUParam param) {
//        List<FsUserCourseMyNoteListUVO> myNoteList = fsUserCourseNoteMapper.selectFsUserCourseMyNoteListUVO(param);
//        List<FsUserCourseMyNoteListUVO> saveNoteList = fsUserCourseNoteMapper.selectFsUserCourseMyNoteListBySave(param);
//        myNoteList.addAll(saveNoteList);
        return fsUserCourseNoteMapper.selectFsUserCourseMyNoteListUVO(param);
    }

    @Override
    public List<FsUserCourseMyNoteListUVO> selectSaveNoteListUVO(FsUserCourseNoteUParam param) {
        return fsUserCourseNoteMapper.selectFsUserCourseMyNoteListBySave(param);
    }

    @Override
    public FsUserCourseNoteUVO selectFsUserCourseNoteUVOByNoteId(Long noteId) {
        return fsUserCourseNoteMapper.selectFsUserCourseNoteUVOByNoteId(noteId);
    }

    @Override
    public List<FsUserCourseNoteListUVO> selectFsUserCourseNoteListUVO(FsUserCourseNoteUParam param) {
        return fsUserCourseNoteMapper.selectFsUserCourseNoteListUVO(param);
    }

    @Override
    public int updateLikes(Long noteId, Integer type) {
        if (type == 1){
            return fsUserCourseNoteMapper.addLikes(noteId);
        }else {
            return fsUserCourseNoteMapper.minusLikes(noteId);
        }
    }
}
