package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.system.domain.SubDocument;
import com.ruoyi.system.mapper.SubDocumentMapper;
import com.ruoyi.system.service.ISubDocumentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 参数配置 服务层实现
 *
 * @author ruoyi
 */
@Service
/*@DataSource(value = DataSourceType.SLAVE)*/
public class SubDocumentServiceImpl extends ServiceImpl<SubDocumentMapper, SubDocument> implements ISubDocumentService {
    @Autowired
    private SubDocumentMapper subDocumentMapper;

    @Override
    public List<SubDocument> listTask() {
        return subDocumentMapper.selectList(new LambdaQueryWrapper<SubDocument>().isNull(SubDocument::getIsHandle).and(true,
                lambdaQueryWrapper1 -> {
                    lambdaQueryWrapper1.or().like(SubDocument::getPermid, "-FG-");
                    lambdaQueryWrapper1.or().like(SubDocument::getPermid, "-JX-");
                }));
    }


    @Override
    @DataSource(value = DataSourceType.SLAVE)
    public boolean saveOrUpdateSlave(SubDocument entity) {
        boolean b = super.saveOrUpdate(entity);
        return b;
    }

    @Override
    public void deleteByCon() {
         subDocumentMapper.delete(new LambdaQueryWrapper<SubDocument>().isNull(SubDocument::getIsHandle).and(true,
                lambdaQueryWrapper1 -> {
                    lambdaQueryWrapper1.notLike(SubDocument::getPermid, "-FG-");
                    lambdaQueryWrapper1.notLike(SubDocument::getPermid, "-JX-");
                }));
    }
}
