Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
smart_gov_platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
smart_gov_platform
Commits
b90a4ee9
Commit
b90a4ee9
authored
Jul 10, 2024
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加门户license验证接口
parent
241121f8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
22 deletions
+41
-22
portal-manager/src/main/java/com/mortals/xhx/base/system/upload/service/impl/UploadServiceImpl.java
...hx/base/system/upload/service/impl/UploadServiceImpl.java
+1
-1
portal-manager/src/main/java/com/mortals/xhx/module/cipher/web/CipherController.java
...a/com/mortals/xhx/module/cipher/web/CipherController.java
+39
-18
portal-manager/src/main/resources/bootstrap.yml
portal-manager/src/main/resources/bootstrap.yml
+1
-3
No files found.
portal-manager/src/main/java/com/mortals/xhx/base/system/upload/service/impl/UploadServiceImpl.java
View file @
b90a4ee9
...
...
@@ -55,7 +55,7 @@ public class UploadServiceImpl implements UploadService {
log
.
error
(
"文件上传大小超过限制,当前文件---"
+
tempFile
.
getSize
()
+
",允许大小----------"
+
type
.
getMaxSize
());
throw
new
AppException
(
"文件上传大小超过限制!"
);
}
if
(
null
!=
fileName
&&
fileName
.
length
()
>
5
0
)
{
if
(
null
!=
fileName
&&
fileName
.
length
()
>
10
0
)
{
throw
new
AppException
(
"文件名称过长,无法上传!"
);
}
...
...
portal-manager/src/main/java/com/mortals/xhx/module/cipher/web/CipherController.java
View file @
b90a4ee9
...
...
@@ -2,23 +2,36 @@ package com.mortals.xhx.module.cipher.web;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.io.FileUtil
;
import
cn.hutool.core.util.ZipUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.mortals.framework.annotation.UnAuth
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.xhx.base.system.upload.service.UploadService
;
import
com.mortals.xhx.common.utils.CipherUtil
;
import
com.mortals.xhx.common.utils.DecodeUtil
;
import
com.mortals.xhx.common.utils.LicenseUtil
;
import
com.mortals.xhx.utils.EncodeUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.nio.charset.Charset
;
import
java.util.HashMap
;
import
java.util.Map
;
import
static
com
.
mortals
.
framework
.
web
.
BaseController
.
VALUE_RESULT_SUCCESS
;
import
static
com
.
mortals
.
xhx
.
base
.
framework
.
exception
.
ExceptionHandle
.*;
/**
* 授权文件上传与检测
*
* @author: zxfei
* @date: 2024/7/10 9:54
*/
...
...
@@ -36,6 +49,13 @@ public class CipherController {
@Value
(
"${sys.license.pub}"
)
private
String
pubPath
;
@Value
(
"${sys.license.enable:false}"
)
private
Boolean
licenseEnable
;
@Autowired
private
UploadService
uploadService
;
/**
* 用户在点击,查看`授权信息`按钮时,请求check接口,进行一次授权验证(每天第一次通过其他接口访问系统时,也会验证一次 )
* 如果通过则返回授权信息(开始+结束时间)
...
...
@@ -47,6 +67,8 @@ public class CipherController {
@UnAuth
public
Rest
<
Map
<
String
,
String
>>
check
()
{
// 验证是否通过了授权,通过了返回授权信息(开始+结束时间)
if
(!
licenseEnable
)
return
Rest
.
ok
();
try
{
Map
<
String
,
String
>
map
=
LicenseUtil
.
loadLicense
(
logPath
,
keyPath
,
pubPath
);
Map
<
String
,
String
>
resultMap
=
new
HashMap
<>(
4
);
...
...
@@ -58,47 +80,46 @@ public class CipherController {
resultMap
.
put
(
"endTime"
,
DateUtil
.
date
(
endTime
).
toDateStr
());
}
String
applicationInfo
=
CipherUtil
.
getApplicationInfo
();
String
encryptAes
=
DecodeUtil
.
encryptBySymmetry
(
applicationInfo
,
DecodeUtil
.
AES_KEY
,
DecodeUtil
.
AES
,
true
);
log
.
info
(
"授权码:"
+
encryptAes
);
return
Rest
.
ok
(
resultMap
);
}
catch
(
Exception
e
)
{
log
.
error
(
"检测授权异常"
,
e
);
return
Rest
.
fail
(
e
.
getMessage
());
}
}
@RequestMapping
(
value
=
"upload"
)
@UnAuth
public
String
doFileUpload
(
MultipartFile
file
)
{
/*
Map<String, Object> model = new HashMap<>();
public
String
doFileUpload
(
MultipartFile
file
,
@RequestParam
(
value
=
"prePath"
,
defaultValue
=
"/file/license"
)
String
prePath
)
{
Map
<
String
,
Object
>
model
=
new
HashMap
<>();
String
jsonStr
=
""
;
try
{
// String filePath = uploadService.saveFileUpload(file, prePath, getCurUser());
model.put("url", filePath);
String
targetFilePath
=
uploadService
.
saveFileUpload
(
file
,
prePath
,
null
);
String
suffix
=
FileUtil
.
getSuffix
(
file
.
getOriginalFilename
());
if
(
"zip"
.
equalsIgnoreCase
(
suffix
))
{
throw
new
AppException
(
"文件格式不正确,请上传zip格式的文件!"
);
}
//解压到指定license目录
String
fileEncode
=
EncodeUtil
.
getEncode
(
targetFilePath
,
true
);
ZipUtil
.
unzip
(
targetFilePath
,
logPath
,
Charset
.
forName
(
fileEncode
));
model
.
put
(
"url"
,
targetFilePath
);
model
.
put
(
"fileName"
,
file
.
getOriginalFilename
());
model
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_SUCCESS
);
jsonStr
=
JSONObject
.
toJSONString
(
model
);
}
catch
(
AppException
e
)
{
log.error("
上传异常",
e);
log
.
error
(
"
异常"
,
e
);
model
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_FAILURE
);
model.put(
KEY_RESULT_MSG
, e.getMessage());
model
.
put
(
"msg"
,
e
.
getMessage
());
jsonStr
=
JSONObject
.
toJSONString
(
model
);
}
catch
(
Exception
e
)
{
// doException(request, "上传文件", new HashMap<>(3), e);
// model.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
// model.put(KEY_RESULT_MSG, "文件上传失败");
model
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_FAILURE
);
model
.
put
(
KEY_RESULT_MSG
,
e
.
getMessage
());
jsonStr
=
JSONObject
.
toJSONString
(
model
);
}
log.info("uploadResp==>{}",jsonStr);
return jsonStr;*/
return
""
;
log
.
info
(
"licenseUploadResp==>{}"
,
jsonStr
);
return
jsonStr
;
}
}
portal-manager/src/main/resources/bootstrap.yml
View file @
b90a4ee9
...
...
@@ -47,6 +47,4 @@ sys:
key
:
/home/license/license.key
pub
:
/home/license/license.pub
log
:
/home/license
license
:
enable
:
false
enable
:
false
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment