token
Showing
6 changed files
with
40 additions
and
31 deletions
| ... | @@ -47,25 +47,25 @@ public class UpgradeController extends BaseController { | ... | @@ -47,25 +47,25 @@ public class UpgradeController extends BaseController { |
| 47 | /** | 47 | /** |
| 48 | * 新增 | 48 | * 新增 |
| 49 | * | 49 | * |
| 50 | * @param UpgradeBo | 50 | * @param upgradeBo |
| 51 | * @return | 51 | * @return |
| 52 | */ | 52 | */ |
| 53 | @RepeatSubmit() | 53 | @RepeatSubmit() |
| 54 | @PostMapping() | 54 | @PostMapping() |
| 55 | public R<Void> addUpgrade(@RequestBody UpgradeBo UpgradeBo) throws ServerException { | 55 | public R<Void> addUpgrade(@RequestBody UpgradeBo upgradeBo) throws ServerException { |
| 56 | return toAjax(service.addUpgrade(UpgradeBo)); | 56 | return toAjax(service.addUpgrade(upgradeBo)); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | /** | 59 | /** |
| 60 | * 修改 | 60 | * 修改 |
| 61 | * | 61 | * |
| 62 | * @param UpgradeBo | 62 | * @param upgradeBo |
| 63 | * @return | 63 | * @return |
| 64 | */ | 64 | */ |
| 65 | @RepeatSubmit() | 65 | @RepeatSubmit() |
| 66 | @PutMapping | 66 | @PutMapping |
| 67 | public R<Void> updateUpgrade(@RequestBody UpgradeBo UpgradeBo) throws ServerException { | 67 | public R<Void> updateUpgrade(@RequestBody UpgradeBo upgradeBo) throws ServerException { |
| 68 | return toAjax(service.updateUpgrade(UpgradeBo)); | 68 | return toAjax(service.updateUpgrade(upgradeBo)); |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | /** | 71 | /** | ... | ... |
| ... | @@ -137,7 +137,10 @@ public class EncryptUtils { | ... | @@ -137,7 +137,10 @@ public class EncryptUtils { |
| 137 | * @return 解密后字符串 | 137 | * @return 解密后字符串 |
| 138 | */ | 138 | */ |
| 139 | public static String decryptByAes(String data) { | 139 | public static String decryptByAes(String data) { |
| 140 | return decryptByAes(data, AES_SECRET); | 140 | if(StringUtils.isNotBlank(data)) { |
| 141 | return decryptByAes(data, AES_SECRET); | ||
| 142 | } | ||
| 143 | return ""; | ||
| 141 | } | 144 | } |
| 142 | 145 | ||
| 143 | /** | 146 | /** |
| ... | @@ -343,4 +346,10 @@ public class EncryptUtils { | ... | @@ -343,4 +346,10 @@ public class EncryptUtils { |
| 343 | return SmUtil.sm3(data); | 346 | return SmUtil.sm3(data); |
| 344 | } | 347 | } |
| 345 | 348 | ||
| 349 | public static void main(String[] args) { | ||
| 350 | |||
| 351 | String str = System.currentTimeMillis()+"&1915289501429309442"; | ||
| 352 | |||
| 353 | System.out.println(encryptByAes(str,"abcdefghijklmnopqrstuvwx")); | ||
| 354 | } | ||
| 346 | } | 355 | } | ... | ... |
| ... | @@ -2,18 +2,12 @@ package com.lego.core.service; | ... | @@ -2,18 +2,12 @@ package com.lego.core.service; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | import com.lego.common.core.page.TableDataInfo; | 4 | import com.lego.common.core.page.TableDataInfo; |
| 5 | import com.lego.core.domin.bo.QuestionBo; | ||
| 6 | import com.lego.core.domin.bo.QuestionQueryBo; | ||
| 7 | import com.lego.core.domin.bo.UpgradeBo; | 5 | import com.lego.core.domin.bo.UpgradeBo; |
| 8 | import com.lego.core.domin.bo.UpgradeQueryBo; | 6 | import com.lego.core.domin.bo.UpgradeQueryBo; |
| 9 | import com.lego.core.domin.vo.CourseVo; | ||
| 10 | import com.lego.core.domin.vo.QuestionVo; | ||
| 11 | import com.lego.core.domin.vo.ResourceVo; | 7 | import com.lego.core.domin.vo.ResourceVo; |
| 12 | import com.lego.core.domin.vo.UpgradeVo; | 8 | import com.lego.core.domin.vo.UpgradeVo; |
| 13 | import com.lego.system.domain.vo.SysOssVo; | ||
| 14 | 9 | ||
| 15 | import java.rmi.ServerException; | 10 | import java.rmi.ServerException; |
| 16 | import java.util.List; | ||
| 17 | 11 | ||
| 18 | /** | 12 | /** |
| 19 | * APP升级Service接口 | 13 | * APP升级Service接口 |
| ... | @@ -43,8 +37,6 @@ public interface IUpgradeService { | ... | @@ -43,8 +37,6 @@ public interface IUpgradeService { |
| 43 | */ | 37 | */ |
| 44 | boolean addUpgrade(UpgradeBo UpgradeBo) throws ServerException; | 38 | boolean addUpgrade(UpgradeBo UpgradeBo) throws ServerException; |
| 45 | 39 | ||
| 46 | UpgradeVo getById(String id); | ||
| 47 | |||
| 48 | 40 | ||
| 49 | /** | 41 | /** |
| 50 | * 修改 | 42 | * 修改 | ... | ... |
| ... | @@ -10,7 +10,9 @@ import com.lego.common.core.page.TableDataInfo; | ... | @@ -10,7 +10,9 @@ import com.lego.common.core.page.TableDataInfo; |
| 10 | import com.lego.common.core.service.ConfigService; | 10 | import com.lego.common.core.service.ConfigService; |
| 11 | import com.lego.common.core.service.OssService; | 11 | import com.lego.common.core.service.OssService; |
| 12 | import com.lego.common.utils.DateUtils; | 12 | import com.lego.common.utils.DateUtils; |
| 13 | import com.lego.common.utils.EncryptUtils; | ||
| 13 | import com.lego.common.utils.MessageUtils; | 14 | import com.lego.common.utils.MessageUtils; |
| 15 | import com.lego.common.utils.redis.CacheUtils; | ||
| 14 | import com.lego.core.annotation.LanguageAnnotation; | 16 | import com.lego.core.annotation.LanguageAnnotation; |
| 15 | import com.lego.core.domin.Course; | 17 | import com.lego.core.domin.Course; |
| 16 | import com.lego.core.domin.Upgrade; | 18 | import com.lego.core.domin.Upgrade; |
| ... | @@ -91,6 +93,7 @@ public class UpgradeServiceImpl implements IUpgradeService { | ... | @@ -91,6 +93,7 @@ public class UpgradeServiceImpl implements IUpgradeService { |
| 91 | .eq(Upgrade::getLanguage, language)); | 93 | .eq(Upgrade::getLanguage, language)); |
| 92 | List<UpgradeVo> list = page.getRecords(); | 94 | List<UpgradeVo> list = page.getRecords(); |
| 93 | for (UpgradeVo vo : list) { | 95 | for (UpgradeVo vo : list) { |
| 96 | vo.setAppSecret(EncryptUtils.decryptByAes(vo.getAppSecret())); | ||
| 94 | if (StrUtil.isNotBlank(vo.getFileOssId())) { | 97 | if (StrUtil.isNotBlank(vo.getFileOssId())) { |
| 95 | SysOssVo oss = iSysOssService.getById(Long.valueOf(vo.getFileOssId())); | 98 | SysOssVo oss = iSysOssService.getById(Long.valueOf(vo.getFileOssId())); |
| 96 | vo.setOssUrl(oss.getUrl()); | 99 | vo.setOssUrl(oss.getUrl()); |
| ... | @@ -102,26 +105,20 @@ public class UpgradeServiceImpl implements IUpgradeService { | ... | @@ -102,26 +105,20 @@ public class UpgradeServiceImpl implements IUpgradeService { |
| 102 | /** | 105 | /** |
| 103 | * 新增 | 106 | * 新增 |
| 104 | * | 107 | * |
| 105 | * @param UpgradeBo | 108 | * @param upgradeBo |
| 106 | * @return | 109 | * @return |
| 107 | */ | 110 | */ |
| 108 | @Override | 111 | @Override |
| 109 | @LanguageAnnotation | 112 | @LanguageAnnotation |
| 110 | public boolean addUpgrade(UpgradeBo UpgradeBo) { | 113 | public boolean addUpgrade(UpgradeBo upgradeBo) { |
| 111 | Upgrade upgrade = BeanUtil.toBean(UpgradeBo, Upgrade.class); | 114 | upgradeBo.setAppSecret(EncryptUtils.encryptByAes(upgradeBo.getAppSecret())); |
| 115 | Upgrade upgrade = BeanUtil.toBean(upgradeBo, Upgrade.class); | ||
| 112 | upgrade.setId(null); | 116 | upgrade.setId(null); |
| 113 | int result = baseMapper.insert(upgrade); | 117 | int result = baseMapper.insert(upgrade); |
| 114 | getById(upgrade.getId()); | 118 | CacheUtils.put(CacheNames.VERSION_CODE, upgrade.getId(), upgrade.getAppSecret()); |
| 115 | return result > 0; | 119 | return result > 0; |
| 116 | } | 120 | } |
| 117 | 121 | ||
| 118 | @Cacheable(cacheNames = CacheNames.SYS_OSS, key = "#id") | ||
| 119 | @Override | ||
| 120 | public UpgradeVo getById(String id) { | ||
| 121 | UpgradeVo vo = baseMapper.selectVoById(id); | ||
| 122 | return vo; | ||
| 123 | } | ||
| 124 | |||
| 125 | /** | 122 | /** |
| 126 | * 修改 | 123 | * 修改 |
| 127 | * | 124 | * |
| ... | @@ -133,9 +130,10 @@ public class UpgradeServiceImpl implements IUpgradeService { | ... | @@ -133,9 +130,10 @@ public class UpgradeServiceImpl implements IUpgradeService { |
| 133 | @LanguageAnnotation | 130 | @LanguageAnnotation |
| 134 | public boolean updateUpgrade(UpgradeBo upgradeBo) throws ServerException { | 131 | public boolean updateUpgrade(UpgradeBo upgradeBo) throws ServerException { |
| 135 | checkExists(upgradeBo.getId()); | 132 | checkExists(upgradeBo.getId()); |
| 133 | upgradeBo.setAppSecret(EncryptUtils.encryptByAes(upgradeBo.getAppSecret())); | ||
| 136 | Upgrade upgrade = BeanUtil.toBean(upgradeBo, Upgrade.class); | 134 | Upgrade upgrade = BeanUtil.toBean(upgradeBo, Upgrade.class); |
| 137 | int result = baseMapper.updateById(upgrade); | 135 | int result = baseMapper.updateById(upgrade); |
| 138 | getById(upgrade.getId()); | 136 | CacheUtils.put(CacheNames.VERSION_CODE, upgrade.getId(), upgrade.getAppSecret()); |
| 139 | return result > 0; | 137 | return result > 0; |
| 140 | } | 138 | } |
| 141 | 139 | ... | ... |
| ... | @@ -10,8 +10,10 @@ import cn.dev33.satoken.router.SaRouter; | ... | @@ -10,8 +10,10 @@ import cn.dev33.satoken.router.SaRouter; |
| 10 | import cn.dev33.satoken.stp.StpInterface; | 10 | import cn.dev33.satoken.stp.StpInterface; |
| 11 | import cn.dev33.satoken.stp.StpLogic; | 11 | import cn.dev33.satoken.stp.StpLogic; |
| 12 | import cn.dev33.satoken.stp.StpUtil; | 12 | import cn.dev33.satoken.stp.StpUtil; |
| 13 | import com.lego.common.constant.CacheNames; | ||
| 13 | import com.lego.common.utils.EncryptUtils; | 14 | import com.lego.common.utils.EncryptUtils; |
| 14 | import com.lego.common.utils.StringUtils; | 15 | import com.lego.common.utils.StringUtils; |
| 16 | import com.lego.common.utils.redis.CacheUtils; | ||
| 15 | import com.lego.common.utils.spring.SpringUtils; | 17 | import com.lego.common.utils.spring.SpringUtils; |
| 16 | import com.lego.framework.config.properties.SecurityProperties; | 18 | import com.lego.framework.config.properties.SecurityProperties; |
| 17 | import com.lego.framework.handler.AllUrlHandler; | 19 | import com.lego.framework.handler.AllUrlHandler; |
| ... | @@ -39,7 +41,6 @@ import java.util.List; | ... | @@ -39,7 +41,6 @@ import java.util.List; |
| 39 | public class SaTokenConfig implements WebMvcConfigurer { | 41 | public class SaTokenConfig implements WebMvcConfigurer { |
| 40 | 42 | ||
| 41 | private final SecurityProperties securityProperties; | 43 | private final SecurityProperties securityProperties; |
| 42 | private final PlusSaTokenDao plusSaTokenDao; | ||
| 43 | 44 | ||
| 44 | /** | 45 | /** |
| 45 | * 注册sa-token的拦截器 | 46 | * 注册sa-token的拦截器 |
| ... | @@ -58,16 +59,23 @@ public class SaTokenConfig implements WebMvcConfigurer { | ... | @@ -58,16 +59,23 @@ public class SaTokenConfig implements WebMvcConfigurer { |
| 58 | // 检查是否登录 是否有token | 59 | // 检查是否登录 是否有token |
| 59 | SaRequest request = SaHolder.getRequest(); | 60 | SaRequest request = SaHolder.getRequest(); |
| 60 | String version = request.getHeader("version"); | 61 | String version = request.getHeader("version"); |
| 62 | System.out.println("versioncode:"+version); | ||
| 61 | if(StringUtils.isNotBlank(version)) { | 63 | if(StringUtils.isNotBlank(version)) { |
| 62 | String token = StpUtil.getTokenValue(); | 64 | String token = request.getHeader("token"); |
| 63 | String secret = plusSaTokenDao.get(version); | 65 | System.out.println("token:"+token); |
| 66 | SaTokenDao plusSaTokenDao = saTokenDao(); | ||
| 67 | String secret = CacheUtils.get(CacheNames.VERSION_CODE,version); | ||
| 68 | System.out.println("secret:"+secret); | ||
| 64 | String appSecret = EncryptUtils.decryptByAes(secret); | 69 | String appSecret = EncryptUtils.decryptByAes(secret); |
| 70 | System.out.println("appSecret"+appSecret); | ||
| 65 | String explicitToken = EncryptUtils.decryptByAes(token,appSecret); | 71 | String explicitToken = EncryptUtils.decryptByAes(token,appSecret); |
| 72 | System.out.println("explicitToken"+explicitToken); | ||
| 66 | List<String> list = Arrays.asList(explicitToken.split("&")); | 73 | List<String> list = Arrays.asList(explicitToken.split("&")); |
| 67 | if(!CollectionUtils.isEmpty(list)){ | 74 | if(!CollectionUtils.isEmpty(list)){ |
| 68 | long time = System.currentTimeMillis(); | 75 | long time = System.currentTimeMillis(); |
| 69 | long period = time-Long.valueOf(list.get(0)); | 76 | long period = time-Long.valueOf(list.get(0)); |
| 70 | if(period<60 && period>0){ | 77 | System.out.println("period:"+period); |
| 78 | if(period<60000 && period>0){ | ||
| 71 | 79 | ||
| 72 | } | 80 | } |
| 73 | else{ | 81 | else{ | ... | ... |
-
Please register or sign in to post a comment