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
e987d372
Commit
e987d372
authored
Mar 19, 2020
by
renjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
第一版bug
parent
814d3b9b
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
35 additions
and
34 deletions
+35
-34
AccountController.java
.../browserbackend/account/controller/AccountController.java
+2
-2
UserDto.java
...java/com/edgec/browserbackend/account/domain/UserDto.java
+10
-10
AccountService.java
.../edgec/browserbackend/account/service/AccountService.java
+1
-1
AccountServiceImpl.java
...owserbackend/account/service/impl/AccountServiceImpl.java
+5
-8
WebSecurityConfig.java
...m/edgec/browserbackend/auth/config/WebSecurityConfig.java
+1
-1
Shop.java
...in/java/com/edgec/browserbackend/browser/domain/Shop.java
+3
-3
ShopResultDto.java
...a/com/edgec/browserbackend/browser/dto/ShopResultDto.java
+3
-3
IpResourceServiceImpl.java
...erbackend/browser/service/Impl/IpResourceServiceImpl.java
+9
-6
ShopServiceImpl.java
.../browserbackend/browser/service/Impl/ShopServiceImpl.java
+1
-0
No files found.
src/main/java/com/edgec/browserbackend/account/controller/AccountController.java
View file @
e987d372
...
@@ -203,10 +203,10 @@ public class AccountController {
...
@@ -203,10 +203,10 @@ public class AccountController {
}
}
@RequestMapping
(
path
=
"/resetpassword"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
path
=
"/resetpassword"
,
method
=
RequestMethod
.
POST
)
public
ResultDto
forgetPassword
(
@Valid
@RequestBody
UserDto
user
)
{
public
ResultDto
forgetPassword
(
Principal
principal
,
@RequestBody
UserDto
user
)
{
ResultDto
resultDto
=
new
ResultDto
();
ResultDto
resultDto
=
new
ResultDto
();
try
{
try
{
accountService
.
resetPassword
(
user
);
accountService
.
resetPassword
(
principal
.
getName
(),
user
);
resultDto
.
setStatus
(
0
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
resultDto
.
setStatus
(-
1
);
...
...
src/main/java/com/edgec/browserbackend/account/domain/UserDto.java
View file @
e987d372
...
@@ -12,9 +12,9 @@ public class UserDto {
...
@@ -12,9 +12,9 @@ public class UserDto {
private
String
phone
;
private
String
phone
;
private
String
otp
;
private
String
authCode
;
private
String
passwd
;
private
String
passw
or
d
;
public
String
getPhone
()
{
public
String
getPhone
()
{
return
phone
;
return
phone
;
...
@@ -24,20 +24,20 @@ public class UserDto {
...
@@ -24,20 +24,20 @@ public class UserDto {
this
.
phone
=
phone
;
this
.
phone
=
phone
;
}
}
public
String
get
Otp
()
{
public
String
get
AuthCode
()
{
return
otp
;
return
authCode
;
}
}
public
void
set
Otp
(
String
otp
)
{
public
void
set
AuthCode
(
String
authCode
)
{
this
.
otp
=
otp
;
this
.
authCode
=
authCode
;
}
}
public
String
getPasswd
()
{
public
String
getPassw
or
d
()
{
return
passwd
;
return
passw
or
d
;
}
}
public
void
setPassw
d
(
String
passw
d
)
{
public
void
setPassw
ord
(
String
passwor
d
)
{
this
.
passw
d
=
passw
d
;
this
.
passw
ord
=
passwor
d
;
}
}
public
String
getEmail
()
{
public
String
getEmail
()
{
...
...
src/main/java/com/edgec/browserbackend/account/service/AccountService.java
View file @
e987d372
...
@@ -42,7 +42,7 @@ public interface AccountService {
...
@@ -42,7 +42,7 @@ public interface AccountService {
*/
*/
Account
saveChanges
(
String
name
,
Account
update
);
Account
saveChanges
(
String
name
,
Account
update
);
void
resetPassword
(
UserDto
user
);
void
resetPassword
(
String
username
,
UserDto
user
);
Account
createSub
(
String
name
,
AccountDto
user
);
Account
createSub
(
String
name
,
AccountDto
user
);
...
...
src/main/java/com/edgec/browserbackend/account/service/impl/AccountServiceImpl.java
View file @
e987d372
...
@@ -750,16 +750,13 @@ public class AccountServiceImpl implements AccountService {
...
@@ -750,16 +750,13 @@ public class AccountServiceImpl implements AccountService {
}
}
@Override
@Override
public
void
resetPassword
(
UserDto
user
)
{
public
void
resetPassword
(
String
username
,
UserDto
user
)
{
if
(
user
==
null
)
if
(
user
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMEOREMAILNOTEXIST
,
"Can't find user with name or mail: "
+
user
);
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMEOREMAILNOTEXIST
,
"Can't find user with name or mail: "
+
user
);
Account
account
=
repository
.
findBy
Email
(
user
.
getEmail
());
Account
account
=
repository
.
findBy
Name
(
user
.
getUsername
());
if
(
account
==
null
)
{
if
(
account
==
null
)
{
Account
accountname
=
repository
.
findByName
(
user
.
getUsername
());
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMEOREMAILNOTEXIST
,
"Can't find user with name: "
+
user
);
if
(
accountname
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMEOREMAILNOTEXIST
,
"Can't find user with name or mail: "
+
user
);
account
=
accountname
;
}
}
User
newuser
=
new
User
();
User
newuser
=
new
User
();
...
@@ -795,7 +792,7 @@ public class AccountServiceImpl implements AccountService {
...
@@ -795,7 +792,7 @@ public class AccountServiceImpl implements AccountService {
if
(
otp
==
null
)
{
if
(
otp
==
null
)
{
throw
new
ClientRequestException
(
AccountErrorCode
.
OTPWRONG
,
AccountErrorCode
.
OTPWRONG
.
getReason
());
throw
new
ClientRequestException
(
AccountErrorCode
.
OTPWRONG
,
AccountErrorCode
.
OTPWRONG
.
getReason
());
}
}
if
(!
otp
.
getOtp
().
equals
(
user
.
get
Otp
()))
{
if
(!
otp
.
getOtp
().
equals
(
user
.
get
AuthCode
()))
{
throw
new
ClientRequestException
(
AccountErrorCode
.
OTPWRONG
,
AccountErrorCode
.
OTPWRONG
.
getReason
());
throw
new
ClientRequestException
(
AccountErrorCode
.
OTPWRONG
,
AccountErrorCode
.
OTPWRONG
.
getReason
());
}
}
...
@@ -806,7 +803,7 @@ public class AccountServiceImpl implements AccountService {
...
@@ -806,7 +803,7 @@ public class AccountServiceImpl implements AccountService {
User
client
=
new
User
();
User
client
=
new
User
();
client
.
setUsername
(
account
.
getName
());
client
.
setUsername
(
account
.
getName
());
client
.
setPassword
(
user
.
getPasswd
());
client
.
setPassword
(
user
.
getPassw
or
d
());
userAuthService
.
resetUserPassword
(
new
com
.
edgec
.
browserbackend
.
auth
.
domain
.
User
(
client
));
userAuthService
.
resetUserPassword
(
new
com
.
edgec
.
browserbackend
.
auth
.
domain
.
User
(
client
));
...
...
src/main/java/com/edgec/browserbackend/auth/config/WebSecurityConfig.java
View file @
e987d372
...
@@ -33,7 +33,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
...
@@ -33,7 +33,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
public
void
configure
(
WebSecurity
web
)
throws
Exception
{
public
void
configure
(
WebSecurity
web
)
throws
Exception
{
web
.
ignoring
()
web
.
ignoring
()
.
antMatchers
(
"/user/authCode"
,
"/user/signUp"
,
.
antMatchers
(
"/user/authCode"
,
"/user/signUp"
,
"/user/
reset
*"
);
"/user/
forgot*
*"
);
}
}
@Override
@Override
...
...
src/main/java/com/edgec/browserbackend/browser/domain/Shop.java
View file @
e987d372
...
@@ -35,7 +35,7 @@ public class Shop {
...
@@ -35,7 +35,7 @@ public class Shop {
private
String
shopUA
;
private
String
shopUA
;
private
CharSequence
shopCookie
;
private
String
shopCookie
;
private
long
createTime
;
private
long
createTime
;
...
@@ -184,11 +184,11 @@ public class Shop {
...
@@ -184,11 +184,11 @@ public class Shop {
this
.
shopPassword
=
shopPassword
;
this
.
shopPassword
=
shopPassword
;
}
}
public
CharSequence
getShopCookie
()
{
public
String
getShopCookie
()
{
return
shopCookie
;
return
shopCookie
;
}
}
public
void
setShopCookie
(
CharSequence
shopCookie
)
{
public
void
setShopCookie
(
String
shopCookie
)
{
this
.
shopCookie
=
shopCookie
;
this
.
shopCookie
=
shopCookie
;
}
}
...
...
src/main/java/com/edgec/browserbackend/browser/dto/ShopResultDto.java
View file @
e987d372
...
@@ -30,7 +30,7 @@ public class ShopResultDto {
...
@@ -30,7 +30,7 @@ public class ShopResultDto {
private
String
shopUA
;
private
String
shopUA
;
private
CharSequence
shopCookie
;
private
String
shopCookie
;
private
IpResource
bindIp
;
private
IpResource
bindIp
;
...
@@ -151,11 +151,11 @@ public class ShopResultDto {
...
@@ -151,11 +151,11 @@ public class ShopResultDto {
this
.
shopUA
=
shopUA
;
this
.
shopUA
=
shopUA
;
}
}
public
CharSequence
getShopCookie
()
{
public
String
getShopCookie
()
{
return
shopCookie
;
return
shopCookie
;
}
}
public
void
setShopCookie
(
CharSequence
shopCookie
)
{
public
void
setShopCookie
(
String
shopCookie
)
{
this
.
shopCookie
=
shopCookie
;
this
.
shopCookie
=
shopCookie
;
}
}
...
...
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpResourceServiceImpl.java
View file @
e987d372
...
@@ -169,7 +169,8 @@ public class IpResourceServiceImpl implements IpResourceService {
...
@@ -169,7 +169,8 @@ public class IpResourceServiceImpl implements IpResourceService {
String
price
=
vendorPrices
.
stream
()
String
price
=
vendorPrices
.
stream
()
.
filter
(
x
->
Vendor
.
valueOf
(
ipResourceRequestDto
.
getVendor
()).
getValue
().
equals
(
x
.
substring
(
0
,
x
.
indexOf
(
"-"
))))
.
filter
(
x
->
Vendor
.
valueOf
(
ipResourceRequestDto
.
getVendor
()).
getValue
().
equals
(
x
.
substring
(
0
,
x
.
indexOf
(
"-"
))))
.
map
(
x
->
x
.
substring
(
x
.
lastIndexOf
(
"-"
)
+
1
)).
collect
(
Collectors
.
joining
());
.
map
(
x
->
x
.
substring
(
x
.
lastIndexOf
(
"-"
)
+
1
)).
collect
(
Collectors
.
joining
());
IpChargeResultDto
ipChargeResultDto
=
accountService
.
preChargeByMoney
(
username
,
Double
.
valueOf
(
price
)
*
ipResourceRequestDto
.
getAmount
());
double
newprice
=
ipResourceRequestDto
.
getUnit
().
equals
(
"week"
)
?
(
Integer
.
valueOf
(
price
)/
3
)
:
Integer
.
valueOf
(
price
);
IpChargeResultDto
ipChargeResultDto
=
accountService
.
preChargeByMoney
(
username
,
newprice
*
ipResourceRequestDto
.
getAmount
());
if
(!
ipChargeResultDto
.
isSuccess
())
{
if
(!
ipChargeResultDto
.
isSuccess
())
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NOTENOUGHBALANCE
);
throw
new
ClientRequestException
(
AccountErrorCode
.
NOTENOUGHBALANCE
);
}
}
...
@@ -244,7 +245,7 @@ public class IpResourceServiceImpl implements IpResourceService {
...
@@ -244,7 +245,7 @@ public class IpResourceServiceImpl implements IpResourceService {
ipBuyResultDto
=
restTemplate
.
postForObject
(
URL
+
"/intelligroup/ipresources?accountId=browser"
,
httpEntity
,
IpBuyResultDto
.
class
);
ipBuyResultDto
=
restTemplate
.
postForObject
(
URL
+
"/intelligroup/ipresources?accountId=browser"
,
httpEntity
,
IpBuyResultDto
.
class
);
if
(
StringUtils
.
isNotBlank
(
ipBuyResultDto
.
getErrorCode
()))
{
if
(
StringUtils
.
isNotBlank
(
ipBuyResultDto
.
getErrorCode
()))
{
IpChargeRequestDto
ipChargeRequestDto
=
buildIpChargeRequestDto
(
ipResourceRequestDto
,
1
);
IpChargeRequestDto
ipChargeRequestDto
=
buildIpChargeRequestDto
(
ipResourceRequestDto
,
1
);
accountService
.
chargeByMoney
(
username
,
-
Double
.
valueOf
(
price
)
*
ipChargeRequestDto
.
getAmount
(),
ipChargeRequestDto
);
accountService
.
chargeByMoney
(
username
,
-
newprice
*
ipChargeRequestDto
.
getAmount
(),
ipChargeRequestDto
);
logger
.
error
(
"fail to buy ip"
);
logger
.
error
(
"fail to buy ip"
);
logger
.
error
(
ipBuyResultDto
.
getErrorCode
());
logger
.
error
(
ipBuyResultDto
.
getErrorCode
());
}
}
...
@@ -264,7 +265,7 @@ public class IpResourceServiceImpl implements IpResourceService {
...
@@ -264,7 +265,7 @@ public class IpResourceServiceImpl implements IpResourceService {
});
});
if
(
ipBuyResultDto
.
getIplist
().
size
()
<
ipResourceDtos
.
size
())
{
if
(
ipBuyResultDto
.
getIplist
().
size
()
<
ipResourceDtos
.
size
())
{
IpChargeRequestDto
ipChargeRequestDto
=
buildIpChargeRequestDto
(
ipResourceRequestDto
,
1
);
IpChargeRequestDto
ipChargeRequestDto
=
buildIpChargeRequestDto
(
ipResourceRequestDto
,
1
);
accountService
.
chargeByMoney
(
username
,
-
Double
.
valueOf
(
price
)
*(
ipResourceDtos
.
size
()
-
ipBuyResultDto
.
getIplist
().
size
()),
ipChargeRequestDto
);
accountService
.
chargeByMoney
(
username
,
-
newprice
*(
ipResourceDtos
.
size
()
-
ipBuyResultDto
.
getIplist
().
size
()),
ipChargeRequestDto
);
}
}
}
}
ipTransaction
.
setStatus
(
1
);
ipTransaction
.
setStatus
(
1
);
...
@@ -275,7 +276,7 @@ public class IpResourceServiceImpl implements IpResourceService {
...
@@ -275,7 +276,7 @@ public class IpResourceServiceImpl implements IpResourceService {
},
ThreadPoolUtils
.
taskExecutorPool
);
},
ThreadPoolUtils
.
taskExecutorPool
);
IpChargeRequestDto
ipChargeRequestDto
=
buildIpChargeRequestDto
(
ipResourceRequestDto
,
1
);
IpChargeRequestDto
ipChargeRequestDto
=
buildIpChargeRequestDto
(
ipResourceRequestDto
,
1
);
accountService
.
chargeByMoney
(
username
,
Double
.
valueOf
(
price
)
*
ipChargeRequestDto
.
getAmount
(),
ipChargeRequestDto
);
accountService
.
chargeByMoney
(
username
,
newprice
*
ipChargeRequestDto
.
getAmount
(),
ipChargeRequestDto
);
return
ipTransactionDto
;
return
ipTransactionDto
;
}
}
...
@@ -294,7 +295,8 @@ public class IpResourceServiceImpl implements IpResourceService {
...
@@ -294,7 +295,8 @@ public class IpResourceServiceImpl implements IpResourceService {
.
filter
(
vendorprice
->
Vendor
.
valueOf
(
ipResourceRequestDto
.
getVendor
()).
getValue
().
equals
(
vendorprice
.
substring
(
0
,
vendorprice
.
indexOf
(
"-"
))))
.
filter
(
vendorprice
->
Vendor
.
valueOf
(
ipResourceRequestDto
.
getVendor
()).
getValue
().
equals
(
vendorprice
.
substring
(
0
,
vendorprice
.
indexOf
(
"-"
))))
.
map
(
vendorprice
->
vendorprice
.
substring
(
vendorprice
.
lastIndexOf
(
"-"
)
+
1
)).
collect
(
Collectors
.
joining
())).
mapToDouble
(
Double:
:
valueOf
).
sum
();
.
map
(
vendorprice
->
vendorprice
.
substring
(
vendorprice
.
lastIndexOf
(
"-"
)
+
1
)).
collect
(
Collectors
.
joining
())).
mapToDouble
(
Double:
:
valueOf
).
sum
();
IpChargeResultDto
ipChargeResultDto
=
accountService
.
preChargeByMoney
(
username
,
Double
.
valueOf
(
totalprice
));
double
newprice
=
ipResourceRequestDto
.
getUnit
().
equals
(
"week"
)
?
(
int
)
(
totalprice
/
3
)
:
(
int
)
totalprice
;
IpChargeResultDto
ipChargeResultDto
=
accountService
.
preChargeByMoney
(
username
,
newprice
);
if
(!
ipChargeResultDto
.
isSuccess
())
{
if
(!
ipChargeResultDto
.
isSuccess
())
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NOTENOUGHBALANCE
);
throw
new
ClientRequestException
(
AccountErrorCode
.
NOTENOUGHBALANCE
);
}
}
...
@@ -324,8 +326,9 @@ public class IpResourceServiceImpl implements IpResourceService {
...
@@ -324,8 +326,9 @@ public class IpResourceServiceImpl implements IpResourceService {
.
filter
(
vendorprice
->
Vendor
.
valueOf
(
ipResourceRequestDto
.
getVendor
()).
getValue
().
equals
(
vendorprice
.
substring
(
0
,
vendorprice
.
indexOf
(
"-"
))))
.
filter
(
vendorprice
->
Vendor
.
valueOf
(
ipResourceRequestDto
.
getVendor
()).
getValue
().
equals
(
vendorprice
.
substring
(
0
,
vendorprice
.
indexOf
(
"-"
))))
.
map
(
vendorprice
->
vendorprice
.
substring
(
vendorprice
.
lastIndexOf
(
"-"
)
+
1
)).
collect
(
Collectors
.
joining
());
.
map
(
vendorprice
->
vendorprice
.
substring
(
vendorprice
.
lastIndexOf
(
"-"
)
+
1
)).
collect
(
Collectors
.
joining
());
double
newprice1
=
ipResourceRequestDto
.
getUnit
().
equals
(
"week"
)
?
(
Integer
.
valueOf
(
price
)/
3
)
:
Integer
.
valueOf
(
price
);
IpChargeRequestDto
ipChargeRequestDto
=
buildIpChargeRequestDto
(
ipResourceRequestDto
,
2
);
IpChargeRequestDto
ipChargeRequestDto
=
buildIpChargeRequestDto
(
ipResourceRequestDto
,
2
);
accountService
.
chargeByMoney
(
username
,
Double
.
valueOf
(
price
)
,
ipChargeRequestDto
);
accountService
.
chargeByMoney
(
username
,
newprice1
,
ipChargeRequestDto
);
ipResource
.
setValidTime
(
Instant
.
parse
(
x
.
getValidTill
()).
toEpochMilli
());
ipResource
.
setValidTime
(
Instant
.
parse
(
x
.
getValidTill
()).
toEpochMilli
());
ipResourceRepository
.
save
(
ipResource
);
ipResourceRepository
.
save
(
ipResource
);
...
...
src/main/java/com/edgec/browserbackend/browser/service/Impl/ShopServiceImpl.java
View file @
e987d372
...
@@ -80,6 +80,7 @@ public class ShopServiceImpl implements ShopService {
...
@@ -80,6 +80,7 @@ public class ShopServiceImpl implements ShopService {
shopResultDto
.
setOwner
(
username
);
shopResultDto
.
setOwner
(
username
);
Shop
shop
=
new
Shop
();
Shop
shop
=
new
Shop
();
shop
.
of
(
shopResultDto
);
shop
.
of
(
shopResultDto
);
shop
.
setCreateTime
(
Instant
.
now
().
toEpochMilli
());
id
=
shopRepository
.
save
(
shop
).
getShopId
();
id
=
shopRepository
.
save
(
shop
).
getShopId
();
UserShop
userShop
=
new
UserShop
();
UserShop
userShop
=
new
UserShop
();
userShop
.
setUsername
(
username
);
userShop
.
setUsername
(
username
);
...
...
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