Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
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
徐少华
midjourney-proxy
Commits
41f1d3a3
Commit
41f1d3a3
authored
Feb 23, 2022
by
guiq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug: [none] 接口性能优化bookAuthCode/checkServe
parent
00910cca
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
17 deletions
+23
-17
BookAuthCodeBizImpl.java
...m/pcloud/book/copyright/biz/impl/BookAuthCodeBizImpl.java
+15
-16
BookAuthInfoBizImpl.java
...m/pcloud/book/copyright/biz/impl/BookAuthInfoBizImpl.java
+1
-1
ThreadPoolUtils.java
...ain/java/com/pcloud/book/util/common/ThreadPoolUtils.java
+7
-0
No files found.
pcloud-service-book/src/main/java/com/pcloud/book/copyright/biz/impl/BookAuthCodeBizImpl.java
View file @
41f1d3a3
package
com
.
pcloud
.
book
.
copyright
.
biz
.
impl
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.collect.Lists
;
import
com.pcloud.book.base.enums.BookStatusEnum
;
...
...
@@ -52,8 +54,8 @@ import com.pcloud.common.utils.string.StringUtil;
import
com.pcloud.readercenter.wechat.entity.WechatUser
;
import
com.pcloud.resourcecenter.base.exceptions.ResBizException
;
import
com.pcloud.settlementcenter.record.exceptions.RecordException
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.MapUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.poi.ss.usermodel.CellStyle
;
import
org.apache.poi.ss.usermodel.HorizontalAlignment
;
...
...
@@ -75,20 +77,21 @@ import java.io.IOException;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.UUID
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.stream.Collectors
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
static
com
.
pcloud
.
book
.
util
.
common
.
ExcelUtils
.
getColumnTopStyle
;
import
static
com
.
pcloud
.
book
.
util
.
common
.
ExcelUtils
.
getDataStyle
;
import
static
com
.
pcloud
.
book
.
util
.
common
.
ThreadPoolUtils
.
REMOTE_CALL_POOL
;
/**
* @author lily
...
...
@@ -190,20 +193,16 @@ public class BookAuthCodeBizImpl implements BookAuthCodeBiz {
}
Long
bookId
=
authBookInfo
.
getBookId
();
Long
adviserId
=
authBookInfo
.
getAdviserId
();
List
<
Long
>
serveIds
=
new
ArrayList
<>();
serveIds
.
add
(
serveId
);
Map
<
String
,
Boolean
>
isHaveServe
=
qrcodeSceneConsr
.
listIsInBook
(
bookId
,
channelId
,
adviserId
,
serveIds
);
if
(
isHaveServe
==
null
)
{
return
false
;
}
//校验服务是否需要授权
Boolean
isNeedAuth
=
bookAuthServeBiz
.
checkIsNeedAuth
(
bookId
,
channelId
,
adviserId
,
serveId
,
serveType
);
if
(!
isNeedAuth
)
{
CompletableFuture
<
Boolean
>
haveServeFuture
=
CompletableFuture
.
supplyAsync
(()
->
MapUtils
.
isNotEmpty
(
qrcodeSceneConsr
.
listIsInBook
(
bookId
,
channelId
,
adviserId
,
Collections
.
singletonList
(
serveId
))),
REMOTE_CALL_POOL
);
CompletableFuture
<
Boolean
>
needAuthFuture
=
CompletableFuture
.
supplyAsync
(()
->
bookAuthServeBiz
.
checkIsNeedAuth
(
bookId
,
channelId
,
adviserId
,
serveId
,
serveType
),
REMOTE_CALL_POOL
);
CompletableFuture
<
Boolean
>
haveAuthFuture
=
CompletableFuture
.
supplyAsync
(()
->
!
bookAuthUserBiz
.
checkIsHaveAuth
(
bookId
,
channelId
,
adviserId
,
wechatUserId
,
null
,
null
,
null
),
REMOTE_CALL_POOL
);
try
{
CompletableFuture
.
allOf
(
haveServeFuture
,
needAuthFuture
,
haveAuthFuture
).
get
();
return
haveServeFuture
.
get
()
&&
needAuthFuture
.
get
()
&&
haveAuthFuture
.
get
();
}
catch
(
InterruptedException
|
ExecutionException
e
)
{
LOGGER
.
warn
(
"校验服务是否需要验证失败! [BookAuthCodeBizImpl.checkServe] ERR:{}"
,
e
.
getMessage
(),
e
);
return
false
;
}
//校验用户是否已经授权过
Boolean
isHaveAuth
=
bookAuthUserBiz
.
checkIsHaveAuth
(
bookId
,
channelId
,
adviserId
,
wechatUserId
,
null
,
null
,
null
);
return
!
isHaveAuth
;
}
@Override
...
...
pcloud-service-book/src/main/java/com/pcloud/book/copyright/biz/impl/BookAuthInfoBizImpl.java
View file @
41f1d3a3
...
...
@@ -596,7 +596,7 @@ public class BookAuthInfoBizImpl implements BookAuthInfoBiz {
}
if
(
null
!=
sceneId
){
//通过二维码获取图书信息
QrcodeSceneDto
qrcodeSceneDto
=
qrcodeSceneConsr
.
getById
(
sceneId
);
QrcodeSceneDto
qrcodeSceneDto
=
qrcodeSceneConsr
.
get
OnlySceneInfo
ById
(
sceneId
);
if
(
qrcodeSceneDto
==
null
){
throw
new
BookBizException
(
BookBizException
.
PARAM_IS_NULL
,
"图书不存在"
);
}
...
...
pcloud-service-book/src/main/java/com/pcloud/book/util/common/ThreadPoolUtils.java
View file @
41f1d3a3
...
...
@@ -102,6 +102,13 @@ public class ThreadPoolUtils {
*/
public
static
final
ThreadPoolExecutor
UPDATE_PRODUCT_CHANNEL
=
new
ThreadPoolExecutor
(
8
,
8
,
0
,
TimeUnit
.
SECONDS
,
new
LinkedBlockingQueue
<>(),
new
ThreadFactoryBuilder
().
setNameFormat
(
"update-product-channel-pool-%d"
).
build
(),
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
/**
* 远程调用线程池
*/
public
static
final
ThreadPoolExecutor
REMOTE_CALL_POOL
=
new
ThreadPoolExecutor
(
8
,
8
,
0
,
TimeUnit
.
SECONDS
,
new
LinkedBlockingQueue
<>(),
new
ThreadFactoryBuilder
().
setNameFormat
(
"remote-call-pool-%d"
).
build
(),
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
}
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