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
738e0979
Commit
738e0979
authored
Mar 09, 2020
by
renjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改shop接口
parent
0423c2d0
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
144 additions
and
62 deletions
+144
-62
ShopController.java
...gec/browserbackend/browser/controller/ShopController.java
+9
-7
Shop.java
...in/java/com/edgec/browserbackend/browser/domain/Shop.java
+56
-19
UserShop.java
...ava/com/edgec/browserbackend/browser/domain/UserShop.java
+1
-2
ShopDto.java
...in/java/com/edgec/browserbackend/browser/dto/ShopDto.java
+36
-14
ShopStringResultDto.java
...edgec/browserbackend/browser/dto/ShopStringResultDto.java
+13
-0
ShopServiceImpl.java
.../browserbackend/browser/service/Impl/ShopServiceImpl.java
+27
-18
ShopService.java
...com/edgec/browserbackend/browser/service/ShopService.java
+2
-2
No files found.
src/main/java/com/edgec/browserbackend/browser/controller/ShopController.java
View file @
738e0979
...
@@ -4,6 +4,7 @@ import com.edgec.browserbackend.account.dto.ResultDto;
...
@@ -4,6 +4,7 @@ import com.edgec.browserbackend.account.dto.ResultDto;
import
com.edgec.browserbackend.browser.domain.Shop
;
import
com.edgec.browserbackend.browser.domain.Shop
;
import
com.edgec.browserbackend.browser.dto.ShopDto
;
import
com.edgec.browserbackend.browser.dto.ShopDto
;
import
com.edgec.browserbackend.browser.dto.ShopRequestDto
;
import
com.edgec.browserbackend.browser.dto.ShopRequestDto
;
import
com.edgec.browserbackend.browser.dto.ShopStringResultDto
;
import
com.edgec.browserbackend.browser.service.ShopService
;
import
com.edgec.browserbackend.browser.service.ShopService
;
import
com.edgec.browserbackend.common.commons.error.ClientRequestException
;
import
com.edgec.browserbackend.common.commons.error.ClientRequestException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -26,11 +27,12 @@ public class ShopController {
...
@@ -26,11 +27,12 @@ public class ShopController {
private
ShopService
shopService
;
private
ShopService
shopService
;
@RequestMapping
(
value
=
"/add"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/add"
,
method
=
RequestMethod
.
POST
)
public
ResultDto
addShop
(
Principal
principal
,
@RequestBody
Shop
shop
)
{
public
ResultDto
addShop
(
Principal
principal
,
@RequestBody
Shop
Dto
shopDto
)
{
ResultDto
resultDto
=
new
ResultDto
();
ResultDto
resultDto
=
new
ResultDto
();
try
{
try
{
ShopDto
shopDto
=
new
ShopDto
();
ShopStringResultDto
shopStringResultDto
=
new
ShopStringResultDto
();
shopDto
.
setId
(
shopService
.
addShop
(
principal
.
getName
(),
shop
));
shopStringResultDto
.
setId
(
shopService
.
addShop
(
principal
.
getName
(),
shopDto
));
resultDto
.
setData
(
shopStringResultDto
);
resultDto
.
setStatus
(
0
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
resultDto
.
setStatus
(-
1
);
...
@@ -48,12 +50,12 @@ public class ShopController {
...
@@ -48,12 +50,12 @@ public class ShopController {
}
}
@RequestMapping
(
value
=
"/update"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/update"
,
method
=
RequestMethod
.
POST
)
public
ResultDto
updateShop
(
Principal
principal
,
@RequestBody
Shop
shop
)
{
public
ResultDto
updateShop
(
Principal
principal
,
@RequestBody
Shop
Dto
shopDto
)
{
ResultDto
resultDto
=
new
ResultDto
();
ResultDto
resultDto
=
new
ResultDto
();
try
{
try
{
Shop
Dto
shopDto
=
new
Shop
Dto
();
Shop
StringResultDto
shopStringResultDto
=
new
ShopStringResult
Dto
();
shop
Dto
.
setId
(
shopService
.
updateShop
(
principal
.
getName
(),
shop
));
shop
StringResultDto
.
setId
(
shopService
.
updateShop
(
principal
.
getName
(),
shopDto
));
resultDto
.
setData
(
shopDto
);
resultDto
.
setData
(
shop
StringResult
Dto
);
resultDto
.
setStatus
(
0
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
resultDto
.
setStatus
(-
1
);
...
...
src/main/java/com/edgec/browserbackend/browser/domain/Shop.java
View file @
738e0979
package
com
.
edgec
.
browserbackend
.
browser
.
domain
;
package
com
.
edgec
.
browserbackend
.
browser
.
domain
;
import
com.edgec.browserbackend.browser.dto.ShopDto
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
org.springframework.data.mongodb.core.mapping.Document
;
...
@@ -17,9 +18,7 @@ public class Shop {
...
@@ -17,9 +18,7 @@ public class Shop {
private
TransferStatus
transferStatus
;
private
TransferStatus
transferStatus
;
private
String
firstGroupId
;
private
String
shopUrl
;
private
String
link
;
private
String
shopPlatform
;
private
String
shopPlatform
;
...
@@ -33,21 +32,47 @@ public class Shop {
...
@@ -33,21 +32,47 @@ public class Shop {
private
String
shopPassword
;
private
String
shopPassword
;
private
String
shopUA
;
private
String
shopCookie
;
public
Shop
(){
public
Shop
(){
}
}
//创建店铺使用
public
static
Shop
of
(
ShopDto
shopDto
)
{
Shop
shop
=
new
Shop
();
if
(
shop
.
getShopUrl
()
!=
null
)
shop
.
setShopUrl
(
shopDto
.
getShopUrl
());
if
(
shop
.
getOwner
()
!=
null
)
shop
.
setOwner
(
shopDto
.
getOwner
());
if
(
shop
.
getShopPlatform
()
!=
null
)
shop
.
setShopPlatform
(
shopDto
.
getShopPlatform
());
if
(
shop
.
getShopName
()
!=
null
)
shop
.
setShopName
(
shopDto
.
getShopName
());
if
(
shop
.
getTransferStatus
()
!=
null
)
shop
.
setTransferStatus
(
shopDto
.
getTransferStatus
());
if
(
shop
.
getShopAccount
()
!=
null
)
shop
.
setShopAccount
(
shopDto
.
getShopAccount
());
if
(
shop
.
getShopPassword
()
!=
null
)
shop
.
setShopPassword
(
shopDto
.
getShopPassword
());
if
(
shop
.
getShopUA
()
!=
null
)
shop
.
setShopUA
(
shopDto
.
getShopUA
());
if
(
shop
.
getShopCookie
()
!=
null
)
shop
.
setShopCookie
(
shopDto
.
getShopCookie
());
return
shop
;
}
public
Shop
of
(
Shop
shop
)
{
public
Shop
of
(
Shop
shop
)
{
if
(
shop
.
getFirstGroupId
()
!=
null
)
this
.
setFirstGroupId
(
shop
.
getFirstGroupId
());
if
(
shop
.
getIp
()
!=
null
)
if
(
shop
.
getIp
()
!=
null
)
this
.
setIp
(
shop
.
getIp
());
this
.
setIp
(
shop
.
getIp
());
if
(
shop
.
getIpId
()
!=
null
)
if
(
shop
.
getIpId
()
!=
null
)
this
.
setIpId
(
shop
.
getIpId
());
this
.
setIpId
(
shop
.
getIpId
());
if
(
shop
.
getIpRegion
()
!=
null
)
if
(
shop
.
getIpRegion
()
!=
null
)
this
.
setIpRegion
(
shop
.
getIpRegion
());
this
.
setIpRegion
(
shop
.
getIpRegion
());
if
(
shop
.
get
Link
()
!=
null
)
if
(
shop
.
get
ShopUrl
()
!=
null
)
this
.
set
Link
(
shop
.
getLink
());
this
.
set
ShopUrl
(
shop
.
getShopUrl
());
if
(
shop
.
getOwner
()
!=
null
)
if
(
shop
.
getOwner
()
!=
null
)
this
.
setOwner
(
shop
.
getOwner
());
this
.
setOwner
(
shop
.
getOwner
());
if
(
shop
.
getShopPlatform
()
!=
null
)
if
(
shop
.
getShopPlatform
()
!=
null
)
...
@@ -60,6 +85,10 @@ public class Shop {
...
@@ -60,6 +85,10 @@ public class Shop {
this
.
setShopAccount
(
shop
.
getShopAccount
());
this
.
setShopAccount
(
shop
.
getShopAccount
());
if
(
shop
.
getShopPassword
()
!=
null
)
if
(
shop
.
getShopPassword
()
!=
null
)
this
.
setShopPassword
(
shop
.
getShopPassword
());
this
.
setShopPassword
(
shop
.
getShopPassword
());
if
(
shop
.
getShopUA
()
!=
null
)
this
.
setShopUA
(
shop
.
getShopUA
());
if
(
shop
.
getShopCookie
()
!=
null
)
this
.
setShopCookie
(
shop
.
getShopCookie
());
return
this
;
return
this
;
}
}
...
@@ -71,10 +100,6 @@ public class Shop {
...
@@ -71,10 +100,6 @@ public class Shop {
return
id
;
return
id
;
}
}
public
String
getFirstGroupId
()
{
return
firstGroupId
;
}
public
String
getIpId
()
{
public
String
getIpId
()
{
return
ipId
;
return
ipId
;
}
}
...
@@ -83,8 +108,8 @@ public class Shop {
...
@@ -83,8 +108,8 @@ public class Shop {
return
ipRegion
;
return
ipRegion
;
}
}
public
String
get
Link
()
{
public
String
get
ShopUrl
()
{
return
link
;
return
shopUrl
;
}
}
public
String
getOwner
()
{
public
String
getOwner
()
{
...
@@ -111,10 +136,6 @@ public class Shop {
...
@@ -111,10 +136,6 @@ public class Shop {
this
.
id
=
id
;
this
.
id
=
id
;
}
}
public
void
setFirstGroupId
(
String
firstGroupId
)
{
this
.
firstGroupId
=
firstGroupId
;
}
public
void
setIpId
(
String
ipId
)
{
public
void
setIpId
(
String
ipId
)
{
this
.
ipId
=
ipId
;
this
.
ipId
=
ipId
;
}
}
...
@@ -123,8 +144,8 @@ public class Shop {
...
@@ -123,8 +144,8 @@ public class Shop {
this
.
ipRegion
=
ipRegion
;
this
.
ipRegion
=
ipRegion
;
}
}
public
void
set
Link
(
String
link
)
{
public
void
set
ShopUrl
(
String
shopUrl
)
{
this
.
link
=
link
;
this
.
shopUrl
=
shopUrl
;
}
}
public
void
setOwner
(
String
owner
)
{
public
void
setOwner
(
String
owner
)
{
...
@@ -158,4 +179,20 @@ public class Shop {
...
@@ -158,4 +179,20 @@ public class Shop {
public
void
setShopPassword
(
String
shopPassword
)
{
public
void
setShopPassword
(
String
shopPassword
)
{
this
.
shopPassword
=
shopPassword
;
this
.
shopPassword
=
shopPassword
;
}
}
public
String
getShopCookie
()
{
return
shopCookie
;
}
public
void
setShopCookie
(
String
shopCookie
)
{
this
.
shopCookie
=
shopCookie
;
}
public
String
getShopUA
()
{
return
shopUA
;
}
public
void
setShopUA
(
String
shopUA
)
{
this
.
shopUA
=
shopUA
;
}
}
}
src/main/java/com/edgec/browserbackend/browser/domain/UserShop.java
View file @
738e0979
...
@@ -5,7 +5,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
...
@@ -5,7 +5,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
import
java.util.List
;
import
java.util.List
;
@Document
(
collection
=
"usershop
s
"
)
@Document
(
collection
=
"usershop"
)
public
class
UserShop
{
public
class
UserShop
{
@Id
@Id
...
@@ -18,7 +18,6 @@ public class UserShop {
...
@@ -18,7 +18,6 @@ public class UserShop {
private
String
groupId
;
private
String
groupId
;
public
UserShop
(){
public
UserShop
(){
}
}
public
UserShop
(
String
username
,
String
shopId
)
{
public
UserShop
(
String
username
,
String
shopId
)
{
...
...
src/main/java/com/edgec/browserbackend/browser/dto/ShopDto.java
View file @
738e0979
...
@@ -18,9 +18,9 @@ public class ShopDto {
...
@@ -18,9 +18,9 @@ public class ShopDto {
private
TransferStatus
transferStatus
;
private
TransferStatus
transferStatus
;
private
String
firstGroupId
;
private
String
group
;
private
String
link
;
private
String
shopUrl
;
private
String
shopPlatform
;
private
String
shopPlatform
;
...
@@ -28,6 +28,10 @@ public class ShopDto {
...
@@ -28,6 +28,10 @@ public class ShopDto {
private
String
shopPassword
;
private
String
shopPassword
;
private
String
shopUA
;
private
String
shopCookie
;
private
IpResource
ipResources
;
private
IpResource
ipResources
;
public
static
ShopDto
of
(
Shop
shop
,
IpResource
ipResources
)
{
public
static
ShopDto
of
(
Shop
shop
,
IpResource
ipResources
)
{
...
@@ -39,14 +43,16 @@ public class ShopDto {
...
@@ -39,14 +43,16 @@ public class ShopDto {
shopDto
.
setShopPlatform
(
shop
.
getShopPlatform
());
shopDto
.
setShopPlatform
(
shop
.
getShopPlatform
());
if
(
shop
.
getShopPassword
()
!=
null
)
if
(
shop
.
getShopPassword
()
!=
null
)
shopDto
.
setShopPassword
(
shop
.
getShopPassword
());
shopDto
.
setShopPassword
(
shop
.
getShopPassword
());
if
(
shop
.
getFirstGroupId
()
!=
null
)
shopDto
.
setFirstGroupId
(
shop
.
getFirstGroupId
());
if
(
shop
.
getTransferStatus
()
!=
null
)
if
(
shop
.
getTransferStatus
()
!=
null
)
shopDto
.
setTransferStatus
(
shop
.
getTransferStatus
());
shopDto
.
setTransferStatus
(
shop
.
getTransferStatus
());
if
(
shop
.
getOwner
()
!=
null
)
if
(
shop
.
getOwner
()
!=
null
)
shopDto
.
setOwner
(
shop
.
getOwner
());
shopDto
.
setOwner
(
shop
.
getOwner
());
if
(
shop
.
getLink
()
!=
null
)
if
(
shop
.
getShopUrl
()
!=
null
)
shopDto
.
setLink
(
shop
.
getLink
());
shopDto
.
setShopUrl
(
shop
.
getShopUrl
());
if
(
shop
.
getShopUA
()
!=
null
)
shopDto
.
setShopUA
(
shop
.
getShopUA
());
if
(
shop
.
getShopCookie
()
!=
null
)
shopDto
.
setShopCookie
(
shop
.
getShopCookie
());
shopDto
.
setIpResources
(
ipResources
);
shopDto
.
setIpResources
(
ipResources
);
return
shopDto
;
return
shopDto
;
}
}
...
@@ -59,12 +65,12 @@ public class ShopDto {
...
@@ -59,12 +65,12 @@ public class ShopDto {
this
.
shopPlatform
=
shopPlatform
;
this
.
shopPlatform
=
shopPlatform
;
}
}
public
String
get
FirstGroupId
()
{
public
String
get
Group
()
{
return
firstGroupId
;
return
group
;
}
}
public
void
set
FirstGroupId
(
String
firstGroupId
)
{
public
void
set
Group
(
String
group
)
{
this
.
firstGroupId
=
firstGroupId
;
this
.
group
=
group
;
}
}
public
String
getShopPassword
()
{
public
String
getShopPassword
()
{
...
@@ -115,12 +121,12 @@ public class ShopDto {
...
@@ -115,12 +121,12 @@ public class ShopDto {
this
.
transferStatus
=
transferStatus
;
this
.
transferStatus
=
transferStatus
;
}
}
public
String
get
Link
()
{
public
String
get
ShopUrl
()
{
return
link
;
return
shopUrl
;
}
}
public
void
set
Link
(
String
link
)
{
public
void
set
ShopUrl
(
String
shopUrl
)
{
this
.
link
=
link
;
this
.
shopUrl
=
shopUrl
;
}
}
public
IpResource
getIpResources
()
{
public
IpResource
getIpResources
()
{
...
@@ -130,4 +136,20 @@ public class ShopDto {
...
@@ -130,4 +136,20 @@ public class ShopDto {
public
void
setIpResources
(
IpResource
ipResources
)
{
public
void
setIpResources
(
IpResource
ipResources
)
{
this
.
ipResources
=
ipResources
;
this
.
ipResources
=
ipResources
;
}
}
public
String
getShopUA
()
{
return
shopUA
;
}
public
void
setShopUA
(
String
shopUA
)
{
this
.
shopUA
=
shopUA
;
}
public
String
getShopCookie
()
{
return
shopCookie
;
}
public
void
setShopCookie
(
String
shopCookie
)
{
this
.
shopCookie
=
shopCookie
;
}
}
}
src/main/java/com/edgec/browserbackend/browser/dto/ShopStringResultDto.java
0 → 100644
View file @
738e0979
package
com
.
edgec
.
browserbackend
.
browser
.
dto
;
public
class
ShopStringResultDto
{
String
id
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
}
src/main/java/com/edgec/browserbackend/browser/service/Impl/ShopServiceImpl.java
View file @
738e0979
...
@@ -50,7 +50,7 @@ public class ShopServiceImpl implements ShopService {
...
@@ -50,7 +50,7 @@ public class ShopServiceImpl implements ShopService {
IpResourceRepository
ipResourceRepository
;
IpResourceRepository
ipResourceRepository
;
@Override
@Override
public
String
addShop
(
String
username
,
Shop
shop
)
{
public
String
addShop
(
String
username
,
Shop
Dto
shopDto
)
{
Account
account
=
accountRepository
.
findByName
(
username
);
Account
account
=
accountRepository
.
findByName
(
username
);
String
id
=
null
;
String
id
=
null
;
if
(
account
==
null
)
{
if
(
account
==
null
)
{
...
@@ -59,16 +59,22 @@ public class ShopServiceImpl implements ShopService {
...
@@ -59,16 +59,22 @@ public class ShopServiceImpl implements ShopService {
if
(
account
.
getPermission
()
<
4
)
{
if
(
account
.
getPermission
()
<
4
)
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
);
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
);
}
}
UserShop
us
=
userShopRepository
.
findByUsernameAndShopId
(
username
,
shop
.
getId
());
UserShop
us
=
userShopRepository
.
findByUsernameAndShopId
(
username
,
shopDto
.
getId
());
if
(
shop
.
getFirstGroupId
()
!=
null
&&
us
==
null
)
{
Group
group
=
groupRepository
.
findById
(
shopDto
.
getGroup
()).
orElse
(
null
);
UserShop
userShop
=
new
UserShop
();
if
(
group
==
null
)
{
userShop
.
setShopId
(
shop
.
getId
());
throw
new
ClientRequestException
(
BrowserErrorCode
.
GROUPNOTEXIST
);
userShop
.
setGroupId
(
shop
.
getFirstGroupId
());
userShopRepository
.
save
(
userShop
);
}
}
try
{
try
{
shop
.
setOwner
(
username
);
shopDto
.
setOwner
(
username
);
Shop
shop
=
Shop
.
of
(
shopDto
);
id
=
shopRepository
.
save
(
shop
).
getId
();
id
=
shopRepository
.
save
(
shop
).
getId
();
UserShop
userShop
=
new
UserShop
();
userShop
.
setUsername
(
username
);
userShop
.
setShopId
(
shopDto
.
getId
());
if
(
shopDto
.
getGroup
()
!=
null
&&
us
==
null
)
{
userShop
.
setGroupId
(
shopDto
.
getGroup
());
}
userShopRepository
.
save
(
userShop
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
ClientRequestException
(
BrowserErrorCode
.
INFORMATIONNOTCOMPELETE
);
throw
new
ClientRequestException
(
BrowserErrorCode
.
INFORMATIONNOTCOMPELETE
);
}
}
...
@@ -81,24 +87,20 @@ public class ShopServiceImpl implements ShopService {
...
@@ -81,24 +87,20 @@ public class ShopServiceImpl implements ShopService {
}
}
@Override
@Override
public
String
updateShop
(
String
username
,
Shop
shop
)
{
public
String
updateShop
(
String
username
,
Shop
Dto
shopDto
)
{
Account
account
=
accountRepository
.
findByName
(
username
);
Account
account
=
accountRepository
.
findByName
(
username
);
if
(
account
==
null
)
{
if
(
account
==
null
)
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
}
}
UserShop
userShop
=
userShopRepository
.
findByUsernameAndShopId
(
username
,
shop
.
getId
());
UserShop
userShop
=
userShopRepository
.
findByUsernameAndShopId
(
username
,
shop
Dto
.
getId
());
if
(
account
.
getPermission
()
<
4
||
userShop
==
null
)
{
if
(
account
.
getPermission
()
<
4
||
userShop
==
null
)
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
);
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
);
}
}
if
(
shop
.
getFirstGroupId
()
!=
null
)
{
Shop
shop_old
=
shopRepository
.
findById
(
shopDto
.
getId
()).
orElseGet
(
null
);
transferShop
(
username
,
shop
.
getId
(),
shop
.
getFirstGroupId
());
}
Shop
shop_old
=
shopRepository
.
findById
(
shop
.
getId
()).
orElseGet
(
null
);
if
(
shop_old
==
null
)
if
(
shop_old
==
null
)
throw
new
ClientRequestException
(
BrowserErrorCode
.
SHOPNOTEXIST
);
throw
new
ClientRequestException
(
BrowserErrorCode
.
SHOPNOTEXIST
);
try
{
try
{
shop_old
=
shop_old
.
of
(
shop
);
shop_old
=
shop_old
.
of
(
shop
Dto
);
shopRepository
.
save
(
shop_old
);
shopRepository
.
save
(
shop_old
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"fail to update"
,
e
.
getMessage
());
logger
.
error
(
"fail to update"
,
e
.
getMessage
());
...
@@ -256,14 +258,21 @@ public class ShopServiceImpl implements ShopService {
...
@@ -256,14 +258,21 @@ public class ShopServiceImpl implements ShopService {
if
(
account
==
null
)
{
if
(
account
==
null
)
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
}
}
Group
group
=
groupRepository
.
findById
(
groupId
).
orElse
(
null
);
Group
group
=
null
;
if
(
groupId
!=
null
&&
!
groupId
.
equals
(
"-1"
))
group
=
groupRepository
.
findById
(
groupId
).
orElse
(
null
);
if
(
group
==
null
)
if
(
group
==
null
)
throw
new
ClientRequestException
(
BrowserErrorCode
.
GROUPNOTEXIST
);
throw
new
ClientRequestException
(
BrowserErrorCode
.
GROUPNOTEXIST
);
if
(
account
.
getPermission
()
<
8
||
!
group
.
getOwner
().
equals
(
username
))
{
if
(
account
.
getPermission
()
<
8
||
!
group
.
getOwner
().
equals
(
username
))
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
);
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
);
}
}
List
<
String
>
shopIds
=
userShopRepository
.
findByUsernameAndGroupId
(
username
,
groupId
).
stream
().
List
<
String
>
shopIds
=
new
ArrayList
<>();
if
(
groupId
.
equals
(
"-1"
)){
shopIds
=
userShopRepository
.
findByUsername
(
username
).
stream
().
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
}
else
{
shopIds
=
userShopRepository
.
findByUsernameAndGroupId
(
username
,
groupId
).
stream
().
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
}
List
<
Shop
>
shops
;
List
<
Shop
>
shops
;
if
(
filterDto
.
getIpRegion
()
!=
null
)
if
(
filterDto
.
getIpRegion
()
!=
null
)
shops
=
shopRepository
.
findByIdInAndIpRegionLike
(
shopIds
,
filterDto
.
getIpRegion
());
shops
=
shopRepository
.
findByIdInAndIpRegionLike
(
shopIds
,
filterDto
.
getIpRegion
());
...
...
src/main/java/com/edgec/browserbackend/browser/service/ShopService.java
View file @
738e0979
...
@@ -9,11 +9,11 @@ import java.util.List;
...
@@ -9,11 +9,11 @@ import java.util.List;
public
interface
ShopService
{
public
interface
ShopService
{
String
addShop
(
String
useranme
,
Shop
shop
);
String
addShop
(
String
useranme
,
Shop
Dto
shopDto
);
List
<
String
>
addShops
(
String
username
,
List
<
Shop
>
shops
);
List
<
String
>
addShops
(
String
username
,
List
<
Shop
>
shops
);
String
updateShop
(
String
username
,
Shop
shop
);
String
updateShop
(
String
username
,
Shop
Dto
shopDto
);
void
deleteShop
(
String
username
,
String
shopId
);
void
deleteShop
(
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