package com.boman.report.service.impl;

import com.boman.domain.GenTable;
import com.boman.report.constant.IgnoreTable;
import com.boman.report.mapper.TableMapper;
import com.boman.report.service.ITableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Set;

@Service
public class TableServiceImpl implements ITableService {

    @Resource
    private TableMapper mapper;
    @Resource
    private IgnoreTable ignoreTable;

    /**
     * 查询业务列表
     *
     * @param genTable 业务信息
     * @return 业务集合
     */
    @Override
    public Integer selectCount(GenTable genTable) {
        return mapper.selectCount(genTable.getTableName(), genTable.getTableComment());
    }

    /**
     * 查询业务列表
     *
     * @param genTable 业务信息
     * @return 业务集合
     */
    @Override
    public List<GenTable> selectList(GenTable genTable) {
        List<GenTable> tables = mapper.selectList(genTable.getTableName(), genTable.getTableComment());
        final Set<String> set = ignoreTable.getSet();
        tables.removeIf(next -> set.contains(next.getTableName()));
        return tables;
    }
}
