/**
 * Project Name : 전사 법무/계약관리시스템 개선
 * File Name    : UsertDao.java
 * Description  : User 관련 서비스
 * Author       : 정성호(jsh)
 * Date         : 2023.04.19 - 임직원정보 Migration (TN_CF_USER)
 * Copyright 	: 2023 by SAMSUNG. All rights reserved.
 */
package com.samsung.embo.common.user.dao;


import java.util.List;
import java.util.stream.Collectors;

import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class UserCfDao {

	/**
	 * SqlSession
	 */
	@Autowired
	private SqlSession sqlSession;

    public int deleteTnInfHrEmpMas() {
        return sqlSession.delete("usercf.deleteTnInfHrEmpMas");
    }
    
    public int insertTnInfHrEmpMas(List list) {
    	//20240514 GHRP → SMDM 변경
    	int skip = 0;
        int limit = 50;
        int iValue = 0;
        while (skip < list.size()) {
        	final List perRequests = (List) list
                            .stream()
                            .skip(skip)
                            .limit(limit)
                            .collect(Collectors.toList());

            skip += limit;

            iValue += sqlSession.insert("usercf.insertTnInfHrEmpMas", perRequests);
        }

        return iValue;
    	//return sqlSession.insert("usercf.insertTnInfHrEmpMasSMDM");
    }

    
    //20240514 GHRP → SMDM 변경 되면서 code가 변경됨
    /* 기존 GHRP
     * T.EMP_STTS_CD = 'AA' THEN  NULL
     * T.EMP_STTS_CD = 'CA' THEN 'LONG_TERM'
     * T.EMP_STTS_CD = 'DA' THEN 'RETIRE'
     * T.EMP_STTS_CD = 'RC' THEN 'DELETED'
     *
     * SMDM
     * 0	Active(재직)
     * 3	Leave of Absence(휴직)
     * R	Termination(퇴직)
     * M	Transfer
     */
    public int insertTnCfUser() {
        return sqlSession.insert("usercf.insertTnCfUser");
    }
	
    public int insertTnCfUserRole() {
        return sqlSession.insert("usercf.insertTnCfUserRole");
    }

    // P1SEC-6900 [3선]인사에서 받아오는 부서정보 관련 데이터 수정
    public int updateTnCfUserDeptName() {
    	return sqlSession.update("usercf.updateTnCfUserDeptName");
    }
    
   
    
    
}
