package com.engine.salary.biz;

import com.engine.salary.entity.datacollection.dto.AttendQuoteListDTO;
import com.engine.salary.entity.datacollection.param.AttendQuoteQueryParam;
import com.engine.salary.entity.datacollection.po.AttendQuotePO;
import com.engine.salary.mapper.datacollection.AttendQuoteMapper;
import org.apache.ibatis.session.SqlSession;
import weaver.conn.mybatis.MyBatisFactory;

import java.util.List;

public class AttendQuoteBiz {

    public List<AttendQuoteListDTO> list(AttendQuoteQueryParam param) {
        SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
        try {
            AttendQuoteMapper mapper = sqlSession.getMapper(AttendQuoteMapper.class);
            return mapper.list(param);
        } finally {
            sqlSession.close();
        }
    }

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

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

    public void updateById(AttendQuotePO attendQuote) {
        SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
        try {
            AttendQuoteMapper mapper = sqlSession.getMapper(AttendQuoteMapper.class);
            mapper.updateIgnoreNull(attendQuote);
            sqlSession.commit();
        } finally {
            sqlSession.close();
        }
    }

    public void insert(AttendQuotePO attendQuote) {
        SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
        try {
            AttendQuoteMapper mapper = sqlSession.getMapper(AttendQuoteMapper.class);
            mapper.insertIgnoreNull(attendQuote);
            sqlSession.commit();
        } finally {
            sqlSession.close();
        }
    }
}
