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
b2a47f58
Commit
b2a47f58
authored
Sep 23, 2020
by
huangjiamin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户白名单、KCP端口号
parent
d3b6e6d7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
36 deletions
+70
-36
AccountDto.java
...a/com/edgec/browserbackend/account/domain/AccountDto.java
+11
-0
IpResource.java
...a/com/edgec/browserbackend/browser/domain/IpResource.java
+5
-0
IpResourceDto.java
...a/com/edgec/browserbackend/browser/dto/IpResourceDto.java
+12
-1
IpResourceServiceImpl.java
...erbackend/browser/service/Impl/IpResourceServiceImpl.java
+42
-35
No files found.
src/main/java/com/edgec/browserbackend/account/domain/AccountDto.java
View file @
b2a47f58
...
...
@@ -42,6 +42,8 @@ public class AccountDto {
private
List
<
String
>
whiteList
=
new
ArrayList
<>();
private
List
<
String
>
userWhiteList
=
new
ArrayList
<>();
private
ShopSummary
shopSummary
;
private
IpSummary
ipSummary
;
...
...
@@ -69,6 +71,7 @@ public class AccountDto {
this
.
setToken
(
account
.
getToken
());
this
.
setPermission
(
account
.
getPermission
());
this
.
setWhiteList
(
account
.
getWhiteList
());
this
.
setUserWhiteList
(
account
.
getWhiteList
());
this
.
setQueryIpUrlList
(
account
.
getQueryIpUrlList
());
if
(
account
.
getPromotion
()
!=
null
)
{
this
.
setPromotion
(
account
.
getPromotion
());
...
...
@@ -256,4 +259,12 @@ public class AccountDto {
public
void
setPromotionCode
(
String
promotionCode
)
{
this
.
promotionCode
=
promotionCode
;
}
public
List
<
String
>
getUserWhiteList
()
{
return
userWhiteList
;
}
public
void
setUserWhiteList
(
List
<
String
>
userWhiteList
)
{
this
.
userWhiteList
=
userWhiteList
;
}
}
src/main/java/com/edgec/browserbackend/browser/domain/IpResource.java
View file @
b2a47f58
...
...
@@ -146,6 +146,11 @@ public class IpResource implements Serializable {
*/
private
int
period
;
/**
* KCP端口号
*/
private
int
secondaryProxyPort
=
-
1
;
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
{
...
...
src/main/java/com/edgec/browserbackend/browser/dto/IpResourceDto.java
View file @
b2a47f58
...
...
@@ -35,6 +35,8 @@ public class IpResourceDto {
private
String
specialLineIp
;
private
int
secondaryProxyPort
=
-
1
;
public
IpResourceDto
()
{
}
...
...
@@ -52,6 +54,7 @@ public class IpResourceDto {
this
.
password
=
ipResource
.
getPassword
();
this
.
protocol
=
ipResource
.
getProtocol
();
this
.
specialLine
=
ipResource
.
isSpecialLine
();
this
.
secondaryProxyPort
=
ipResource
.
getSecondaryProxyPort
();
if
(
CollectionUtils
.
isNotEmpty
(
shopDtos
))
{
this
.
bindShops
=
shopDtos
;
this
.
bindShop
=
shopDtos
.
get
(
0
);
...
...
@@ -63,7 +66,6 @@ public class IpResourceDto {
this
.
bindHistories
=
ipResource
.
getBindHistory
();
else
this
.
bindHistories
=
new
ArrayList
<>();
}
public
IpResourceDto
(
IpResource
ipResource
,
List
<
ShopDto
>
shopDtos
,
boolean
useHistory
,
SpecialLine
specialLine1
)
{
...
...
@@ -84,6 +86,7 @@ public class IpResourceDto {
this
.
proxyPort
=
specialLine1
.
getProxyPort
();
this
.
proxyProtocol
=
specialLine1
.
getProxyProtocol
();
this
.
specialLine
=
ipResource
.
isSpecialLine
();
this
.
secondaryProxyPort
=
ipResource
.
getSecondaryProxyPort
();
if
(
CollectionUtils
.
isNotEmpty
(
shopDtos
))
{
this
.
bindShops
=
shopDtos
;
this
.
bindShop
=
shopDtos
.
get
(
0
);
...
...
@@ -265,4 +268,12 @@ public class IpResourceDto {
public
void
setBindShop
(
ShopDto
bindShop
)
{
this
.
bindShop
=
bindShop
;
}
public
int
getSecondaryProxyPort
()
{
return
secondaryProxyPort
;
}
public
void
setSecondaryProxyPort
(
int
secondaryProxyPort
)
{
this
.
secondaryProxyPort
=
secondaryProxyPort
;
}
}
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpResourceServiceImpl.java
View file @
b2a47f58
...
...
@@ -175,9 +175,9 @@ public class IpResourceServiceImpl implements IpResourceService {
Map
<
String
,
List
<
String
>>
priceList
=
ipOptionsRepository
.
findAll
().
get
(
0
).
getIpPlatForm
();
List
<
String
>
vendorPrices
=
priceList
.
get
(
ipResourceRequestDto
.
getRegionCn
());
String
price
=
vendorPrices
.
stream
()
.
filter
(
x
->
Vendor
.
valueOf
(
ipResourceRequestDto
.
getVendor
()).
getValue
().
equals
(
x
.
substring
(
0
,
x
.
indexOf
(
"-"
))))
.
map
(
x
->
x
.
substring
(
x
.
lastIndexOf
(
"-"
)
+
1
))
.
collect
(
Collectors
.
joining
());
.
filter
(
x
->
Vendor
.
valueOf
(
ipResourceRequestDto
.
getVendor
()).
getValue
().
equals
(
x
.
substring
(
0
,
x
.
indexOf
(
"-"
))))
.
map
(
x
->
x
.
substring
(
x
.
lastIndexOf
(
"-"
)
+
1
))
.
collect
(
Collectors
.
joining
());
newprice
=
"week"
.
equals
(
ipResourceRequestDto
.
getUnit
())
?
(
Integer
.
valueOf
(
price
)
/
3
)
:
Integer
.
valueOf
(
price
);
}
...
...
@@ -357,9 +357,9 @@ public class IpResourceServiceImpl implements IpResourceService {
List
<
String
>
vendorPrices
=
ipPlatForm
.
get
(
ipResource
.
getRegionCn
());
// 计算 ip 价格
String
price
=
vendorPrices
.
stream
()
.
filter
(
vendorprice
->
ipResource
.
getVendor
().
getValue
().
equals
(
vendorprice
.
substring
(
0
,
vendorprice
.
indexOf
(
"-"
))))
.
map
(
vendorprice
->
vendorprice
.
substring
(
vendorprice
.
lastIndexOf
(
"-"
)
+
1
))
.
collect
(
Collectors
.
joining
());
.
filter
(
vendorprice
->
ipResource
.
getVendor
().
getValue
().
equals
(
vendorprice
.
substring
(
0
,
vendorprice
.
indexOf
(
"-"
))))
.
map
(
vendorprice
->
vendorprice
.
substring
(
vendorprice
.
lastIndexOf
(
"-"
)
+
1
))
.
collect
(
Collectors
.
joining
());
double
newprice1
=
ipResourceRequestDto
.
getUnit
().
equals
(
"week"
)
?
(
Integer
.
valueOf
(
price
)
/
3
)
:
Integer
.
valueOf
(
price
);
// 封装 ip 的续费 信息
...
...
@@ -398,9 +398,9 @@ public class IpResourceServiceImpl implements IpResourceService {
}
String
price
=
vendorPrices
.
stream
()
.
filter
(
vendorprice
->
ipResource
.
getVendor
().
getValue
().
equals
(
vendorprice
.
substring
(
0
,
vendorprice
.
indexOf
(
"-"
))))
.
map
(
vendorprice
->
vendorprice
.
substring
(
vendorprice
.
lastIndexOf
(
"-"
)
+
1
))
.
collect
(
Collectors
.
joining
());
.
filter
(
vendorprice
->
ipResource
.
getVendor
().
getValue
().
equals
(
vendorprice
.
substring
(
0
,
vendorprice
.
indexOf
(
"-"
))))
.
map
(
vendorprice
->
vendorprice
.
substring
(
vendorprice
.
lastIndexOf
(
"-"
)
+
1
))
.
collect
(
Collectors
.
joining
());
double
newprice1
=
ipResourceRequestDto
.
getUnit
().
equals
(
"week"
)
?
(
Integer
.
valueOf
(
price
)
/
3
)
:
Integer
.
valueOf
(
price
);
IpChargeRequestDto
ipChargeRequestDto
=
buildIpChargeRequestDto
(
ipResourceRequestDto
,
2
,
ipResourceRequestDto
.
getPayMethod
());
...
...
@@ -409,10 +409,10 @@ public class IpResourceServiceImpl implements IpResourceService {
if
(
ipResourceRequestDto
.
getUnit
().
equals
(
"week"
))
{
ipResource
.
setValidTime
(
Instant
.
ofEpochMilli
(
ipResource
.
getValidTime
()).
atZone
(
ZoneOffset
.
UTC
)
.
plusWeeks
(
finalPeriod
).
toInstant
().
toEpochMilli
());
.
plusWeeks
(
finalPeriod
).
toInstant
().
toEpochMilli
());
}
else
{
ipResource
.
setValidTime
(
Instant
.
ofEpochMilli
(
ipResource
.
getValidTime
()).
atZone
(
ZoneOffset
.
UTC
)
.
plusMonths
(
finalPeriod
).
toInstant
().
toEpochMilli
());
.
plusMonths
(
finalPeriod
).
toInstant
().
toEpochMilli
());
}
ipResourceRepository
.
save
(
ipResource
);
ipOperationResultDto
.
getSuccessList
().
add
(
x
);
...
...
@@ -639,6 +639,9 @@ public class IpResourceServiceImpl implements IpResourceService {
return
ipOperationResultDto
;
}
/**********************************************************************************
* todo - D E V E L O P M E N T *
**********************************************************************************/
@Override
public
IpPageResultDto
getIpList
(
String
username
,
int
groupType
,
int
page
,
int
amount
,
IpFilterDto
ipFilterDto
)
{
// 获取当前用户的账户
...
...
@@ -823,15 +826,19 @@ public class IpResourceServiceImpl implements IpResourceService {
return
false
;
}
/**********************************************************************************
* todo - D E V E L O P M E N T *
**********************************************************************************/
@Override
public
IpResourceDto
queryIp
(
String
username
,
IpResourceRequestDto
ipResourceRequestDto
)
{
Account
account
=
accountRepository
.
findByName
(
username
).
orElseThrow
(()
->
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
));
IpResource
ipResource
=
null
;
if
(
ipResourceRequestDto
.
getAddr
()
!=
null
&&
ipResourceRequestDto
.
getAddr
().
size
()
>
0
)
ipResource
=
ipResourceRepository
.
findByAddrAndIsDeleted
(
ipResourceRequestDto
.
getAddr
().
get
(
0
),
false
);
else
if
(
ipResourceRequestDto
.
getIpId
()
!=
null
&&
ipResourceRequestDto
.
getIpId
().
size
()
>
0
)
ipResource
=
ipResourceRepository
.
findByIdAndIsDeleted
(
ipResourceRequestDto
.
getIpId
().
get
(
0
),
false
);
else
{
else
if
(
ipResourceRequestDto
.
getIpId
()
!=
null
&&
ipResourceRequestDto
.
getIpId
().
size
()
>
0
)
{
String
s
=
ipResourceRequestDto
.
getIpId
().
get
(
0
);
ipResource
=
ipResourceRepository
.
findByIdAndIsDeleted
(
s
,
false
);
}
else
{
throw
new
ClientRequestException
(
BrowserErrorCode
.
INFORMATIONNOTCOMPELETE
);
}
...
...
@@ -977,9 +984,9 @@ public class IpResourceServiceImpl implements IpResourceService {
case
5
:
// 已分配且未过期
ipResources
=
ipResourceRepository
.
findShopIdInList
(
shopIds
,
false
)
.
stream
()
.
filter
(
x
->
x
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
.
collect
(
Collectors
.
toList
());
.
stream
()
.
filter
(
x
->
x
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
.
collect
(
Collectors
.
toList
());
if
(!
isParent
)
notUsed
=
ipResourceRepository
.
findByOwnerAndStatusInAndIsDeletedAndBind
(
username
,
Arrays
.
asList
(
0
,
2
,
4
,
8
),
false
,
false
);
else
...
...
@@ -1043,24 +1050,24 @@ public class IpResourceServiceImpl implements IpResourceService {
private
AtomicReference
<
Double
>
getDoubleAtomicReference
(
IpResourceRequestDto
ipResourceRequestDto
,
Map
<
String
,
List
<
String
>>
ipPlatForm
)
{
AtomicReference
<
Double
>
totalprice
=
new
AtomicReference
<>((
double
)
0
);
ipResourceRequestDto
.
getAddr
().
stream
()
.
map
(
x
->
ipResourceRepository
.
findByAddrAndIsDeleted
(
x
,
false
))
.
forEach
(
ipResource
->
{
List
<
String
>
regionAndPriceInfos
;
if
(!
ipResourceRequestDto
.
getVendor
().
equals
(
"own"
))
{
regionAndPriceInfos
=
ipPlatForm
.
get
(
ipResource
.
getRegionCn
());
}
else
{
regionAndPriceInfos
=
ipResource
.
isSpecialLine
()
?
ipPlatForm
.
get
(
"自有专线"
)
:
ipPlatForm
.
get
(
"自有"
);
}
for
(
String
vendorprice
:
regionAndPriceInfos
)
{
if
(
ipResource
.
getVendor
().
getValue
().
equals
(
vendorprice
.
substring
(
0
,
vendorprice
.
indexOf
(
"-"
))))
totalprice
.
updateAndGet
(
v
->
new
Double
(
v
+
Double
.
valueOf
(
vendorprice
.
substring
(
vendorprice
.
lastIndexOf
(
"-"
)
+
1
)))
);
}
}
);
.
map
(
x
->
ipResourceRepository
.
findByAddrAndIsDeleted
(
x
,
false
))
.
forEach
(
ipResource
->
{
List
<
String
>
regionAndPriceInfos
;
if
(!
ipResourceRequestDto
.
getVendor
().
equals
(
"own"
))
{
regionAndPriceInfos
=
ipPlatForm
.
get
(
ipResource
.
getRegionCn
());
}
else
{
regionAndPriceInfos
=
ipResource
.
isSpecialLine
()
?
ipPlatForm
.
get
(
"自有专线"
)
:
ipPlatForm
.
get
(
"自有"
);
}
for
(
String
vendorprice
:
regionAndPriceInfos
)
{
if
(
ipResource
.
getVendor
().
getValue
().
equals
(
vendorprice
.
substring
(
0
,
vendorprice
.
indexOf
(
"-"
))))
totalprice
.
updateAndGet
(
v
->
new
Double
(
v
+
Double
.
valueOf
(
vendorprice
.
substring
(
vendorprice
.
lastIndexOf
(
"-"
)
+
1
)))
);
}
}
);
return
totalprice
;
}
...
...
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