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
0cbfbe94
Commit
0cbfbe94
authored
Jul 16, 2020
by
xuxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
未绑定店铺的信息获取
parent
18f61d97
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
181 additions
and
333 deletions
+181
-333
IpResource.java
...a/com/edgec/browserbackend/browser/domain/IpResource.java
+93
-6
IpResourceUnwindResultDto.java
...browserbackend/browser/dto/IpResourceUnwindResultDto.java
+60
-265
IpResourceRepositoryCustomImpl.java
...nd/browser/repository/IpResourceRepositoryCustomImpl.java
+28
-62
No files found.
src/main/java/com/edgec/browserbackend/browser/domain/IpResource.java
View file @
0cbfbe94
...
...
@@ -21,42 +21,129 @@ public class IpResource implements Serializable {
@Id
private
String
id
;
/**
* ip 地址
*/
private
String
addr
;
/**
* ip 类型,默认是 ip代理 模式
*/
private
IpType
ipType
=
IpType
.
VENDOR
;
/**
* ip 的具体代理使用
*/
private
Vendor
vendor
;
private
String
vendorCn
;
/**
* ip 地域
*/
private
String
region
;
private
String
regionCn
;
//0:正常, 1:已过期, 2:即将过期, 3:正在分配, 4:未使用, 5:已失效, 6:未分配, 7:未缴费, 8:分配成功
/**
* ip 的状态
* 0:正常, 1:已过期, 2:即将过期, 3:正在分配, 4:未使用, 5:已失效, 6:未分配, 7:未缴费, 8:分配成功
*/
private
int
status
;
/**
* ip 端口号
*/
private
List
<
String
>
port
;
/**
* ip的购买时间点
*/
private
long
purchasedTime
;
/**
* ip的过期的时间点
*/
private
long
validTime
;
private
String
details
;
/**
* ip的绑定历史
*/
private
List
<
BindHistory
>
bindHistory
=
new
ArrayList
<>();
/**
* ip的状态
* 当 ip 资源过期的时候,系统不会直接删除 ip 资源,而是将 isDeleted 设置为 true
* 过期7天后再删除这个ip资源
*/
private
boolean
isDeleted
;
/**
* 如果 使用的 ip 资源 是在我们系统申请的,则默认为 fangguanlianbrowser
*/
private
String
username
;
/**
* ip 资源的购买者(拥有者)
*/
private
String
owner
;
private
String
userParent
;
/**
* ip访问协议
*/
private
List
<
String
>
protocol
;
private
String
password
;
private
double
price
;
private
boolean
specialLine
;
//是否使用专线
private
boolean
usingSpecialLine
;
//是否正在使用专线
//专线数据
private
String
proxyUsername
;
//专线的代理用户名
private
String
proxyPassword
;
//专线的代理密码
/**
* 是否使用专线
*/
private
boolean
specialLine
;
/**
* 是否正在使用专线
*/
private
boolean
usingSpecialLine
;
/**
* 专线的代理用户名
*/
private
String
proxyUsername
;
/**
* 专线的代理密码
*/
private
String
proxyPassword
;
/**
* ip 资源绑定的 商铺号
*/
private
String
shopId
;
private
List
<
String
>
shopIds
=
new
ArrayList
<>();
/**
* 绑定状态
*/
private
boolean
bind
;
private
boolean
isLocked
;
private
long
lockTimestamp
;
private
long
healthLockTimestamp
;
/**
* 购买方式(按月、按周)
*/
private
String
unit
;
/**
* 购买数量
* 例如 购买了 2 个月 的 ip资源,则
* period:2
* unit:month
*/
private
int
period
;
@Override
...
...
src/main/java/com/edgec/browserbackend/browser/dto/IpResourceUnwindResultDto.java
View file @
0cbfbe94
...
...
@@ -4,11 +4,15 @@ import com.edgec.browserbackend.browser.domain.BindHistory;
import
com.edgec.browserbackend.browser.domain.IpResource
;
import
com.edgec.browserbackend.browser.domain.IpType
;
import
com.edgec.browserbackend.browser.domain.Vendor
;
import
org.springframework.data.annotation.Id
;
import
lombok.Getter
;
import
lombok.Setter
;
import
org.springframework.util.StringUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
@Getter
@Setter
public
class
IpResourceUnwindResultDto
{
private
String
id
;
private
String
addr
;
...
...
@@ -39,6 +43,13 @@ public class IpResourceUnwindResultDto {
private
String
proxyPassword
;
//专线的代理密码
private
String
shopId
;
/**
* 对应 IpResource 中 shopIds 的展开字段
*/
private
String
shopIds
;
private
boolean
bind
;
private
boolean
isLocked
;
...
...
@@ -49,299 +60,83 @@ public class IpResourceUnwindResultDto {
private
int
period
;
public
String
getDetails
()
{
return
details
;
}
public
void
setDetails
(
String
details
)
{
this
.
details
=
details
;
}
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getRegion
()
{
return
region
;
}
public
void
setRegion
(
String
region
)
{
this
.
region
=
region
;
}
public
String
getRegionCn
()
{
return
regionCn
;
}
public
void
setRegionCn
(
String
regionCn
)
{
this
.
regionCn
=
regionCn
;
}
public
int
getStatus
()
{
return
status
;
}
public
void
setStatus
(
int
status
)
{
this
.
status
=
status
;
}
public
IpType
getIpType
()
{
return
ipType
;
}
public
void
setIpType
(
IpType
ipType
)
{
this
.
ipType
=
ipType
;
}
public
List
<
BindHistory
>
getBindHistory
()
{
return
bindHistory
;
}
public
void
setBindHistory
(
List
<
BindHistory
>
bindHistory
)
{
this
.
bindHistory
=
bindHistory
;
}
public
long
getPurchasedTime
()
{
return
purchasedTime
;
}
public
void
setPurchasedTime
(
long
purchasedTime
)
{
this
.
purchasedTime
=
purchasedTime
;
}
public
long
getValidTime
()
{
return
validTime
;
}
public
void
setValidTime
(
long
validTime
)
{
this
.
validTime
=
validTime
;
}
public
Vendor
getVendor
()
{
return
vendor
;
}
public
void
setVendor
(
Vendor
vendor
)
{
this
.
vendor
=
vendor
;
}
public
boolean
isDeleted
()
{
return
isDeleted
;
}
public
void
setDeleted
(
boolean
deleted
)
{
isDeleted
=
deleted
;
}
public
String
getUsername
()
{
return
username
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
List
<
String
>
getPort
()
{
return
port
;
}
public
void
setPort
(
List
<
String
>
port
)
{
this
.
port
=
port
;
}
public
String
getAddr
()
{
return
addr
;
}
public
void
setAddr
(
String
addr
)
{
this
.
addr
=
addr
;
}
public
String
getUserParent
()
{
return
userParent
;
}
public
void
setUserParent
(
String
userParent
)
{
this
.
userParent
=
userParent
;
}
public
List
<
String
>
getProtocol
()
{
return
protocol
;
}
public
void
setProtocol
(
List
<
String
>
protocol
)
{
this
.
protocol
=
protocol
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
String
getOwner
()
{
return
owner
;
}
public
void
setOwner
(
String
owner
)
{
this
.
owner
=
owner
;
}
public
boolean
isLocked
()
{
return
isLocked
;
}
public
void
setLocked
(
boolean
locked
)
{
isLocked
=
locked
;
}
public
long
getLockTimestamp
()
{
return
lockTimestamp
;
}
public
void
setLockTimestamp
(
long
lockTimestamp
)
{
this
.
lockTimestamp
=
lockTimestamp
;
}
public
String
getUnit
()
{
return
unit
;
}
public
void
setUnit
(
String
unit
)
{
this
.
unit
=
unit
;
}
public
int
getPeriod
()
{
return
period
;
}
public
void
setPeriod
(
int
period
)
{
this
.
period
=
period
;
}
public
double
getPrice
()
{
return
price
;
}
public
void
setPrice
(
double
price
)
{
this
.
price
=
price
;
}
public
String
getShopId
()
{
return
shopId
;
}
public
void
setShopId
(
String
shopId
)
{
this
.
shopId
=
shopId
;
}
public
String
getVendorCn
()
{
return
vendorCn
;
}
public
void
setVendorCn
(
String
vendorCn
)
{
this
.
vendorCn
=
vendorCn
;
}
public
String
getProxyPassword
()
{
return
proxyPassword
;
}
public
void
setProxyPassword
(
String
proxyPassword
)
{
this
.
proxyPassword
=
proxyPassword
;
}
public
String
getProxyUsername
()
{
return
proxyUsername
;
}
public
void
setProxyUsername
(
String
proxyUsername
)
{
this
.
proxyUsername
=
proxyUsername
;
}
public
boolean
isSpecialLine
()
{
return
specialLine
;
}
public
void
setSpecialLine
(
boolean
specialLine
)
{
this
.
specialLine
=
specialLine
;
}
public
long
getHealthLockTimestamp
()
{
return
healthLockTimestamp
;
}
public
void
setHealthLockTimestamp
(
long
healthLockTimestamp
)
{
this
.
healthLockTimestamp
=
healthLockTimestamp
;
}
public
boolean
isUsingSpecialLine
()
{
return
usingSpecialLine
;
}
public
void
setUsingSpecialLine
(
boolean
usingSpecialLine
)
{
this
.
usingSpecialLine
=
usingSpecialLine
;
}
public
boolean
isBind
()
{
return
bind
;
}
public
void
setBind
(
boolean
bind
)
{
this
.
bind
=
bind
;
}
public
IpResource
toResource
()
{
IpResource
ipResource
=
new
IpResource
();
ipResource
.
setId
(
getId
());
if
(
shopId
!=
null
)
ipResource
.
getShopIds
().
add
(
getShopId
());
if
(!
StringUtils
.
isEmpty
(
getShopIds
()))
{
ipResource
.
setShopId
(
getShopIds
());
ipResource
.
getShopIds
().
add
(
getShopIds
());
}
ipResource
.
setHealthLockTimestamp
(
getHealthLockTimestamp
());
ipResource
.
setUsingSpecialLine
(
isUsingSpecialLine
());
ipResource
.
setPeriod
(
getPeriod
());
ipResource
.
setSpecialLine
(
isSpecialLine
());
if
(
addr
!=
null
)
if
(
addr
!=
null
)
{
ipResource
.
setAddr
(
getAddr
());
}
ipResource
.
setStatus
(
getStatus
());
if
(
proxyPassword
!=
null
)
if
(
proxyPassword
!=
null
)
{
ipResource
.
setProxyPassword
(
getProxyPassword
());
if
(
proxyUsername
!=
null
)
}
if
(
proxyUsername
!=
null
)
{
ipResource
.
setProxyUsername
(
getProxyUsername
());
}
ipResource
.
setLockTimestamp
(
getLockTimestamp
());
if
(
username
!=
null
)
if
(
username
!=
null
)
{
ipResource
.
setUsername
(
getUsername
());
if
(
regionCn
!=
null
)
}
if
(
regionCn
!=
null
)
{
ipResource
.
setRegionCn
(
getRegionCn
());
if
(
vendorCn
!=
null
)
}
if
(
vendorCn
!=
null
)
{
ipResource
.
setVendorCn
(
getVendorCn
());
if
(
password
!=
null
)
}
if
(
password
!=
null
)
{
ipResource
.
setPassword
(
getPassword
());
if
(
unit
!=
null
)
}
if
(
unit
!=
null
)
{
ipResource
.
setUnit
(
getUnit
());
}
ipResource
.
setLocked
(
isLocked
());
ipResource
.
setValidTime
(
getValidTime
());
if
(
bindHistory
!=
null
)
if
(
bindHistory
!=
null
)
{
ipResource
.
setBindHistory
(
getBindHistory
());
}
ipResource
.
setDeleted
(
isDeleted
());
if
(
owner
!=
null
)
if
(
owner
!=
null
)
{
ipResource
.
setOwner
(
getOwner
());
if
(
protocol
!=
null
)
}
if
(
protocol
!=
null
)
{
ipResource
.
setProtocol
(
getProtocol
());
if
(
userParent
!=
null
)
}
if
(
userParent
!=
null
)
{
ipResource
.
setUserParent
(
getUserParent
());
}
ipResource
.
setPurchasedTime
(
getPurchasedTime
());
ipResource
.
setIpType
(
getIpType
());
if
(
port
!=
null
)
if
(
port
!=
null
)
{
ipResource
.
setPort
(
getPort
());
}
ipResource
.
setPrice
(
getPrice
());
if
(
details
!=
null
)
if
(
details
!=
null
)
{
ipResource
.
setDetails
(
getDetails
());
}
return
ipResource
;
}
}
src/main/java/com/edgec/browserbackend/browser/repository/IpResourceRepositoryCustomImpl.java
View file @
0cbfbe94
...
...
@@ -161,79 +161,52 @@ public class IpResourceRepositoryCustomImpl implements IpResourceRepositoryCusto
@Override
public
List
<
IpResource
>
findShopIdInList
(
List
<
String
>
shopIds
,
boolean
isDeleted
)
{
MatchOperation
matchOperation
=
Aggregation
.
match
(
where
(
"isDeleted"
).
is
(
isDeleted
));
return
getResult
(
matchOperation
,
shopIds
);
}
@Override
public
List
<
IpResource
>
findShopIdInListAndStatus
(
List
<
String
>
shopIds
,
boolean
isDeleted
,
int
status
)
{
MatchOperation
matchOperation
=
Aggregation
.
match
(
where
(
"isDeleted"
).
is
(
isDeleted
).
and
(
"status"
).
is
(
status
));
return
getResult
(
matchOperation
,
shopIds
);
}
@Override
public
List
<
IpResource
>
findShopIdInListAndRegionLike
(
List
<
String
>
shopIds
,
boolean
isDeleted
,
String
region
)
{
MatchOperation
matchOperation
=
Aggregation
.
match
(
where
(
"isDeleted"
).
is
(
isDeleted
).
and
(
"regionCn"
).
regex
(
".*?\\"
+
region
+
".*"
));
return
getResult
(
matchOperation
,
shopIds
);
}
@Override
public
List
<
IpResource
>
findIds
()
{
BasicQuery
basicQuery
=
new
BasicQuery
(
new
Document
());
basicQuery
.
fields
().
include
(
"id"
);
return
mongoTemplate
.
find
(
basicQuery
,
IpResource
.
class
);
}
private
List
<
IpResource
>
getResult
(
MatchOperation
matchOperation
,
List
<
String
>
shopIds
)
{
UnwindOperation
unwind
=
Aggregation
.
unwind
(
"shopIds"
);
MatchOperation
matchshopId
=
Aggregation
.
match
(
where
(
"shopIds"
).
in
(
shopIds
));
List
<
IpResourceUnwindResultDto
>
ipResourceUnwindResultDtos
=
mongoTemplate
.
aggregate
(
Aggregation
.
newAggregation
(
matchOperation
,
unwind
,
matchshopId
),
IpResource
.
class
,
IpResourceUnwindResultDto
.
class
).
getMappedResults
();
List
<
IpResource
>
result
=
new
ArrayList
<>();
if
(
ipResourceUnwindResultDtos
.
isEmpty
())
{
return
new
ArrayList
<>()
;
return
result
;
}
HashMap
<
String
,
IpResource
>
ipResourceHashMap
=
new
HashMap
<>();
ipResourceUnwindResultDtos
.
forEach
(
x
->
{
if
(
ipResourceHashMap
.
containsKey
(
x
.
getId
()))
{
ipResourceHashMap
.
get
(
x
.
getId
()).
getShopIds
().
add
(
x
.
getShopId
());
ipResourceHashMap
.
get
(
x
.
getId
()).
getShopIds
().
add
(
x
.
getShopId
s
());
}
else
{
ipResourceHashMap
.
put
(
x
.
getId
(),
x
.
toResource
());
}
}
);
List
<
IpResource
>
result
=
new
ArrayList
<>();
Set
<
Map
.
Entry
<
String
,
IpResource
>>
entry
=
ipResourceHashMap
.
entrySet
();
for
(
Map
.
Entry
<
String
,
IpResource
>
e
:
entry
)
{
result
.
add
(
e
.
getValue
());
}
return
result
;
}
@Override
public
List
<
IpResource
>
findShopIdInListAndStatus
(
List
<
String
>
shopIds
,
boolean
isDeleted
,
int
status
)
{
MatchOperation
matchOperation
=
Aggregation
.
match
(
where
(
"isDeleted"
).
is
(
isDeleted
).
and
(
"status"
).
is
(
status
));
UnwindOperation
unwind
=
Aggregation
.
unwind
(
"shopIds"
);
MatchOperation
matchshopId
=
Aggregation
.
match
(
where
(
"shopIds"
).
in
(
shopIds
));
List
<
IpResourceUnwindResultDto
>
ipResourceUnwindResultDtos
=
mongoTemplate
.
aggregate
(
Aggregation
.
newAggregation
(
matchOperation
,
unwind
,
matchshopId
),
IpResource
.
class
,
IpResourceUnwindResultDto
.
class
).
getMappedResults
();
if
(
ipResourceUnwindResultDtos
.
isEmpty
())
{
return
new
ArrayList
<>();
}
HashMap
<
String
,
IpResource
>
ipResourceHashMap
=
new
HashMap
<>();
ipResourceUnwindResultDtos
.
forEach
(
x
->
{
if
(
ipResourceHashMap
.
containsKey
(
x
.
getId
()))
{
ipResourceHashMap
.
get
(
x
.
getId
()).
getShopIds
().
add
(
x
.
getShopId
());
}
else
{
ipResourceHashMap
.
put
(
x
.
getId
(),
x
.
toResource
());
}
});
List
<
IpResource
>
result
=
new
ArrayList
<>();
Set
<
Map
.
Entry
<
String
,
IpResource
>>
entry
=
ipResourceHashMap
.
entrySet
();
for
(
Map
.
Entry
<
String
,
IpResource
>
e
:
entry
)
{
result
.
add
(
e
.
getValue
());
}
return
result
;
}
@Override
public
List
<
IpResource
>
findShopIdInListAndRegionLike
(
List
<
String
>
shopIds
,
boolean
isDeleted
,
String
region
)
{
MatchOperation
matchOperation
=
Aggregation
.
match
(
where
(
"isDeleted"
).
is
(
isDeleted
).
and
(
"regionCn"
).
regex
(
".*?\\"
+
region
+
".*"
));
UnwindOperation
unwind
=
Aggregation
.
unwind
(
"shopIds"
);
MatchOperation
matchshopId
=
Aggregation
.
match
(
where
(
"shopIds"
).
in
(
shopIds
));
List
<
IpResourceUnwindResultDto
>
ipResourceUnwindResultDtos
=
mongoTemplate
.
aggregate
(
Aggregation
.
newAggregation
(
matchOperation
,
unwind
,
matchshopId
),
IpResource
.
class
,
IpResourceUnwindResultDto
.
class
).
getMappedResults
();
if
(
ipResourceUnwindResultDtos
.
isEmpty
())
{
return
new
ArrayList
<>();
}
HashMap
<
String
,
IpResource
>
ipResourceHashMap
=
new
HashMap
<>();
ipResourceUnwindResultDtos
.
forEach
(
x
->
{
if
(
ipResourceHashMap
.
containsKey
(
x
.
getId
()))
{
ipResourceHashMap
.
get
(
x
.
getId
()).
getShopIds
().
add
(
x
.
getShopId
());
}
else
{
ipResourceHashMap
.
put
(
x
.
getId
(),
x
.
toResource
());
}
});
List
<
IpResource
>
result
=
new
ArrayList
<>();
Set
<
Map
.
Entry
<
String
,
IpResource
>>
entry
=
ipResourceHashMap
.
entrySet
();
for
(
Map
.
Entry
<
String
,
IpResource
>
e
:
entry
)
{
result
.
add
(
e
.
getValue
());
...
...
@@ -241,12 +214,5 @@ public class IpResourceRepositoryCustomImpl implements IpResourceRepositoryCusto
return
result
;
}
@Override
public
List
<
IpResource
>
findIds
()
{
BasicQuery
basicQuery
=
new
BasicQuery
(
new
Document
());
basicQuery
.
fields
().
include
(
"id"
);
return
mongoTemplate
.
find
(
basicQuery
,
IpResource
.
class
);
}
}
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