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
6dbd46bb
Commit
6dbd46bb
authored
Mar 18, 2020
by
renjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
异步任务
parent
3b1002a9
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
193 additions
and
82 deletions
+193
-82
BrowserErrorCode.java
...ec/browserbackend/browser/ErrorCode/BrowserErrorCode.java
+4
-1
IpControlloer.java
...dgec/browserbackend/browser/controller/IpControlloer.java
+19
-1
IpTransaction.java
...om/edgec/browserbackend/browser/domain/IpTransaction.java
+15
-3
IpTransactionDto.java
...om/edgec/browserbackend/browser/dto/IpTransactionDto.java
+22
-5
IpTransactionRepository.java
...erbackend/browser/repository/IpTransactionRepository.java
+13
-0
IpResourceServiceImpl.java
...erbackend/browser/service/Impl/IpResourceServiceImpl.java
+119
-71
IpResourceService.java
...gec/browserbackend/browser/service/IpResourceService.java
+1
-1
No files found.
src/main/java/com/edgec/browserbackend/browser/ErrorCode/BrowserErrorCode.java
View file @
6dbd46bb
package
com
.
edgec
.
browserbackend
.
browser
.
ErrorCode
;
import
com.edgec.browserbackend.browser.domain.IpTransaction
;
import
com.edgec.browserbackend.common.commons.error.ErrorCode
;
import
com.fasterxml.jackson.annotation.JsonValue
;
...
...
@@ -14,7 +15,9 @@ public enum BrowserErrorCode implements ErrorCode {
IPNOTEXIST
(
BROWSER_BASE
+
201
,
"The ip do not exist"
),
IPNOTBINDTOSHOP
(
BROWSER_BASE
+
202
,
"The ip do not bind this shop."
),
GROUPNOTEXIST
(
BROWSER_BASE
+
301
,
"The group do not exist"
);
GROUPNOTEXIST
(
BROWSER_BASE
+
301
,
"The group do not exist"
),
IPTRANSACTIONNOTEXIST
(
BROWSER_BASE
+
401
,
"The ipTransaction do not exist"
);
...
...
src/main/java/com/edgec/browserbackend/browser/controller/IpControlloer.java
View file @
6dbd46bb
...
...
@@ -26,7 +26,7 @@ public class IpControlloer {
public
ResultDto
buyIp
(
Principal
principal
,
@RequestBody
IpResourceRequestDto
ipResourceRequestDto
){
ResultDto
resultDto
=
new
ResultDto
();
try
{
List
<
IpResourceDto
>
ipResourceDto
=
ipResourceService
.
buyIp
(
principal
.
getName
(),
ipResourceRequestDto
);
IpTransactionDto
ipResourceDto
=
ipResourceService
.
buyIp
(
principal
.
getName
(),
ipResourceRequestDto
);
resultDto
.
setData
(
ipResourceDto
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
...
...
@@ -100,4 +100,22 @@ public class IpControlloer {
}
return
resultDto
;
}
@RequestMapping
(
value
=
"/queryTransaction"
,
method
=
RequestMethod
.
POST
)
public
ResultDto
queryTransaction
(
Principal
principal
,
@RequestBody
IpTransactionDto
ipTransactionDto
)
{
ResultDto
resultDto
=
new
ResultDto
();
try
{
IpTransactionDto
ipTransactionDto1
=
ipResourceService
.
queryTransaction
(
principal
.
getName
(),
ipTransactionDto
.
getTid
());
resultDto
.
setData
(
ipTransactionDto1
);
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
;
}
}
src/main/java/com/edgec/browserbackend/browser/domain/IpTransaction.java
View file @
6dbd46bb
...
...
@@ -3,6 +3,8 @@ package com.edgec.browserbackend.browser.domain;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
java.util.List
;
/**
* @Desc
* @Author jason
...
...
@@ -13,17 +15,19 @@ public class IpTransaction {
@Id
private
String
tid
;
private
int
username
;
private
String
username
;
private
long
createTime
;
private
int
status
;
public
int
getUsername
()
{
private
List
<
String
>
ipIds
;
public
String
getUsername
()
{
return
username
;
}
public
void
setUsername
(
int
username
)
{
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
...
...
@@ -50,4 +54,12 @@ public class IpTransaction {
public
void
setTid
(
String
tid
)
{
this
.
tid
=
tid
;
}
public
List
<
String
>
getIpIds
()
{
return
ipIds
;
}
public
void
setIpIds
(
List
<
String
>
ipIds
)
{
this
.
ipIds
=
ipIds
;
}
}
src/main/java/com/edgec/browserbackend/browser/dto/IpTransactionDto.java
View file @
6dbd46bb
package
com
.
edgec
.
browserbackend
.
browser
.
dto
;
import
com.edgec.browserbackend.browser.domain.IpTransaction
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @Desc
* @Author jason
* @CreateTime 2020/3/18 9:57 上午
**/
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
IpTransactionDto
{
private
String
tid
;
private
int
status
;
private
IpResourceDto
ipResourceDto
;
private
List
<
IpResourceDto
>
ipResourceDtos
;
public
IpTransactionDto
(){
}
public
IpTransactionDto
(
IpTransaction
ipTransaction
)
{
this
.
tid
=
ipTransaction
.
getTid
();
this
.
status
=
ipTransaction
.
getStatus
();
ipResourceDtos
=
new
ArrayList
<>();
}
public
String
getTid
()
{
return
tid
;
...
...
@@ -26,11 +43,11 @@ public class IpTransactionDto {
this
.
status
=
status
;
}
public
IpResourceDto
getIpResourceDto
()
{
return
ipResourceDto
;
public
List
<
IpResourceDto
>
getIpResourceDtos
()
{
return
ipResourceDto
s
;
}
public
void
setIpResourceDto
(
IpResourceDto
ipResourceDto
)
{
this
.
ipResourceDto
=
ipResourceDto
;
public
void
setIpResourceDto
s
(
List
<
IpResourceDto
>
ipResourceDtos
)
{
this
.
ipResourceDto
s
=
ipResourceDtos
;
}
}
src/main/java/com/edgec/browserbackend/browser/repository/IpTransactionRepository.java
0 → 100644
View file @
6dbd46bb
package
com
.
edgec
.
browserbackend
.
browser
.
repository
;
import
com.edgec.browserbackend.browser.domain.IpTransaction
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
/**
* @Desc
* @Author jason
* @CreateTime 2020/3/18 5:21 下午
**/
public
interface
IpTransactionRepository
extends
MongoRepository
<
IpTransaction
,
String
>
{
}
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpResourceServiceImpl.java
View file @
6dbd46bb
...
...
@@ -5,8 +5,6 @@ import com.alibaba.fastjson.JSONObject;
import
com.edgec.browserbackend.account.domain.Account
;
import
com.edgec.browserbackend.account.domain.IpChargeRequestDto
;
import
com.edgec.browserbackend.account.domain.IpChargeResultDto
;
import
com.edgec.browserbackend.account.dto.CvmChargeRegion
;
import
com.edgec.browserbackend.account.dto.ResultDto
;
import
com.edgec.browserbackend.account.exception.AccountErrorCode
;
import
com.edgec.browserbackend.account.repository.AccountRepository
;
import
com.edgec.browserbackend.account.service.AccountService
;
...
...
@@ -16,31 +14,26 @@ import com.edgec.browserbackend.browser.dto.*;
import
com.edgec.browserbackend.browser.repository.*
;
import
com.edgec.browserbackend.browser.service.IpResourceService
;
import
com.edgec.browserbackend.common.commons.error.ClientRequestException
;
import
com.edgec.browserbackend.common.commons.error.ErrorCode
;
import
com.edgec.browserbackend.common.dto.Result
;
import
com.edgec.browserbackend.common.utils.FileUtil
;
import
com.edgec.browserbackend.common.utils.ThreadPoolUtils
;
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
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.mongodb.core.aggregation.ArrayOperators
;
import
org.springframework.http.*
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.client.RestTemplate
;
import
javax.swing.text.Document
;
import
java.io.File
;
import
java.text.MessageFormat
;
import
java.time.Instant
;
import
java.util.*
;
import
java.util.regex.Pattern
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.stream.Collectors
;
@Service
...
...
@@ -82,6 +75,9 @@ public class IpResourceServiceImpl implements IpResourceService {
@Autowired
private
PlatformOptionsRepository
platformOptionsRepository
;
@Autowired
private
IpTransactionRepository
ipTransactionRepository
;
public
HttpHeaders
buildPostHeader
()
{
HttpHeaders
header
=
new
HttpHeaders
();
header
.
setContentType
(
MediaType
.
APPLICATION_JSON
);
...
...
@@ -158,7 +154,7 @@ public class IpResourceServiceImpl implements IpResourceService {
}
@Override
public
List
<
IpResourceDto
>
buyIp
(
String
username
,
IpResourceRequestDto
ipResourceRequestDto
)
throws
Exception
{
public
IpTransactionDto
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
)
...
...
@@ -173,78 +169,114 @@ public class IpResourceServiceImpl implements IpResourceService {
String
price
=
vendorPrices
.
stream
()
.
filter
(
x
->
Vendor
.
valueOf
(
ipResourceRequestDto
.
getVendor
()).
getValue
().
equals
(
x
.
substring
(
0
,
x
.
indexOf
(
"-"
))))
.
map
(
x
->
x
.
substring
(
x
.
lastIndexOf
(
"-"
)
+
1
)).
collect
(
Collectors
.
joining
());
IpChargeResultDto
ipChargeResultDto
=
accountService
.
preChargeByMoney
(
username
,
Double
.
valueOf
(
price
));
IpChargeResultDto
ipChargeResultDto
=
accountService
.
preChargeByMoney
(
username
,
Double
.
valueOf
(
price
)
*
ipResourceRequestDto
.
getAmount
()
);
if
(!
ipChargeResultDto
.
isSuccess
())
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NOTENOUGHBALANCE
);
}
List
<
IpResourceDto
>
ipResourceDtos
=
new
ArrayList
<>();
RestTemplate
restTemplate
=
new
RestTemplate
();
HttpHeaders
header
=
buildPostHeader
();
HashMap
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"name"
,
ipResourceRequestDto
.
getName
());
map
.
put
(
"region"
,
ipResourceRequestDto
.
getRegion
());
if
(
ipResourceRequestDto
.
getUnit
().
equals
(
"month"
)
&&
ipResourceRequestDto
.
getPeriod
()
==
6
)
ipResourceRequestDto
.
setPeriod
(
7
);
else
if
(
ipResourceRequestDto
.
getUnit
().
equals
(
"month"
)
&&
ipResourceRequestDto
.
getPeriod
()
==
12
)
ipResourceRequestDto
.
setPeriod
(
14
);
map
.
put
(
"period"
,
String
.
valueOf
(
ipResourceRequestDto
.
getPeriod
()));
map
.
put
(
"provider"
,
ipResourceRequestDto
.
getVendor
());
map
.
put
(
"unit"
,
ipResourceRequestDto
.
getUnit
());
map
.
put
(
"amount"
,
String
.
valueOf
(
ipResourceRequestDto
.
getAmount
()));
String
password
;
if
(
StringUtils
.
isNotBlank
(
ipResourceRequestDto
.
getPassword
()))
password
=
ipResourceRequestDto
.
getPassword
();
else
password
=
genRandom
(
3
,
12
);
map
.
put
(
"loginPassword"
,
password
);
map
.
put
(
"startscript"
,
startscript
);
map
.
put
(
"ipkeptperiod"
,
ipResourceRequestDto
.
getIpkeptperiod
());
HttpEntity
<
Map
<
String
,
Object
>>
httpEntity
=
new
HttpEntity
<>(
map
,
header
);
IpBuyResultDto
ipBuyResultDto
=
null
;
try
{
ipBuyResultDto
=
restTemplate
.
postForObject
(
URL
+
"/intelligroup/ipresources?accountId=browser"
,
httpEntity
,
IpBuyResultDto
.
class
);
if
(
StringUtils
.
isNotBlank
(
ipBuyResultDto
.
getErrorCode
()))
throw
new
Exception
(
ipBuyResultDto
.
getErrorCode
());
}
catch
(
Throwable
e
)
{
logger
.
error
(
"fail to post request"
,
e
.
getMessage
());
logger
.
error
(
e
.
getMessage
());
throw
e
;
}
try
{
if
(
ipBuyResultDto
!=
null
&&
ipBuyResultDto
.
getIplist
()
!=
null
&&
ipBuyResultDto
.
getIplist
().
size
()
>=
1
)
{
ipBuyResultDto
.
getIplist
().
forEach
(
x
->
{
IpResource
ipResource
=
new
IpResource
();
ipResource
.
setAddr
(
x
.
getIp
());
ipResource
.
setIpType
(
IpType
.
VENDOR
);
ipResource
.
setPurchasedTime
(
Instant
.
now
().
toEpochMilli
());
ipResource
.
setValidTime
(
Instant
.
parse
(
x
.
getValidTill
()).
toEpochMilli
());
ipResource
.
setPort
(
port
);
ipResource
.
setVendor
(
Vendor
.
valueOf
(
ipResourceRequestDto
.
getVendor
()));
ipResource
.
setStatus
(
0
);
ipResource
.
setUsername
(
USERNAME
);
if
(
account
.
getParent
()
!=
null
)
ipResource
.
setUserParent
(
account
.
getParent
());
ipResource
.
setRegion
(
ipResourceRequestDto
.
getRegion
());
ipResource
.
setRegionCn
(
ipResourceRequestDto
.
getRegionCn
());
ipResource
.
setProtocol
(
protocol
);
ipResource
.
setPassword
(
password
);
ipResource
.
setOwner
(
username
);
ipResourceRepository
.
save
(
ipResource
);
ipResourceDtos
.
add
(
new
IpResourceDto
(
ipResource
,
null
));
});
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"fail to post request"
,
e
.
getMessage
());
logger
.
error
(
e
.
getMessage
());
throw
new
ClientRequestException
(
BrowserErrorCode
.
UNKNOWN
);
IpTransaction
ipTransaction
=
new
IpTransaction
();
ipTransaction
.
setCreateTime
(
Instant
.
now
().
toEpochMilli
());
ipTransaction
.
setUsername
(
username
);
ipTransaction
.
setStatus
(
0
);
List
<
IpResourceDto
>
ipResourceDtos
=
new
ArrayList
<>();
List
<
String
>
ipIds
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
ipResourceRequestDto
.
getAmount
();
i
++)
{
IpResource
ipResource
=
new
IpResource
();
ipResource
.
setAddr
(
""
);
ipResource
.
setIpType
(
IpType
.
VENDOR
);
ipResource
.
setPurchasedTime
(
Instant
.
now
().
toEpochMilli
());
ipResource
.
setValidTime
(
Instant
.
now
().
toEpochMilli
());
ipResource
.
setPort
(
port
);
ipResource
.
setVendor
(
Vendor
.
valueOf
(
ipResourceRequestDto
.
getVendor
()));
ipResource
.
setStatus
(
0
);
ipResource
.
setUsername
(
USERNAME
);
if
(
account
.
getParent
()
!=
null
)
ipResource
.
setUserParent
(
account
.
getParent
());
ipResource
.
setRegion
(
ipResourceRequestDto
.
getRegion
());
ipResource
.
setRegionCn
(
ipResourceRequestDto
.
getRegionCn
());
ipResource
.
setProtocol
(
protocol
);
ipResource
.
setPassword
(
password
);
ipResource
.
setOwner
(
username
);
IpResource
ipResource1
=
ipResourceRepository
.
save
(
ipResource
);
ipResourceDtos
.
add
(
new
IpResourceDto
(
ipResource1
,
null
));
ipIds
.
add
(
ipResource1
.
getId
());
}
ipTransaction
.
setIpIds
(
ipIds
);
ipTransactionRepository
.
save
(
ipTransaction
);
IpTransactionDto
ipTransactionDto
=
new
IpTransactionDto
(
ipTransaction
);
ipTransactionDto
.
setIpResourceDtos
(
ipResourceDtos
);
CompletableFuture
.
runAsync
(()
->
{
try
{
Thread
.
sleep
(
2000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
RestTemplate
restTemplate
=
new
RestTemplate
();
HttpHeaders
header
=
buildPostHeader
();
HashMap
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"name"
,
ipResourceRequestDto
.
getName
());
map
.
put
(
"region"
,
ipResourceRequestDto
.
getRegion
());
if
(
ipResourceRequestDto
.
getUnit
().
equals
(
"month"
)
&&
ipResourceRequestDto
.
getPeriod
()
==
6
)
ipResourceRequestDto
.
setPeriod
(
7
);
else
if
(
ipResourceRequestDto
.
getUnit
().
equals
(
"month"
)
&&
ipResourceRequestDto
.
getPeriod
()
==
12
)
ipResourceRequestDto
.
setPeriod
(
14
);
map
.
put
(
"period"
,
String
.
valueOf
(
ipResourceRequestDto
.
getPeriod
()));
map
.
put
(
"provider"
,
ipResourceRequestDto
.
getVendor
());
map
.
put
(
"unit"
,
ipResourceRequestDto
.
getUnit
());
map
.
put
(
"amount"
,
String
.
valueOf
(
ipResourceRequestDto
.
getAmount
()));
map
.
put
(
"loginPassword"
,
password
);
map
.
put
(
"startscript"
,
startscript
);
map
.
put
(
"ipkeptperiod"
,
ipResourceRequestDto
.
getIpkeptperiod
());
HttpEntity
<
Map
<
String
,
Object
>>
httpEntity
=
new
HttpEntity
<>(
map
,
header
);
IpBuyResultDto
ipBuyResultDto
=
null
;
try
{
ipBuyResultDto
=
restTemplate
.
postForObject
(
URL
+
"/intelligroup/ipresources?accountId=browser"
,
httpEntity
,
IpBuyResultDto
.
class
);
if
(
StringUtils
.
isNotBlank
(
ipBuyResultDto
.
getErrorCode
()))
{
IpChargeRequestDto
ipChargeRequestDto
=
buildIpChargeRequestDto
(
ipResourceRequestDto
,
1
);
accountService
.
chargeByMoney
(
username
,
-
Double
.
valueOf
(
price
)*
ipChargeRequestDto
.
getAmount
(),
ipChargeRequestDto
);
logger
.
error
(
"fail to buy ip"
);
logger
.
error
(
ipBuyResultDto
.
getErrorCode
());
}
if
(
ipBuyResultDto
!=
null
&&
ipBuyResultDto
.
getIplist
()
!=
null
&&
ipBuyResultDto
.
getIplist
().
size
()
>=
1
)
{
AtomicInteger
index
=
new
AtomicInteger
();
ipBuyResultDto
.
getIplist
().
forEach
(
x
->
{
IpResource
ipResource
=
ipResourceRepository
.
findById
(
ipResourceDtos
.
get
(
index
.
get
()).
getId
()).
orElse
(
null
);
if
(
ipResource
!=
null
)
{
ipResource
.
setAddr
(
x
.
getIp
());
ipResource
.
setPurchasedTime
(
Instant
.
now
().
toEpochMilli
());
ipResource
.
setValidTime
(
Instant
.
parse
(
x
.
getValidTill
()).
toEpochMilli
());
ipResourceRepository
.
save
(
ipResource
);
}
else
{
logger
.
error
(
"no ipResource"
);
}
index
.
getAndIncrement
();
});
if
(
ipBuyResultDto
.
getIplist
().
size
()
<
ipResourceDtos
.
size
())
{
IpChargeRequestDto
ipChargeRequestDto
=
buildIpChargeRequestDto
(
ipResourceRequestDto
,
1
);
accountService
.
chargeByMoney
(
username
,
-
Double
.
valueOf
(
price
)*(
ipResourceDtos
.
size
()
-
ipBuyResultDto
.
getIplist
().
size
()),
ipChargeRequestDto
);
}
}
ipTransaction
.
setStatus
(
1
);
ipTransactionRepository
.
save
(
ipTransaction
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
());
}
},
ThreadPoolUtils
.
taskExecutorPool
);
IpChargeRequestDto
ipChargeRequestDto
=
buildIpChargeRequestDto
(
ipResourceRequestDto
,
1
);
accountService
.
chargeByMoney
(
username
,
Double
.
valueOf
(
price
),
ipChargeRequestDto
);
return
ip
ResourceDtos
;
accountService
.
chargeByMoney
(
username
,
Double
.
valueOf
(
price
)
*
ipChargeRequestDto
.
getAmount
()
,
ipChargeRequestDto
);
return
ip
TransactionDto
;
}
@Override
...
...
@@ -512,6 +544,22 @@ public class IpResourceServiceImpl implements IpResourceService {
@Override
public
IpTransactionDto
queryTransaction
(
String
username
,
String
tid
)
{
Account
account
=
accountRepository
.
findByName
(
username
);
if
(
account
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
if
(
account
.
getPermission
()
<
8
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
);
IpTransaction
ipTransaction
=
ipTransactionRepository
.
findById
(
tid
).
orElse
(
null
);
if
(
ipTransaction
==
null
)
throw
new
ClientRequestException
(
BrowserErrorCode
.
IPTRANSACTIONNOTEXIST
);
IpTransactionDto
ipTransactionDto
=
new
IpTransactionDto
(
ipTransaction
);
for
(
String
id
:
ipTransaction
.
getIpIds
())
{
IpResource
ipResource
=
ipResourceRepository
.
findById
(
id
).
orElse
(
null
);
if
(
ipResource
!=
null
)
{
IpResourceDto
ipResourceDto
=
new
IpResourceDto
(
ipResource
,
null
);
ipTransactionDto
.
getIpResourceDtos
().
add
(
ipResourceDto
);
}
}
// IpInfoResultDto ipInfoResultDto = new IpInfoResultDto();
// Map<String, String> params = new HashMap<String, String>();
// params.put("accountId", "browser");
...
...
@@ -524,6 +572,6 @@ public class IpResourceServiceImpl implements IpResourceService {
// ipResource.setPurchasedTime(Long.valueOf((String) jsonObject.get("createdWhen")));
// ipResource.setValidTime(Long.valueOf((String)jsonObject.get("validTill")));
// }
return
null
;
return
ipTransactionDto
;
}
}
src/main/java/com/edgec/browserbackend/browser/service/IpResourceService.java
View file @
6dbd46bb
...
...
@@ -7,7 +7,7 @@ import java.util.List;
public
interface
IpResourceService
{
List
<
IpResourceDto
>
buyIp
(
String
username
,
IpResourceRequestDto
ipResourceRequestDto
)
throws
Exception
;
IpTransactionDto
buyIp
(
String
username
,
IpResourceRequestDto
ipResourceRequestDto
)
throws
Exception
;
IpOperationResultDto
renewIp
(
String
username
,
IpResourceRequestDto
ipResourceRequestDto
)
throws
Exception
;
...
...
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