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
70d76bbd
Commit
70d76bbd
authored
May 27, 2020
by
renjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-zrj' into 'staging'
共有ip修改 See merge request
!139
parents
ea679c63
869ec8ce
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
864 additions
and
131 deletions
+864
-131
IpResource.java
...a/com/edgec/browserbackend/browser/domain/IpResource.java
+14
-14
IpResourceDto.java
...a/com/edgec/browserbackend/browser/dto/IpResourceDto.java
+26
-10
IpResourceUnwindResultDto.java
...browserbackend/browser/dto/IpResourceUnwindResultDto.java
+347
-0
ShopResultDto.java
...a/com/edgec/browserbackend/browser/dto/ShopResultDto.java
+35
-4
IpResourceRepository.java
...owserbackend/browser/repository/IpResourceRepository.java
+9
-10
IpResourceRepositoryCustom.java
...ackend/browser/repository/IpResourceRepositoryCustom.java
+15
-0
IpResourceRepositoryCustomImpl.java
...nd/browser/repository/IpResourceRepositoryCustomImpl.java
+143
-6
ShopRepository.java
...gec/browserbackend/browser/repository/ShopRepository.java
+1
-0
IpAndShopServiceImpl.java
...serbackend/browser/service/Impl/IpAndShopServiceImpl.java
+52
-13
IpResourceServiceImpl.java
...erbackend/browser/service/Impl/IpResourceServiceImpl.java
+55
-52
ShopServiceImpl.java
.../browserbackend/browser/service/Impl/ShopServiceImpl.java
+19
-17
IpAndShopService.java
...dgec/browserbackend/browser/service/IpAndShopService.java
+2
-0
BrowserTask.java
...va/com/edgec/browserbackend/browser/task/BrowserTask.java
+8
-5
JsonUtils.java
...java/com/edgec/browserbackend/common/utils/JsonUtils.java
+138
-0
No files found.
src/main/java/com/edgec/browserbackend/browser/domain/IpResource.java
View file @
70d76bbd
...
@@ -42,8 +42,8 @@ public class IpResource implements Serializable {
...
@@ -42,8 +42,8 @@ public class IpResource implements Serializable {
private
String
proxyUsername
;
//专线的代理用户名
private
String
proxyUsername
;
//专线的代理用户名
private
String
proxyPassword
;
//专线的代理密码
private
String
proxyPassword
;
//专线的代理密码
private
String
shopId
;
private
List
<
String
>
shopIds
=
new
ArrayList
<>()
;
private
String
shopName
;
private
boolean
bind
;
private
boolean
isLocked
;
private
boolean
isLocked
;
private
long
lockTimestamp
;
private
long
lockTimestamp
;
...
@@ -239,20 +239,12 @@ public class IpResource implements Serializable {
...
@@ -239,20 +239,12 @@ public class IpResource implements Serializable {
this
.
price
=
price
;
this
.
price
=
price
;
}
}
public
String
getShopId
()
{
public
List
<
String
>
getShopIds
()
{
return
shopId
;
return
shopId
s
;
}
}
public
void
setShopId
(
String
shopId
)
{
public
void
setShopIds
(
List
<
String
>
shopIds
)
{
this
.
shopId
=
shopId
;
this
.
shopIds
=
shopIds
;
}
public
String
getShopName
()
{
return
shopName
;
}
public
void
setShopName
(
String
shopName
)
{
this
.
shopName
=
shopName
;
}
}
public
String
getVendorCn
()
{
public
String
getVendorCn
()
{
...
@@ -302,4 +294,12 @@ public class IpResource implements Serializable {
...
@@ -302,4 +294,12 @@ public class IpResource implements Serializable {
public
void
setUsingSpecialLine
(
boolean
usingSpecialLine
)
{
public
void
setUsingSpecialLine
(
boolean
usingSpecialLine
)
{
this
.
usingSpecialLine
=
usingSpecialLine
;
this
.
usingSpecialLine
=
usingSpecialLine
;
}
}
public
boolean
isBind
()
{
return
bind
;
}
public
void
setBind
(
boolean
bind
)
{
this
.
bind
=
bind
;
}
}
}
src/main/java/com/edgec/browserbackend/browser/dto/IpResourceDto.java
View file @
70d76bbd
...
@@ -21,7 +21,8 @@ public class IpResourceDto {
...
@@ -21,7 +21,8 @@ public class IpResourceDto {
private
String
details
;
private
String
details
;
private
String
password
;
private
String
password
;
private
List
<
String
>
protocol
;
private
List
<
String
>
protocol
;
ShopDto
bindShop
;
List
<
ShopDto
>
bindShops
;
private
ShopDto
bindShop
;
private
List
<
BindHistory
>
bindHistories
;
private
List
<
BindHistory
>
bindHistories
;
private
boolean
specialLine
;
private
boolean
specialLine
;
...
@@ -36,7 +37,7 @@ public class IpResourceDto {
...
@@ -36,7 +37,7 @@ public class IpResourceDto {
public
IpResourceDto
(){
public
IpResourceDto
(){
}
}
public
IpResourceDto
(
IpResource
ipResource
,
ShopDto
shopDto
,
boolean
useHistory
){
public
IpResourceDto
(
IpResource
ipResource
,
List
<
ShopDto
>
shopDtos
,
boolean
useHistory
){
this
.
id
=
ipResource
.
getId
();
this
.
id
=
ipResource
.
getId
();
this
.
addr
=
ipResource
.
getAddr
();
this
.
addr
=
ipResource
.
getAddr
();
this
.
vendor
=
ipResource
.
getVendor
();
this
.
vendor
=
ipResource
.
getVendor
();
...
@@ -50,15 +51,18 @@ public class IpResourceDto {
...
@@ -50,15 +51,18 @@ public class IpResourceDto {
this
.
password
=
ipResource
.
getPassword
();
this
.
password
=
ipResource
.
getPassword
();
this
.
protocol
=
ipResource
.
getProtocol
();
this
.
protocol
=
ipResource
.
getProtocol
();
this
.
specialLine
=
ipResource
.
isSpecialLine
();
this
.
specialLine
=
ipResource
.
isSpecialLine
();
if
(
shopDto
!=
null
)
if
(
shopDtos
!=
null
)
this
.
bindShop
=
shopDto
;
this
.
bindShops
=
shopDtos
;
else
this
.
bindShops
=
new
ArrayList
<>();
if
(
useHistory
)
if
(
useHistory
)
this
.
bindHistories
=
ipResource
.
getBindHistory
();
this
.
bindHistories
=
ipResource
.
getBindHistory
();
else
else
this
.
bindHistories
=
new
ArrayList
<>();
this
.
bindHistories
=
new
ArrayList
<>();
this
.
bindShop
=
new
ShopDto
();
}
}
public
IpResourceDto
(
IpResource
ipResource
,
ShopDto
shopDto
,
boolean
useHistory
,
SpecialLine
specialLine1
){
public
IpResourceDto
(
IpResource
ipResource
,
List
<
ShopDto
>
shopDtos
,
boolean
useHistory
,
SpecialLine
specialLine1
){
this
.
id
=
ipResource
.
getId
();
this
.
id
=
ipResource
.
getId
();
this
.
addr
=
ipResource
.
getAddr
();
this
.
addr
=
ipResource
.
getAddr
();
this
.
vendor
=
ipResource
.
getVendor
();
this
.
vendor
=
ipResource
.
getVendor
();
...
@@ -76,12 +80,16 @@ public class IpResourceDto {
...
@@ -76,12 +80,16 @@ public class IpResourceDto {
this
.
proxyPort
=
specialLine1
.
getProxyPort
();
this
.
proxyPort
=
specialLine1
.
getProxyPort
();
this
.
proxyProtocol
=
specialLine1
.
getProxyProtocol
();
this
.
proxyProtocol
=
specialLine1
.
getProxyProtocol
();
this
.
specialLine
=
ipResource
.
isSpecialLine
();
this
.
specialLine
=
ipResource
.
isSpecialLine
();
this
.
bindShop
=
shopDto
;
if
(
shopDtos
!=
null
)
this
.
bindShops
=
shopDtos
;
else
this
.
bindShops
=
new
ArrayList
<>();
this
.
specialLineIp
=
specialLine1
.
getIp
();
this
.
specialLineIp
=
specialLine1
.
getIp
();
if
(
useHistory
)
if
(
useHistory
)
this
.
bindHistories
=
ipResource
.
getBindHistory
();
this
.
bindHistories
=
ipResource
.
getBindHistory
();
else
else
this
.
bindHistories
=
new
ArrayList
<>();
this
.
bindHistories
=
new
ArrayList
<>();
this
.
bindShop
=
new
ShopDto
();
}
}
public
String
getId
()
{
public
String
getId
()
{
...
@@ -172,12 +180,12 @@ public class IpResourceDto {
...
@@ -172,12 +180,12 @@ public class IpResourceDto {
this
.
password
=
password
;
this
.
password
=
password
;
}
}
public
ShopDto
getBindShop
()
{
public
List
<
ShopDto
>
getBindShops
()
{
return
bindShop
;
return
bindShop
s
;
}
}
public
void
setBindShop
(
ShopDto
bindShop
)
{
public
void
setBindShop
s
(
List
<
ShopDto
>
bindShops
)
{
this
.
bindShop
=
bindShop
;
this
.
bindShop
s
=
bindShops
;
}
}
public
List
<
String
>
getProtocol
()
{
public
List
<
String
>
getProtocol
()
{
...
@@ -243,4 +251,12 @@ public class IpResourceDto {
...
@@ -243,4 +251,12 @@ public class IpResourceDto {
public
void
setProxyPort
(
List
<
String
>
proxyPort
)
{
public
void
setProxyPort
(
List
<
String
>
proxyPort
)
{
this
.
proxyPort
=
proxyPort
;
this
.
proxyPort
=
proxyPort
;
}
}
public
ShopDto
getBindShop
()
{
return
bindShop
;
}
public
void
setBindShop
(
ShopDto
bindShop
)
{
this
.
bindShop
=
bindShop
;
}
}
}
src/main/java/com/edgec/browserbackend/browser/dto/IpResourceUnwindResultDto.java
0 → 100644
View file @
70d76bbd
package
com
.
edgec
.
browserbackend
.
browser
.
dto
;
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
java.util.ArrayList
;
import
java.util.List
;
public
class
IpResourceUnwindResultDto
{
private
String
id
;
private
String
addr
;
private
IpType
ipType
=
IpType
.
VENDOR
;
private
Vendor
vendor
;
private
String
vendorCn
;
private
String
region
;
private
String
regionCn
;
//0:正常, 1:已过期, 2:即将过期, 3:正在分配, 4:未使用, 5:已失效, 6:未分配, 7:未缴费, 8:分配成功
private
int
status
;
private
List
<
String
>
port
;
private
long
purchasedTime
;
private
long
validTime
;
private
String
details
;
private
List
<
BindHistory
>
bindHistory
=
new
ArrayList
<>();
private
boolean
isDeleted
;
private
String
username
;
private
String
owner
;
private
String
userParent
;
private
List
<
String
>
protocol
;
private
String
password
;
private
double
price
;
private
boolean
specialLine
;
//是否使用专线
private
boolean
usingSpecialLine
;
//是否正在使用专线
//专线数据
private
String
proxyUsername
;
//专线的代理用户名
private
String
proxyPassword
;
//专线的代理密码
private
String
shopId
;
private
boolean
bind
;
private
boolean
isLocked
;
private
long
lockTimestamp
;
private
long
healthLockTimestamp
;
private
String
unit
;
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
());
ipResource
.
setHealthLockTimestamp
(
getHealthLockTimestamp
());
ipResource
.
setUsingSpecialLine
(
isUsingSpecialLine
());
ipResource
.
setPeriod
(
getPeriod
());
ipResource
.
setSpecialLine
(
isSpecialLine
());
if
(
addr
!=
null
)
ipResource
.
setAddr
(
getAddr
());
ipResource
.
setStatus
(
getStatus
());
if
(
proxyPassword
!=
null
)
ipResource
.
setProxyPassword
(
getProxyPassword
());
if
(
proxyUsername
!=
null
)
ipResource
.
setProxyUsername
(
getProxyUsername
());
ipResource
.
setLockTimestamp
(
getLockTimestamp
());
if
(
username
!=
null
)
ipResource
.
setUsername
(
getUsername
());
if
(
regionCn
!=
null
)
ipResource
.
setRegionCn
(
getRegionCn
());
if
(
vendorCn
!=
null
)
ipResource
.
setVendorCn
(
getVendorCn
());
if
(
password
!=
null
)
ipResource
.
setPassword
(
getPassword
());
if
(
unit
!=
null
)
ipResource
.
setUnit
(
getUnit
());
ipResource
.
setLocked
(
isLocked
());
ipResource
.
setValidTime
(
getValidTime
());
if
(
bindHistory
!=
null
)
ipResource
.
setBindHistory
(
getBindHistory
());
ipResource
.
setDeleted
(
isDeleted
());
if
(
owner
!=
null
)
ipResource
.
setOwner
(
getOwner
());
if
(
protocol
!=
null
)
ipResource
.
setProtocol
(
getProtocol
());
if
(
userParent
!=
null
)
ipResource
.
setUserParent
(
getUserParent
());
ipResource
.
setPurchasedTime
(
getPurchasedTime
());
ipResource
.
setIpType
(
getIpType
());
if
(
port
!=
null
)
ipResource
.
setPort
(
getPort
());
ipResource
.
setPrice
(
getPrice
());
if
(
details
!=
null
)
ipResource
.
setDetails
(
getDetails
());
return
ipResource
;
}
}
src/main/java/com/edgec/browserbackend/browser/dto/ShopResultDto.java
View file @
70d76bbd
...
@@ -6,6 +6,10 @@ import com.edgec.browserbackend.browser.domain.Shop;
...
@@ -6,6 +6,10 @@ import com.edgec.browserbackend.browser.domain.Shop;
import
com.edgec.browserbackend.browser.domain.TransferStatus
;
import
com.edgec.browserbackend.browser.domain.TransferStatus
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonObject
;
import
org.elasticsearch.client.license.LicensesStatus
;
import
java.util.ArrayList
;
import
java.util.List
;
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
ShopResultDto
{
public
class
ShopResultDto
{
...
@@ -32,11 +36,11 @@ public class ShopResultDto {
...
@@ -32,11 +36,11 @@ public class ShopResultDto {
private
String
shopCookie
;
private
String
shopCookie
;
private
IpResourceDto
bindIp
;
private
List
<
IpResourceDto
>
bindIp
=
new
ArrayList
<>()
;
private
long
createTime
;
private
long
createTime
;
public
static
ShopResultDto
of
(
Shop
shop
,
String
group
,
IpResourceDto
ipResources
)
{
public
static
ShopResultDto
of
(
Shop
shop
,
String
group
,
List
<
IpResourceDto
>
ipResources
)
{
ShopResultDto
shopResultDto
=
new
ShopResultDto
();
ShopResultDto
shopResultDto
=
new
ShopResultDto
();
shopResultDto
.
setShopId
(
shop
.
getShopId
());
shopResultDto
.
setShopId
(
shop
.
getShopId
());
if
(
shop
.
getShopName
()
!=
null
)
if
(
shop
.
getShopName
()
!=
null
)
...
@@ -63,6 +67,33 @@ public class ShopResultDto {
...
@@ -63,6 +67,33 @@ public class ShopResultDto {
return
shopResultDto
;
return
shopResultDto
;
}
}
public
static
ShopResultDto
of
(
Shop
shop
,
String
group
,
IpResourceDto
ipResource
)
{
ShopResultDto
shopResultDto
=
new
ShopResultDto
();
shopResultDto
.
setShopId
(
shop
.
getShopId
());
if
(
shop
.
getShopName
()
!=
null
)
shopResultDto
.
setShopName
(
shop
.
getShopName
());
if
(
shop
.
getShopPlatform
()
!=
null
)
shopResultDto
.
setShopPlatform
(
shop
.
getShopPlatform
());
if
(
shop
.
getShopPassword
()
!=
null
)
shopResultDto
.
setShopPassword
(
shop
.
getShopPassword
());
if
(
shop
.
getTransferStatus
()
!=
null
)
shopResultDto
.
setTransferStatus
(
shop
.
getTransferStatus
());
if
(
shop
.
getOwner
()
!=
null
)
shopResultDto
.
setOwner
(
shop
.
getOwner
());
if
(
shop
.
getShopUrl
()
!=
null
)
shopResultDto
.
setShopUrl
(
shop
.
getShopUrl
());
if
(
shop
.
getShopUA
()
!=
null
)
shopResultDto
.
setShopUA
(
shop
.
getShopUA
());
if
(
shop
.
getShopCookie
()
!=
null
)
shopResultDto
.
setShopCookie
(
shop
.
getShopCookie
());
if
(
shop
.
getShopAccount
()
!=
null
)
shopResultDto
.
setShopAccount
(
shop
.
getShopAccount
());
shopResultDto
.
setGroup
(
group
);
shopResultDto
.
getBindIp
().
add
(
ipResource
);
shopResultDto
.
setCreateTime
(
shop
.
getCreateTime
());
return
shopResultDto
;
}
public
String
getShopPlatform
()
{
public
String
getShopPlatform
()
{
return
shopPlatform
;
return
shopPlatform
;
}
}
...
@@ -135,11 +166,11 @@ public class ShopResultDto {
...
@@ -135,11 +166,11 @@ public class ShopResultDto {
this
.
shopUrl
=
shopUrl
;
this
.
shopUrl
=
shopUrl
;
}
}
public
IpResourceDto
getBindIp
()
{
public
List
<
IpResourceDto
>
getBindIp
()
{
return
bindIp
;
return
bindIp
;
}
}
public
void
setBindIp
(
IpResourceDto
bindIp
)
{
public
void
setBindIp
(
List
<
IpResourceDto
>
bindIp
)
{
this
.
bindIp
=
bindIp
;
this
.
bindIp
=
bindIp
;
}
}
...
...
src/main/java/com/edgec/browserbackend/browser/repository/IpResourceRepository.java
View file @
70d76bbd
...
@@ -17,20 +17,19 @@ public interface IpResourceRepository extends MongoRepository<IpResource, String
...
@@ -17,20 +17,19 @@ public interface IpResourceRepository extends MongoRepository<IpResource, String
IpResource
findByAddrAndIsDeleted
(
String
addr
,
boolean
isDeleted
);
IpResource
findByAddrAndIsDeleted
(
String
addr
,
boolean
isDeleted
);
IpResource
findByIdAndIsDeletedAndIsLocked
(
String
id
,
boolean
isDeleted
,
boolean
isLocked
);
IpResource
findByIdAndIsDeletedAndIsLocked
(
String
id
,
boolean
isDeleted
,
boolean
isLocked
);
IpResource
findByIdAndIsDeleted
(
String
id
,
boolean
isDeleted
);
IpResource
findByIdAndIsDeleted
(
String
id
,
boolean
isDeleted
);
List
<
IpResource
>
findByShopIdInAndIsDeleted
(
List
<
String
>
ipIds
,
boolean
isDeleted
);
Page
<
IpResource
>
findByIdInAndIsDeletedOrderByPurchasedTimeDesc
(
List
<
String
>
ipIds
,
boolean
isDeleted
,
Pageable
pageable
);
Page
<
IpResource
>
findByIdInAndIsDeletedOrderByPurchasedTimeDesc
(
List
<
String
>
ipIds
,
boolean
isDeleted
,
Pageable
pageable
);
List
<
IpResource
>
findByOwnerAndIsDeletedAnd
ShopIdIsNull
(
String
owner
,
boolean
isDelete
d
);
List
<
IpResource
>
findByOwnerAndIsDeletedAnd
Bind
(
String
owner
,
boolean
isDeleted
,
boolean
bin
d
);
List
<
IpResource
>
findByOwnerAndStatusIsNotInAndIsDeletedAnd
ShopIdIsNull
(
String
owner
,
List
<
Integer
>
status
,
boolean
isDelete
d
);
List
<
IpResource
>
findByOwnerAndStatusIsNotInAndIsDeletedAnd
Bind
(
String
owner
,
List
<
Integer
>
status
,
boolean
isDeleted
,
boolean
bin
d
);
List
<
IpResource
>
findByOwnerAndStatusAndIsDeletedAnd
ShopIdIsNull
(
String
owner
,
int
status
,
boolean
isDelete
d
);
List
<
IpResource
>
findByOwnerAndStatusAndIsDeletedAnd
Bind
(
String
owner
,
int
status
,
boolean
isDeleted
,
boolean
bin
d
);
List
<
IpResource
>
findByOwnerInAndIsDeletedAnd
ShopIdIsNull
(
List
<
String
>
owner
,
boolean
isDelete
d
);
List
<
IpResource
>
findByOwnerInAndIsDeletedAnd
Bind
(
List
<
String
>
owner
,
boolean
isDeleted
,
boolean
bin
d
);
List
<
IpResource
>
findByOwnerInAndStatusIsNotInAndIsDeletedAnd
ShopIdIsNull
(
List
<
String
>
owner
,
List
<
Integer
>
status
,
boolean
isDelete
d
);
List
<
IpResource
>
findByOwnerInAndStatusIsNotInAndIsDeletedAnd
Bind
(
List
<
String
>
owner
,
List
<
Integer
>
status
,
boolean
isDeleted
,
boolean
bin
d
);
List
<
IpResource
>
findByOwnerInAndStatusAndIsDeletedAnd
ShopIdIsNull
(
List
<
String
>
owner
,
int
status
,
boolean
isDelete
d
);
List
<
IpResource
>
findByOwnerInAndStatusAndIsDeletedAnd
Bind
(
List
<
String
>
owner
,
int
status
,
boolean
isDeleted
,
boolean
bin
d
);
List
<
IpResource
>
findByStatusAndShopIdInAndIsDeleted
(
int
status
,
List
<
String
>
ipIds
,
boolean
isDeleted
);
Page
<
IpResource
>
findByIsDeletedAndIdInAndAddrLikeOrderByPurchasedTimeDesc
(
boolean
isDeleted
,
List
<
String
>
ipIds
,
String
addr
,
Pageable
pageable
);
Page
<
IpResource
>
findByIsDeletedAndIdInAndAddrLikeOrderByPurchasedTimeDesc
(
boolean
isDeleted
,
List
<
String
>
ipIds
,
String
addr
,
Pageable
pageable
);
Page
<
IpResource
>
findByIsDeletedAndIdInAndVendorCnLikeOrderByPurchasedTimeDesc
(
boolean
isDeleted
,
List
<
String
>
ipIds
,
String
vendorCn
,
Pageable
pageable
);
Page
<
IpResource
>
findByIsDeletedAndIdInAndVendorCnLikeOrderByPurchasedTimeDesc
(
boolean
isDeleted
,
List
<
String
>
ipIds
,
String
vendorCn
,
Pageable
pageable
);
Page
<
IpResource
>
findByIsDeletedAndIdInAndVendorLikeOrderByPurchasedTimeDesc
(
boolean
isDeleted
,
List
<
String
>
ipIds
,
String
vendor
,
Pageable
pageable
);
Page
<
IpResource
>
findByIsDeletedAndIdInAndVendorLikeOrderByPurchasedTimeDesc
(
boolean
isDeleted
,
List
<
String
>
ipIds
,
String
vendor
,
Pageable
pageable
);
Page
<
IpResource
>
findByIsDeletedAndIdInAndRegionCnLikeOrderByPurchasedTimeDesc
(
boolean
isDeleted
,
List
<
String
>
ipIds
,
String
region
,
Pageable
pageable
);
Page
<
IpResource
>
findByIsDeletedAndIdInAndRegionCnLikeOrderByPurchasedTimeDesc
(
boolean
isDeleted
,
List
<
String
>
ipIds
,
String
region
,
Pageable
pageable
);
List
<
IpResource
>
findByIsDeletedAndShopIdInAndRegionCnLike
(
boolean
isDeleted
,
List
<
String
>
shopIds
,
String
regionCn
);
List
<
IpResource
>
findByIsDeleted
(
boolean
isDeleted
);
List
<
IpResource
>
findByIsDeleted
(
boolean
isDeleted
);
...
@@ -43,7 +42,7 @@ public interface IpResourceRepository extends MongoRepository<IpResource, String
...
@@ -43,7 +42,7 @@ public interface IpResourceRepository extends MongoRepository<IpResource, String
List
<
IpResource
>
findByValidTimeBetweenAndIsDeleted
(
long
beginTime
,
long
endTime
,
boolean
isDeleted
);
List
<
IpResource
>
findByValidTimeBetweenAndIsDeleted
(
long
beginTime
,
long
endTime
,
boolean
isDeleted
);
IpResource
findFirstByShopIdAndIsDeleted
(
String
shopId
,
boolean
isDeleted
);
IpResource
findFirstByShopId
sIs
AndIsDeleted
(
String
shopId
,
boolean
isDeleted
);
int
countByStatusAndIdInAndIsDeleted
(
int
status
,
List
<
String
>
ipIds
,
boolean
isDeleted
);
int
countByStatusAndIdInAndIsDeleted
(
int
status
,
List
<
String
>
ipIds
,
boolean
isDeleted
);
...
...
src/main/java/com/edgec/browserbackend/browser/repository/IpResourceRepositoryCustom.java
View file @
70d76bbd
package
com
.
edgec
.
browserbackend
.
browser
.
repository
;
package
com
.
edgec
.
browserbackend
.
browser
.
repository
;
import
com.edgec.browserbackend.browser.domain.BindHistory
;
import
com.edgec.browserbackend.browser.domain.IpResource
;
import
com.edgec.browserbackend.browser.domain.IpResource
;
import
java.util.List
;
import
java.util.List
;
...
@@ -17,4 +18,18 @@ public interface IpResourceRepositoryCustom {
...
@@ -17,4 +18,18 @@ public interface IpResourceRepositoryCustom {
List
<
IpResource
>
sampleTasks
(
int
status
,
long
timestamp
);
List
<
IpResource
>
sampleTasks
(
int
status
,
long
timestamp
);
List
<
IpResource
>
sampleTasks
(
List
<
Integer
>
status
);
List
<
IpResource
>
sampleTasks
(
List
<
Integer
>
status
);
boolean
addShopId
(
String
ipId
,
String
shopId
);
boolean
deleteShopId
(
String
ipId
,
String
shopId
,
BindHistory
bindHistory
);
boolean
updateStatus
(
String
id
,
int
status
);
boolean
updateBind
(
String
id
,
boolean
isbind
);
List
<
IpResource
>
findShopIdInList
(
List
<
String
>
shopIds
,
boolean
isDeleted
);
List
<
IpResource
>
findShopIdInListAndStatus
(
List
<
String
>
shopIds
,
boolean
isDeleted
,
int
status
);
List
<
IpResource
>
findShopIdInListAndRegionLike
(
List
<
String
>
shopIds
,
boolean
isDeleted
,
String
region
);
}
}
src/main/java/com/edgec/browserbackend/browser/repository/IpResourceRepositoryCustomImpl.java
View file @
70d76bbd
package
com
.
edgec
.
browserbackend
.
browser
.
repository
;
package
com
.
edgec
.
browserbackend
.
browser
.
repository
;
import
com.edgec.browserbackend.browser.domain.BindHistory
;
import
com.edgec.browserbackend.browser.domain.IpResource
;
import
com.edgec.browserbackend.browser.domain.IpResource
;
import
com.edgec.browserbackend.browser.dto.IpResourceUnwindResultDto
;
import
com.edgec.browserbackend.common.utils.JsonUtils
;
import
com.mongodb.client.result.UpdateResult
;
import
com.mongodb.client.result.UpdateResult
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.bson.Document
;
import
org.bson.Document
;
import
org.elasticsearch.common.recycler.Recycler
;
import
org.elasticsearch.common.recycler.Recycler
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.aggregation.Aggregation
;
import
org.springframework.data.mongodb.core.aggregation.*
;
import
org.springframework.data.mongodb.core.aggregation.AggregationResults
;
import
org.springframework.data.mongodb.core.aggregation.MatchOperation
;
import
org.springframework.data.mongodb.core.aggregation.SampleOperation
;
import
org.springframework.data.mongodb.core.query.BasicQuery
;
import
org.springframework.data.mongodb.core.query.BasicQuery
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.CriteriaDefinition
;
import
org.springframework.data.mongodb.core.query.CriteriaDefinition
;
import
org.springframework.data.mongodb.core.query.Update
;
import
org.springframework.data.mongodb.core.query.Update
;
import
java.time.Instant
;
import
java.time.Instant
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.List
;
import
static
org
.
springframework
.
data
.
mongodb
.
core
.
query
.
Criteria
.
where
;
import
static
org
.
springframework
.
data
.
mongodb
.
core
.
query
.
Criteria
.
where
;
...
@@ -124,4 +123,142 @@ public class IpResourceRepositoryCustomImpl implements IpResourceRepositoryCusto
...
@@ -124,4 +123,142 @@ public class IpResourceRepositoryCustomImpl implements IpResourceRepositoryCusto
return
mappedResults
;
return
mappedResults
;
}
}
@Override
public
boolean
addShopId
(
String
ipId
,
String
shopId
)
{
Document
doc
=
new
Document
();
BasicQuery
basicQuery
=
new
BasicQuery
(
doc
);
basicQuery
.
addCriteria
(
where
(
"id"
).
is
(
ipId
).
and
(
"isDeleted"
).
is
(
false
));
Update
update
=
new
Update
();
update
.
push
(
"shopIds"
,
shopId
);
update
.
set
(
"bind"
,
true
);
UpdateResult
result
=
mongoTemplate
.
updateFirst
(
basicQuery
,
update
,
IpResource
.
class
);
if
(
result
.
getModifiedCount
()
<
1
)
return
false
;
else
return
true
;
}
@Override
public
boolean
deleteShopId
(
String
ipId
,
String
shopId
,
BindHistory
bindHistory
)
{
Document
doc
=
new
Document
();
BasicQuery
basicQuery
=
new
BasicQuery
(
doc
);
basicQuery
.
addCriteria
(
where
(
"id"
).
is
(
ipId
).
and
(
"isDeleted"
).
is
(
false
));
Update
update
=
new
Update
();
update
.
pull
(
"shopIds"
,
shopId
).
push
(
"bindhistory"
,
bindHistory
);
UpdateResult
result
=
mongoTemplate
.
updateFirst
(
basicQuery
,
update
,
IpResource
.
class
);
if
(
result
.
getModifiedCount
()
<
1
)
return
false
;
else
return
true
;
}
@Override
public
boolean
updateStatus
(
String
id
,
int
status
)
{
Document
doc
=
new
Document
();
BasicQuery
basicQuery
=
new
BasicQuery
(
doc
);
basicQuery
.
addCriteria
(
where
(
"id"
).
is
(
id
).
and
(
"isDeleted"
).
is
(
false
));
Update
update
=
new
Update
();
update
.
set
(
"status"
,
status
);
UpdateResult
result
=
mongoTemplate
.
updateFirst
(
basicQuery
,
update
,
IpResource
.
class
);
if
(
result
.
getModifiedCount
()
<
1
)
return
false
;
else
return
true
;
}
@Override
public
boolean
updateBind
(
String
id
,
boolean
isbind
)
{
Document
doc
=
new
Document
();
BasicQuery
basicQuery
=
new
BasicQuery
(
doc
);
basicQuery
.
addCriteria
(
where
(
"id"
).
is
(
id
).
and
(
"isDeleted"
).
is
(
false
));
Update
update
=
new
Update
();
update
.
set
(
"bind"
,
isbind
);
UpdateResult
result
=
mongoTemplate
.
updateFirst
(
basicQuery
,
update
,
IpResource
.
class
);
if
(
result
.
getModifiedCount
()
<
1
)
return
false
;
else
return
true
;
}
@Override
public
List
<
IpResource
>
findShopIdInList
(
List
<
String
>
shopIds
,
boolean
isDeleted
)
{
MatchOperation
matchOperation
=
Aggregation
.
match
(
where
(
"isDeleted"
).
is
(
isDeleted
));
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
>
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
());
}
return
result
;
}
}
}
src/main/java/com/edgec/browserbackend/browser/repository/ShopRepository.java
View file @
70d76bbd
...
@@ -11,4 +11,5 @@ public interface ShopRepository extends MongoRepository<Shop, String> {
...
@@ -11,4 +11,5 @@ public interface ShopRepository extends MongoRepository<Shop, String> {
Page
<
Shop
>
findByShopIdInAndShopAccountLikeOrderByCreateTimeDesc
(
List
<
String
>
shopIds
,
String
shopAccount
,
Pageable
pageable
);
Page
<
Shop
>
findByShopIdInAndShopAccountLikeOrderByCreateTimeDesc
(
List
<
String
>
shopIds
,
String
shopAccount
,
Pageable
pageable
);
Page
<
Shop
>
findByShopIdInAndShopNameLikeOrderByCreateTimeDesc
(
List
<
String
>
shopIds
,
String
shopName
,
Pageable
pageable
);
Page
<
Shop
>
findByShopIdInAndShopNameLikeOrderByCreateTimeDesc
(
List
<
String
>
shopIds
,
String
shopName
,
Pageable
pageable
);
Page
<
Shop
>
findByShopIdInOrderByCreateTimeDesc
(
List
<
String
>
shopIds
,
Pageable
pageable
);
Page
<
Shop
>
findByShopIdInOrderByCreateTimeDesc
(
List
<
String
>
shopIds
,
Pageable
pageable
);
List
<
Shop
>
findByShopIdIn
(
List
<
String
>
shopIds
);
}
}
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpAndShopServiceImpl.java
View file @
70d76bbd
...
@@ -65,16 +65,12 @@ public class IpAndShopServiceImpl implements IpAndShopService {
...
@@ -65,16 +65,12 @@ public class IpAndShopServiceImpl implements IpAndShopService {
if
(
ipResource
==
null
)
if
(
ipResource
==
null
)
throw
new
ClientRequestException
(
BrowserErrorCode
.
IPNOTEXIST
);
throw
new
ClientRequestException
(
BrowserErrorCode
.
IPNOTEXIST
);
IpResource
bind
=
ipResourceRepository
.
findFirstByShopIdAndIsDeleted
(
shopId
,
false
);
IpResource
bind
=
ipResourceRepository
.
findFirstByShopId
sIs
AndIsDeleted
(
shopId
,
false
);
if
(
bind
!=
null
)
{
if
(
bind
!=
null
)
{
shopRequestDto
.
setShopId
(
shopId
);
return
;
shopRequestDto
.
setIpId
(
ipResource
.
getId
());
unBindShop
(
username
,
shopRequestDto
);
}
}
try
{
try
{
ipResource
.
setShopId
(
shop
.
getShopId
());
ipResourceRepository
.
addShopId
(
ipResource
.
getId
(),
shopId
);
ipResource
.
setShopName
(
shop
.
getShopName
());
ipResourceRepository
.
save
(
ipResource
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"fail to bind shop and ip"
,
e
.
getMessage
());
logger
.
error
(
"fail to bind shop and ip"
,
e
.
getMessage
());
throw
new
ClientRequestException
(
BrowserErrorCode
.
UNKNOWN
);
throw
new
ClientRequestException
(
BrowserErrorCode
.
UNKNOWN
);
...
@@ -105,22 +101,65 @@ public class IpAndShopServiceImpl implements IpAndShopService {
...
@@ -105,22 +101,65 @@ public class IpAndShopServiceImpl implements IpAndShopService {
}
}
if
(
ipResource
==
null
)
if
(
ipResource
==
null
)
throw
new
ClientRequestException
(
BrowserErrorCode
.
IPNOTEXIST
);
throw
new
ClientRequestException
(
BrowserErrorCode
.
IPNOTEXIST
);
if
(
ipResource
.
getShopId
()
==
null
&&
!
ipResource
.
getShopId
().
equal
s
(
shop
.
getShopId
()))
if
(
ipResource
.
getShopId
s
()
==
null
&&
!
ipResource
.
getShopIds
().
contain
s
(
shop
.
getShopId
()))
throw
new
ClientRequestException
(
BrowserErrorCode
.
IPNOTBINDTOSHOP
);
throw
new
ClientRequestException
(
BrowserErrorCode
.
IPNOTBINDTOSHOP
);
try
{
try
{
List
<
BindHistory
>
history
=
ipResource
.
getBindHistory
();
BindHistory
bindHistory
=
new
BindHistory
();
BindHistory
bindHistory
=
new
BindHistory
();
bindHistory
.
setIp
(
ipResource
.
getAddr
());
bindHistory
.
setIp
(
ipResource
.
getAddr
());
bindHistory
.
setPlatform
(
shop
.
getShopPlatform
());
bindHistory
.
setPlatform
(
shop
.
getShopPlatform
());
bindHistory
.
setShopName
(
shop
.
getShopName
());
bindHistory
.
setShopName
(
shop
.
getShopName
());
bindHistory
.
setUnbindTime
(
ZonedDateTime
.
now
().
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
)));
bindHistory
.
setUnbindTime
(
ZonedDateTime
.
now
().
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
)));
history
.
add
(
bindHistory
);
ipResourceRepository
.
deleteShopId
(
ipResource
.
getId
(),
shopId
,
bindHistory
);
ipResource
.
setShopId
(
null
);
IpResource
newIp
=
ipResourceRepository
.
findById
(
ipResource
.
getId
()).
orElse
(
null
);
i
pResource
.
setShopName
(
null
);
i
f
(
newIp
.
getShopIds
()
==
null
||
newIp
.
getShopIds
().
size
()
==
0
)
ipResourceRepository
.
save
(
ipResourc
e
);
ipResourceRepository
.
updateBind
(
ipResource
.
getId
(),
fals
e
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"fail to unbind"
,
e
.
getMessage
());
logger
.
error
(
"fail to unbind"
,
e
.
getMessage
());
throw
new
ClientRequestException
(
BrowserErrorCode
.
UNKNOWN
);
throw
new
ClientRequestException
(
BrowserErrorCode
.
UNKNOWN
);
}
}
}
}
@Override
public
void
unBindShops
(
String
username
,
ShopRequestDto
shopRequestDto
)
{
List
<
String
>
shopIds
=
null
;
if
(
shopRequestDto
.
getShopIds
()
!=
null
&&
shopRequestDto
.
getShopIds
().
size
()
>
0
)
shopIds
=
shopRequestDto
.
getShopIds
();
Account
account
=
accountRepository
.
findByName
(
username
);
if
(
account
==
null
)
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
}
IpResource
ipResource
=
null
;
if
(
StringUtils
.
isNotBlank
(
shopRequestDto
.
getIpAddr
()))
{
ipResource
=
ipResourceRepository
.
findByAddrAndIsDeleted
(
shopRequestDto
.
getIpAddr
(),
false
);
}
else
if
(
StringUtils
.
isNotBlank
(
shopRequestDto
.
getIpId
()))
{
ipResource
=
ipResourceRepository
.
findByIdAndIsDeleted
(
shopRequestDto
.
getIpId
(),
false
);
}
if
(
ipResource
==
null
)
throw
new
ClientRequestException
(
BrowserErrorCode
.
IPNOTEXIST
);
for
(
String
shopId
:
shopIds
)
{
UserShop
userShop
=
userShopRepository
.
findByUsernameAndShopId
(
username
,
shopId
);
if
(
account
.
getPermission
()
<
4
||
userShop
==
null
)
{
continue
;
}
Shop
shop
=
shopRepository
.
findById
(
shopId
).
orElse
(
null
);
if
(
shop
==
null
)
continue
;
if
(
ipResource
.
getShopIds
()
==
null
&&
!
ipResource
.
getShopIds
().
contains
(
shop
.
getShopId
()))
continue
;
try
{
BindHistory
bindHistory
=
new
BindHistory
();
bindHistory
.
setIp
(
ipResource
.
getAddr
());
bindHistory
.
setPlatform
(
shop
.
getShopPlatform
());
bindHistory
.
setShopName
(
shop
.
getShopName
());
bindHistory
.
setUnbindTime
(
ZonedDateTime
.
now
().
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
)));
ipResourceRepository
.
deleteShopId
(
ipResource
.
getId
(),
shopId
,
bindHistory
);
IpResource
newIp
=
ipResourceRepository
.
findById
(
ipResource
.
getId
()).
orElse
(
null
);
if
(
newIp
.
getShopIds
()
==
null
||
newIp
.
getShopIds
().
size
()
==
0
)
ipResourceRepository
.
updateBind
(
ipResource
.
getId
(),
false
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"fail to unbind"
,
e
.
getMessage
());
throw
new
ClientRequestException
(
BrowserErrorCode
.
UNKNOWN
);
}
}
}
}
}
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpResourceServiceImpl.java
View file @
70d76bbd
...
@@ -466,8 +466,10 @@ public class IpResourceServiceImpl implements IpResourceService {
...
@@ -466,8 +466,10 @@ public class IpResourceServiceImpl implements IpResourceService {
}
}
UserShop
userShop
=
null
;
UserShop
userShop
=
null
;
if
(
ipResource
.
getShopId
()
!=
null
)
{
if
(
ipResource
.
getShopIds
()
!=
null
)
{
Shop
shop
=
shopRepository
.
findById
(
ipResource
.
getShopId
()).
orElse
(
null
);
List
<
Shop
>
shops
=
shopRepository
.
findByShopIdIn
(
ipResource
.
getShopIds
());
if
(
shops
!=
null
&&
shops
.
size
()
>
0
)
{
for
(
Shop
shop
:
shops
)
{
if
(
shop
!=
null
)
{
if
(
shop
!=
null
)
{
userShop
=
userShopRepository
.
findByUsernameAndShopId
(
username
,
shop
.
getShopId
());
userShop
=
userShopRepository
.
findByUsernameAndShopId
(
username
,
shop
.
getShopId
());
if
(
userShop
==
null
)
{
if
(
userShop
==
null
)
{
...
@@ -479,6 +481,8 @@ public class IpResourceServiceImpl implements IpResourceService {
...
@@ -479,6 +481,8 @@ public class IpResourceServiceImpl implements IpResourceService {
return
;
return
;
}
}
}
}
}
}
try
{
try
{
ResponseEntity
<
String
>
result
=
restTemplate
.
exchange
(
URL
+
"/intelligroup/ipresources?accountId=browser&ip={ip}"
,
HttpMethod
.
DELETE
,
httpEntity
,
String
.
class
,
ipAddr
);
ResponseEntity
<
String
>
result
=
restTemplate
.
exchange
(
URL
+
"/intelligroup/ipresources?accountId=browser&ip={ip}"
,
HttpMethod
.
DELETE
,
httpEntity
,
String
.
class
,
ipAddr
);
DeleteIpResultDto
deleteIpResultDto
=
JSON
.
parseObject
(
result
.
getBody
(),
DeleteIpResultDto
.
class
);
DeleteIpResultDto
deleteIpResultDto
=
JSON
.
parseObject
(
result
.
getBody
(),
DeleteIpResultDto
.
class
);
...
@@ -490,8 +494,7 @@ public class IpResourceServiceImpl implements IpResourceService {
...
@@ -490,8 +494,7 @@ public class IpResourceServiceImpl implements IpResourceService {
if
(
ipResource
.
getStatus
()
==
6
)
if
(
ipResource
.
getStatus
()
==
6
)
ipResourceRepository
.
delete
(
ipResource
);
ipResourceRepository
.
delete
(
ipResource
);
else
{
else
{
ipResource
.
setShopId
(
null
);
ipResource
.
setShopIds
(
null
);
ipResource
.
setShopName
(
null
);
ipResource
.
setDeleted
(
true
);
ipResource
.
setDeleted
(
true
);
ipResourceRepository
.
save
(
ipResource
);
ipResourceRepository
.
save
(
ipResource
);
}
}
...
@@ -522,8 +525,10 @@ public class IpResourceServiceImpl implements IpResourceService {
...
@@ -522,8 +525,10 @@ public class IpResourceServiceImpl implements IpResourceService {
}
}
}
}
UserShop
userShop
=
null
;
UserShop
userShop
=
null
;
if
(
ipResource
.
getShopId
()
!=
null
)
{
if
(
ipResource
.
getShopIds
()
!=
null
)
{
Shop
shop
=
shopRepository
.
findById
(
ipResource
.
getShopId
()).
orElse
(
null
);
List
<
Shop
>
shops
=
shopRepository
.
findByShopIdIn
(
ipResource
.
getShopIds
());
if
(
shops
!=
null
&&
shops
.
size
()
>
0
)
{
for
(
Shop
shop
:
shops
)
{
if
(
shop
!=
null
)
{
if
(
shop
!=
null
)
{
userShop
=
userShopRepository
.
findByUsernameAndShopId
(
username
,
shop
.
getShopId
());
userShop
=
userShopRepository
.
findByUsernameAndShopId
(
username
,
shop
.
getShopId
());
if
(
userShop
==
null
)
{
if
(
userShop
==
null
)
{
...
@@ -535,9 +540,10 @@ public class IpResourceServiceImpl implements IpResourceService {
...
@@ -535,9 +540,10 @@ public class IpResourceServiceImpl implements IpResourceService {
return
;
return
;
}
}
}
}
}
}
ipResource
.
setDeleted
(
true
);
ipResource
.
setDeleted
(
true
);
ipResource
.
setShopId
(
null
);
ipResource
.
setShopIds
(
null
);
ipResource
.
setShopName
(
null
);
ipResourceRepository
.
save
(
ipResource
);
ipResourceRepository
.
save
(
ipResource
);
ipOperationResultDto
.
getSuccessList
().
add
(
ipId
);
ipOperationResultDto
.
getSuccessList
().
add
(
ipId
);
});
});
...
@@ -570,31 +576,31 @@ public class IpResourceServiceImpl implements IpResourceService {
...
@@ -570,31 +576,31 @@ public class IpResourceServiceImpl implements IpResourceService {
switch
(
groupType
)
{
switch
(
groupType
)
{
case
1
:
case
1
:
ipResources
=
ipResourceRepository
.
find
ByShopIdInAndIsDeleted
(
shopIds
,
false
);
ipResources
=
ipResourceRepository
.
find
ShopIdInList
(
shopIds
,
false
);
if
(!
isParent
)
if
(!
isParent
)
notUsed
=
ipResourceRepository
.
findByOwnerAndIsDeletedAnd
ShopIdIsNull
(
usernam
e
,
false
);
notUsed
=
ipResourceRepository
.
findByOwnerAndIsDeletedAnd
Bind
(
username
,
fals
e
,
false
);
else
else
notUsed
=
ipResourceRepository
.
findByOwnerInAndIsDeletedAnd
ShopIdIsNull
(
children
,
false
);
notUsed
=
ipResourceRepository
.
findByOwnerInAndIsDeletedAnd
Bind
(
children
,
false
,
false
);
break
;
break
;
case
2
:
case
2
:
ipResources
=
ipResourceRepository
.
find
ByStatusAndShopIdInAndIsDeleted
(
2
,
shopIds
,
false
);
ipResources
=
ipResourceRepository
.
find
ShopIdInListAndStatus
(
shopIds
,
false
,
2
);
if
(!
isParent
)
if
(!
isParent
)
notUsed
=
ipResourceRepository
.
findByOwnerAndStatusAndIsDeletedAnd
ShopIdIsNull
(
username
,
2
,
false
);
notUsed
=
ipResourceRepository
.
findByOwnerAndStatusAndIsDeletedAnd
Bind
(
username
,
2
,
false
,
false
);
else
else
notUsed
=
ipResourceRepository
.
findByOwnerInAndStatusAndIsDeletedAnd
ShopIdIsNull
(
children
,
2
,
false
);
notUsed
=
ipResourceRepository
.
findByOwnerInAndStatusAndIsDeletedAnd
Bind
(
children
,
2
,
false
,
false
);
break
;
break
;
case
3
:
case
3
:
ipResources
=
ipResourceRepository
.
find
ByStatusAndShopIdInAndIsDeleted
(
1
,
shopIds
,
false
);
ipResources
=
ipResourceRepository
.
find
ShopIdInListAndStatus
(
shopIds
,
false
,
1
);
if
(!
isParent
)
if
(!
isParent
)
notUsed
=
ipResourceRepository
.
findByOwnerAndStatusAndIsDeletedAnd
ShopIdIsNull
(
username
,
1
,
false
);
notUsed
=
ipResourceRepository
.
findByOwnerAndStatusAndIsDeletedAnd
Bind
(
username
,
1
,
false
,
false
);
else
else
notUsed
=
ipResourceRepository
.
findByOwnerInAndStatusAndIsDeletedAnd
ShopIdIsNull
(
children
,
1
,
false
);
notUsed
=
ipResourceRepository
.
findByOwnerInAndStatusAndIsDeletedAnd
Bind
(
children
,
1
,
false
,
false
);
break
;
break
;
case
4
:
case
4
:
if
(!
isParent
)
if
(!
isParent
)
notUsed
=
ipResourceRepository
.
findByOwnerAndStatusIsNotInAndIsDeletedAnd
ShopIdIsNull
(
username
,
Arrays
.
asList
(
3
,
5
,
6
),
false
);
notUsed
=
ipResourceRepository
.
findByOwnerAndStatusIsNotInAndIsDeletedAnd
Bind
(
username
,
Arrays
.
asList
(
3
,
5
,
6
),
false
,
false
);
else
else
notUsed
=
ipResourceRepository
.
findByOwnerInAndStatusIsNotInAndIsDeletedAnd
ShopIdIsNull
(
children
,
Arrays
.
asList
(
3
,
5
,
6
)
,
false
);
notUsed
=
ipResourceRepository
.
findByOwnerInAndStatusIsNotInAndIsDeletedAnd
Bind
(
children
,
Arrays
.
asList
(
3
,
5
,
6
),
false
,
false
);
break
;
break
;
}
}
if
(
notUsed
!=
null
)
if
(
notUsed
!=
null
)
...
@@ -615,14 +621,16 @@ public class IpResourceServiceImpl implements IpResourceService {
...
@@ -615,14 +621,16 @@ public class IpResourceServiceImpl implements IpResourceService {
}
}
if
(
ipResources1
!=
null
)
{
if
(
ipResources1
!=
null
)
{
ipResources1
.
getContent
().
forEach
(
x
->
{
ipResources1
.
getContent
().
forEach
(
x
->
{
ShopDto
shopDto
;
List
<
ShopDto
>
shopDtos
=
new
ArrayList
<>()
;
Shop
shop
=
null
;
List
<
Shop
>
shops
=
null
;
if
(
x
.
getShopId
()
!=
null
)
if
(
x
.
getShopId
s
()
!=
null
)
shop
=
shopRepository
.
findById
(
x
.
getShopId
()).
orElse
(
null
);
shop
s
=
shopRepository
.
findByShopIdIn
(
x
.
getShopIds
()
);
if
(
shop
==
null
)
{
if
(
shop
s
==
null
||
shops
.
size
()
==
0
)
{
shopDto
=
new
ShopDto
(
);
shopDto
s
.
add
(
new
ShopDto
()
);
}
else
{
}
else
{
shopDto
=
new
ShopDto
(
shop
);
for
(
Shop
shop
:
shops
)
{
shopDtos
.
add
(
new
ShopDto
(
shop
));
}
}
}
if
(
StringUtils
.
isNotBlank
(
x
.
getAddr
()))
{
if
(
StringUtils
.
isNotBlank
(
x
.
getAddr
()))
{
if
(
x
.
getLockTimestamp
()
>=
Instant
.
now
().
minusSeconds
(
120
).
toEpochMilli
()
&&
x
.
getIpType
()
==
IpType
.
VENDOR
&&
(
x
.
getStatus
()
==
0
||
x
.
getStatus
()
==
2
))
{
if
(
x
.
getLockTimestamp
()
>=
Instant
.
now
().
minusSeconds
(
120
).
toEpochMilli
()
&&
x
.
getIpType
()
==
IpType
.
VENDOR
&&
(
x
.
getStatus
()
==
0
||
x
.
getStatus
()
==
2
))
{
...
@@ -630,8 +638,7 @@ public class IpResourceServiceImpl implements IpResourceService {
...
@@ -630,8 +638,7 @@ public class IpResourceServiceImpl implements IpResourceService {
}
}
else
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
x
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
else
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
x
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
if
(
x
.
getStatus
()
!=
5
&&
x
.
getStatus
()
!=
3
&&
x
.
getStatus
()
!=
6
)
{
if
(
x
.
getStatus
()
!=
5
&&
x
.
getStatus
()
!=
3
&&
x
.
getStatus
()
!=
6
)
{
x
.
setStatus
(
2
);
ipResourceRepository
.
updateStatus
(
x
.
getId
(),
2
);
ipResourceRepository
.
save
(
x
);
}
}
}
}
else
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
x
.
getStatus
()
!=
3
&&
x
.
getStatus
()
!=
6
)
{
else
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
x
.
getStatus
()
!=
3
&&
x
.
getStatus
()
!=
6
)
{
...
@@ -647,16 +654,13 @@ public class IpResourceServiceImpl implements IpResourceService {
...
@@ -647,16 +654,13 @@ public class IpResourceServiceImpl implements IpResourceService {
return
;
return
;
}
}
else
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
toEpochMilli
()
&&
x
.
getStatus
()
!=
3
&&
x
.
getStatus
()
!=
6
)
{
else
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
toEpochMilli
()
&&
x
.
getStatus
()
!=
3
&&
x
.
getStatus
()
!=
6
)
{
x
.
setStatus
(
1
);
ipResourceRepository
.
updateStatus
(
x
.
getId
(),
1
);
ipResourceRepository
.
save
(
x
);
}
}
else
{
else
{
if
((
x
.
getStatus
()
==
0
||
x
.
getStatus
()
==
1
||
x
.
getStatus
()
==
2
)
&&
!
x
.
getVendor
().
equals
(
Vendor
.
local
))
{
if
((
x
.
getStatus
()
==
0
||
x
.
getStatus
()
==
1
||
x
.
getStatus
()
==
2
)
&&
!
x
.
getVendor
().
equals
(
Vendor
.
local
))
{
x
.
setStatus
(
0
);
ipResourceRepository
.
updateStatus
(
x
.
getId
(),
0
);
ipResourceRepository
.
save
(
x
);
}
else
if
(
x
.
getIpType
().
equals
(
IpType
.
LOCAL
)
&&
(
x
.
getStatus
()
==
1
||
x
.
getStatus
()
==
2
)
&&
x
.
getAddr
().
equals
(
"本地Ip未使用"
)
)
{
}
else
if
(
x
.
getIpType
().
equals
(
IpType
.
LOCAL
)
&&
(
x
.
getStatus
()
==
1
||
x
.
getStatus
()
==
2
)
&&
x
.
getAddr
().
equals
(
"本地Ip未使用"
)
)
{
x
.
setStatus
(
4
);
ipResourceRepository
.
updateStatus
(
x
.
getId
(),
4
);
ipResourceRepository
.
save
(
x
);
}
}
}
}
}
}
...
@@ -667,9 +671,9 @@ public class IpResourceServiceImpl implements IpResourceService {
...
@@ -667,9 +671,9 @@ public class IpResourceServiceImpl implements IpResourceService {
}
}
SpecialLine
specialLine
=
specialLineRepository
.
findAll
().
get
(
0
);
SpecialLine
specialLine
=
specialLineRepository
.
findAll
().
get
(
0
);
if
(
x
.
isSpecialLine
())
if
(
x
.
isSpecialLine
())
ipResourceDtos
.
add
(
new
IpResourceDto
(
x
,
shopDto
,
false
,
specialLine
));
ipResourceDtos
.
add
(
new
IpResourceDto
(
x
,
shopDto
s
,
false
,
specialLine
));
else
else
ipResourceDtos
.
add
(
new
IpResourceDto
(
x
,
shopDto
,
false
));
ipResourceDtos
.
add
(
new
IpResourceDto
(
x
,
shopDto
s
,
false
));
});
});
}
}
...
@@ -720,8 +724,8 @@ public class IpResourceServiceImpl implements IpResourceService {
...
@@ -720,8 +724,8 @@ public class IpResourceServiceImpl implements IpResourceService {
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
IpSummary
ipSummary
=
new
IpSummary
();
IpSummary
ipSummary
=
new
IpSummary
();
List
<
String
>
shopIds
=
userShopRepository
.
findByUsername
(
username
).
stream
().
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
List
<
String
>
shopIds
=
userShopRepository
.
findByUsername
(
username
).
stream
().
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
List
<
String
>
used
=
ipResourceRepository
.
find
ByShopIdInAndIsDeleted
(
shopIds
,
false
).
stream
().
map
(
x
->
x
.
getId
()).
collect
(
Collectors
.
toList
());
List
<
String
>
used
=
ipResourceRepository
.
find
ShopIdInList
(
shopIds
,
false
).
stream
().
map
(
x
->
x
.
getId
()).
collect
(
Collectors
.
toList
());
List
<
String
>
unbind
=
ipResourceRepository
.
findByOwnerAndIsDeletedAnd
ShopIdIsNull
(
usernam
e
,
false
).
stream
().
map
(
x
->
x
.
getId
()).
collect
(
Collectors
.
toList
());
List
<
String
>
unbind
=
ipResourceRepository
.
findByOwnerAndIsDeletedAnd
Bind
(
username
,
fals
e
,
false
).
stream
().
map
(
x
->
x
.
getId
()).
collect
(
Collectors
.
toList
());
ipSummary
.
setUnbind
(
unbind
.
size
());
ipSummary
.
setUnbind
(
unbind
.
size
());
unbind
.
addAll
(
used
);
unbind
.
addAll
(
used
);
int
expired
=
ipResourceRepository
.
countByStatusAndIdInAndIsDeleted
(
1
,
unbind
,
false
);
int
expired
=
ipResourceRepository
.
countByStatusAndIdInAndIsDeleted
(
1
,
unbind
,
false
);
...
@@ -783,32 +787,31 @@ public class IpResourceServiceImpl implements IpResourceService {
...
@@ -783,32 +787,31 @@ public class IpResourceServiceImpl implements IpResourceService {
if
(
ipResource
==
null
)
if
(
ipResource
==
null
)
throw
new
ClientRequestException
(
BrowserErrorCode
.
IPNOTEXIST
);
throw
new
ClientRequestException
(
BrowserErrorCode
.
IPNOTEXIST
);
ShopDto
shopDto
;
List
<
ShopDto
>
shopDtos
=
new
ArrayList
<>()
;
Shop
shop
=
null
;
List
<
Shop
>
shops
=
null
;
if
(
ipResource
.
getShopId
()
!=
null
)
if
(
ipResource
.
getShopId
s
()
!=
null
)
shop
=
shopRepository
.
findById
(
ipResource
.
getShopId
()).
orElse
(
null
);
shop
s
=
shopRepository
.
findByShopIdIn
(
ipResource
.
getShopIds
()
);
if
(
shop
==
null
)
{
if
(
shop
s
==
null
||
shops
.
size
()
>
0
)
{
shopDto
=
new
ShopDto
(
);
shopDto
s
.
add
(
new
ShopDto
()
);
}
else
{
}
else
{
shopDto
=
new
ShopDto
(
shop
);
for
(
Shop
shop
:
shops
)
{
shopDtos
.
add
(
new
ShopDto
(
shop
));
}
}
}
if
(
StringUtils
.
isNotBlank
(
ipResource
.
getAddr
()))
{
if
(
StringUtils
.
isNotBlank
(
ipResource
.
getAddr
()))
{
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
ipResource
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
ipResource
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
ipResource
.
setStatus
(
2
);
ipResourceRepository
.
updateStatus
(
ipResource
.
getId
(),
2
);
ipResourceRepository
.
save
(
ipResource
);
}
else
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
())
{
}
else
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
())
{
deleteIp
(
username
,
ipResourceRequestDto
);
deleteIp
(
username
,
ipResourceRequestDto
);
}
else
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
toEpochMilli
())
{
}
else
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
toEpochMilli
())
{
ipResource
.
setStatus
(
1
);
ipResourceRepository
.
updateStatus
(
ipResource
.
getId
(),
1
);
ipResourceRepository
.
save
(
ipResource
);
}
else
{
}
else
{
if
(
ipResource
.
getStatus
()
!=
4
&&
ipResource
.
getStatus
()
!=
5
)
{
if
(
ipResource
.
getStatus
()
!=
4
&&
ipResource
.
getStatus
()
!=
5
)
{
ipResource
.
setStatus
(
0
);
ipResourceRepository
.
updateStatus
(
ipResource
.
getId
(),
0
);
ipResourceRepository
.
save
(
ipResource
);
}
}
}
}
}
}
IpResourceDto
ipResourceDto
=
new
IpResourceDto
(
ipResource
,
shopDto
,
true
);
IpResourceDto
ipResourceDto
=
new
IpResourceDto
(
ipResource
,
shopDto
s
,
true
);
return
ipResourceDto
;
return
ipResourceDto
;
}
}
...
...
src/main/java/com/edgec/browserbackend/browser/service/Impl/ShopServiceImpl.java
View file @
70d76bbd
...
@@ -228,11 +228,12 @@ public class ShopServiceImpl implements ShopService {
...
@@ -228,11 +228,12 @@ public class ShopServiceImpl implements ShopService {
Shop
shop
=
shopRepository
.
findById
(
shopId
).
orElse
(
null
);
Shop
shop
=
shopRepository
.
findById
(
shopId
).
orElse
(
null
);
if
(
shop
==
null
)
if
(
shop
==
null
)
throw
new
ClientRequestException
(
BrowserErrorCode
.
SHOPNOTEXIST
);
throw
new
ClientRequestException
(
BrowserErrorCode
.
SHOPNOTEXIST
);
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdAndIsDeleted
(
shop
.
getShopId
(),
false
);
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopId
sIs
AndIsDeleted
(
shop
.
getShopId
(),
false
);
if
(
ipResource
!=
null
)
{
if
(
ipResource
!=
null
)
{
ipResource
.
setShopName
(
null
);
ShopRequestDto
shopRequestDto
=
new
ShopRequestDto
();
ipResource
.
setShopId
(
null
);
shopRequestDto
.
setIpId
(
ipResource
.
getId
());
ipResourceRepository
.
save
(
ipResource
);
shopRequestDto
.
setShopId
(
shopId
);
ipAndShopService
.
unBindShop
(
username
,
shopRequestDto
);
}
}
boolean
result
=
userShopRepository
.
deleteByShopId
(
shopId
);
boolean
result
=
userShopRepository
.
deleteByShopId
(
shopId
);
if
(
result
)
{
if
(
result
)
{
...
@@ -335,7 +336,7 @@ public class ShopServiceImpl implements ShopService {
...
@@ -335,7 +336,7 @@ public class ShopServiceImpl implements ShopService {
if
(
shop
==
null
)
{
if
(
shop
==
null
)
{
throw
new
ClientRequestException
(
BrowserErrorCode
.
SHOPNOTEXIST
);
throw
new
ClientRequestException
(
BrowserErrorCode
.
SHOPNOTEXIST
);
}
}
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdAndIsDeleted
(
shopId
,
false
);
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopId
sIs
AndIsDeleted
(
shopId
,
false
);
if
(
ipResource
==
null
)
if
(
ipResource
==
null
)
throw
new
ClientRequestException
(
BrowserErrorCode
.
IPNOTEXIST
);
throw
new
ClientRequestException
(
BrowserErrorCode
.
IPNOTEXIST
);
String
group
=
userShopRepository
.
findByUsernameAndShopId
(
username
,
shop
.
getShopId
()).
getGroupId
();
String
group
=
userShopRepository
.
findByUsernameAndShopId
(
username
,
shop
.
getShopId
()).
getGroupId
();
...
@@ -374,18 +375,19 @@ public class ShopServiceImpl implements ShopService {
...
@@ -374,18 +375,19 @@ public class ShopServiceImpl implements ShopService {
else
if
(
shopFilterDto
.
getBindIp
()
==
1
)
{
else
if
(
shopFilterDto
.
getBindIp
()
==
1
)
{
List
<
String
>
allIds
=
userShopRepository
.
findByUsername
(
username
).
stream
()
List
<
String
>
allIds
=
userShopRepository
.
findByUsername
(
username
).
stream
()
.
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
.
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
shopIds
=
ipResourceRepository
.
find
ByShopIdInAndIsDeleted
(
allIds
,
false
)
shopIds
=
ipResourceRepository
.
find
ShopIdInList
(
allIds
,
false
)
.
stream
().
map
(
x
->
x
.
getShopId
(
)).
collect
(
Collectors
.
toList
());
.
stream
().
flatMap
((
x
->
x
.
getShopIds
().
stream
()
)).
collect
(
Collectors
.
toList
());
}
}
else
{
else
{
List
<
String
>
allIds
=
userShopRepository
.
findByUsername
(
username
).
stream
()
List
<
String
>
allIds
=
userShopRepository
.
findByUsername
(
username
).
stream
()
.
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
.
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
for
(
String
id:
allIds
)
{
for
(
String
id:
allIds
)
{
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdAndIsDeleted
(
id
,
false
);
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopId
sIs
AndIsDeleted
(
id
,
false
);
if
(
ipResource
==
null
)
if
(
ipResource
==
null
)
{
shopIds
.
add
(
id
);
shopIds
.
add
(
id
);
}
}
}
}
}
}
else
{
}
else
{
if
(
shopFilterDto
.
getBindIp
()
==
0
)
if
(
shopFilterDto
.
getBindIp
()
==
0
)
shopIds
=
userShopRepository
.
findByUsernameAndGroupId
(
username
,
groupId
).
stream
().
shopIds
=
userShopRepository
.
findByUsernameAndGroupId
(
username
,
groupId
).
stream
().
...
@@ -393,14 +395,14 @@ public class ShopServiceImpl implements ShopService {
...
@@ -393,14 +395,14 @@ public class ShopServiceImpl implements ShopService {
else
if
(
shopFilterDto
.
getBindIp
()
==
1
)
{
else
if
(
shopFilterDto
.
getBindIp
()
==
1
)
{
List
<
String
>
allIds
=
userShopRepository
.
findByUsernameAndGroupId
(
username
,
groupId
).
stream
().
List
<
String
>
allIds
=
userShopRepository
.
findByUsernameAndGroupId
(
username
,
groupId
).
stream
().
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
shopIds
=
ipResourceRepository
.
find
ByShopIdInAndIsDeleted
(
allIds
,
false
)
shopIds
=
ipResourceRepository
.
find
ShopIdInList
(
allIds
,
false
)
.
stream
().
map
(
x
->
x
.
getShopId
(
)).
collect
(
Collectors
.
toList
());
.
stream
().
flatMap
((
x
->
x
.
getShopIds
().
stream
()
)).
collect
(
Collectors
.
toList
());
}
}
else
{
else
{
List
<
String
>
allIds
=
userShopRepository
.
findByUsernameAndGroupId
(
username
,
groupId
).
stream
()
List
<
String
>
allIds
=
userShopRepository
.
findByUsernameAndGroupId
(
username
,
groupId
).
stream
()
.
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
.
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
for
(
String
id:
allIds
)
{
for
(
String
id:
allIds
)
{
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdAndIsDeleted
(
id
,
false
);
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopId
sIs
AndIsDeleted
(
id
,
false
);
if
(
ipResource
==
null
)
if
(
ipResource
==
null
)
shopIds
.
add
(
id
);
shopIds
.
add
(
id
);
}
}
...
@@ -408,8 +410,8 @@ public class ShopServiceImpl implements ShopService {
...
@@ -408,8 +410,8 @@ public class ShopServiceImpl implements ShopService {
}
}
Page
<
Shop
>
shops
;
Page
<
Shop
>
shops
;
if
(
shopFilterDto
!=
null
&&
StringUtils
.
isNotBlank
(
shopFilterDto
.
getIpRegion
()))
{
if
(
shopFilterDto
!=
null
&&
StringUtils
.
isNotBlank
(
shopFilterDto
.
getIpRegion
()))
{
List
<
String
>
filter
=
ipResourceRepository
.
find
ByIsDeletedAndShopIdInAndRegionCnLike
(
false
,
shopIds
,
shopFilterDto
.
getIpRegion
())
List
<
String
>
filter
=
ipResourceRepository
.
find
ShopIdInListAndRegionLike
(
shopIds
,
false
,
shopFilterDto
.
getIpRegion
())
.
stream
().
map
(
x
->
x
.
getShopId
(
)).
collect
(
Collectors
.
toList
());
.
stream
().
flatMap
((
x
->
x
.
getShopIds
().
stream
()
)).
collect
(
Collectors
.
toList
());
shops
=
shopRepository
.
findByShopIdInOrderByCreateTimeDesc
(
filter
,
pageable
);
shops
=
shopRepository
.
findByShopIdInOrderByCreateTimeDesc
(
filter
,
pageable
);
}
}
else
if
(
shopFilterDto
!=
null
&&
StringUtils
.
isNotBlank
(
shopFilterDto
.
getShopAccount
()))
else
if
(
shopFilterDto
!=
null
&&
StringUtils
.
isNotBlank
(
shopFilterDto
.
getShopAccount
()))
...
@@ -422,7 +424,7 @@ public class ShopServiceImpl implements ShopService {
...
@@ -422,7 +424,7 @@ public class ShopServiceImpl implements ShopService {
return
new
ShopPageResultDto
();
return
new
ShopPageResultDto
();
List
<
ShopResultDto
>
shopResultDtos
=
new
ArrayList
<>();
List
<
ShopResultDto
>
shopResultDtos
=
new
ArrayList
<>();
shops
.
getContent
().
stream
().
forEach
(
x
->
{
shops
.
getContent
().
stream
().
forEach
(
x
->
{
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdAndIsDeleted
(
x
.
getShopId
(),
false
);
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopId
sIs
AndIsDeleted
(
x
.
getShopId
(),
false
);
if
(
ipResource
!=
null
)
{
if
(
ipResource
!=
null
)
{
if
(
StringUtils
.
isNotBlank
(
ipResource
.
getAddr
()))
{
if
(
StringUtils
.
isNotBlank
(
ipResource
.
getAddr
()))
{
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
ipResource
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
ipResource
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
...
@@ -496,7 +498,7 @@ public class ShopServiceImpl implements ShopService {
...
@@ -496,7 +498,7 @@ public class ShopServiceImpl implements ShopService {
List
<
String
>
unbind
=
new
ArrayList
<>();
List
<
String
>
unbind
=
new
ArrayList
<>();
if
(
allShopIds
!=
null
&&
allShopIds
.
size
()
>
0
)
{
if
(
allShopIds
!=
null
&&
allShopIds
.
size
()
>
0
)
{
for
(
String
id:
allShopIds
)
{
for
(
String
id:
allShopIds
)
{
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdAndIsDeleted
(
id
,
false
);
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopId
sIs
AndIsDeleted
(
id
,
false
);
if
(
ipResource
==
null
)
{
if
(
ipResource
==
null
)
{
unbind
.
add
(
id
);
unbind
.
add
(
id
);
}
}
...
@@ -504,7 +506,7 @@ public class ShopServiceImpl implements ShopService {
...
@@ -504,7 +506,7 @@ public class ShopServiceImpl implements ShopService {
}
}
shopSummary
.
setUnbind
(
unbind
.
size
());
shopSummary
.
setUnbind
(
unbind
.
size
());
List
<
String
>
shopIds
=
userShopRepository
.
findByUsername
(
username
).
stream
().
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
List
<
String
>
shopIds
=
userShopRepository
.
findByUsername
(
username
).
stream
().
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
List
<
String
>
bind
=
ipResourceRepository
.
find
ByShopIdInAndIsDeleted
(
shopIds
,
false
).
stream
().
map
(
x
->
x
.
getId
()).
collect
(
Collectors
.
toList
());
List
<
String
>
bind
=
ipResourceRepository
.
find
ShopIdInList
(
shopIds
,
false
).
stream
().
map
(
x
->
x
.
getId
()).
collect
(
Collectors
.
toList
());
int
expired
=
ipResourceRepository
.
countByStatusAndIdInAndIsDeleted
(
1
,
bind
,
false
);
int
expired
=
ipResourceRepository
.
countByStatusAndIdInAndIsDeleted
(
1
,
bind
,
false
);
int
willexpired
=
ipResourceRepository
.
countByStatusAndIdInAndIsDeleted
(
2
,
bind
,
false
);
int
willexpired
=
ipResourceRepository
.
countByStatusAndIdInAndIsDeleted
(
2
,
bind
,
false
);
shopSummary
.
setExpired
(
expired
);
shopSummary
.
setExpired
(
expired
);
...
...
src/main/java/com/edgec/browserbackend/browser/service/IpAndShopService.java
View file @
70d76bbd
...
@@ -7,4 +7,6 @@ public interface IpAndShopService {
...
@@ -7,4 +7,6 @@ public interface IpAndShopService {
void
bindShop
(
String
username
,
ShopRequestDto
shopRequestDto
);
void
bindShop
(
String
username
,
ShopRequestDto
shopRequestDto
);
void
unBindShop
(
String
username
,
ShopRequestDto
shopRequestDto
);
void
unBindShop
(
String
username
,
ShopRequestDto
shopRequestDto
);
void
unBindShops
(
String
username
,
ShopRequestDto
shopRequestDto
);
}
}
src/main/java/com/edgec/browserbackend/browser/task/BrowserTask.java
View file @
70d76bbd
...
@@ -168,11 +168,11 @@ public class BrowserTask {
...
@@ -168,11 +168,11 @@ public class BrowserTask {
if
(
result
==
false
&&
(
ipResource
.
getPurchasedTime
()
<
Instant
.
now
().
minusSeconds
(
7200
).
toEpochMilli
()))
{
if
(
result
==
false
&&
(
ipResource
.
getPurchasedTime
()
<
Instant
.
now
().
minusSeconds
(
7200
).
toEpochMilli
()))
{
IpChargeRequestDto
ipChargeRequestDto
=
buildIpChargeRequestDto
(
ipResource
,
3
,
0
);
IpChargeRequestDto
ipChargeRequestDto
=
buildIpChargeRequestDto
(
ipResource
,
3
,
0
);
accountService
.
chargeByMoney
(
ipResource
.
getUsername
(),
-
ipResource
.
getPrice
(),
ipChargeRequestDto
);
accountService
.
chargeByMoney
(
ipResource
.
getUsername
(),
-
ipResource
.
getPrice
(),
ipChargeRequestDto
);
if
(
ipResource
.
getShopId
()
!=
null
)
{
if
(
ipResource
.
getShopId
s
()
!=
null
&&
ipResource
.
getShopIds
().
size
()
>
0
)
{
ShopRequestDto
shopRequestDto
=
new
ShopRequestDto
();
ShopRequestDto
shopRequestDto
=
new
ShopRequestDto
();
shopRequestDto
.
setIpId
(
ipResource
.
getId
());
shopRequestDto
.
setIpId
(
ipResource
.
getId
());
shopRequestDto
.
setShopId
(
ipResource
.
getShopId
());
shopRequestDto
.
setShopId
s
(
ipResource
.
getShopIds
());
ipAndShopService
.
unBindShop
(
ipResource
.
getUsername
(),
shopRequestDto
);
ipAndShopService
.
unBindShop
s
(
ipResource
.
getUsername
(),
shopRequestDto
);
}
}
ipResourceRepository
.
deleteById
(
ipResource
.
getId
());
ipResourceRepository
.
deleteById
(
ipResource
.
getId
());
}
}
...
@@ -202,14 +202,17 @@ public class BrowserTask {
...
@@ -202,14 +202,17 @@ public class BrowserTask {
CompletableFuture
.
runAsync
(()
->
{
CompletableFuture
.
runAsync
(()
->
{
if
(
ipResourceRepository
.
lockTask
(
ipResource
))
{
if
(
ipResourceRepository
.
lockTask
(
ipResource
))
{
try
{
try
{
log
.
error
(
"test"
);
String
url
=
URL
+
"/ecc/ipinfo?accountId=browser&ip="
+
ipResource
.
getAddr
();
String
url
=
URL
+
"/ecc/ipinfo?accountId=browser&ip="
+
ipResource
.
getAddr
();
Map
<
String
,
String
>
header
=
buildGetHeader
();
Map
<
String
,
String
>
header
=
buildGetHeader
();
String
rs
=
HttpClientutils
.
doGet
(
url
,
header
);
String
rs
=
HttpClientutils
.
doGet
(
url
,
header
);
IpInfoResultDto
ipInfoResultDto
=
JSONObject
.
parseObject
(
rs
,
IpInfoResultDto
.
class
);
IpInfoResultDto
ipInfoResultDto
=
JSONObject
.
parseObject
(
rs
,
IpInfoResultDto
.
class
);
if
(
ipInfoResultDto
!=
null
&&
StringUtils
.
isBlank
(
ipInfoResultDto
.
getErrorCode
()))
{
if
(
ipInfoResultDto
!=
null
&&
StringUtils
.
isBlank
(
ipInfoResultDto
.
getErrorCode
()))
{
log
.
error
(
ipInfoResultDto
.
getErrorCode
());
log
.
error
(
ipInfoResultDto
.
getStatus
());
log
.
error
(
ipInfoResultDto
.
getEipIPAddr
());
if
(
StringUtils
.
isNotEmpty
(
ipInfoResultDto
.
getStatus
()))
{
if
(
StringUtils
.
isNotEmpty
(
ipInfoResultDto
.
getStatus
()))
{
ipResource
.
setStatus
(
0
);
ipResourceRepository
.
updateStatus
(
ipResource
.
getId
(),
0
);
ipResourceRepository
.
save
(
ipResource
);
}
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
src/main/java/com/edgec/browserbackend/common/utils/JsonUtils.java
0 → 100644
View file @
70d76bbd
package
com
.
edgec
.
browserbackend
.
common
.
utils
;
import
com.alibaba.fastjson.JSONArray
;
import
com.edgec.browserbackend.account.exception.AccountErrorCode
;
import
com.edgec.browserbackend.common.commons.error.ClientRequestException
;
import
com.fasterxml.jackson.annotation.JsonInclude.Include
;
import
com.fasterxml.jackson.core.JsonFactory
;
import
com.fasterxml.jackson.core.JsonGenerator
;
import
com.fasterxml.jackson.core.JsonParser.Feature
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
java.beans.BeanInfo
;
import
java.beans.Introspector
;
import
java.beans.PropertyDescriptor
;
import
java.io.IOException
;
import
java.io.StringWriter
;
import
java.lang.reflect.Method
;
import
java.util.*
;
/**
* Json工具类
*/
public
class
JsonUtils
{
private
static
final
ObjectMapper
mapper
=
new
ObjectMapper
();
static
{
mapper
.
configure
(
Feature
.
ALLOW_UNQUOTED_FIELD_NAMES
,
true
);
mapper
.
configure
(
Feature
.
ALLOW_UNQUOTED_CONTROL_CHARS
,
true
);
mapper
.
setSerializationInclusion
(
Include
.
NON_NULL
);
}
private
JsonUtils
()
{
}
/**
* json字符串转换为类
*/
public
static
<
T
>
T
toBean
(
String
json
,
Class
<
T
>
clazz
)
{
try
{
T
bean
=
(
T
)
mapper
.
readValue
(
json
,
clazz
);
return
bean
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
@SuppressWarnings
(
"unchecked"
)
public
static
HashMap
<
String
,
Object
>
toBean
(
String
json
)
{
return
toBean
(
json
,
HashMap
.
class
);
}
@SuppressWarnings
(
"unchecked"
)
public
static
HashMap
<
String
,
String
>
toBeanStr
(
String
json
)
{
return
toBean
(
json
,
HashMap
.
class
);
}
@SuppressWarnings
(
"unchecked"
)
public
static
<
T
>
T
toBean
(
String
json
,
TypeReference
<
T
>
tr
){
try
{
T
bean
=
(
T
)
mapper
.
readValue
(
json
,
tr
);
return
bean
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
/**
* 对象转换为json字符串
*/
public
static
String
toJson
(
Object
bean
)
{
String
json
=
null
;
JsonGenerator
gen
=
null
;
StringWriter
sw
=
new
StringWriter
();
try
{
gen
=
new
JsonFactory
().
createGenerator
(
sw
);
mapper
.
writeValue
(
gen
,
bean
);
json
=
sw
.
toString
();
}
catch
(
IOException
e
)
{
throw
new
ClientRequestException
(
AccountErrorCode
.
UNKNOWN
);
}
finally
{
try
{
if
(
gen
!=
null
)
{
gen
.
close
();
}
if
(
sw
!=
null
)
{
sw
.
close
();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
return
json
;
}
@SuppressWarnings
(
"unchecked"
)
public
static
List
<
Object
>
toList
(
String
json
)
{
return
toBean
(
json
,
ArrayList
.
class
);
}
/**
* 对象转换为Map
*/
public
static
Map
<
String
,
Object
>
transBean2Map
(
Object
obj
)
{
if
(
obj
==
null
)
{
return
null
;
}
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
try
{
BeanInfo
beanInfo
=
Introspector
.
getBeanInfo
(
obj
.
getClass
());
PropertyDescriptor
[]
propertyDescriptors
=
beanInfo
.
getPropertyDescriptors
();
for
(
PropertyDescriptor
property
:
propertyDescriptors
)
{
String
key
=
property
.
getName
();
if
(!
key
.
equals
(
"class"
))
{
Method
getter
=
property
.
getReadMethod
();
Object
value
=
getter
.
invoke
(
obj
);
map
.
put
(
key
,
value
);
}
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"transBean2Map Error "
+
e
);
}
return
map
;
}
/**
* json字符串转换为List
*/
public
static
<
T
>
List
<
T
>
json2ListBean
(
String
json
,
Class
<
T
>
cls
){
JSONArray
jArray
=
JSONArray
.
parseArray
(
json
);
List
<
T
>
collection
=
jArray
.
toJavaList
(
cls
);
return
collection
;
}
}
\ No newline at end of file
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