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
1ee52a4d
Commit
1ee52a4d
authored
Jun 29, 2020
by
jim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
log
parent
b89daafd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
15 deletions
+14
-15
ShopServiceImpl.java
.../browserbackend/browser/service/Impl/ShopServiceImpl.java
+14
-15
No files found.
src/main/java/com/edgec/browserbackend/browser/service/Impl/ShopServiceImpl.java
View file @
1ee52a4d
...
@@ -69,12 +69,12 @@ public class ShopServiceImpl implements ShopService {
...
@@ -69,12 +69,12 @@ public class ShopServiceImpl implements ShopService {
}
}
if
(
shopResultDto
.
getGroup
()
!=
null
)
{
if
(
shopResultDto
.
getGroup
()
!=
null
)
{
Group
group
=
groupRepository
.
findById
(
shopResultDto
.
getGroup
())
Group
group
=
groupRepository
.
findById
(
shopResultDto
.
getGroup
())
.
orElseThrow
(()
->
new
ClientRequestException
(
BrowserErrorCode
.
GROUPNOTEXIST
));
.
orElseThrow
(()
->
new
ClientRequestException
(
BrowserErrorCode
.
GROUPNOTEXIST
));
}
}
// 2. 对当前用户的 account 信息进行校验
// 2. 对当前用户的 account 信息进行校验
Account
account
=
accountRepository
.
findByName
(
username
)
Account
account
=
accountRepository
.
findByName
(
username
)
.
orElseThrow
(()
->
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
));
.
orElseThrow
(()
->
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
));
if
(
account
.
getPermission
()
<
4
)
{
if
(
account
.
getPermission
()
<
4
)
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
);
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
);
}
}
...
@@ -102,7 +102,7 @@ public class ShopServiceImpl implements ShopService {
...
@@ -102,7 +102,7 @@ public class ShopServiceImpl implements ShopService {
userShopRepository
.
save
(
userShop1
);
userShopRepository
.
save
(
userShop1
);
Account
parentAccount
=
accountRepository
.
findByName
(
account
.
getParent
())
Account
parentAccount
=
accountRepository
.
findByName
(
account
.
getParent
())
.
orElseThrow
(()
->
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
));
.
orElseThrow
(()
->
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
));
account
.
setShopCount
(
parentAccount
.
getShopCount
()
+
1
);
account
.
setShopCount
(
parentAccount
.
getShopCount
()
+
1
);
accountRepository
.
save
(
parentAccount
);
accountRepository
.
save
(
parentAccount
);
}
}
...
@@ -161,7 +161,7 @@ public class ShopServiceImpl implements ShopService {
...
@@ -161,7 +161,7 @@ public class ShopServiceImpl implements ShopService {
userShopRepository
.
save
(
userShop1
);
userShopRepository
.
save
(
userShop1
);
Account
parentAccount
=
accountRepository
.
findByName
(
account
.
getParent
())
Account
parentAccount
=
accountRepository
.
findByName
(
account
.
getParent
())
.
orElseThrow
(()
->
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
));
.
orElseThrow
(()
->
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
));
account
.
setShopCount
(
parentAccount
.
getShopCount
()
+
1
);
account
.
setShopCount
(
parentAccount
.
getShopCount
()
+
1
);
accountRepository
.
save
(
parentAccount
);
accountRepository
.
save
(
parentAccount
);
}
}
...
@@ -372,14 +372,14 @@ public class ShopServiceImpl implements ShopService {
...
@@ -372,14 +372,14 @@ public class ShopServiceImpl implements ShopService {
List
<
String
>
allIds
=
null
;
List
<
String
>
allIds
=
null
;
if
(
"-1"
.
equals
(
groupId
))
{
if
(
"-1"
.
equals
(
groupId
))
{
allIds
=
userShopRepository
.
findByUsername
(
username
).
stream
()
allIds
=
userShopRepository
.
findByUsername
(
username
).
stream
()
.
map
(
UserShop:
:
getShopId
).
collect
(
Collectors
.
toList
());
.
map
(
UserShop:
:
getShopId
).
collect
(
Collectors
.
toList
());
// 如果分组
// 如果分组
}
else
{
}
else
{
allIds
=
userShopRepository
.
findByUsernameAndGroupId
(
username
,
groupId
).
stream
()
allIds
=
userShopRepository
.
findByUsernameAndGroupId
(
username
,
groupId
).
stream
()
.
map
(
UserShop:
:
getShopId
).
collect
(
Collectors
.
toList
());
.
map
(
UserShop:
:
getShopId
).
collect
(
Collectors
.
toList
());
}
}
List
<
String
>
shopIds
=
n
ull
;
List
<
String
>
shopIds
=
n
ew
ArrayList
<>()
;
if
(
shopFilterDto
.
getBindIp
()
==
0
)
{
if
(
shopFilterDto
.
getBindIp
()
==
0
)
{
shopIds
=
allIds
;
shopIds
=
allIds
;
...
@@ -387,7 +387,7 @@ public class ShopServiceImpl implements ShopService {
...
@@ -387,7 +387,7 @@ public class ShopServiceImpl implements ShopService {
}
else
if
(
shopFilterDto
.
getBindIp
()
==
1
)
{
}
else
if
(
shopFilterDto
.
getBindIp
()
==
1
)
{
// ip资源已经分配了 的店铺
// ip资源已经分配了 的店铺
shopIds
=
ipResourceRepository
.
findShopIdInList
(
allIds
,
false
).
stream
()
shopIds
=
ipResourceRepository
.
findShopIdInList
(
allIds
,
false
).
stream
()
.
flatMap
((
x
->
x
.
getShopIds
().
stream
())).
collect
(
Collectors
.
toList
());
.
flatMap
((
x
->
x
.
getShopIds
().
stream
())).
collect
(
Collectors
.
toList
());
// 这个地方的其他情况是指什么情况
// 这个地方的其他情况是指什么情况
}
else
{
}
else
{
...
@@ -400,7 +400,7 @@ public class ShopServiceImpl implements ShopService {
...
@@ -400,7 +400,7 @@ public class ShopServiceImpl implements ShopService {
}
}
}
}
amount
=
amount
>
100
?
100
:
amount
;
amount
=
Math
.
min
(
amount
,
100
)
;
Pageable
pageable
=
PageRequest
.
of
(
pageNum
,
amount
);
Pageable
pageable
=
PageRequest
.
of
(
pageNum
,
amount
);
// 根据商铺ids 与 过滤条件 得到商铺
// 根据商铺ids 与 过滤条件 得到商铺
Page
<
Shop
>
shops
=
getShopsByFilter
(
shopFilterDto
,
shopIds
,
pageable
);
Page
<
Shop
>
shops
=
getShopsByFilter
(
shopFilterDto
,
shopIds
,
pageable
);
...
@@ -408,7 +408,7 @@ public class ShopServiceImpl implements ShopService {
...
@@ -408,7 +408,7 @@ public class ShopServiceImpl implements ShopService {
ShopPageResultDto
<
ShopResultDto
>
shopPageResultDto
=
new
ShopPageResultDto
<>();
ShopPageResultDto
<
ShopResultDto
>
shopPageResultDto
=
new
ShopPageResultDto
<>();
if
(
shops
!=
null
&&
shops
.
getNumberOfElements
()
>=
1
)
{
if
(
shops
!=
null
&&
shops
.
getNumberOfElements
()
>=
1
)
{
List
<
ShopResultDto
>
shopResultDtos
=
new
ArrayList
<>();
List
<
ShopResultDto
>
shopResultDtos
=
new
ArrayList
<>();
shops
.
getContent
().
stream
().
forEach
(
shops
.
getContent
().
forEach
(
x
->
{
x
->
{
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdsIsAndIsDeleted
(
x
.
getShopId
(),
false
);
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdsIsAndIsDeleted
(
x
.
getShopId
(),
false
);
// 如果 ip资源非空 且 addr 也非空
// 如果 ip资源非空 且 addr 也非空
...
@@ -476,10 +476,9 @@ public class ShopServiceImpl implements ShopService {
...
@@ -476,10 +476,9 @@ public class ShopServiceImpl implements ShopService {
public
ShopSummary
getShopSummary
(
String
username
)
{
public
ShopSummary
getShopSummary
(
String
username
)
{
Account
account
=
accountRepository
.
findByName
(
username
).
orElseThrow
(()
->
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
));
Account
account
=
accountRepository
.
findByName
(
username
).
orElseThrow
(()
->
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
));
ShopSummary
shopSummary
=
new
ShopSummary
();
ShopSummary
shopSummary
=
new
ShopSummary
();
List
<
String
>
allShopIds
=
userShopRepository
.
findByUsername
(
username
).
stream
()
List
<
String
>
allShopIds
=
userShopRepository
.
findByUsername
(
username
).
stream
()
.
map
(
UserShop:
:
getShopId
).
collect
(
Collectors
.
toList
());
.
map
(
UserShop:
:
getShopId
).
collect
(
Collectors
.
toList
());
List
<
String
>
unbind
=
new
ArrayList
<>();
List
<
String
>
unbind
=
new
ArrayList
<>();
if
(!
allShopIds
.
isEmpty
())
{
if
(!
allShopIds
.
isEmpty
())
{
for
(
String
id
:
allShopIds
)
{
for
(
String
id
:
allShopIds
)
{
...
@@ -492,9 +491,9 @@ public class ShopServiceImpl implements ShopService {
...
@@ -492,9 +491,9 @@ public class ShopServiceImpl implements ShopService {
shopSummary
.
setUnbind
(
unbind
.
size
());
shopSummary
.
setUnbind
(
unbind
.
size
());
List
<
String
>
shopIds
=
userShopRepository
.
findByUsername
(
username
).
stream
()
List
<
String
>
shopIds
=
userShopRepository
.
findByUsername
(
username
).
stream
()
.
map
(
UserShop:
:
getShopId
).
collect
(
Collectors
.
toList
());
.
map
(
UserShop:
:
getShopId
).
collect
(
Collectors
.
toList
());
List
<
String
>
bind
=
ipResourceRepository
.
findShopIdInList
(
shopIds
,
false
).
stream
()
List
<
String
>
bind
=
ipResourceRepository
.
findShopIdInList
(
shopIds
,
false
).
stream
()
.
map
(
IpResource:
:
getId
).
collect
(
Collectors
.
toList
());
.
map
(
IpResource:
:
getId
).
collect
(
Collectors
.
toList
());
int
expired
=
ipResourceRepository
.
countByStatusAndIdInAndIsDeleted
(
1
,
bind
,
false
);
int
expired
=
ipResourceRepository
.
countByStatusAndIdInAndIsDeleted
(
1
,
bind
,
false
);
int
willexpired
=
ipResourceRepository
.
countByStatusAndIdInAndIsDeleted
(
2
,
bind
,
false
);
int
willexpired
=
ipResourceRepository
.
countByStatusAndIdInAndIsDeleted
(
2
,
bind
,
false
);
shopSummary
.
setExpired
(
expired
);
shopSummary
.
setExpired
(
expired
);
...
@@ -560,7 +559,7 @@ public class ShopServiceImpl implements ShopService {
...
@@ -560,7 +559,7 @@ public class ShopServiceImpl implements ShopService {
Page
<
Shop
>
shops
=
null
;
Page
<
Shop
>
shops
=
null
;
if
(!
StringUtils
.
isEmpty
(
shopFilterDto
.
getIpRegion
()))
{
if
(!
StringUtils
.
isEmpty
(
shopFilterDto
.
getIpRegion
()))
{
List
<
String
>
filter
=
ipResourceRepository
.
findShopIdInListAndRegionLike
(
shopIds
,
false
,
shopFilterDto
.
getIpRegion
())
List
<
String
>
filter
=
ipResourceRepository
.
findShopIdInListAndRegionLike
(
shopIds
,
false
,
shopFilterDto
.
getIpRegion
())
.
stream
().
flatMap
((
x
->
x
.
getShopIds
().
stream
())).
collect
(
Collectors
.
toList
());
.
stream
().
flatMap
((
x
->
x
.
getShopIds
().
stream
())).
collect
(
Collectors
.
toList
());
shops
=
shopRepository
.
findByShopIdInOrderByCreateTimeDesc
(
filter
,
pageable
);
shops
=
shopRepository
.
findByShopIdInOrderByCreateTimeDesc
(
filter
,
pageable
);
}
}
if
(!
StringUtils
.
isEmpty
(
shopFilterDto
.
getShopAccount
()))
{
if
(!
StringUtils
.
isEmpty
(
shopFilterDto
.
getShopAccount
()))
{
...
...
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