package com.fs.sop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fs.common.annotation.DataSource;
import com.fs.common.enums.DataSourceType;
import com.fs.sop.domain.QwSopTempContent;
import com.fs.sop.mapper.QwSopTempContentMapper;
import com.fs.sop.service.IQwSopTempContentService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * sop任务模板内容Service业务层处理
 *
 * @author fs
 * @date 2025-02-06
 */
@Service
public class QwSopTempContentServiceImpl extends ServiceImpl<QwSopTempContentMapper, QwSopTempContent> implements IQwSopTempContentService {

    /**
     * 查询sop任务模板内容
     *
     * @param id sop任务模板内容主键
     * @return sop任务模板内容
     */
    @Override
    public QwSopTempContent selectQwSopTempContentById(String id)
    {
        return baseMapper.selectQwSopTempContentById(id);
    }

    /**
     * 查询sop任务模板内容列表
     *
     * @param qwSopTempContent sop任务模板内容
     * @return sop任务模板内容
     */
    @Override
    public List<QwSopTempContent> selectQwSopTempContentList(QwSopTempContent qwSopTempContent)
    {
        return baseMapper.selectQwSopTempContentList(qwSopTempContent);
    }

    /**
     * 新增sop任务模板内容
     *
     * @param qwSopTempContent sop任务模板内容
     * @return 结果
     */
    @Override
    public int insertQwSopTempContent(QwSopTempContent qwSopTempContent)
    {
        return baseMapper.insertQwSopTempContent(qwSopTempContent);
    }

    /**
     * 修改sop任务模板内容
     *
     * @param qwSopTempContent sop任务模板内容
     * @return 结果
     */
    @Override
    public int updateQwSopTempContent(QwSopTempContent qwSopTempContent)
    {
        return baseMapper.updateQwSopTempContent(qwSopTempContent);
    }

    /**
     * 批量删除sop任务模板内容
     *
     * @param ids 需要删除的sop任务模板内容主键
     * @return 结果
     */
    @Override
    public int deleteQwSopTempContentByIds(String[] ids)
    {
        return baseMapper.deleteQwSopTempContentByIds(ids);
    }

    /**
     * 删除sop任务模板内容信息
     *
     * @param id sop任务模板内容主键
     * @return 结果
     */
    @Override
    public int deleteQwSopTempContentById(String id){
        return baseMapper.deleteQwSopTempContentById(id);
    }

    @Override
    public void deleteByTempId(String id) {
        baseMapper.deleteByTempId(id);
    }

    @Override
    @DataSource(DataSourceType.SOP)
    public void insertBatch(List<QwSopTempContent> list) {
        super.saveBatch(list);
    }

    @Override
    public void deleteByRulesId(String id) {
        baseMapper.deleteByRulesId(id);
    }

    @Override
    public List<QwSopTempContent> listByRulesIds(List<Long> ids) {
        return baseMapper.listByRulesIds(ids);
    }

    @Override
    public void deleteByRulesIdList(List<Long> ids) {
        baseMapper.deleteByRulesIdList(ids);
    }

    @Override
    @DataSource(DataSourceType.SOP)
    public void saveList(List<QwSopTempContent> contentList) {
        super.saveBatch(contentList);
    }

    @Override@DataSource(DataSourceType.SOP)
    public void removeByDayId(Long dayId) {
        super.remove(new QueryWrapper<QwSopTempContent>().eq("day_id", dayId));
    }

    @Override
    public List<QwSopTempContent> listVoice(String tempId) {
        return baseMapper.listVoice(tempId);
    }

    @Override
    public List<QwSopTempContent> listByTempAndDay(String tempId, Long dayId) {
        return baseMapper.listByTempAndDay(tempId, dayId);
    }

    @Override
    public void updateDay(QwSopTempContent content) {
        baseMapper.updateDay(content.getId(), content.getDayId());
    }
}
