Commit ba94d64250a74da6f7d76b393ee32627998765a5

Authored by 云中非
1 parent d9eb373a

fix(cache): redis缓存地区信息异常的问题

... ... @@ -23,6 +23,8 @@ public interface FastIotConstants {
23 23 String CACHE_CONFIG_KEY = "yunTengIotCache";
24 24 String USER_PERMISSION_PREFIX = "userPermissionFor_";
25 25 String MOBILE_LOGIN_SMS_CODE = "mobileLoginSmsCode";
  26 +
  27 + String AREA = "thingsArea";
26 28 }
27 29 interface TBCacheConfig {
28 30 String TB_CACHE_CONFIG_KEY = "TB_CONNECT_CACHE";
... ... @@ -46,10 +48,6 @@ public interface FastIotConstants {
46 48 int DRAFT = 0;
47 49 }
48 50
49   - interface CacheKey {
50   - String area = "thingsArea";
51   - int DRAFT = 0;
52   - }
53 51
54 52 interface ConfigureLevel {
55 53 String CONFIGURE = "CONFIGURE";
... ...
... ... @@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModelProperty;
5 5 import lombok.Data;
6 6 import org.thingsboard.server.common.data.yunteng.enums.AreaLevelEnum;
7 7
  8 +import java.io.Serializable;
  9 +
8 10 /**
9 11 * @author: 徐浩然
10 12 * @desc: 中国省市区街关联
... ... @@ -12,7 +14,7 @@ import org.thingsboard.server.common.data.yunteng.enums.AreaLevelEnum;
12 14 */
13 15 @Data
14 16 @ApiModel(value = "中国省市区街关联")
15   -public class SysAreaDTO {
  17 +public class SysAreaDTO implements Serializable {
16 18 @ApiModelProperty(value = "上级Code")
17 19 private Long parentId;
18 20
... ...
... ... @@ -29,8 +29,7 @@ public class SysAreaServiceImpl implements SysAreaService {
29 29
30 30 @Override
31 31 public List<SysAreaDTO> list(SysAreaDTO sysAreaDTO) {
32   - cacheManager.getCache(FastIotConstants.CacheKey.area).get(sysAreaDTO.getParentId());
33   - List<SysAreaDTO> result = cacheManager.getCache(FastIotConstants.CacheKey.area).get(sysAreaDTO.getParentId(),List.class);
  32 + List<SysAreaDTO> result = cacheManager.getCache(FastIotConstants.CacheConfigKey.AREA).get(sysAreaDTO.getParentId(),List.class);
34 33 if(result == null || result.isEmpty()){
35 34 result = ReflectUtils.sourceToTarget(
36 35 sysAreaMapper.selectList(
... ... @@ -46,7 +45,7 @@ public class SysAreaServiceImpl implements SysAreaService {
46 45 SysAreaEntity::getName,
47 46 sysAreaDTO.getName())),
48 47 SysAreaDTO.class);
49   - cacheManager.getCache(FastIotConstants.CacheKey.area).put(sysAreaDTO.getParentId(),result);
  48 + cacheManager.getCache(FastIotConstants.CacheConfigKey.AREA).put(sysAreaDTO.getParentId(),result);
50 49 }
51 50
52 51
... ...