package com.engine.salary.biz;

import com.engine.salary.entity.datacollection.po.AttendQuoteFieldSettingPO;
import com.engine.salary.enums.datacollection.AttendQuoteSourceTypeEnum;
import com.engine.salary.mapper.datacollection.AttendQuoteSyncSetMapper;
import org.apache.ibatis.session.SqlSession;
import weaver.conn.mybatis.MyBatisFactory;

import java.util.List;

public class AttendQuoteFieldSettingBiz {
    public List<AttendQuoteFieldSettingPO> getAttendQuoteFieldSetting(AttendQuoteSourceTypeEnum sourceType) {
        SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
        try {
            AttendQuoteSyncSetMapper mapper = sqlSession.getMapper(AttendQuoteSyncSetMapper.class);
            return mapper.listSome(AttendQuoteFieldSettingPO.builder().sourceType(sourceType.getValue()).build());
        } finally {
            sqlSession.close();
        }
    }


    public void insert(AttendQuoteFieldSettingPO po) {
        SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
        try {
            AttendQuoteSyncSetMapper mapper = sqlSession.getMapper(AttendQuoteSyncSetMapper.class);
            mapper.insertIgnoreNull(po);
            sqlSession.commit();
        } finally {
            sqlSession.close();
        }
    }

    public void updateById(AttendQuoteFieldSettingPO po) {
        SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
        try {
            AttendQuoteSyncSetMapper mapper = sqlSession.getMapper(AttendQuoteSyncSetMapper.class);
            mapper.updateIgnoreNull(po);
            sqlSession.commit();
        } finally {
            sqlSession.close();
        }
    }


}
