Merge branch 'developer' into alpha
| | |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.TypeReference; |
| | | import com.matrix.component.tools.HttpCurlUtil; |
| | | import com.matrix.core.pojo.AjaxResult; |
| | | import com.matrix.core.tools.*; |
| | |
| | | return AjaxResult.buildFailInstance("该手机号不存在"); |
| | | } |
| | | |
| | | String codeExist = LocalCache.get(smsCodeDto.getTelphone()); |
| | | String codeExist = LocalCache.get(smsCodeDto.getTelphone(),new TypeReference<String>(){}); |
| | | if (StringUtils.isNotBlank(codeExist)) { |
| | | return AjaxResult.buildFailInstance("请勿重复发送验证码"); |
| | | } |
| | |
| | | return AjaxResult.buildFailInstance("该手机号不存在"); |
| | | } |
| | | |
| | | String code = LocalCache.get(pwdResetDto.getTelphone()); |
| | | String code = LocalCache.get(pwdResetDto.getTelphone(),new TypeReference<String>(){}); |
| | | if (StringUtils.isBlank(code)) { |
| | | return AjaxResult.buildFailInstance("验证码已失效,请重新发送"); |
| | | } |
| | |
| | | |
| | | |
| | | String redisKey = USER_POWER_REDISKEY_APP + SecureUtil.md5(user.getSuId()+""); |
| | | Map<String, Object> cachePowerMap = LocalCache.get(redisKey); |
| | | Map<String, Object> cachePowerMap = LocalCache.get(redisKey,new TypeReference<Map<String,Object>>(){}); |
| | | if (Objects.nonNull(cachePowerMap)) { |
| | | userFunction = JSONObject.parseObject(JSON.toJSONString( cachePowerMap.get(USERFUNCTION)), new TypeReference<Map<String, SysFunction>>(){}); |
| | | userUrlMapping =JSONObject.parseObject(JSON.toJSONString( cachePowerMap.get(USER_URL_MAPPING)) , new TypeReference<List<String>>(){}); |
| | |
| | | SysUsers sysUser = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); |
| | | |
| | | String redisKey = USER_POWER_REDISKEY_PC + SecureUtil.md5(sysUser.getSuId() + ""); |
| | | Map<String, Object> cachePowerMap = LocalCache.get(redisKey); |
| | | Map<String, Object> cachePowerMap = LocalCache.get(redisKey,new TypeReference<Map<String,Object>>(){}); |
| | | |
| | | if (Objects.nonNull(cachePowerMap)) { |
| | | userFunction = JSONObject.parseObject(JSON.toJSONString( cachePowerMap.get(USERFUNCTION)), new TypeReference<Map<String, SysFunction>>(){}); |
| | |
| | | * @param key |
| | | * @param <T> |
| | | * @return |
| | | */ |
| | | *//* |
| | | public static <T> T get(String key) { |
| | | CacheValue value = localCache.get(key); |
| | | if (Objects.nonNull(value)) { |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | */ |
| | | /** |
| | | * 获取本地缓存,如果需要转换为List,Map类型的具体泛型使用本方法 |
| | | * @param key |
| | |
| | | */ |
| | | package com.matrix.system.common.init; |
| | | |
| | | import com.alibaba.fastjson.TypeReference; |
| | | import com.matrix.core.constance.SystemErrorCode; |
| | | import com.matrix.core.exception.GlobleException; |
| | | import com.matrix.core.tools.StringUtils; |
| | | import com.matrix.core.tools.UUIDUtil; |
| | | import com.matrix.core.tools.WebUtil; |
| | | import com.matrix.system.common.bean.SysUsers; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | public boolean isUserLogin() { |
| | | String token = getUserToken(); |
| | | if (StringUtils.isNotBlank(token)) { |
| | | return LocalCache.get(token) != null; |
| | | return LocalCache.get(token,new TypeReference<String>(){}) != null; |
| | | } else { |
| | | return false; |
| | | } |
| | |
| | | public <T> T getLoginUser() { |
| | | String userToken = getUserToken(); |
| | | if (userToken != null) { |
| | | T user = LocalCache.get(userToken); |
| | | T user = LocalCache.get(userToken,new TypeReference<SysUsers>(){}); |
| | | if (Objects.nonNull(user)) { |
| | | //重新设置key过期时间 |
| | | LocalCache.resetExpire(userToken); |
| | |
| | | package com.matrix.system.common.interceptor; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.TypeReference; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.matrix.core.constance.MatrixConstance; |
| | | import com.matrix.core.pojo.AjaxResult; |
| | |
| | | return false; |
| | | } |
| | | |
| | | SysUsers sysUsers = LocalCache.get(token); |
| | | SysUsers sysUsers = LocalCache.get(token,new TypeReference<SysUsers>(){}); |
| | | if (Objects.isNull(sysUsers)) { |
| | | ajaxResult.setInfo("login time out"); |
| | | response.getWriter().write(new ObjectMapper().writeValueAsString(ajaxResult)); |
| | |
| | | */ |
| | | package com.matrix; |
| | | |
| | | import com.alibaba.fastjson.TypeReference; |
| | | import com.matrix.system.common.bean.SysUsers; |
| | | import com.matrix.system.common.init.LocalCache; |
| | | import org.junit.Assert; |
| | | import org.junit.Test; |
| | |
| | | public void testNoticeTask() throws IOException, InterruptedException { |
| | | LocalCache.save("name","jyy",1000*3); |
| | | System.out.println("放入对象"); |
| | | Assert.assertNotNull(LocalCache.get("name")); |
| | | Assert.assertNotNull(LocalCache.get("name",new TypeReference<SysUsers>(){})); |
| | | Thread.sleep(1000*5); |
| | | Assert.assertNull(LocalCache.get("name")); |
| | | Assert.assertNull(LocalCache.get("name",new TypeReference<SysUsers>(){})); |
| | | } |
| | | |
| | | } |