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
83c6d537
Commit
83c6d537
authored
Apr 02, 2020
by
renjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shopusers
parent
6cae06fb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
0 deletions
+36
-0
ShopController.java
...gec/browserbackend/browser/controller/ShopController.java
+17
-0
ShopServiceImpl.java
.../browserbackend/browser/service/Impl/ShopServiceImpl.java
+17
-0
ShopService.java
...com/edgec/browserbackend/browser/service/ShopService.java
+2
-0
No files found.
src/main/java/com/edgec/browserbackend/browser/controller/ShopController.java
View file @
83c6d537
...
@@ -196,4 +196,21 @@ public class ShopController {
...
@@ -196,4 +196,21 @@ public class ShopController {
}
}
return
resultDto
;
return
resultDto
;
}
}
@RequestMapping
(
value
=
"/subusers"
,
method
=
RequestMethod
.
POST
)
public
ResultDto
getShopSubUsers
(
Principal
principal
,
@RequestBody
ShopRequestDto
shopRequestDto
)
{
ResultDto
resultDto
=
new
ResultDto
();
try
{
List
<
String
>
subUsers
=
shopService
.
getShopUsers
(
principal
.
getName
(),
shopRequestDto
.
getShopId
());
resultDto
.
setData
(
subUsers
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
resultDto
.
setStatusInfo
(
statusInfo
);
}
return
resultDto
;
}
}
}
src/main/java/com/edgec/browserbackend/browser/service/Impl/ShopServiceImpl.java
View file @
83c6d537
...
@@ -262,6 +262,10 @@ public class ShopServiceImpl implements ShopService {
...
@@ -262,6 +262,10 @@ public class ShopServiceImpl implements ShopService {
List
<
Account
>
accounts
=
accountRepository
.
findByNameIn
(
users
);
List
<
Account
>
accounts
=
accountRepository
.
findByNameIn
(
users
);
if
(
accounts
==
null
||
accounts
.
size
()
!=
users
.
size
())
if
(
accounts
==
null
||
accounts
.
size
()
!=
users
.
size
())
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
for
(
Account
ac
:
accounts
)
{
if
(
ac
.
getParent
()
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
);
}
shops
.
stream
().
forEach
(
shop
->
{
shops
.
stream
().
forEach
(
shop
->
{
try
{
try
{
userShopRepository
.
deleteByShopIdExceptOwner
(
shop
.
getShopId
(),
shop
.
getOwner
());
userShopRepository
.
deleteByShopIdExceptOwner
(
shop
.
getShopId
(),
shop
.
getOwner
());
...
@@ -269,6 +273,8 @@ public class ShopServiceImpl implements ShopService {
...
@@ -269,6 +273,8 @@ public class ShopServiceImpl implements ShopService {
UserShop
userShop1
=
userShopRepository
.
findByUsernameAndShopId
(
account1
.
getName
(),
shop
.
getShopId
());
UserShop
userShop1
=
userShopRepository
.
findByUsernameAndShopId
(
account1
.
getName
(),
shop
.
getShopId
());
if
(
userShop1
!=
null
)
if
(
userShop1
!=
null
)
return
;
return
;
userShop1
=
new
UserShop
(
account1
.
getName
(),
shop
.
getShopId
(),
"-1"
);
userShopRepository
.
save
(
userShop1
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"fail to assign"
,
e
.
getMessage
());
logger
.
error
(
"fail to assign"
,
e
.
getMessage
());
...
@@ -393,4 +399,15 @@ public class ShopServiceImpl implements ShopService {
...
@@ -393,4 +399,15 @@ public class ShopServiceImpl implements ShopService {
shopSummary
.
setTotal
(
userShopRepository
.
countByUsername
(
username
));
shopSummary
.
setTotal
(
userShopRepository
.
countByUsername
(
username
));
return
shopSummary
;
return
shopSummary
;
}
}
@Override
public
List
<
String
>
getShopUsers
(
String
username
,
String
shopId
)
{
Account
account
=
accountRepository
.
findByName
(
username
);
if
(
account
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
if
(
account
.
getParent
()
!=
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
);
List
<
String
>
shopUsers
=
userShopRepository
.
findByShopId
(
shopId
).
stream
().
map
(
x
->
x
.
getUsername
()).
filter
(
x
->
x
!=
username
).
collect
(
Collectors
.
toList
());
return
shopUsers
;
}
}
}
src/main/java/com/edgec/browserbackend/browser/service/ShopService.java
View file @
83c6d537
...
@@ -28,4 +28,6 @@ public interface ShopService {
...
@@ -28,4 +28,6 @@ public interface ShopService {
ShopPageResultDto
getShopList
(
String
username
,
String
groupId
,
int
page
,
int
amount
,
ShopFilterDto
shopFilterDto
);
ShopPageResultDto
getShopList
(
String
username
,
String
groupId
,
int
page
,
int
amount
,
ShopFilterDto
shopFilterDto
);
ShopSummary
getShopSummary
(
String
username
);
ShopSummary
getShopSummary
(
String
username
);
List
<
String
>
getShopUsers
(
String
username
,
String
shopId
);
}
}
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