Commit ba94d64250a74da6f7d76b393ee32627998765a5

Authored by 云中非
1 parent d9eb373a

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

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