jiazx0107@163.com
2023-05-17 620eab6cca2bc9ef9ea6d3067a0a5ba1deadbd1c
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
package com.ld.igds.th.impl;
 
import com.ld.igds.common.dto.THDto;
import com.ld.igds.constant.RedisConst;
import com.ld.igds.th.CoreThService;
import com.ld.igds.util.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
@Service(CoreThService.BEAN_ID)
public class CoreThServiceImpl implements CoreThService {
 
    @Autowired
    private RedisUtil redisUtil;
 
    @Override
    public void setCacheTH(THDto data) {
        if (null == data.getThConf()) {
            data.setThConf("1");
        }
        String tempKey = data.getSerId() + "_" + data.getThConf();
 
        String key = RedisConst.buildKey(data.getCompanyId(), RedisConst.KEY_T_TH, tempKey);
        redisUtil.set(key, data, 3 * 60 * 60);
    }
 
    @Override
    public THDto getCacheTH(String companyId, String thSerId, String thConf) {
        if (null == thConf) thConf = "1";
        String tempKey = thSerId + "_" + thConf;
        String key = RedisConst.buildKey(companyId, RedisConst.KEY_T_TH, tempKey);
        return (THDto) redisUtil.get(key);
    }
}