peter
2025-06-25 252184b1fff1b75e24032973996bfdc5b6126cb0
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
package com.yami.trading.service.impl;
 
import com.yami.trading.common.util.TimeWindow;
import com.yami.trading.service.IdentifyingCodeTimeWindowService;
 
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Service;
 
@Service
public class IdentifyingCodeTimeWindowServiceImpl  implements  IdentifyingCodeTimeWindowService,InitializingBean {
    private TimeWindow timeWindow = new TimeWindow();
 
    public void afterPropertiesSet() throws Exception {
        /**
         * 30分钟
         */
        this.timeWindow.setTimeSize(60 * 30);
        this.timeWindow.start();
    }
 
    public String getAuthCode(String key) {
        Object authcode = this.timeWindow.findObject(key);
        if (authcode != null) {
            return String.valueOf(authcode);
        }
        return null;
    }
 
    public void putAuthCode(String key, String authcode) {
        this.timeWindow.add(key, authcode);
    }
 
    public void delAuthCode(String key) {
        this.timeWindow.remove(key);
    }
}