package kr.co.uplus.ez.api.login.dto;

import org.joda.time.DateTime;

import kr.co.uplus.ez.common.data.Const;
import kr.co.uplus.ez.common.utils.DateUtils;
import lombok.Data;

@Data
public class SmsAuthNum {
	private String userId;
	private String issNum;
	private String regDt;
	private Integer authFailCnt;
	private String issLockYn;

	public boolean isAuthNumIssuable() {
		if (isIssueLocked() && !isIssueLockExpired()) {
			return false;
		}
		return true;
	}

	public boolean isIssueLocked() {
		return "Y".equals(issLockYn);
	}

	public boolean isIssueLockExpired() {
		DateTime last = DateUtils.str2dateYMDHMS(regDt);
		DateTime now = DateTime.now();
		int minutes = DateUtils.diffMinutes(last, now);
		return minutes >= Const.AUTHNUM_LOCK_EXPIRE_MINS;
	}

}
