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
62494496
Commit
62494496
authored
Mar 15, 2020
by
renjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
生产环境参数
parent
bfee1df5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
10 deletions
+20
-10
pom.xml
pom.xml
+0
-5
IpResourceServiceImpl.java
...erbackend/browser/service/Impl/IpResourceServiceImpl.java
+20
-5
No files found.
pom.xml
View file @
62494496
...
...
@@ -93,11 +93,6 @@
<artifactId>
aliyun-java-sdk-core
</artifactId>
<version>
4.1.0
</version>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
<version>
4.5.3
</version>
</dependency>
<dependency>
<groupId>
com.alipay.sdk
</groupId>
<artifactId>
alipay-sdk-java
</artifactId>
...
...
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpResourceServiceImpl.java
View file @
62494496
...
...
@@ -23,6 +23,9 @@ import org.apache.commons.lang3.StringUtils;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.couchbase.CouchbaseProperties
;
import
org.springframework.core.env.Environment
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.data.domain.PageRequest
;
...
...
@@ -55,6 +58,9 @@ public class IpResourceServiceImpl implements IpResourceService {
private
static
String
startscript
=
""
;
@Value
(
"${spring.profiles.active}"
)
private
String
profiles
;
@Autowired
private
AccountRepository
accountRepository
;
...
...
@@ -79,13 +85,19 @@ public class IpResourceServiceImpl implements IpResourceService {
public
HttpHeaders
buildPostHeader
()
{
HttpHeaders
header
=
new
HttpHeaders
();
header
.
setContentType
(
MediaType
.
APPLICATION_JSON
);
header
.
setBearerAuth
(
"oq5tg3gMsflHcK5iZ2741G5R30XYd9blyOqH9qeBItKtrzfTsGIoy8AsxqqNXdcm"
);
if
(
profiles
.
equals
(
"dev"
))
header
.
setBearerAuth
(
"oq5tg3gMsflHcK5iZ2741G5R30XYd9blyOqH9qeBItKtrzfTsGIoy8AsxqqNXdcm"
);
else
if
(
profiles
.
equals
(
"prod"
))
header
.
setBearerAuth
(
"tKWsuHzcngf0RQPMss70f9jgymDIwgQ9zbLfESJdcou3pZSNWl7lNTzto8VQgwaO"
);
return
header
;
}
public
HttpHeaders
buildGetHeader
()
{
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setBearerAuth
(
"oq5tg3gMsflHcK5iZ2741G5R30XYd9blyOqH9qeBItKtrzfTsGIoy8AsxqqNXdcm"
);
if
(
profiles
.
equals
(
"dev"
))
headers
.
setBearerAuth
(
"oq5tg3gMsflHcK5iZ2741G5R30XYd9blyOqH9qeBItKtrzfTsGIoy8AsxqqNXdcm"
);
else
if
(
profiles
.
equals
(
"prod"
))
headers
.
setBearerAuth
(
"tKWsuHzcngf0RQPMss70f9jgymDIwgQ9zbLfESJdcou3pZSNWl7lNTzto8VQgwaO"
);
return
headers
;
}
...
...
@@ -112,6 +124,7 @@ public class IpResourceServiceImpl implements IpResourceService {
@Override
public
List
<
IpResourceDto
>
buyIp
(
String
username
,
IpResourceRequestDto
ipResourceRequestDto
)
throws
Exception
{
String
URL
=
(
profiles
.
equals
(
"dev"
)
||
profiles
.
equals
(
"staging"
))?
TESTURL
:
CLOUDAMURL
;
Account
account
=
accountRepository
.
findByName
(
username
);
if
(
account
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
...
...
@@ -156,7 +169,7 @@ public class IpResourceServiceImpl implements IpResourceService {
HttpEntity
<
Map
<
String
,
Object
>>
httpEntity
=
new
HttpEntity
<>(
map
,
header
);
IpBuyResultDto
ipBuyResultDto
=
null
;
try
{
ipBuyResultDto
=
restTemplate
.
postForObject
(
TEST
URL
+
"/intelligroup/ipresources?accountId=browser"
,
httpEntity
,
IpBuyResultDto
.
class
);
ipBuyResultDto
=
restTemplate
.
postForObject
(
URL
+
"/intelligroup/ipresources?accountId=browser"
,
httpEntity
,
IpBuyResultDto
.
class
);
if
(
StringUtils
.
isNotBlank
(
ipBuyResultDto
.
getErrorCode
()))
throw
new
Exception
(
ipBuyResultDto
.
getErrorCode
());
}
catch
(
Throwable
e
)
{
...
...
@@ -213,6 +226,7 @@ public class IpResourceServiceImpl implements IpResourceService {
@Override
public
IpOperationResultDto
renewIp
(
String
username
,
IpResourceRequestDto
ipResourceRequestDto
)
{
String
URL
=
(
profiles
.
equals
(
"dev"
)
||
profiles
.
equals
(
"staging"
))?
TESTURL
:
CLOUDAMURL
;
Account
account
=
accountRepository
.
findByName
(
username
);
if
(
account
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
...
...
@@ -240,7 +254,7 @@ public class IpResourceServiceImpl implements IpResourceService {
map
.
put
(
"period"
,
ipResourceRequestDto
.
getPeriod
());
HttpHeaders
headers
=
buildPostHeader
();
HttpEntity
<
Map
<
String
,
Object
>>
entity
=
new
HttpEntity
<>(
map
,
headers
);
ResponseEntity
<
String
>
result
=
restTemplate
.
exchange
(
TEST
URL
+
"/intelligroup/renewip?accountId=browser"
,
HttpMethod
.
PUT
,
entity
,
String
.
class
);
ResponseEntity
<
String
>
result
=
restTemplate
.
exchange
(
URL
+
"/intelligroup/renewip?accountId=browser"
,
HttpMethod
.
PUT
,
entity
,
String
.
class
);
RenewIpResultDto
renewIpResultDto
=
JSON
.
parseObject
(
result
.
getBody
(),
RenewIpResultDto
.
class
);
if
(
StringUtils
.
isNotBlank
(
renewIpResultDto
.
getErrorCode
()))
{
logger
.
error
(
renewIpResultDto
.
getErrorCode
());
...
...
@@ -272,6 +286,7 @@ public class IpResourceServiceImpl implements IpResourceService {
@Override
public
IpOperationResultDto
deleteIp
(
String
username
,
List
<
String
>
ipAddrs
)
{
String
URL
=
(
profiles
.
equals
(
"dev"
)
||
profiles
.
equals
(
"staging"
))?
TESTURL
:
CLOUDAMURL
;
Account
account
=
accountRepository
.
findByName
(
username
);
if
(
account
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
...
...
@@ -298,7 +313,7 @@ public class IpResourceServiceImpl implements IpResourceService {
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
HttpEntity
<
Map
<
String
,
String
>>
httpEntity
=
new
HttpEntity
<>(
params
,
headers
);
try
{
ResponseEntity
<
String
>
result
=
restTemplate
.
exchange
(
TEST
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
);
if
(
StringUtils
.
isNotBlank
(
deleteIpResultDto
.
getErrorCode
()))
throw
new
Exception
(
deleteIpResultDto
.
getErrorCode
());
...
...
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