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
b360da96
Commit
b360da96
authored
May 08, 2020
by
renjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-zrj' into 'staging'
自有专线 See merge request
!62
parents
ec6afd2f
87168aac
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
1 deletion
+47
-1
AdministratorController.java
...erbackend/account/controller/AdministratorController.java
+18
-0
AdministratorService.java
.../browserbackend/account/service/AdministratorService.java
+2
-0
AdministratorServiceImpl.java
...ackend/account/service/impl/AdministratorServiceImpl.java
+9
-0
IpResourceRequestDto.java
...dgec/browserbackend/browser/dto/IpResourceRequestDto.java
+9
-0
IpResourceServiceImpl.java
...erbackend/browser/service/Impl/IpResourceServiceImpl.java
+9
-1
No files found.
src/main/java/com/edgec/browserbackend/account/controller/AdministratorController.java
View file @
b360da96
...
...
@@ -396,6 +396,24 @@ public class AdministratorController {
return
resultDto
;
}
//添加白名单
@PreAuthorize
(
Securitys
.
ADMIN_EL
)
@RequestMapping
(
path
=
"/0xadministrator/userwhitelist/add"
,
method
=
RequestMethod
.
PUT
)
public
ResultDto
addWhiteList
(
Principal
principal
,
@RequestParam
(
"username"
)
String
username
,
@RequestParam
(
"website"
)
String
website
)
{
ResultDto
resultDto
=
new
ResultDto
();
try
{
administratorService
.
addUserWhiteList
(
username
,
website
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
resultDto
.
setStatusInfo
(
statusInfo
);
}
return
resultDto
;
}
//统计ip数量
@PreAuthorize
(
Securitys
.
ADMIN_EL
)
@RequestMapping
(
path
=
"/0xadministrator/ip/count"
,
method
=
RequestMethod
.
GET
)
...
...
src/main/java/com/edgec/browserbackend/account/service/AdministratorService.java
View file @
b360da96
...
...
@@ -62,5 +62,7 @@ public interface AdministratorService {
void
addWhiteList
(
String
website
);
void
addUserWhiteList
(
String
username
,
String
website
);
File
getProxyConfig
();
}
src/main/java/com/edgec/browserbackend/account/service/impl/AdministratorServiceImpl.java
View file @
b360da96
...
...
@@ -465,6 +465,15 @@ public class AdministratorServiceImpl implements AdministratorService {
whiteSiteRepository
.
save
(
whiteSite
);
}
@Override
public
void
addUserWhiteList
(
String
username
,
String
website
)
{
Account
account
=
accountRepository
.
findByName
(
username
);
if
(
account
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
account
.
getWhiteList
().
add
(
website
);
accountRepository
.
save
(
account
);
}
@Override
public
File
getProxyConfig
()
{
ProxyConfig
proxyConfig
=
null
;
...
...
src/main/java/com/edgec/browserbackend/browser/dto/IpResourceRequestDto.java
View file @
b360da96
...
...
@@ -29,6 +29,7 @@ public class IpResourceRequestDto {
private
int
ipkeptperiod
=
7
;
private
String
startscript
=
""
;
private
boolean
specialLine
;
//自有IP需要传proxy的账号
private
String
username
;
private
String
password
;
...
...
@@ -206,4 +207,12 @@ public class IpResourceRequestDto {
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
boolean
isSpecialLine
()
{
return
specialLine
;
}
public
void
setSpecialLine
(
boolean
specialLine
)
{
this
.
specialLine
=
specialLine
;
}
}
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpResourceServiceImpl.java
View file @
b360da96
...
...
@@ -218,6 +218,8 @@ public class IpResourceServiceImpl implements IpResourceService {
.
filter
(
x
->
Vendor
.
valueOf
(
ipResourceRequestDto
.
getVendor
()).
getValue
().
equals
(
x
.
substring
(
0
,
x
.
indexOf
(
"-"
))))
.
map
(
x
->
x
.
substring
(
x
.
lastIndexOf
(
"-"
)
+
1
)).
collect
(
Collectors
.
joining
());
newprice
=
ipResourceRequestDto
.
getUnit
().
equals
(
"week"
)
?
(
Integer
.
valueOf
(
price
)/
3
)
:
Integer
.
valueOf
(
price
);
if
(
ipResourceRequestDto
.
isSpecialLine
())
newprice
*=
3
;
}
IpChargeResultDto
ipChargeResultDto
=
accountService
.
preChargeByMoney
(
username
,
newprice
*
ipResourceRequestDto
.
getAmount
()
*
ipResourceRequestDto
.
getPeriod
());
...
...
@@ -253,6 +255,7 @@ public class IpResourceServiceImpl implements IpResourceService {
throw
new
ClientRequestException
(
BrowserErrorCode
.
INFORMATIONNOTCOMPELETE
);
if
(
StringUtils
.
isBlank
(
ipResourceRequestDto
.
getAddr
().
get
(
0
)))
throw
new
ClientRequestException
(
BrowserErrorCode
.
INFORMATIONNOTCOMPELETE
);
ipResource
.
setSpecialLine
(
ipResourceRequestDto
.
isSpecialLine
());
ipResource
.
setAddr
(
ipResourceRequestDto
.
getAddr
().
get
(
0
));
ipResource
.
setIpType
(
IpType
.
OWN
);
ipResource
.
setVendor
(
Vendor
.
valueOf
(
ipResourceRequestDto
.
getVendor
()));
...
...
@@ -611,11 +614,16 @@ public class IpResourceServiceImpl implements IpResourceService {
}
}
}
if
(
x
.
getStatus
()
==
6
||
(
x
.
isSpecialLine
()
&&
x
.
getPurchasedTime
()
>
(
Instant
.
now
().
toEpochMilli
()
-
12
*
60
*
1000
))
)
if
(
x
.
getStatus
()
==
6
)
x
.
setStatus
(
3
);
if
(
x
.
getStatus
()
==
3
)
{
x
.
setAddr
(
""
);
}
if
(
x
.
isSpecialLine
()
&&
x
.
getPurchasedTime
()
>
(
Instant
.
now
().
toEpochMilli
()
-
12
*
60
*
1000
))
{
x
.
setStatus
(
3
);
ipResourceRepository
.
save
(
x
);
x
.
setAddr
(
""
);
}
SpecialLine
specialLine
=
specialLineRepository
.
findAll
().
get
(
0
);
if
(
x
.
isSpecialLine
())
ipResourceDtos
.
add
(
new
IpResourceDto
(
x
,
shopDto
,
false
,
specialLine
));
...
...
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