Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
ShenghuoquanBusiness
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
bp
ShenghuoquanBusiness
Commits
134ccd49
Commit
134ccd49
authored
Jul 30, 2021
by
shiyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
数据解析代码块进行异常捕获,防止线上问题
parent
f6f0c2b9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
17 deletions
+24
-17
RunConfig.kt
...on/src/main/java/com/yidian/bcommon/constant/RunConfig.kt
+3
-0
HttpParamsUtils.kt
.../src/main/java/com/yidian/bcommon/http/HttpParamsUtils.kt
+21
-17
No files found.
CommonLib/BCommon/src/main/java/com/yidian/bcommon/constant/RunConfig.kt
View file @
134ccd49
...
@@ -3,6 +3,9 @@ package com.yidian.bcommon.constant
...
@@ -3,6 +3,9 @@ package com.yidian.bcommon.constant
/**
/**
* 运行配置,提供切换运行环境的能力(变量配置)
* 运行配置,提供切换运行环境的能力(变量配置)
*
* ⚠️⚠️注意:对于使用包名注册的三方SDK,目前不支持使用RunConfig切换,需要使用Flavor进行区分
* 例如:高德地图
*/
*/
object
RunConfig
{
object
RunConfig
{
...
...
CommonLib/BCommon/src/main/java/com/yidian/bcommon/http/HttpParamsUtils.kt
View file @
134ccd49
...
@@ -54,25 +54,29 @@ class HttpParamsUtils {
...
@@ -54,25 +54,29 @@ class HttpParamsUtils {
decodeResult
.
reason
=
res
.
reason
decodeResult
.
reason
=
res
.
reason
decodeResult
.
status
=
res
.
status
decodeResult
.
status
=
res
.
status
if
(
rsaResult
!=
null
)
{
if
(
rsaResult
!=
null
)
{
if
(
RunConfig
.
IS_ENCRYPT
)
{
try
{
// 捕获数据解析异常, 防止T内部的字端解析失败
val
result
=
BCommonManager
.
getEncryptIml
().
rsaDecrypt
(
rsaResult
as
String
)
if
(
RunConfig
.
IS_ENCRYPT
)
{
Timber
.
tag
(
BCommonManager
.
TAG_HTTP
).
d
(
"response result: $result"
)
val
result
=
BCommonManager
.
getEncryptIml
().
rsaDecrypt
(
rsaResult
as
String
)
val
decryptResult
=
gson
.
fromJson
<
HttpDecryptResult
<
T
>>(
result
,
object
:
TypeToken
<
HttpDecryptResult
<
T
>>()
{}.
type
)
Timber
.
tag
(
BCommonManager
.
TAG_HTTP
).
d
(
"response result: $result"
)
val
verify
=
BCommonManager
.
getEncryptIml
().
verifySign
(
decryptResult
.
reqid
+
decryptResult
.
ts
,
decryptResult
.
secret
)
val
decryptResult
=
gson
.
fromJson
<
HttpDecryptResult
<
T
>>(
result
,
object
:
TypeToken
<
HttpDecryptResult
<
T
>>()
{}.
type
)
return
if
(
verify
)
{
val
verify
=
BCommonManager
.
getEncryptIml
().
verifySign
(
decryptResult
.
reqid
+
decryptResult
.
ts
,
decryptResult
.
secret
)
Timber
.
tag
(
BCommonManager
.
TAG_HTTP
).
d
(
"verify success"
)
return
if
(
verify
)
{
val
resultJson
=
gson
.
toJson
(
decryptResult
.
data
)
Timber
.
tag
(
BCommonManager
.
TAG_HTTP
).
d
(
"verify success"
)
decodeResult
.
result
=
gson
.
fromJson
<
T
>(
resultJson
,
type
)
val
resultJson
=
gson
.
toJson
(
decryptResult
.
data
)
decodeResult
decodeResult
.
result
=
gson
.
fromJson
<
T
>(
resultJson
,
type
)
decodeResult
}
else
{
Timber
.
tag
(
BCommonManager
.
TAG_HTTP
).
d
(
"verify failure"
)
decodeResult
}
}
else
{
}
else
{
Timber
.
tag
(
BCommonManager
.
TAG_HTTP
).
d
(
"verify failure"
)
val
resultJson
=
gson
.
toJson
(
rsaResult
)
decodeResult
Timber
.
tag
(
BCommonManager
.
TAG_HTTP
).
d
(
"response result: $resultJson"
)
decodeResult
.
result
=
gson
.
fromJson
<
T
>(
resultJson
,
type
)
return
decodeResult
}
}
}
else
{
}
catch
(
e
:
Exception
)
{
val
resultJson
=
gson
.
toJson
(
rsaResult
)
e
.
printStackTrace
()
Timber
.
tag
(
BCommonManager
.
TAG_HTTP
).
d
(
"response result: $resultJson"
)
decodeResult
.
result
=
gson
.
fromJson
<
T
>(
resultJson
,
type
)
return
decodeResult
}
}
}
}
return
decodeResult
return
decodeResult
...
...
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