package com.fs.chat.service.impl;

import com.fs.chat.domain.ChatDataset;
import com.fs.chat.mapper.ChatDatasetMapper;
import com.fs.chat.param.ChatDatasetCParam;
import com.fs.chat.service.IChatDatasetService;
import com.fs.chat.vo.ChatDatasetListCVO;
import com.fs.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 知识库Service业务层处理
 *
 * @author fs
 * @date 2024-04-21
 */
@Service
public class ChatDatasetServiceImpl implements IChatDatasetService
{
    @Autowired
    private ChatDatasetMapper chatDatasetMapper;

    /**
     * 查询知识库
     *
     * @param datasetId 知识库主键
     * @return 知识库
     */
    @Override
    public ChatDataset selectChatDatasetByDatasetId(Long datasetId)
    {
        return chatDatasetMapper.selectChatDatasetByDatasetId(datasetId);
    }

    /**
     * 查询知识库列表
     *
     * @param chatDataset 知识库
     * @return 知识库
     */
    @Override
    public List<ChatDataset> selectChatDatasetList(ChatDataset chatDataset)
    {
        return chatDatasetMapper.selectChatDatasetList(chatDataset);
    }

    /**
     * 新增知识库
     *
     * @param chatDataset 知识库
     * @return 结果
     */
    @Override
    public int insertChatDataset(ChatDataset chatDataset)
    {
        chatDataset.setCreateTime(DateUtils.getNowDate());
        return chatDatasetMapper.insertChatDataset(chatDataset);
    }

    /**
     * 修改知识库
     *
     * @param chatDataset 知识库
     * @return 结果
     */
    @Override
    public int updateChatDataset(ChatDataset chatDataset)
    {
        return chatDatasetMapper.updateChatDataset(chatDataset);
    }

    /**
     * 批量删除知识库
     *
     * @param datasetIds 需要删除的知识库主键
     * @return 结果
     */
    @Override
    public int deleteChatDatasetByDatasetIds(Long[] datasetIds)
    {
        return chatDatasetMapper.deleteChatDatasetByDatasetIds(datasetIds);
    }

    /**
     * 删除知识库信息
     *
     * @param datasetId 知识库主键
     * @return 结果
     */
    @Override
    public int deleteChatDatasetByDatasetId(Long datasetId)
    {
        return chatDatasetMapper.deleteChatDatasetByDatasetId(datasetId);
    }

    @Override
    public int check(Long roleId) {
        return chatDatasetMapper.check(roleId);
    }

    @Override
    public List<ChatDatasetListCVO> selectChatDatasetListCVO(ChatDatasetCParam chatDataset) {
        return chatDatasetMapper.selectChatDatasetListCVO(chatDataset);
    }
}
