package com.mortals.xhx.module.attendance.dao.ibatis;

import com.mortals.xhx.module.attendance.model.vo.AttendanceSummaryQuery;
import com.mortals.xhx.module.attendance.model.vo.ErrorSummaryVo;
import com.mortals.xhx.module.attendance.model.vo.LeaveSummaryVo;
import com.mortals.xhx.module.attendance.model.vo.VacationBalanceSummaryVo;
import com.mortals.xhx.module.attendance.dao.AttendanceSummaryDao;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("attendanceSummaryDao")
public class AttendanceSummaryDaoImpl extends SqlSessionDaoSupport implements AttendanceSummaryDao {

    protected String namespace = this.getClass().getName();

    @Autowired
    public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
        super.setSqlSessionFactory(sqlSessionFactory);
    }

    protected String getSqlId(String id) {
        return this.namespace + "." + id;
    }

    @Override
    public List<VacationBalanceSummaryVo> getVacationBalanceSummary(AttendanceSummaryQuery query) {
        return this.getSqlSession().selectList(this.getSqlId("getVacationBalanceSummary"), query);
    }

    @Override
    public List<LeaveSummaryVo> getLeaveSummary(AttendanceSummaryQuery query) {
        return this.getSqlSession().selectList(this.getSqlId("getLeaveSummary"), query);
    }

    @Override
    public List<ErrorSummaryVo> getErrorSummary(AttendanceSummaryQuery query) {
        return this.getSqlSession().selectList(this.getSqlId("getErrorSummary"), query);
    }
}
