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
5e9a7946
Commit
5e9a7946
authored
Apr 03, 2020
by
renjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分配店铺bug
parent
f22e948f
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
114 additions
and
3 deletions
+114
-3
AccountServiceImpl.java
...owserbackend/account/service/impl/AccountServiceImpl.java
+9
-1
ShopController.java
...gec/browserbackend/browser/controller/ShopController.java
+17
-0
UserShopRepository.java
...browserbackend/browser/repository/UserShopRepository.java
+2
-0
ShopServiceImpl.java
.../browserbackend/browser/service/Impl/ShopServiceImpl.java
+34
-2
ShopService.java
...com/edgec/browserbackend/browser/service/ShopService.java
+2
-0
EncodeUtil.java
...ava/com/edgec/browserbackend/common/utils/EncodeUtil.java
+50
-0
No files found.
src/main/java/com/edgec/browserbackend/account/service/impl/AccountServiceImpl.java
View file @
5e9a7946
...
...
@@ -124,6 +124,9 @@ public class AccountServiceImpl implements AccountService {
@Autowired
private
QueryIpUrlListRepository
queryIpUrlListRepository
;
@Autowired
private
PaymentService
paymentService
;
@Override
public
List
<
UserBillList
>
getUserBills0
(
String
name
)
{
...
...
@@ -465,8 +468,9 @@ public class AccountServiceImpl implements AccountService {
account
.
setEmail
(
user
.
getEmail
());
account
.
setPhoneNumber
(
user
.
getUsername
());
account
.
setPermission
(
15
);
if
(
user
.
getPromotionCode
()
!=
null
)
if
(
user
.
getPromotionCode
()
!=
null
)
{
account
.
setPromotionCode
(
user
.
getPromotionCode
());
}
Account
inviter
=
repository
.
findByPromotion
(
user
.
getPromotionCode
());
if
(
inviter
!=
null
)
{
...
...
@@ -498,6 +502,10 @@ public class AccountServiceImpl implements AccountService {
userAuthService
.
create
(
new
com
.
edgec
.
browserbackend
.
auth
.
domain
.
User
(
user
));
repository
.
save
(
account
);
if
(
inviter
!=
null
)
{
paymentService
.
bankTransferInsertion
(
account
.
getName
(),
12
);
}
log
.
info
(
"new account has been created: "
+
account
.
getName
());
notifyCustomerRegister
(
account
);
...
...
src/main/java/com/edgec/browserbackend/browser/controller/ShopController.java
View file @
5e9a7946
...
...
@@ -213,4 +213,21 @@ public class ShopController {
}
return
resultDto
;
}
@RequestMapping
(
value
=
"/batch/subusers"
,
method
=
RequestMethod
.
POST
)
public
ResultDto
getBatchShopSubUsers
(
Principal
principal
,
@RequestBody
ShopRequestDto
shopRequestDto
)
{
ResultDto
resultDto
=
new
ResultDto
();
try
{
List
<
String
>
subUsers
=
shopService
.
getBatchShopUsers
(
principal
.
getName
(),
shopRequestDto
.
getShopIds
());
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/repository/UserShopRepository.java
View file @
5e9a7946
...
...
@@ -12,4 +12,6 @@ public interface UserShopRepository extends MongoRepository<UserShop, String>, U
List
<
UserShop
>
findByUsernameAndGroupId
(
String
username
,
String
groupId
);
List
<
UserShop
>
findByUsernameAndShopIdIn
(
String
username
,
List
<
String
>
shopIds
);
int
countByUsername
(
String
username
);
int
countByShopId
(
String
shopId
);
int
countByUsernameAndShopIdIn
(
String
username
,
List
<
String
>
shopIds
);
}
src/main/java/com/edgec/browserbackend/browser/service/Impl/ShopServiceImpl.java
View file @
5e9a7946
...
...
@@ -24,6 +24,7 @@ import org.springframework.data.domain.Page;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.security.core.parameters.P
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.multipart.MultipartFile
;
...
...
@@ -267,7 +268,6 @@ public class ShopServiceImpl implements ShopService {
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
);
}
}
shops
.
stream
().
forEach
(
shop
->
{
try
{
...
...
@@ -410,7 +410,39 @@ public class ShopServiceImpl implements ShopService {
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
());
List
<
String
>
shopUsers
=
userShopRepository
.
findByShopId
(
shopId
).
stream
().
map
(
x
->
x
.
getUsername
()).
filter
(
x
->
!
x
.
equals
(
username
)).
collect
(
Collectors
.
toList
());
return
shopUsers
;
}
@Override
public
List
<
String
>
getBatchShopUsers
(
String
username
,
List
<
String
>
shopIds
)
{
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
=
new
ArrayList
<>();
if
(
shopIds
!=
null
&&
shopIds
.
size
()
>
0
)
{
String
maxShopId
=
null
;
int
max
=
0
;
for
(
String
shopId:
shopIds
)
{
int
userCount
=
userShopRepository
.
countByShopId
(
shopId
);
if
(
userCount
>
max
)
{
max
=
userCount
;
maxShopId
=
shopId
;
}
}
if
(
maxShopId
==
null
)
return
new
ArrayList
<>();
List
<
String
>
users
=
userShopRepository
.
findByShopId
(
maxShopId
).
stream
().
map
(
x
->
x
.
getUsername
()).
filter
(
x
->
!
x
.
equals
(
username
)).
collect
(
Collectors
.
toList
());
for
(
String
user
:
users
)
{
int
shopCount
=
userShopRepository
.
countByUsernameAndShopIdIn
(
user
,
shopIds
);
if
(
shopCount
<
shopIds
.
size
())
continue
;
else
shopUsers
.
add
(
user
);
}
}
return
shopUsers
;
}
}
src/main/java/com/edgec/browserbackend/browser/service/ShopService.java
View file @
5e9a7946
...
...
@@ -30,4 +30,6 @@ public interface ShopService {
ShopSummary
getShopSummary
(
String
username
);
List
<
String
>
getShopUsers
(
String
username
,
String
shopId
);
List
<
String
>
getBatchShopUsers
(
String
username
,
List
<
String
>
shopIds
);
}
src/main/java/com/edgec/browserbackend/common/utils/EncodeUtil.java
0 → 100644
View file @
5e9a7946
package
com
.
edgec
.
browserbackend
.
common
.
utils
;
import
org.bouncycastle.jce.provider.BouncyCastleProvider
;
import
org.springframework.util.StringUtils
;
import
javax.crypto.*
;
import
javax.crypto.spec.PBEKeySpec
;
import
javax.crypto.spec.SecretKeySpec
;
import
java.io.UnsupportedEncodingException
;
import
java.security.InvalidKeyException
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.NoSuchProviderException
;
import
java.security.Security
;
import
java.security.spec.InvalidKeySpecException
;
import
java.security.spec.KeySpec
;
import
java.util.Base64
;
public
class
EncodeUtil
{
public
void
decodeBase64
()
{
System
.
out
.
println
(
Base64
.
getDecoder
().
decode
(
"G65nlqVr9c7ZBUN/uEG136nZ/a1lneIHbQ3sY8Cj5SA="
));
}
public
void
encodeBase64
()
throws
NoSuchPaddingException
,
NoSuchAlgorithmException
,
NoSuchProviderException
,
UnsupportedEncodingException
,
InvalidKeySpecException
,
InvalidKeyException
,
BadPaddingException
,
IllegalBlockSizeException
{
byte
[]
byteContent
=
new
byte
[
0
];
byteContent
=
"b3LcaXzXzf4Z6GzB6q2KyMP5RC1pF6"
.
getBytes
(
"utf-8"
);
byte
[]
salt
=
new
byte
[]{
0x47
,
0x8
,
0x0e
,
0x0b
,
0x02
,
0x0f
,
0x0b
,
0x0c
,
0x01
,
0x03
,
0x12
,
0x07
,
0x0c
,
0x02
,
0x07
,
0x09
,
0x0a
,
0x0a
,
0x01
,
0x07
,
0x0b
,
0x07
,
0x09
,
0x0d
};
SecretKeyFactory
factory
=
null
;
factory
=
SecretKeyFactory
.
getInstance
(
"PBKDF2WithHmacSHA256"
);
char
[]
passphrase
=
(
StringUtils
.
isEmpty
(
System
.
getenv
(
"INTELLIGROUP_PHRASE"
))
?
"ACtrecje!@9cs93cdeMMdkc"
:
System
.
getenv
(
"INTELLIGROUP_PHRASE"
)).
toCharArray
();
KeySpec
spec
=
new
PBEKeySpec
(
passphrase
,
salt
,
65536
,
256
);
SecretKey
tmp
=
null
;
tmp
=
factory
.
generateSecret
(
spec
);
SecretKeySpec
secret
=
new
SecretKeySpec
(
tmp
.
getEncoded
(),
"AES"
);
Security
.
addProvider
(
new
BouncyCastleProvider
());
Cipher
encryptor
=
null
;
encryptor
=
Cipher
.
getInstance
(
"AES/ECB/PKCS7Padding"
,
"BC"
);
encryptor
.
init
(
Cipher
.
ENCRYPT_MODE
,
secret
);
byte
[]
cryptograph
=
new
byte
[
0
];
cryptograph
=
encryptor
.
doFinal
(
byteContent
);
String
encryptedKeyId
=
Base64
.
getEncoder
().
encodeToString
(
cryptograph
);
System
.
out
.
println
(
encryptedKeyId
);
}
}
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