no message
Showing
2 changed files
with
25 additions
and
24 deletions
| 1 | package com.lego.web.controller.core; | 1 | package com.lego.web.controller.core; |
| 2 | 2 | ||
| 3 | import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 3 | import com.lego.common.annotation.RepeatSubmit; | 4 | import com.lego.common.annotation.RepeatSubmit; |
| 4 | import com.lego.common.core.controller.BaseController; | 5 | import com.lego.common.core.controller.BaseController; |
| 5 | import com.lego.common.core.domain.R; | 6 | import com.lego.common.core.domain.R; |
| 6 | import com.lego.common.core.page.TableDataInfo; | 7 | import com.lego.common.core.page.TableDataInfo; |
| 8 | import com.lego.common.utils.EncryptUtils; | ||
| 9 | import com.lego.common.utils.MessageUtils; | ||
| 7 | import com.lego.core.domin.bo.UpgradeBo; | 10 | import com.lego.core.domin.bo.UpgradeBo; |
| 8 | import com.lego.core.domin.bo.UpgradeQueryBo; | 11 | import com.lego.core.domin.bo.UpgradeQueryBo; |
| 9 | import com.lego.core.domin.vo.ResourceVo; | 12 | import com.lego.core.domin.vo.ResourceVo; |
| ... | @@ -40,8 +43,16 @@ public class UpgradeController extends BaseController { | ... | @@ -40,8 +43,16 @@ public class UpgradeController extends BaseController { |
| 40 | } | 43 | } |
| 41 | 44 | ||
| 42 | @GetMapping("/list") | 45 | @GetMapping("/list") |
| 43 | public R<ResourceVo> list() { | 46 | public R<String> list() { |
| 44 | return R.ok(service.list()); | 47 | try { |
| 48 | ResourceVo resourceVo = service.list(); | ||
| 49 | ObjectMapper objectMapper = new ObjectMapper(); | ||
| 50 | String json = objectMapper.writeValueAsString(resourceVo); | ||
| 51 | return R.ok(MessageUtils.message("system.success"),EncryptUtils.encryptByAes(json)); | ||
| 52 | } | ||
| 53 | catch(Exception e){ | ||
| 54 | return R.fail(); | ||
| 55 | } | ||
| 45 | } | 56 | } |
| 46 | 57 | ||
| 47 | /** | 58 | /** | ... | ... |
| ... | @@ -58,29 +58,19 @@ public class SaTokenConfig implements WebMvcConfigurer { | ... | @@ -58,29 +58,19 @@ public class SaTokenConfig implements WebMvcConfigurer { |
| 58 | .check(() -> { | 58 | .check(() -> { |
| 59 | // 检查是否登录 是否有token | 59 | // 检查是否登录 是否有token |
| 60 | SaRequest request = SaHolder.getRequest(); | 60 | SaRequest request = SaHolder.getRequest(); |
| 61 | String version = request.getHeader("version"); | 61 | String token = request.getHeader("token"); |
| 62 | System.out.println("versioncode:"+version); | 62 | System.out.println("token:"+token); |
| 63 | if(StringUtils.isNotBlank(version)) { | 63 | if(StringUtils.isNotBlank(token)) { |
| 64 | String token = request.getHeader("token"); | 64 | String timestamp = EncryptUtils.decryptByAes(token); |
| 65 | System.out.println("token:"+token); | 65 | System.out.println("timestamp:"+timestamp); |
| 66 | SaTokenDao plusSaTokenDao = saTokenDao(); | 66 | long time = System.currentTimeMillis(); |
| 67 | String secret = CacheUtils.get(CacheNames.VERSION_CODE,version); | 67 | long period = time-Long.valueOf(timestamp); |
| 68 | System.out.println("secret:"+secret); | 68 | System.out.println("period:"+period); |
| 69 | String appSecret = EncryptUtils.decryptByAes(secret); | 69 | if(period<=60000 && period>=0){ |
| 70 | System.out.println("appSecret"+appSecret); | ||
| 71 | String explicitToken = EncryptUtils.decryptByAes(token,appSecret); | ||
| 72 | System.out.println("explicitToken"+explicitToken); | ||
| 73 | List<String> list = Arrays.asList(explicitToken.split("&")); | ||
| 74 | if(!CollectionUtils.isEmpty(list)){ | ||
| 75 | long time = System.currentTimeMillis(); | ||
| 76 | long period = time-Long.valueOf(list.get(0)); | ||
| 77 | System.out.println("period:"+period); | ||
| 78 | if(period<60000 && period>0){ | ||
| 79 | 70 | ||
| 80 | } | 71 | } |
| 81 | else{ | 72 | else{ |
| 82 | throw NotLoginException.newInstance("", "-2", "token 无效", token).setCode(403); | 73 | throw NotLoginException.newInstance("", "-2", "token 无效", token).setCode(403); |
| 83 | } | ||
| 84 | } | 74 | } |
| 85 | } | 75 | } |
| 86 | else{ | 76 | else{ | ... | ... |
-
Please register or sign in to post a comment