Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gxpt_ht
Overview
Overview
Details
Activity
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
pseer
gxpt_ht
Commits
fe1d8cb0
Commit
fe1d8cb0
authored
Feb 28, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加抖音权限过期错误自动获取权限
parent
377a72c3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
1 deletions
+34
-1
ErrorCodeEnum.java
...ommon/src/main/java/share/common/enums/ErrorCodeEnum.java
+4
-0
TiktokServiceImpl.java
...ain/java/share/system/service/impl/TiktokServiceImpl.java
+30
-1
No files found.
share-common/src/main/java/share/common/enums/ErrorCodeEnum.java
View file @
fe1d8cb0
...
@@ -9,6 +9,10 @@ public enum ErrorCodeEnum {
...
@@ -9,6 +9,10 @@ public enum ErrorCodeEnum {
PARAM_ERROR
(
"2100005"
,
"参数不合法"
),
PARAM_ERROR
(
"2100005"
,
"参数不合法"
),
//2100007 无权限操作
//2100007 无权限操作
NO_PERMISSION
(
"2100007"
,
"无权限操作"
),
NO_PERMISSION
(
"2100007"
,
"无权限操作"
),
//2190002 access_token无效
ACCESS_TOKEN_INVALID
(
"2190002"
,
"access_token无效"
),
//2190008 access_token过期,请刷新或重新授权
ACCESS_TOKEN_EXPIRE
(
"2190008"
,
"access_token过期,请刷新或重新授权"
),
;
;
private
String
code
;
private
String
code
;
...
...
share-system/src/main/java/share/system/service/impl/TiktokServiceImpl.java
View file @
fe1d8cb0
...
@@ -155,6 +155,10 @@ public class TiktokServiceImpl implements TiktokService {
...
@@ -155,6 +155,10 @@ public class TiktokServiceImpl implements TiktokService {
}
}
JSONObject
entries
=
new
JSONObject
(
result
);
JSONObject
entries
=
new
JSONObject
(
result
);
JSONObject
data
=
entries
.
getJSONObject
(
"data"
);
JSONObject
data
=
entries
.
getJSONObject
(
"data"
);
if
(
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
ACCESS_TOKEN_INVALID
.
getCode
())
|
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
ACCESS_TOKEN_EXPIRE
.
getCode
()))
{
clientToken
();
prepare
(
tiktokCouponDto
);
}
if
(!
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
()))
{
if
(!
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
()))
{
logger
.
error
(
"抖音验券准备失败:{}"
,
data
.
getStr
(
"description"
));
logger
.
error
(
"抖音验券准备失败:{}"
,
data
.
getStr
(
"description"
));
throw
new
RuntimeException
(
data
.
getStr
(
"description"
));
throw
new
RuntimeException
(
data
.
getStr
(
"description"
));
...
@@ -177,6 +181,10 @@ public class TiktokServiceImpl implements TiktokService {
...
@@ -177,6 +181,10 @@ public class TiktokServiceImpl implements TiktokService {
.
body
(
jsonObject
.
toString
()).
execute
().
body
();
.
body
(
jsonObject
.
toString
()).
execute
().
body
();
JSONObject
entries
=
new
JSONObject
(
result
);
JSONObject
entries
=
new
JSONObject
(
result
);
JSONObject
data
=
entries
.
getJSONObject
(
"data"
);
JSONObject
data
=
entries
.
getJSONObject
(
"data"
);
if
(
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
ACCESS_TOKEN_INVALID
.
getCode
())
|
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
ACCESS_TOKEN_EXPIRE
.
getCode
()))
{
clientToken
();
verify
(
tiktokCouponDto
);
}
JSONObject
extra
=
entries
.
getJSONObject
(
"extra"
);
JSONObject
extra
=
entries
.
getJSONObject
(
"extra"
);
if
(
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
())
&&
((
JSONObject
)
data
.
getJSONArray
(
"verify_results"
).
get
(
0
)).
getStr
(
"result"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
()))
{
if
(
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
())
&&
((
JSONObject
)
data
.
getJSONArray
(
"verify_results"
).
get
(
0
)).
getStr
(
"result"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
()))
{
return
data
;
return
data
;
...
@@ -202,6 +210,10 @@ public class TiktokServiceImpl implements TiktokService {
...
@@ -202,6 +210,10 @@ public class TiktokServiceImpl implements TiktokService {
.
body
(
jsonObject
.
toString
()).
execute
().
body
();
.
body
(
jsonObject
.
toString
()).
execute
().
body
();
JSONObject
entries
=
new
JSONObject
(
result
);
JSONObject
entries
=
new
JSONObject
(
result
);
JSONObject
data
=
entries
.
getJSONObject
(
"data"
);
JSONObject
data
=
entries
.
getJSONObject
(
"data"
);
if
(
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
ACCESS_TOKEN_INVALID
.
getCode
())
|
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
ACCESS_TOKEN_EXPIRE
.
getCode
()))
{
clientToken
();
cancel
(
tiktokCouponDto
);
}
if
(!
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
()))
{
if
(!
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
()))
{
logger
.
error
(
"抖音撤销核销失败:{}"
,
data
.
getStr
(
"description"
));
logger
.
error
(
"抖音撤销核销失败:{}"
,
data
.
getStr
(
"description"
));
throw
new
RuntimeException
(
data
.
getStr
(
"description"
));
throw
new
RuntimeException
(
data
.
getStr
(
"description"
));
...
@@ -225,6 +237,10 @@ public class TiktokServiceImpl implements TiktokService {
...
@@ -225,6 +237,10 @@ public class TiktokServiceImpl implements TiktokService {
.
form
(
"encrypted_code"
,
encode
).
execute
().
body
();
.
form
(
"encrypted_code"
,
encode
).
execute
().
body
();
JSONObject
entries
=
new
JSONObject
(
result
);
JSONObject
entries
=
new
JSONObject
(
result
);
JSONObject
data
=
entries
.
getJSONObject
(
"data"
);
JSONObject
data
=
entries
.
getJSONObject
(
"data"
);
if
(
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
ACCESS_TOKEN_INVALID
.
getCode
())
|
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
ACCESS_TOKEN_EXPIRE
.
getCode
()))
{
clientToken
();
certificateGet
(
encryptedCode
);
}
if
(!
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
()))
{
if
(!
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
()))
{
logger
.
error
(
"抖音获取核销信息失败:{}"
,
data
.
getStr
(
"description"
));
logger
.
error
(
"抖音获取核销信息失败:{}"
,
data
.
getStr
(
"description"
));
throw
new
BaseException
(
data
.
getStr
(
"description"
));
throw
new
BaseException
(
data
.
getStr
(
"description"
));
...
@@ -245,6 +261,10 @@ public class TiktokServiceImpl implements TiktokService {
...
@@ -245,6 +261,10 @@ public class TiktokServiceImpl implements TiktokService {
.
execute
().
body
();
.
execute
().
body
();
JSONObject
entries
=
new
JSONObject
(
result
);
JSONObject
entries
=
new
JSONObject
(
result
);
JSONObject
data
=
entries
.
getJSONObject
(
"data"
);
JSONObject
data
=
entries
.
getJSONObject
(
"data"
);
if
(
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
ACCESS_TOKEN_INVALID
.
getCode
())
|
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
ACCESS_TOKEN_EXPIRE
.
getCode
()))
{
clientToken
();
poiQuery
(
tiktokCouponDto
);
}
if
(!
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
()))
{
if
(!
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
()))
{
throw
new
RuntimeException
(
data
.
getStr
(
"description"
));
throw
new
RuntimeException
(
data
.
getStr
(
"description"
));
}
}
...
@@ -278,6 +298,10 @@ public class TiktokServiceImpl implements TiktokService {
...
@@ -278,6 +298,10 @@ public class TiktokServiceImpl implements TiktokService {
.
execute
().
body
();
.
execute
().
body
();
JSONObject
entries
=
new
JSONObject
(
result
);
JSONObject
entries
=
new
JSONObject
(
result
);
JSONObject
data
=
entries
.
getJSONObject
(
"data"
);
JSONObject
data
=
entries
.
getJSONObject
(
"data"
);
if
(
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
ACCESS_TOKEN_INVALID
.
getCode
())
|
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
ACCESS_TOKEN_EXPIRE
.
getCode
()))
{
clientToken
();
onlineQuery
(
onlineQueryDto
);
}
if
(!
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
()))
{
if
(!
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
SUCCESS
.
getCode
()))
{
throw
new
RuntimeException
(
data
.
getStr
(
"description"
));
throw
new
RuntimeException
(
data
.
getStr
(
"description"
));
}
}
...
@@ -294,7 +318,12 @@ public class TiktokServiceImpl implements TiktokService {
...
@@ -294,7 +318,12 @@ public class TiktokServiceImpl implements TiktokService {
.
form
(
"account_id"
,
accountId
)
.
form
(
"account_id"
,
accountId
)
.
execute
().
body
();
.
execute
().
body
();
JSONObject
entries
=
new
JSONObject
(
result
);
JSONObject
entries
=
new
JSONObject
(
result
);
return
entries
.
getJSONObject
(
"data"
);
JSONObject
data
=
entries
.
getJSONObject
(
"data"
);
if
(
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
ACCESS_TOKEN_INVALID
.
getCode
())
|
data
.
getStr
(
"error_code"
).
equals
(
ErrorCodeEnum
.
ACCESS_TOKEN_EXPIRE
.
getCode
()))
{
clientToken
();
onlineGet
(
productIds
,
accountId
);
}
return
data
;
}
}
@Override
@Override
...
...
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