保誠-保戶業務員媒合平台
wayne
2021-12-17 374045ebbeaa725ec2d030f5474067e37f568637
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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);
    }
}