Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
browser-backend
Project
Project
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
Administrator
browser-backend
Commits
657320f5
Commit
657320f5
authored
Sep 29, 2020
by
Administrator
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix-hotbugs' into 'master'
页面打开慢加日志 See merge request
!184
parents
39ba0089
aa68278b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
+14
-2
ShopServiceImpl.java
.../browserbackend/browser/service/Impl/ShopServiceImpl.java
+14
-2
No files found.
src/main/java/com/edgec/browserbackend/browser/service/Impl/ShopServiceImpl.java
View file @
657320f5
...
...
@@ -393,10 +393,13 @@ public class ShopServiceImpl implements ShopService {
@Override
public
ShopPageResultDto
getShopList
(
String
username
,
String
groupId
,
int
pageNum
,
int
amount
,
ShopFilterDto
shopFilterDto
,
String
tag
)
{
long
start
=
System
.
currentTimeMillis
();
// 1. 校验当前登录用户的账户是否存在
Account
account
=
accountRepository
.
findByName
(
username
).
orElseThrow
(()
->
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
));
logger
.
info
(
"getshoplist step-1:{}"
,
System
.
currentTimeMillis
()
-
start
);
// 2. 如有有分组校验当前查询的分组信息是否正确
start
=
System
.
currentTimeMillis
();
Group
group
=
null
;
if
(
groupId
!=
null
)
{
group
=
groupRepository
.
findById
(
groupId
).
orElseThrow
(()
->
new
ClientRequestException
(
BrowserErrorCode
.
GROUPNOTEXIST
));
...
...
@@ -404,10 +407,11 @@ public class ShopServiceImpl implements ShopService {
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
);
}
}
logger
.
info
(
"getshoplist step-2:{}"
,
System
.
currentTimeMillis
()
-
start
);
// 3. 根据 groupId 与 username 来查询 shopIds (如果当前用户是父账户,则查询结果包含子账户的shopId)
start
=
System
.
currentTimeMillis
();
List
<
String
>
allIds
=
null
;
if
(!
"penghai"
.
equals
(
tag
))
{
if
(
"-1"
.
equals
(
groupId
))
{
allIds
=
userShopRepository
.
findByUsername
(
username
).
stream
().
map
(
UserShop:
:
getShopId
).
collect
(
Collectors
.
toList
());
...
...
@@ -421,8 +425,10 @@ public class ShopServiceImpl implements ShopService {
if
(
"penghai"
.
equals
(
tag
))
{
allIds
=
userShopRepository
.
findByUsernameAndGroupId
(
username
,
groupId
).
stream
().
map
(
UserShop:
:
getShopId
).
collect
(
Collectors
.
toList
());
}
logger
.
info
(
"getshoplist step-3:{}"
,
System
.
currentTimeMillis
()
-
start
);
// 4. 根据传入的过滤条件得到 shopIds
start
=
System
.
currentTimeMillis
();
List
<
String
>
shopIds
=
null
;
if
(
shopFilterDto
.
getBindIp
()
==
0
)
{
shopIds
=
allIds
;
...
...
@@ -450,19 +456,24 @@ public class ShopServiceImpl implements ShopService {
allIds
.
removeAll
(
shopIds2
);
shopIds
=
allIds
;
}
logger
.
info
(
"getshoplist step-4:{}"
,
System
.
currentTimeMillis
()
-
start
);
amount
=
amount
>
100
?
100
:
amount
;
Pageable
pageable
=
PageRequest
.
of
(
pageNum
,
amount
);
// 5. 根据过滤后的商铺ids 与 其他过滤条件 得到商铺信息并分页
start
=
System
.
currentTimeMillis
();
Page
<
Shop
>
shops
=
getShopsByFilter
(
shopFilterDto
,
shopIds
,
pageable
);
logger
.
info
(
"getshoplist step-5:{}"
,
System
.
currentTimeMillis
()
-
start
);
// 6. 封装 shopResultDtos 信息并返回
start
=
System
.
currentTimeMillis
();
ShopPageResultDto
<
ShopResultDto
>
shopPageResultDto
=
new
ShopPageResultDto
<>();
if
(
shops
!=
null
&&
shops
.
getNumberOfElements
()
>=
1
)
{
List
<
ShopResultDto
>
shopResultDtos
=
new
ArrayList
<>();
shops
.
getContent
().
stream
().
forEach
(
// 设置ip资源状态 并 封装 shopResultDto信息
x
->
{
long
start1
=
System
.
currentTimeMillis
();
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdsIsAndIsDeleted
(
x
.
getShopId
(),
false
);
// 如果 ip资源非空 且 addr 也非空
if
(
ipResource
!=
null
&&
!
StringUtils
.
isEmpty
(
ipResource
.
getAddr
()))
{
...
...
@@ -513,6 +524,7 @@ public class ShopServiceImpl implements ShopService {
ShopResultDto
shopResultDto
=
getShopResultDto
(
username
,
x
,
ipResource
);
shopResultDtos
.
add
(
shopResultDto
);
logger
.
info
(
"getshoplist step-6.x:{}"
,
System
.
currentTimeMillis
()
-
start1
);
}
);
...
...
@@ -521,7 +533,7 @@ public class ShopServiceImpl implements ShopService {
PageInfo
pageInfo
=
new
PageInfo
(
shopDtoPage
.
getPageable
().
getPageNumber
(),
shopDtoPage
.
getTotalPages
(),
shopIds
.
size
());
shopPageResultDto
.
setShopPage
(
pageInfo
);
}
logger
.
info
(
"getshoplist step-6:{}"
,
System
.
currentTimeMillis
()
-
start
);
return
shopPageResultDto
;
}
...
...
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