Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
szpt
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
以墨为白
szpt
Commits
fe52cacd
Commit
fe52cacd
authored
Jan 16, 2025
by
以墨为白
🎧
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
45cbcaed
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
40 deletions
+43
-40
pom.xml
pom.xml
+30
-0
src/main/resources/application-prod.yml
src/main/resources/application-prod.yml
+3
-3
src/main/resources/application.yml
src/main/resources/application.yml
+1
-1
src/test/java/com/zksy/szpt/MainTest.java
src/test/java/com/zksy/szpt/MainTest.java
+2
-32
src/test/java/com/zksy/szpt/TestAppStore.java
src/test/java/com/zksy/szpt/TestAppStore.java
+3
-3
src/test/java/com/zksy/szpt/TestHttpUtil.java
src/test/java/com/zksy/szpt/TestHttpUtil.java
+4
-1
No files found.
pom.xml
View file @
fe52cacd
...
...
@@ -185,8 +185,38 @@
</resource>
<resource>
<directory>
src/main/resources
</directory>
<!-- 解决 found character '@' that cannot start any token-->
<filtering>
true
</filtering>
</resource>
</resources>
</build>
<profiles>
<!-- 开发 -->
<profile>
<id>
dev
</id>
<activation>
<!--默认激活配置-->
<activeByDefault>
true
</activeByDefault>
</activation>
<properties>
<!--当前环境-->
<config.group>
szpt
</config.group>
<profile.name>
dev
</profile.name>
<config.server-addr>
192.168.168.212
</config.server-addr>
</properties>
</profile>
<!-- 生产 -->
<profile>
<id>
prod
</id>
<properties>
<config.group>
szpt
</config.group>
<!--当前环境-->
<profile.name>
prod
</profile.name>
<!--Nacos服务地址-->
<config.server-addr>
localhost
</config.server-addr>
</properties>
</profile>
</profiles>
</project>
src/main/resources/application-prod.yml
View file @
fe52cacd
spring
:
datasource
:
url
:
jdbc:mysql://
192.168.168.110
:3306/szpt_shgz?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&failOverReadOnly=false&serverTimezone=GMT%2B8
url
:
jdbc:mysql://
localhost
:3306/szpt_shgz?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&failOverReadOnly=false&serverTimezone=GMT%2B8
username
:
root
password
:
Qmrz@2024
driver-class-name
:
com.mysql.cj.jdbc.Driver
...
...
@@ -8,6 +8,6 @@ spring:
redis
:
database
:
0
port
:
6379
password
:
1qaz2wsx
password
:
sjjs@2025
timeout
:
1000
host
:
192.168.168.110
\ No newline at end of file
host
:
localhost
\ No newline at end of file
src/main/resources/application.yml
View file @
fe52cacd
...
...
@@ -3,7 +3,7 @@ server:
spring
:
profiles
:
active
:
dev
active
:
@
profile.name@
main
:
allow-bean-definition-overriding
:
true
mvc
:
...
...
src/test/java/com/zksy/szpt/MainTest.java
View file @
fe52cacd
...
...
@@ -92,41 +92,11 @@ public class MainTest {
@Test
@DisplayName
(
"文件上传"
)
public
void
uploadFileTest
()
{
nonce
=
UUID
.
randomUUID
().
toString
();
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
String
secretKey
=
this
.
appStoreService
.
getAppSecretByAppKey
(
appId
);
Assertions
.
assertNotNull
(
secretKey
,
"appId不存在"
);
//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
//请求参数
UploadImageDTO
uploadImageDTO
=
new
UploadImageDTO
();
uploadImageDTO
.
setImagePath
(
"http://192.168.168.21
9/guoqing1
.jpg"
);
uploadImageDTO
.
setImagePath
(
"http://192.168.168.21
1/guoqing
.jpg"
);
uploadImageDTO
.
setImageType
(
ListImageType
.
FACE
);
String
json
=
null
;
try
{
json
=
objectMapper
.
writeValueAsString
(
uploadImageDTO
);
}
catch
(
JsonProcessingException
e
)
{
Assertions
.
fail
(
"json序列化失败"
);
}
//请求体加密
json
=
EncryptUtil
.
getInstance
().
AESEncode
(
json
,
secretKey
);
//签名appId+nonce+timestampStr+aes(body)
String
data
=
String
.
format
(
"%s%s%s%s"
,
appId
,
nonce
,
timestampStr
,
json
);
String
generatedSignature
=
DigestUtil
.
md5Hex
(
data
);
//请求
WebClient
webClient
=
WebClient
.
builder
()
.
baseUrl
(
"http://localhost:8086"
)
.
defaultHeader
(
"Content-Type"
,
"application/json"
)
.
build
();
String
response
=
webClient
.
post
().
uri
(
"/rest/image/upload"
)
.
header
(
SignatureUtil
.
APPID
,
appId
)
.
header
(
SignatureUtil
.
NONCE
,
nonce
)
.
header
(
SignatureUtil
.
TIMESTAMP
,
timestampStr
)
.
header
(
SignatureUtil
.
SIGNATURE
,
generatedSignature
)
.
body
(
Mono
.
just
(
uploadImageDTO
),
XxRwwcqkDTO
.
class
)
.
retrieve
()
.
bodyToMono
(
String
.
class
)
.
block
();
System
.
out
.
println
(
response
);
TestHttpUtil
.
signatureAndRequest
(
"/rest/image/upload"
,
uploadImageDTO
,
UploadImageDTO
.
class
);
}
/**
...
...
src/test/java/com/zksy/szpt/TestAppStore.java
View file @
fe52cacd
...
...
@@ -25,12 +25,12 @@ public class TestAppStore {
// }
AppStoreDTO
appStoreDTO
=
new
AppStoreDTO
();
appStoreDTO
.
setAppKey
(
"
scal
e"
);
appStoreDTO
.
setAppSecret
(
DigestUtil
.
md5Hex
(
"
scale
"
));
appStoreDTO
.
setAppKey
(
"
wcyue
e"
);
appStoreDTO
.
setAppSecret
(
DigestUtil
.
md5Hex
(
"
1qaz2wsx
"
));
appStoreDTO
.
setDeptCode
(
"330103"
);
TestHttpUtil
.
signatureAndRequest
(
"/rest/appStore/insertAppStore"
,
appStoreDTO
,
AppStoreDTO
.
class
);
TestHttpUtil
.
signatureAndRequest
(
"/
szptsjjs/
rest/appStore/insertAppStore"
,
appStoreDTO
,
AppStoreDTO
.
class
);
// TestHttpUtil.signatureAndRequest("/rest/appStore/insertAppStore", appStoreDTO, AppStoreDTO.class);
// TestHttpUtil.signatureAndRequest("/rest/appStore/insertAppStore", appStoreDTO);
...
...
src/test/java/com/zksy/szpt/TestHttpUtil.java
View file @
fe52cacd
...
...
@@ -12,6 +12,9 @@ import reactor.core.publisher.Mono;
public
class
TestHttpUtil
{
private
static
final
org
.
slf4j
.
Logger
log
=
org
.
slf4j
.
LoggerFactory
.
getLogger
(
TestHttpUtil
.
class
);
// final static String baseUrl = "https://demo.qmrzhz.cn:18030";
final
static
String
baseUrl
=
"http://localhost:8086"
;
static
String
nonce
=
"2"
;
static
String
timestampStr
=
"21"
;
static
String
appId
=
"1872576325743943682"
;
...
...
@@ -43,7 +46,7 @@ public class TestHttpUtil {
log
.
info
(
"已签名:{}"
,
generatedSignature
);
//请求
WebClient
webClient
=
WebClient
.
builder
()
.
baseUrl
(
"http://localhost:8086"
)
.
baseUrl
(
baseUrl
)
.
defaultHeader
(
"Content-Type"
,
"application/json"
)
.
build
();
String
response
=
webClient
.
post
().
uri
(
path
)
...
...
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