package com.dbs.mplus.service.mobile.user.repository.dao;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.dbs.mplus.framework.service.admin.userAttr.repository.dao.UserAttr;
import com.dbs.mplus.framework.util.ConvertUtil;
import com.dbs.mplus.framework.util.DateDeserializer;
import com.dbs.mplus.framework.util.DateSerializer;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
/**
 * 사용자 
 * @author siyoung.ahn 
 *
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class MPlusUser {
	// 시퀀스 
	private Long userSeq; 
	// 사용자번호 
	private String userId; 
	// 사용자 이름
	private String userNm;
	// 부서 리스트
	private List<Map<String, Object>> departmentList;
	// 속성 리스트
	private List<UserAttr> userAttrList;
	
	// 로컬 암호화 키 
	private String localCipherKeyValue; 
	// 로그인 실패 횟수 
	private Integer loginFailCnt; 
	// 로그인 암호 
	private String passWordValue; 
	// 사용 등록일 
	@JsonSerialize(using = DateSerializer.class)
	@JsonDeserialize(using = DateDeserializer.class)		
	private Date registerDt; 
	// 동의서 목록 
	private List<MPlusUserAgreement> agreementList;
	// 사용자가 다음에 이동할 페이지 
	// DB에 저장되는 값은 아니고, 로그인 처리용임 
	private String nextPage; 
	// 사용자가 선택한 속성
	private Long useAttrOrder;
	// 사용자의 Job 종류 코드
	private String jobKindCd;
	// 사용자의 Job 종류 이름
	private String jobKindNm;
	// 병원 코드
	private String hospitalCd;
	// 응답코드(0000: 성공, 0001:에러)
	private String returnCd;
	// 응답메시지
	private String returnMsg;
	// 실패 횟수
	private String failCnt;	
		
	// 생성자
	public MPlusUser() {}
	
	public String getHospitalCd() {
		return hospitalCd;
	}

	public void setHospitalCd(String hospitalCd) {
		this.hospitalCd = hospitalCd;
	}

	public String getJobKindCd() {
		return jobKindCd;
	}

	public void setJobKindCd(String jobKindCd) {
		this.jobKindCd = jobKindCd;
	}
	
	public String getJobKindNm() {
		return jobKindNm;
	}

	public void setJobKindNm(String jobKindNm) {
		this.jobKindNm = jobKindNm;
	}

	public String getUserNm() {
		return userNm;
	}

	public void setUserNm(String userNm) {
		this.userNm = userNm;
	}

	public List<Map<String, Object>> getDepartmentList() {
		return departmentList;
	}

	public void setDepartmentList(List<Map<String, Object>> departmentList) {
		this.departmentList = departmentList;
	}

	public Long getUserSeq() {
		return this.userSeq;
	}

	public void setUserSeq(Long userSeq) {
		this.userSeq = userSeq;
	}

	public String getUserId() {
		return this.userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}


	public String getLocalCipherKeyValue() {
		return this.localCipherKeyValue;
	}

	public void setLocalCipherKeyValue(String localCipherKeyValue) {
		this.localCipherKeyValue = localCipherKeyValue;
	}

	public Integer getLoginFailCnt() {
		return this.loginFailCnt;
	}

	public void setLoginFailCnt(Integer loginFailCnt) {
		this.loginFailCnt = loginFailCnt;
	}

	public String getPassWordValue() {
		return this.passWordValue;
	}

	public void setPassWordValue(String passWordValue) {
		this.passWordValue = passWordValue;
	}

	public Date getRegisterDt() {
		return this.registerDt;
	}

	public void setRegisterDt(Date registerDt) {
		this.registerDt = registerDt;
	}

	public List<MPlusUserAgreement> getAgreementList() {
		return this.agreementList;
	}

	public void setAgreementList(List<MPlusUserAgreement> agreementList) {
		this.agreementList = agreementList;
	}

	public String getNextPage() {
		return this.nextPage;
	}

	public void setNextPage(String nextPage) {
		this.nextPage = nextPage;
	}

	public Long getUseAttrOrder() {
		return useAttrOrder;
	}

	public void setUseAttrOrder(Long useAttrOrder) {
		this.useAttrOrder = useAttrOrder;
	}
	
	public List<UserAttr> getUserAttrList() {
		return userAttrList;
	}

	public void setUserAttrList(List<UserAttr> userAttrList) {
		this.userAttrList = userAttrList;
	}

	/**
	 * 변환 
	 * @param map
	 * @return
	 */
	public static MPlusUser convert(Map<String, Object> userMap) { 
		final MPlusUser user = new MPlusUser(); 
		//final BigDecimal b = (BigDecimal) userMap.get("loginFailCnt"); 
		final BigDecimal attrOrder = (BigDecimal) userMap.get("useAttrOrder"); 
		
		user.setUserId((String) userMap.get("userId"));
		user.setUserNm((String) userMap.get("userNm"));
		//user.setLoginFailCnt(ConvertUtil.convertInteger(b));
		user.setPassWordValue((String) userMap.get("passwordValue"));
		user.setLocalCipherKeyValue((String) userMap.get("localCipherKeyValue"));
		user.setUseAttrOrder(ConvertUtil.convertLong(attrOrder));
		return user; 
	}
	
	@Override
	public String toString() {
		return "MPUser [userSeq=" + this.userSeq + ", userId=" + this.userId 
				+ ", localCipherKeyValue=" + this.localCipherKeyValue + ", loginFailCnt=" + this.loginFailCnt
				+ ", passWordValue=" + this.passWordValue + ", registerDt="
				+ this.registerDt + ", agreementList=" + this.agreementList + ", nextPage=" + this.nextPage + "]";
	}

	public String getReturnCd() {
		return returnCd;
	}

	public void setReturnCd(String returnCd) {
		this.returnCd = returnCd;
	}

	public String getReturnMsg() {
		return returnMsg;
	}

	public void setReturnMsg(String returnMsg) {
		this.returnMsg = returnMsg;
	}

	public String getFailCnt() {
		return failCnt;
	}

	public void setFailCnt(String failCnt) {
		this.failCnt = failCnt;
	}
}
