package com.engine.salary.biz;

import com.engine.salary.entity.taxagent.param.TaxAgentQueryParam;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.mapper.taxagent.TaxAgentMapper;
import org.apache.ibatis.session.SqlSession;
import weaver.conn.mybatis.MyBatisFactory;

import java.util.Collection;
import java.util.List;

public class TaxAgentBiz {

    public List<TaxAgentPO> listAll() {
        SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
        try {
            TaxAgentMapper taxAgentMapper = sqlSession.getMapper(TaxAgentMapper.class);
            return taxAgentMapper.listAll();
        } finally {
            sqlSession.close();
        }
    }

    public List<TaxAgentPO> listByIds(Collection<Long> taxAgentIds) {
        SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
        try {
            TaxAgentMapper taxAgentMapper = sqlSession.getMapper(TaxAgentMapper.class);
            return taxAgentMapper.listBySome(TaxAgentQueryParam.builder().ids(taxAgentIds).build());
        } finally {
            sqlSession.close();
        }
    }

    public TaxAgentPO getById(Long taxAgentId) {
        SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
        try {
            TaxAgentMapper taxAgentMapper = sqlSession.getMapper(TaxAgentMapper.class);
            return taxAgentMapper.getById(taxAgentId);
        } finally {
            sqlSession.close();
        }
    }
}
