package com.engine.salary.biz;

import com.engine.salary.entity.salarysob.po.SalarySobPO;
import com.engine.salary.mapper.salarysob.SalarySobMapper;
import org.apache.ibatis.session.SqlSession;
import weaver.conn.mybatis.MyBatisFactory;

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

public class SalarySobBiz {
    public SalarySobPO getById(Long id) {
        SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
        try {
            SalarySobMapper mapper = sqlSession.getMapper(SalarySobMapper.class);
            return mapper.getById(id);
        } finally {
            sqlSession.close();
        }
    }


    public List<SalarySobPO> listSome(SalarySobPO build) {
        SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
        try {
            SalarySobMapper mapper = sqlSession.getMapper(SalarySobMapper.class);
            return mapper.listSome(build);
        } finally {
            sqlSession.close();
        }
    }

    public List<SalarySobPO> listByParam(SalarySobPO build) {
        SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
        try {
            SalarySobMapper mapper = sqlSession.getMapper(SalarySobMapper.class);
            return mapper.listByParam(build);
        } finally {
            sqlSession.close();
        }
    }

    public void insert(SalarySobPO salarySobPO) {
        SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
        try {
            SalarySobMapper mapper = sqlSession.getMapper(SalarySobMapper.class);
            mapper.insertIgnoreNull(salarySobPO);
            sqlSession.commit();
        } finally {
            sqlSession.close();
        }
    }

    public void updateById(SalarySobPO newSalarySobPO) {
        SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
        try {
            SalarySobMapper mapper = sqlSession.getMapper(SalarySobMapper.class);
            mapper.updateIgnoreNull(newSalarySobPO);
            sqlSession.commit();
        } finally {
            sqlSession.close();
        }

    }

    public void deleteByIds(Collection<Long> ids) {
        SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
        try {
            SalarySobMapper mapper = sqlSession.getMapper(SalarySobMapper.class);
            mapper.deleteByIds(ids);
            sqlSession.commit();
        } finally {
            sqlSession.close();
        }
    }

    public List<SalarySobPO> listByName(SalarySobPO build) {
        SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
        try {
            SalarySobMapper mapper = sqlSession.getMapper(SalarySobMapper.class);
            return mapper.listByName(build);
        } finally {
            sqlSession.close();
        }
    }
}
