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
54138c3c
Commit
54138c3c
authored
Mar 12, 2020
by
renjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
付费功能
删除ip修改
parent
ab204c18
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
103 additions
and
30 deletions
+103
-30
IpChargeRequestDto.java
...gec/browserbackend/account/domain/IpChargeRequestDto.java
+11
-1
UserPrePaidBilling.java
...gec/browserbackend/account/domain/UserPrePaidBilling.java
+12
-2
AccountErrorCode.java
...ec/browserbackend/account/exception/AccountErrorCode.java
+4
-2
AccountServiceImpl.java
...owserbackend/account/service/impl/AccountServiceImpl.java
+1
-3
IpControlloer.java
...dgec/browserbackend/browser/controller/IpControlloer.java
+18
-5
IpResource.java
...a/com/edgec/browserbackend/browser/domain/IpResource.java
+12
-3
Vendor.java
.../java/com/edgec/browserbackend/browser/domain/Vendor.java
+20
-0
IpResourceDto.java
...a/com/edgec/browserbackend/browser/dto/IpResourceDto.java
+4
-7
IpResourceRequestDto.java
...dgec/browserbackend/browser/dto/IpResourceRequestDto.java
+14
-0
IpResourceRepository.java
...owserbackend/browser/repository/IpResourceRepository.java
+7
-7
IpResourceServiceImpl.java
...erbackend/browser/service/Impl/IpResourceServiceImpl.java
+0
-0
No files found.
src/main/java/com/edgec/browserbackend/account/domain/IpChargeRequestDto.java
View file @
54138c3c
...
@@ -7,8 +7,10 @@ public class IpChargeRequestDto {
...
@@ -7,8 +7,10 @@ public class IpChargeRequestDto {
private
String
unit
=
"month"
;
private
String
unit
=
"month"
;
private
String
target
;
private
String
target
;
//0 --
newip, 1 --renew, 2 --ipkeptfee, 3 --deleteip, 4 -- stopinstanceonly , 5 -- bindinstance, 6 -- refundipkeptfee
//0 --
充值, 1 -- newip, 2 --renew, 3 --ipkeptfee, 4 --deleteip,
private
int
chargeType
=
0
;
private
int
chargeType
=
0
;
//0 -- 余额, 2 -- 支付宝, 3 -- 微信
private
int
payMethod
=
0
;
private
float
daysPerMonth
=
0
;
private
float
daysPerMonth
=
0
;
...
@@ -87,4 +89,12 @@ public class IpChargeRequestDto {
...
@@ -87,4 +89,12 @@ public class IpChargeRequestDto {
public
void
setAmount
(
int
amount
)
{
public
void
setAmount
(
int
amount
)
{
this
.
amount
=
amount
;
this
.
amount
=
amount
;
}
}
public
int
getPayMethod
()
{
return
payMethod
;
}
public
void
setPayMethod
(
int
payMethod
)
{
this
.
payMethod
=
payMethod
;
}
}
}
src/main/java/com/edgec/browserbackend/account/domain/UserPrePaidBilling.java
View file @
54138c3c
...
@@ -35,6 +35,9 @@ public class UserPrePaidBilling {
...
@@ -35,6 +35,9 @@ public class UserPrePaidBilling {
private
BillStatus
status
;
private
BillStatus
status
;
//0 -- 余额, 2 -- 支付宝, 3 -- 微信
private
int
payMethod
;
private
boolean
isPrepaid
;
private
boolean
isPrepaid
;
private
String
user
;
private
String
user
;
...
@@ -46,8 +49,7 @@ public class UserPrePaidBilling {
...
@@ -46,8 +49,7 @@ public class UserPrePaidBilling {
private
float
ownBillingCost
=
0
;
private
float
ownBillingCost
=
0
;
private
float
total
;
private
float
total
;
//0 -- newip, 1 --renew, 2 --ipkeptfee, 3 --deleteip, 4 -- stopinstanceonly , 5 -- bindinstance, 6 -- refundipkeptfee
//0 -- 充值, 1 -- newip, 2 --renew, 3 --ipkeptfee, 4 --deleteip,
//7 -- newcvm , 8 -- renewcvm , 9 -- intelligroup
private
int
chargeType
;
private
int
chargeType
;
private
String
target
;
private
String
target
;
...
@@ -221,4 +223,12 @@ public class UserPrePaidBilling {
...
@@ -221,4 +223,12 @@ public class UserPrePaidBilling {
public
void
setUser
(
String
user
)
{
public
void
setUser
(
String
user
)
{
this
.
user
=
user
;
this
.
user
=
user
;
}
}
public
int
getPayMethod
()
{
return
payMethod
;
}
public
void
setPayMethod
(
int
payMethod
)
{
this
.
payMethod
=
payMethod
;
}
}
}
src/main/java/com/edgec/browserbackend/account/exception/AccountErrorCode.java
View file @
54138c3c
...
@@ -53,8 +53,10 @@ public enum AccountErrorCode implements ErrorCode {
...
@@ -53,8 +53,10 @@ public enum AccountErrorCode implements ErrorCode {
NOPERMISSION
(
ACCOUNT_BASE
+
140
,
"You have no right to do this operarion"
),
NOPERMISSION
(
ACCOUNT_BASE
+
140
,
"You have no right to do this operarion"
),
GROUPMAX
(
ACCOUNT_BASE
+
141
,
"You can not have more groups"
),
GROUPMAX
(
ACCOUNT_BASE
+
141
,
"You can not have more groups"
),
SHOPMAX
(
ACCOUNT_BASE
+
141
,
"You can not have more shops"
),
SHOPMAX
(
ACCOUNT_BASE
+
142
,
"You can not have more shops"
),
CHILDMAX
(
ACCOUNT_BASE
+
141
,
"You can not have more subUsers"
);
CHILDMAX
(
ACCOUNT_BASE
+
143
,
"You can not have more subUsers"
),
NOTENOUGHBALANCE
(
ErrorCode
.
ACCOUNT_BASE
+
150
,
"Your balance is not enough"
);
...
...
src/main/java/com/edgec/browserbackend/account/service/impl/AccountServiceImpl.java
View file @
54138c3c
...
@@ -213,21 +213,19 @@ public class AccountServiceImpl implements AccountService {
...
@@ -213,21 +213,19 @@ public class AccountServiceImpl implements AccountService {
userBalanceRepository
.
incrementBalance
(
userBalance
,
-(
float
)
money
,
(
float
)
money
);
userBalanceRepository
.
incrementBalance
(
userBalance
,
-(
float
)
money
,
(
float
)
money
);
userBalance
=
userBalanceRepository
.
findById
(
name
).
orElse
(
null
);
userBalance
=
userBalanceRepository
.
findById
(
name
).
orElse
(
null
);
charge
.
setBalance
(
Math
.
round
(
userBalance
.
getBalanced
()));
charge
.
setBalance
(
Math
.
round
(
userBalance
.
getBalanced
()));
charge
.
setSuccess
(
true
);
charge
.
setSuccess
(
true
);
UserPrePaidBilling
bill
=
new
UserPrePaidBilling
();
UserPrePaidBilling
bill
=
new
UserPrePaidBilling
();
bill
.
setChargeType
(
requestDto
.
getChargeType
());
bill
.
setChargeType
(
requestDto
.
getChargeType
());
bill
.
setServices
(
Services
.
valueOf
(
requestDto
.
getServices
()));
bill
.
setAmount
(
requestDto
.
getAmount
());
bill
.
setAmount
(
requestDto
.
getAmount
());
bill
.
setUnit
(
requestDto
.
getUnit
());
bill
.
setUnit
(
requestDto
.
getUnit
());
bill
.
setPeriod
(
requestDto
.
getPeriod
());
bill
.
setPeriod
(
requestDto
.
getPeriod
());
bill
.
setPayMethod
(
requestDto
.
getPayMethod
());
bill
.
setUsername
(
name
);
bill
.
setUsername
(
name
);
bill
.
setTotal
((
float
)
money
);
bill
.
setTotal
((
float
)
money
);
bill
.
setStatus
(
BillStatus
.
PAID
);
bill
.
setStatus
(
BillStatus
.
PAID
);
bill
.
setPrepaid
(
true
);
bill
.
setPrepaid
(
true
);
bill
.
setUsername
(
name
);
bill
.
setTimestamp
(
Instant
.
now
().
toEpochMilli
());
bill
.
setTimestamp
(
Instant
.
now
().
toEpochMilli
());
...
...
src/main/java/com/edgec/browserbackend/browser/controller/IpControlloer.java
View file @
54138c3c
...
@@ -3,6 +3,7 @@ package com.edgec.browserbackend.browser.controller;
...
@@ -3,6 +3,7 @@ package com.edgec.browserbackend.browser.controller;
import
com.edgec.browserbackend.account.dto.ResultDto
;
import
com.edgec.browserbackend.account.dto.ResultDto
;
import
com.edgec.browserbackend.browser.dto.*
;
import
com.edgec.browserbackend.browser.dto.*
;
import
com.edgec.browserbackend.browser.service.IpResourceService
;
import
com.edgec.browserbackend.browser.service.IpResourceService
;
import
com.edgec.browserbackend.common.commons.error.ClientRequestException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
@@ -28,7 +29,13 @@ public class IpControlloer {
...
@@ -28,7 +29,13 @@ public class IpControlloer {
List
<
IpResourceDto
>
ipResourceDto
=
ipResourceService
.
buyIp
(
principal
.
getName
(),
ipResourceRequestDto
);
List
<
IpResourceDto
>
ipResourceDto
=
ipResourceService
.
buyIp
(
principal
.
getName
(),
ipResourceRequestDto
);
resultDto
.
setData
(
ipResourceDto
);
resultDto
.
setData
(
ipResourceDto
);
resultDto
.
setStatus
(
0
);
resultDto
.
setStatus
(
0
);
}
catch
(
Exception
e
)
{
}
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
);
}
catch
(
Exception
e
)
{
resultDto
.
setStatus
(-
1
);
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
80001
);
statusInfo
.
put
(
"code"
,
80001
);
...
@@ -44,7 +51,13 @@ public class IpControlloer {
...
@@ -44,7 +51,13 @@ public class IpControlloer {
try
{
try
{
resultDto
.
setData
(
ipResourceService
.
renewIp
(
principal
.
getName
(),
ipResourceRequestDto
));
resultDto
.
setData
(
ipResourceService
.
renewIp
(
principal
.
getName
(),
ipResourceRequestDto
));
resultDto
.
setStatus
(
0
);
resultDto
.
setStatus
(
0
);
}
catch
(
Exception
e
)
{
}
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
);
}
catch
(
Exception
e
)
{
resultDto
.
setStatus
(-
1
);
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
80001
);
statusInfo
.
put
(
"code"
,
80001
);
...
@@ -60,7 +73,7 @@ public class IpControlloer {
...
@@ -60,7 +73,7 @@ public class IpControlloer {
try
{
try
{
resultDto
.
setData
(
ipResourceService
.
deleteIp
(
principal
.
getName
(),
ipResourceRequestDto
.
getAddr
()));
resultDto
.
setData
(
ipResourceService
.
deleteIp
(
principal
.
getName
(),
ipResourceRequestDto
.
getAddr
()));
resultDto
.
setStatus
(
0
);
resultDto
.
setStatus
(
0
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
resultDto
.
setStatus
(-
1
);
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
80001
);
statusInfo
.
put
(
"code"
,
80001
);
...
@@ -78,10 +91,10 @@ public class IpControlloer {
...
@@ -78,10 +91,10 @@ public class IpControlloer {
ipListRequestDto
.
getAmount
(),
ipListRequestDto
.
getIpFilterDto
());
ipListRequestDto
.
getAmount
(),
ipListRequestDto
.
getIpFilterDto
());
resultDto
.
setData
(
ipResourceDto
);
resultDto
.
setData
(
ipResourceDto
);
resultDto
.
setStatus
(
0
);
resultDto
.
setStatus
(
0
);
}
catch
(
Exception
e
)
{
}
catch
(
ClientRequest
Exception
e
)
{
resultDto
.
setStatus
(-
1
);
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
80001
);
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
()
);
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
resultDto
.
setStatusInfo
(
statusInfo
);
resultDto
.
setStatusInfo
(
statusInfo
);
}
}
...
...
src/main/java/com/edgec/browserbackend/browser/domain/IpResource.java
View file @
54138c3c
...
@@ -15,8 +15,9 @@ public class IpResource {
...
@@ -15,8 +15,9 @@ public class IpResource {
private
String
id
;
private
String
id
;
private
String
addr
;
private
String
addr
;
private
IpType
ipType
=
IpType
.
VENDOR
;
private
IpType
ipType
=
IpType
.
VENDOR
;
private
String
vendor
;
private
Vendor
vendor
;
private
String
region
;
private
String
region
;
private
String
regionCn
;
//0:正常, 1:已过期, 2:即将过期
//0:正常, 1:已过期, 2:即将过期
private
int
status
;
private
int
status
;
private
List
<
String
>
port
;
private
List
<
String
>
port
;
...
@@ -57,6 +58,14 @@ public class IpResource {
...
@@ -57,6 +58,14 @@ public class IpResource {
this
.
region
=
region
;
this
.
region
=
region
;
}
}
public
String
getRegionCn
()
{
return
regionCn
;
}
public
void
setRegionCn
(
String
regionCn
)
{
this
.
regionCn
=
regionCn
;
}
public
int
getStatus
()
{
public
int
getStatus
()
{
return
status
;
return
status
;
}
}
...
@@ -105,11 +114,11 @@ public class IpResource {
...
@@ -105,11 +114,11 @@ public class IpResource {
this
.
addr
=
ipAddr
;
this
.
addr
=
ipAddr
;
}
}
public
String
getVendor
()
{
public
Vendor
getVendor
()
{
return
vendor
;
return
vendor
;
}
}
public
void
setVendor
(
String
vendor
)
{
public
void
setVendor
(
Vendor
vendor
)
{
this
.
vendor
=
vendor
;
this
.
vendor
=
vendor
;
}
}
...
...
src/main/java/com/edgec/browserbackend/browser/domain/Vendor.java
0 → 100644
View file @
54138c3c
package
com
.
edgec
.
browserbackend
.
browser
.
domain
;
/**
* @Desc
* @Author jason
* @CreateTime 2020/3/12 4:01 下午
**/
public
enum
Vendor
{
aliyun
(
"阿里云"
),
JDCLOUD
(
"京东云"
),
aws
(
"亚马逊云"
),
awscn
(
"亚马逊中国"
),
tencent
(
"腾讯云"
);
private
String
value
;
private
Vendor
(
String
value
)
{
this
.
value
=
value
;
}
public
String
getValue
()
{
return
value
;
}
}
src/main/java/com/edgec/browserbackend/browser/dto/IpResourceDto.java
View file @
54138c3c
package
com
.
edgec
.
browserbackend
.
browser
.
dto
;
package
com
.
edgec
.
browserbackend
.
browser
.
dto
;
import
com.edgec.browserbackend.browser.domain.IpResource
;
import
com.edgec.browserbackend.browser.domain.*
;
import
com.edgec.browserbackend.browser.domain.IpStatus
;
import
com.edgec.browserbackend.browser.domain.IpType
;
import
com.edgec.browserbackend.browser.domain.Shop
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
java.util.List
;
import
java.util.List
;
...
@@ -12,7 +9,7 @@ import java.util.List;
...
@@ -12,7 +9,7 @@ import java.util.List;
public
class
IpResourceDto
{
public
class
IpResourceDto
{
private
String
id
;
private
String
id
;
private
String
addr
;
private
String
addr
;
private
String
vendor
;
private
Vendor
vendor
;
private
String
region
;
private
String
region
;
private
int
status
;
private
int
status
;
private
List
<
String
>
port
;
private
List
<
String
>
port
;
...
@@ -67,11 +64,11 @@ public class IpResourceDto {
...
@@ -67,11 +64,11 @@ public class IpResourceDto {
this
.
region
=
region
;
this
.
region
=
region
;
}
}
public
String
getVendor
()
{
public
Vendor
getVendor
()
{
return
vendor
;
return
vendor
;
}
}
public
void
setVendor
(
String
vendor
)
{
public
void
setVendor
(
Vendor
vendor
)
{
this
.
vendor
=
vendor
;
this
.
vendor
=
vendor
;
}
}
...
...
src/main/java/com/edgec/browserbackend/browser/dto/IpResourceRequestDto.java
View file @
54138c3c
...
@@ -2,6 +2,8 @@ package com.edgec.browserbackend.browser.dto;
...
@@ -2,6 +2,8 @@ package com.edgec.browserbackend.browser.dto;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
javax.validation.constraints.Max
;
import
javax.validation.constraints.Min
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -9,8 +11,12 @@ import java.util.List;
...
@@ -9,8 +11,12 @@ import java.util.List;
public
class
IpResourceRequestDto
{
public
class
IpResourceRequestDto
{
private
String
name
;
private
String
name
;
private
String
region
;
private
String
region
;
private
String
regionCn
;
private
String
vendor
=
"aliyun"
;
private
String
vendor
=
"aliyun"
;
private
String
logintype
=
"password"
;
private
String
logintype
=
"password"
;
@Max
(
12
)
@Min
(
1
)
private
int
period
=
1
;
private
int
period
=
1
;
private
String
unit
=
"month"
;
private
String
unit
=
"month"
;
private
int
amount
=
1
;
private
int
amount
=
1
;
...
@@ -83,6 +89,14 @@ public class IpResourceRequestDto {
...
@@ -83,6 +89,14 @@ public class IpResourceRequestDto {
this
.
region
=
region
;
this
.
region
=
region
;
}
}
public
String
getRegionCn
()
{
return
regionCn
;
}
public
void
setAutorenew
(
boolean
autorenew
)
{
this
.
autorenew
=
autorenew
;
}
public
int
getIpkeptperiod
()
{
public
int
getIpkeptperiod
()
{
return
ipkeptperiod
;
return
ipkeptperiod
;
}
}
...
...
src/main/java/com/edgec/browserbackend/browser/repository/IpResourceRepository.java
View file @
54138c3c
...
@@ -10,11 +10,11 @@ import java.util.List;
...
@@ -10,11 +10,11 @@ import java.util.List;
public
interface
IpResourceRepository
extends
MongoRepository
<
IpResource
,
String
>
{
public
interface
IpResourceRepository
extends
MongoRepository
<
IpResource
,
String
>
{
IpResource
findByAddrAndIsDeleted
(
String
addr
,
boolean
isDeleted
);
IpResource
findByAddrAndIsDeleted
(
String
addr
,
boolean
isDeleted
);
List
<
IpResource
>
findByIdIn
(
List
<
String
>
ipIds
);
List
<
IpResource
>
findByIdIn
AndIsDeleted
(
List
<
String
>
ipIds
,
boolean
isDeleted
);
List
<
IpResource
>
findByOwnerAnd
ShopIdIsNull
(
String
owner
);
List
<
IpResource
>
findByOwnerAnd
IsDeletedAndShopIdIsNull
(
String
owner
,
boolean
isDeleted
);
List
<
IpResource
>
findByOwnerAndStatusAnd
ShopIdIsNull
(
String
owner
,
int
status
);
List
<
IpResource
>
findByOwnerAndStatusAnd
IsDeletedAndShopIdIsNull
(
String
owner
,
int
status
,
boolean
isDeleted
);
List
<
IpResource
>
findByStatusAndIdIn
(
int
status
,
List
<
String
>
ipIds
);
List
<
IpResource
>
findByStatusAndIdIn
AndIsDeleted
(
int
status
,
List
<
String
>
ipIds
,
boolean
isDeleted
);
Page
<
IpResource
>
findByAddrLikeAndIdIn
(
String
addr
,
List
<
String
>
ipIds
,
Pageable
pageable
);
Page
<
IpResource
>
findByAddrLikeAndIdIn
AndIsDeleted
(
String
addr
,
List
<
String
>
ipIds
,
boolean
isDeleted
,
Pageable
pageable
);
Page
<
IpResource
>
findByVendorLikeAndIdIn
(
String
vendor
,
List
<
String
>
ipIds
,
Pageable
pageable
);
Page
<
IpResource
>
findByVendorLikeAndIdIn
AndIsDeleted
(
String
vendor
,
List
<
String
>
ipIds
,
boolean
isDeleted
,
Pageable
pageable
);
Page
<
IpResource
>
findByRegionLikeAndIdIn
(
String
region
,
List
<
String
>
ipIds
,
Pageable
pageable
);
Page
<
IpResource
>
findByRegionLikeAndIdIn
AndIsDeleted
(
String
region
,
List
<
String
>
ipIds
,
boolean
isDeleted
,
Pageable
pageable
);
}
}
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpResourceServiceImpl.java
View file @
54138c3c
This diff is collapsed.
Click to expand it.
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