Commit fe52cacd authored by 以墨为白's avatar 以墨为白 🎧

优化

parent 45cbcaed
......@@ -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>
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
......@@ -3,7 +3,7 @@ server:
spring:
profiles:
active: dev
active: @profile.name@
main:
allow-bean-definition-overriding: true
mvc:
......
......@@ -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.219/guoqing1.jpg");
uploadImageDTO.setImagePath("http://192.168.168.211/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);
}
/**
......
......@@ -25,12 +25,12 @@ public class TestAppStore {
// }
AppStoreDTO appStoreDTO = new AppStoreDTO();
appStoreDTO.setAppKey("scale");
appStoreDTO.setAppSecret(DigestUtil.md5Hex("scale"));
appStoreDTO.setAppKey("wcyuee");
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);
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment