Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
windows
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
zhanhai
windows
Commits
92097ab0
Commit
92097ab0
authored
Oct 24, 2023
by
张庆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
请求参数
parent
78e7a029
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
133 additions
and
11 deletions
+133
-11
ZyJsonResult.java
...n/java/com/jqtx/windows/component/model/ZyJsonResult.java
+114
-0
AbcHttpClient.java
src/main/java/com/jqtx/windows/utils/AbcHttpClient.java
+19
-11
No files found.
src/main/java/com/jqtx/windows/component/model/ZyJsonResult.java
0 → 100644
View file @
92097ab0
package
com
.
jqtx
.
windows
.
component
.
model
;
import
com.jqtx.windows.common.exception.BizException
;
import
com.jqtx.windows.infrastructure.enums.ExceptionCodeEnum
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.ToString
;
import
java.io.Serializable
;
@ApiModel
(
value
=
"ZyJsonResult"
,
description
=
"通用返回结果模型"
)
@ToString
public
class
ZyJsonResult
<
T
>
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1475348231900998033L
;
@ApiModelProperty
(
"状态码"
)
private
String
code
;
@ApiModelProperty
(
"请求成功与否,true:成功,false:失败"
)
private
Boolean
success
;
@ApiModelProperty
(
"提示信息"
)
private
String
message
;
@ApiModelProperty
(
"返回业务数据"
)
private
T
result
;
public
ZyJsonResult
()
{
}
public
ZyJsonResult
(
boolean
isSuccess
,
String
code
,
String
message
)
{
this
.
success
=
isSuccess
;
this
.
code
=
code
;
this
.
message
=
message
;
}
public
static
JsonResult
success
()
{
return
new
JsonResult
(
true
,
"200"
,
"操作成功!"
);
}
public
static
JsonResult
success
(
Object
data
)
{
JsonResult
result
=
new
JsonResult
(
true
,
"200"
,
"操作成功!"
);
result
.
setResult
(
data
);
return
result
;
}
public
static
JsonResult
error
(
String
message
)
{
JsonResult
result
=
new
JsonResult
(
false
,
"500"
,
message
);
return
result
;
}
public
static
JsonResult
error
(
ExceptionCodeEnum
message
)
{
JsonResult
result
=
new
JsonResult
(
false
,
message
.
getCode
(),
message
.
getMessageCN
());
return
result
;
}
public
static
JsonResult
error
(
ExceptionCodeEnum
message
,
String
msg
)
{
JsonResult
result
=
new
JsonResult
(
false
,
message
.
getCode
(),
msg
);
return
result
;
}
public
static
JsonResult
error
(
String
message
,
String
code
)
{
JsonResult
result
=
new
JsonResult
(
false
,
code
,
message
);
result
.
setCode
(
code
);
return
result
;
}
public
void
apiCheck
()
{
if
(!
this
.
isSuccess
())
{
throw
new
BizException
(
ExceptionCodeEnum
.
SYSTEM_REMOTE_ERROR
,
message
);
}
}
public
void
resultCheck
()
{
if
(!
this
.
isSuccess
())
{
throw
new
BizException
(
ExceptionCodeEnum
.
SYSTEM_REMOTE_ERROR
,
message
);
}
if
(
this
.
getResult
()
==
null
)
{
throw
new
BizException
(
ExceptionCodeEnum
.
SYSTEM_REMOTE_ERROR
,
message
);
}
}
public
String
getCode
()
{
return
this
.
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
boolean
isSuccess
()
{
return
this
.
success
;
}
public
void
setSuccess
(
boolean
success
)
{
this
.
success
=
success
;
}
public
String
getMessage
()
{
return
this
.
message
;
}
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
public
T
getResult
()
{
return
this
.
result
;
}
public
void
setResult
(
T
result
)
{
this
.
result
=
result
;
}
}
src/main/java/com/jqtx/windows/utils/AbcHttpClient.java
View file @
92097ab0
...
...
@@ -10,6 +10,7 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONObject
;
import
com.jqtx.windows.component.model.ZyHttpBaseResponse
;
import
com.jqtx.windows.component.model.ZyHttpBaseRquest
;
import
com.jqtx.windows.component.model.ZyJsonResult
;
import
com.jqtx.windows.web.request.AbcRequest
;
import
com.jqtx.windows.web.response.JsonResult
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -39,7 +40,7 @@ public class AbcHttpClient {
private
String
clientId
;
public
Zy
HttpBaseResponse
postRequest
(
String
paramJson
,
String
method
)
{
public
Zy
JsonResult
postRequest
(
String
paramJson
,
String
method
)
{
try
{
final
String
url
=
posetUrl
;
ZyHttpBaseRquest
zyHttpBaseRquest
=
new
ZyHttpBaseRquest
();
...
...
@@ -60,16 +61,23 @@ public class AbcHttpClient {
.
setConnectionTimeout
(
5000
).
execute
();
log
.
info
(
"请求浙农加密返回数据:{}"
,
JSON
.
toJSONString
(
response
.
body
()));
String
body
=
response
.
body
();
JSONObject
responseJson
=
JSONObject
.
parseObject
(
body
);
String
data
=
responseJson
.
getString
(
"data"
);
String
sign
=
responseJson
.
getString
(
"sign"
);
boolean
f
=
SignUtil
.
veriSign
(
data
,
sign
,
AbcRsaUtil
.
getPublicKey
(
ypdPublicKey
));
if
(
f
)
{
String
dec
=
EncryptUtil
.
decrypt
(
data
,
AbcRsaUtil
.
getPrivateKey
(
privateKey
));
log
.
info
(
"请求浙农解密返回数据:{}"
,
JSON
.
toJSONString
(
dec
));
return
JSONObject
.
parseObject
(
dec
,
ZyHttpBaseResponse
.
class
);
ZyHttpBaseResponse
zyHttpBaseResponse
=
JSONObject
.
parseObject
(
body
,
ZyHttpBaseResponse
.
class
);
//成功
if
(
zyHttpBaseResponse
.
getReturnCode
().
equals
(
"0000"
))
{
JSONObject
responseJson
=
JSONObject
.
parseObject
(
body
);
String
data
=
zyHttpBaseResponse
.
getData
();
String
sign
=
zyHttpBaseResponse
.
getSign
();
boolean
f
=
SignUtil
.
veriSign
(
data
,
sign
,
AbcRsaUtil
.
getPublicKey
(
ypdPublicKey
));
if
(
f
)
{
String
dec
=
EncryptUtil
.
decrypt
(
data
,
AbcRsaUtil
.
getPrivateKey
(
privateKey
));
log
.
info
(
"请求浙农解密返回数据:{}"
,
JSON
.
toJSONString
(
dec
));
return
JSONObject
.
parseObject
(
dec
,
ZyJsonResult
.
class
);
}
else
{
log
.
info
(
"验签异常"
);
}
}
else
{
log
.
info
(
"验签异常"
);
log
.
error
(
"请求浙农异常"
);
return
null
;
}
}
catch
(
Exception
e
)
{
...
...
@@ -94,7 +102,7 @@ public class AbcHttpClient {
/*验签*/
boolean
f
=
SignUtil
.
veriSign
(
data
,
sign
,
AbcRsaUtil
.
getPublicKey
(
ypdPublicKey
));
if
(
f
)
{
data
=
"LbfVKZfHTWm0S6h81XLAgv8zRmUwljGCznpVln1be2oiuXH1vw00sPW2uA5iOJND0d+5KtCzT8O3xD4avg4qEHvwlUWDZ7nFCqs5y5X470MCSwyxrH1UbBGLNlrfiq8yWmz5eKcxlyjyhLy46IuVqpJlxZ8hP3yU2gObcACuT8YmiVgzPvzefomyF+YalaFf9l7kObTvmfayVfugC1vCvYDyIWlNs9BUeHpPboo8KUUMi7E7e/jIpunCSSd7fF7Sh3rziwa+170cZfE5wrkJ/m4cvHzK86kCzDrIOABbhuvTFIpaUs8SFNujV2E6YP6jxYJ2FR8IlgMS/W/B4fX7dQ=="
;
//
data = "LbfVKZfHTWm0S6h81XLAgv8zRmUwljGCznpVln1be2oiuXH1vw00sPW2uA5iOJND0d+5KtCzT8O3xD4avg4qEHvwlUWDZ7nFCqs5y5X470MCSwyxrH1UbBGLNlrfiq8yWmz5eKcxlyjyhLy46IuVqpJlxZ8hP3yU2gObcACuT8YmiVgzPvzefomyF+YalaFf9l7kObTvmfayVfugC1vCvYDyIWlNs9BUeHpPboo8KUUMi7E7e/jIpunCSSd7fF7Sh3rziwa+170cZfE5wrkJ/m4cvHzK86kCzDrIOABbhuvTFIpaUs8SFNujV2E6YP6jxYJ2FR8IlgMS/W/B4fX7dQ==";
String
dec
=
EncryptUtil
.
decrypt
(
data
,
AbcRsaUtil
.
getPrivateKey
(
privateKey
));
System
.
out
.
println
(
"解密后返回数据:"
+
dec
);
}
else
{
...
...
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