Commit 51ec1c16 authored by 夏敏伟's avatar 夏敏伟

swagger

parent 4c0d9cf5
...@@ -34,10 +34,12 @@ public class SwaggerConfig { ...@@ -34,10 +34,12 @@ public class SwaggerConfig {
Parameter param2 = new ParameterBuilder().name(SignatureUtil.NONCE).description("nonce").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); Parameter param2 = new ParameterBuilder().name(SignatureUtil.NONCE).description("nonce").modelRef(new ModelRef("string")).parameterType("header").required(false).build();
Parameter param3 = new ParameterBuilder().name(SignatureUtil.TIMESTAMP).description("timestamp").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); Parameter param3 = new ParameterBuilder().name(SignatureUtil.TIMESTAMP).description("timestamp").modelRef(new ModelRef("string")).parameterType("header").required(false).build();
Parameter param4 = new ParameterBuilder().name(SignatureUtil.SIGNATURE).description("signature").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); Parameter param4 = new ParameterBuilder().name(SignatureUtil.SIGNATURE).description("signature").modelRef(new ModelRef("string")).parameterType("header").required(false).build();
Parameter param5 = new ParameterBuilder().name(SignatureUtil.DEPT_CODE).description("deptCode").modelRef(new ModelRef("string")).parameterType("header").required(false).build();
pars.add(param1); pars.add(param1);
pars.add(param2); pars.add(param2);
pars.add(param3); pars.add(param3);
pars.add(param4); pars.add(param4);
pars.add(param5);
ApiInfo apiInfo = new ApiInfoBuilder() ApiInfo apiInfo = new ApiInfoBuilder()
.title("模块服务接口文档") .title("模块服务接口文档")
.description("服务接口文档,遵循RESTful API设计规范") .description("服务接口文档,遵循RESTful API设计规范")
......
...@@ -15,14 +15,22 @@ public class TestAppStore { ...@@ -15,14 +15,22 @@ public class TestAppStore {
@Test @Test
@DisplayName("新增AppId") @DisplayName("新增AppId")
public void addAppId() { public void addAppId() {
for (int i = 0; i < 10000; i++) { // for (int i = 0; i < 10000; i++) {
// AppStoreDTO appStoreDTO = new AppStoreDTO();
// appStoreDTO.setAppKey("scale");
// appStoreDTO.setAppSecret(DigestUtil.md5Hex("scale"));
// appStoreDTO.setDeptCode("330102");
//
// TestHttpUtil.signatureAndRequest("/rest/appStore/insertAppStore", appStoreDTO, AppStoreDTO.class);
// }
AppStoreDTO appStoreDTO = new AppStoreDTO(); AppStoreDTO appStoreDTO = new AppStoreDTO();
appStoreDTO.setAppKey("scale"); appStoreDTO.setAppKey("scale");
appStoreDTO.setAppSecret(DigestUtil.md5Hex("scale")); appStoreDTO.setAppSecret(DigestUtil.md5Hex("scale"));
appStoreDTO.setDeptCode("330102"); appStoreDTO.setDeptCode("330103");
TestHttpUtil.signatureAndRequest("/rest/appStore/insertAppStore", appStoreDTO, AppStoreDTO.class); TestHttpUtil.signatureAndRequest("/rest/appStore/insertAppStore", appStoreDTO, AppStoreDTO.class);
}
// TestHttpUtil.signatureAndRequest("/rest/appStore/insertAppStore", appStoreDTO, AppStoreDTO.class); // TestHttpUtil.signatureAndRequest("/rest/appStore/insertAppStore", appStoreDTO, AppStoreDTO.class);
// TestHttpUtil.signatureAndRequest("/rest/appStore/insertAppStore", appStoreDTO); // TestHttpUtil.signatureAndRequest("/rest/appStore/insertAppStore", appStoreDTO);
......
...@@ -32,11 +32,15 @@ public class TestHttpUtil { ...@@ -32,11 +32,15 @@ public class TestHttpUtil {
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
Assertions.fail("json序列化失败"); Assertions.fail("json序列化失败");
} }
log.info("原始body:{}", json);
//请求体加密 //请求体加密
json = EncryptUtil.getInstance().AESEncode(json, appSecret); json = EncryptUtil.getInstance().AESEncode(json, appSecret);
log.info("加密后body:{}", json);
//签名appId+nonce+timestampStr+aes(body)+deptCode //签名appId+nonce+timestampStr+aes(body)+deptCode
String data = String.format("%s%s%s%s%S", appId, nonce, timestampStr, json, deptCode); String data = String.format("%s%s%s%s%S", appId, nonce, timestampStr, json, deptCode);
log.info("待签名:{}", data);
String generatedSignature = DigestUtil.md5Hex(data); String generatedSignature = DigestUtil.md5Hex(data);
log.info("已签名:{}", generatedSignature);
//请求 //请求
WebClient webClient = WebClient.builder() WebClient webClient = WebClient.builder()
.baseUrl("http://localhost:8086") .baseUrl("http://localhost:8086")
......
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