Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
legobackend
/
lego-manage
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
2f067e16
authored
2025-08-05 08:23:17 +0800
by
chentao
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
token
1 parent
f835cc59
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
31 deletions
lego-admin/src/main/java/com/lego/web/controller/core/UpgradeController.java
lego-common/src/main/java/com/lego/common/constant/CacheNames.java
lego-common/src/main/java/com/lego/common/utils/EncryptUtils.java
lego-core/src/main/java/com/lego/core/service/IUpgradeService.java
lego-core/src/main/java/com/lego/core/service/impl/UpgradeServiceImpl.java
lego-framework/src/main/java/com/lego/framework/config/SaTokenConfig.java
lego-admin/src/main/java/com/lego/web/controller/core/UpgradeController.java
View file @
2f067e1
...
...
@@ -47,25 +47,25 @@ public class UpgradeController extends BaseController {
/**
* 新增
*
* @param
U
pgradeBo
* @param
u
pgradeBo
* @return
*/
@RepeatSubmit
()
@PostMapping
()
public
R
<
Void
>
addUpgrade
(
@RequestBody
UpgradeBo
U
pgradeBo
)
throws
ServerException
{
return
toAjax
(
service
.
addUpgrade
(
U
pgradeBo
));
public
R
<
Void
>
addUpgrade
(
@RequestBody
UpgradeBo
u
pgradeBo
)
throws
ServerException
{
return
toAjax
(
service
.
addUpgrade
(
u
pgradeBo
));
}
/**
* 修改
*
* @param
U
pgradeBo
* @param
u
pgradeBo
* @return
*/
@RepeatSubmit
()
@PutMapping
public
R
<
Void
>
updateUpgrade
(
@RequestBody
UpgradeBo
U
pgradeBo
)
throws
ServerException
{
return
toAjax
(
service
.
updateUpgrade
(
U
pgradeBo
));
public
R
<
Void
>
updateUpgrade
(
@RequestBody
UpgradeBo
u
pgradeBo
)
throws
ServerException
{
return
toAjax
(
service
.
updateUpgrade
(
u
pgradeBo
));
}
/**
...
...
lego-common/src/main/java/com/lego/common/constant/CacheNames.java
View file @
2f067e1
...
...
@@ -45,6 +45,8 @@ public interface CacheNames {
*/
String
SYS_OSS
=
"sys_oss#30d"
;
String
VERSION_CODE
=
"version_code"
;
/**
* OSS配置
*/
...
...
lego-common/src/main/java/com/lego/common/utils/EncryptUtils.java
View file @
2f067e1
...
...
@@ -137,7 +137,10 @@ public class EncryptUtils {
* @return 解密后字符串
*/
public
static
String
decryptByAes
(
String
data
)
{
return
decryptByAes
(
data
,
AES_SECRET
);
if
(
StringUtils
.
isNotBlank
(
data
))
{
return
decryptByAes
(
data
,
AES_SECRET
);
}
return
""
;
}
/**
...
...
@@ -343,4 +346,10 @@ public class EncryptUtils {
return
SmUtil
.
sm3
(
data
);
}
public
static
void
main
(
String
[]
args
)
{
String
str
=
System
.
currentTimeMillis
()+
"&1915289501429309442"
;
System
.
out
.
println
(
encryptByAes
(
str
,
"abcdefghijklmnopqrstuvwx"
));
}
}
...
...
lego-core/src/main/java/com/lego/core/service/IUpgradeService.java
View file @
2f067e1
...
...
@@ -2,18 +2,12 @@ package com.lego.core.service;
import
com.lego.common.core.page.TableDataInfo
;
import
com.lego.core.domin.bo.QuestionBo
;
import
com.lego.core.domin.bo.QuestionQueryBo
;
import
com.lego.core.domin.bo.UpgradeBo
;
import
com.lego.core.domin.bo.UpgradeQueryBo
;
import
com.lego.core.domin.vo.CourseVo
;
import
com.lego.core.domin.vo.QuestionVo
;
import
com.lego.core.domin.vo.ResourceVo
;
import
com.lego.core.domin.vo.UpgradeVo
;
import
com.lego.system.domain.vo.SysOssVo
;
import
java.rmi.ServerException
;
import
java.util.List
;
/**
* APP升级Service接口
...
...
@@ -43,8 +37,6 @@ public interface IUpgradeService {
*/
boolean
addUpgrade
(
UpgradeBo
UpgradeBo
)
throws
ServerException
;
UpgradeVo
getById
(
String
id
);
/**
* 修改
...
...
lego-core/src/main/java/com/lego/core/service/impl/UpgradeServiceImpl.java
View file @
2f067e1
...
...
@@ -10,7 +10,9 @@ import com.lego.common.core.page.TableDataInfo;
import
com.lego.common.core.service.ConfigService
;
import
com.lego.common.core.service.OssService
;
import
com.lego.common.utils.DateUtils
;
import
com.lego.common.utils.EncryptUtils
;
import
com.lego.common.utils.MessageUtils
;
import
com.lego.common.utils.redis.CacheUtils
;
import
com.lego.core.annotation.LanguageAnnotation
;
import
com.lego.core.domin.Course
;
import
com.lego.core.domin.Upgrade
;
...
...
@@ -91,6 +93,7 @@ public class UpgradeServiceImpl implements IUpgradeService {
.
eq
(
Upgrade:
:
getLanguage
,
language
));
List
<
UpgradeVo
>
list
=
page
.
getRecords
();
for
(
UpgradeVo
vo
:
list
)
{
vo
.
setAppSecret
(
EncryptUtils
.
decryptByAes
(
vo
.
getAppSecret
()));
if
(
StrUtil
.
isNotBlank
(
vo
.
getFileOssId
()))
{
SysOssVo
oss
=
iSysOssService
.
getById
(
Long
.
valueOf
(
vo
.
getFileOssId
()));
vo
.
setOssUrl
(
oss
.
getUrl
());
...
...
@@ -102,26 +105,20 @@ public class UpgradeServiceImpl implements IUpgradeService {
/**
* 新增
*
* @param
U
pgradeBo
* @param
u
pgradeBo
* @return
*/
@Override
@LanguageAnnotation
public
boolean
addUpgrade
(
UpgradeBo
UpgradeBo
)
{
Upgrade
upgrade
=
BeanUtil
.
toBean
(
UpgradeBo
,
Upgrade
.
class
);
public
boolean
addUpgrade
(
UpgradeBo
upgradeBo
)
{
upgradeBo
.
setAppSecret
(
EncryptUtils
.
encryptByAes
(
upgradeBo
.
getAppSecret
()));
Upgrade
upgrade
=
BeanUtil
.
toBean
(
upgradeBo
,
Upgrade
.
class
);
upgrade
.
setId
(
null
);
int
result
=
baseMapper
.
insert
(
upgrade
);
getById
(
upgrade
.
getId
());
CacheUtils
.
put
(
CacheNames
.
VERSION_CODE
,
upgrade
.
getId
(),
upgrade
.
getAppSecret
());
return
result
>
0
;
}
@Cacheable
(
cacheNames
=
CacheNames
.
SYS_OSS
,
key
=
"#id"
)
@Override
public
UpgradeVo
getById
(
String
id
)
{
UpgradeVo
vo
=
baseMapper
.
selectVoById
(
id
);
return
vo
;
}
/**
* 修改
*
...
...
@@ -133,9 +130,10 @@ public class UpgradeServiceImpl implements IUpgradeService {
@LanguageAnnotation
public
boolean
updateUpgrade
(
UpgradeBo
upgradeBo
)
throws
ServerException
{
checkExists
(
upgradeBo
.
getId
());
upgradeBo
.
setAppSecret
(
EncryptUtils
.
encryptByAes
(
upgradeBo
.
getAppSecret
()));
Upgrade
upgrade
=
BeanUtil
.
toBean
(
upgradeBo
,
Upgrade
.
class
);
int
result
=
baseMapper
.
updateById
(
upgrade
);
getById
(
upgrade
.
getId
());
CacheUtils
.
put
(
CacheNames
.
VERSION_CODE
,
upgrade
.
getId
(),
upgrade
.
getAppSecret
());
return
result
>
0
;
}
...
...
lego-framework/src/main/java/com/lego/framework/config/SaTokenConfig.java
View file @
2f067e1
...
...
@@ -10,8 +10,10 @@ import cn.dev33.satoken.router.SaRouter;
import
cn.dev33.satoken.stp.StpInterface
;
import
cn.dev33.satoken.stp.StpLogic
;
import
cn.dev33.satoken.stp.StpUtil
;
import
com.lego.common.constant.CacheNames
;
import
com.lego.common.utils.EncryptUtils
;
import
com.lego.common.utils.StringUtils
;
import
com.lego.common.utils.redis.CacheUtils
;
import
com.lego.common.utils.spring.SpringUtils
;
import
com.lego.framework.config.properties.SecurityProperties
;
import
com.lego.framework.handler.AllUrlHandler
;
...
...
@@ -39,7 +41,6 @@ import java.util.List;
public
class
SaTokenConfig
implements
WebMvcConfigurer
{
private
final
SecurityProperties
securityProperties
;
private
final
PlusSaTokenDao
plusSaTokenDao
;
/**
* 注册sa-token的拦截器
...
...
@@ -58,16 +59,23 @@ public class SaTokenConfig implements WebMvcConfigurer {
// 检查是否登录 是否有token
SaRequest
request
=
SaHolder
.
getRequest
();
String
version
=
request
.
getHeader
(
"version"
);
System
.
out
.
println
(
"versioncode:"
+
version
);
if
(
StringUtils
.
isNotBlank
(
version
))
{
String
token
=
StpUtil
.
getTokenValue
();
String
secret
=
plusSaTokenDao
.
get
(
version
);
String
token
=
request
.
getHeader
(
"token"
);
System
.
out
.
println
(
"token:"
+
token
);
SaTokenDao
plusSaTokenDao
=
saTokenDao
();
String
secret
=
CacheUtils
.
get
(
CacheNames
.
VERSION_CODE
,
version
);
System
.
out
.
println
(
"secret:"
+
secret
);
String
appSecret
=
EncryptUtils
.
decryptByAes
(
secret
);
System
.
out
.
println
(
"appSecret"
+
appSecret
);
String
explicitToken
=
EncryptUtils
.
decryptByAes
(
token
,
appSecret
);
System
.
out
.
println
(
"explicitToken"
+
explicitToken
);
List
<
String
>
list
=
Arrays
.
asList
(
explicitToken
.
split
(
"&"
));
if
(!
CollectionUtils
.
isEmpty
(
list
)){
long
time
=
System
.
currentTimeMillis
();
long
period
=
time
-
Long
.
valueOf
(
list
.
get
(
0
));
if
(
period
<
60
&&
period
>
0
){
System
.
out
.
println
(
"period:"
+
period
);
if
(
period
<
60000
&&
period
>
0
){
}
else
{
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment