package com.pollex.pam.service;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import com.pollex.pam.domain.OtpTmp;
|
import com.pollex.pam.enums.OtpLoginTypeEnum;
|
import com.pollex.pam.enums.OtpTmpStatusEnum;
|
import com.pollex.pam.repository.OtpTmpRepository;
|
|
@Service
|
@Transactional
|
public class OtpTmpService {
|
|
@Autowired
|
OtpTmpRepository otpTmpRepository;
|
|
public OtpTmp createOtpTmp(String account, String indexKey) {
|
OtpTmp oldTmp = otpTmpRepository.findByAccount(account);
|
if(oldTmp==null) {
|
OtpTmp otpTmp = new OtpTmp();
|
otpTmp.setIndexKey(indexKey);
|
otpTmp.setAccount(account);
|
otpTmp.setStatus(OtpTmpStatusEnum.UNVERIFIED);
|
return otpTmpRepository.save(otpTmp);
|
}else {
|
oldTmp.setIndexKey(indexKey);
|
oldTmp.setStatus(OtpTmpStatusEnum.UNVERIFIED);
|
return otpTmpRepository.save(oldTmp);
|
}
|
}
|
|
public OtpTmp findByAccountAndIndexKey(String account, String indexKey) {
|
return otpTmpRepository.findByAccountAndIndexKey(account, indexKey);
|
}
|
|
public OtpTmp save(OtpTmp otpTmp) {
|
return otpTmpRepository.save(otpTmp);
|
}
|
}
|