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
e90964d0
Commit
e90964d0
authored
Jun 11, 2020
by
xuxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
浏览器bug修复
parent
7d5c94f5
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
243 additions
and
254 deletions
+243
-254
BrowserBackendApplication.java
...a/com/edgec/browserbackend/BrowserBackendApplication.java
+0
-13
AccountController.java
.../browserbackend/account/controller/AccountController.java
+1
-1
AccountErrorCode.java
...ec/browserbackend/account/exception/AccountErrorCode.java
+38
-32
AccountServiceImpl.java
...owserbackend/account/service/impl/AccountServiceImpl.java
+9
-7
WebSecurityConfig.java
...m/edgec/browserbackend/auth/config/WebSecurityConfig.java
+2
-1
AuthErrorCode.java
...om/edgec/browserbackend/auth/exception/AuthErrorCode.java
+12
-9
AuthenticationSuccessEventListener.java
.../service/security/AuthenticationSuccessEventListener.java
+2
-4
BrowserErrorCode.java
...ec/browserbackend/browser/ErrorCode/BrowserErrorCode.java
+13
-10
HistoryController.java
.../browserbackend/browser/controller/HistoryController.java
+9
-19
IpControlloer.java
...dgec/browserbackend/browser/controller/IpControlloer.java
+12
-3
ShopController.java
...gec/browserbackend/browser/controller/ShopController.java
+17
-57
HistoryServiceImpl.java
...owserbackend/browser/service/Impl/HistoryServiceImpl.java
+19
-14
IpAndShopServiceImpl.java
...serbackend/browser/service/Impl/IpAndShopServiceImpl.java
+14
-6
IpResourceServiceImpl.java
...erbackend/browser/service/Impl/IpResourceServiceImpl.java
+26
-31
ShopServiceImpl.java
.../browserbackend/browser/service/Impl/ShopServiceImpl.java
+64
-43
ClientRequestException.java
...rbackend/common/commons/error/ClientRequestException.java
+1
-1
ErrorCode.java
.../edgec/browserbackend/common/commons/error/ErrorCode.java
+4
-3
No files found.
src/main/java/com/edgec/browserbackend/BrowserBackendApplication.java
View file @
e90964d0
package
com
.
edgec
.
browserbackend
;
package
com
.
edgec
.
browserbackend
;
import
com.mongodb.MongoClient
;
import
net.javacrumbs.shedlock.core.LockProvider
;
import
org.apache.catalina.Context
;
import
org.apache.catalina.connector.Connector
;
import
org.springframework.beans.factory.SmartInitializingSingleton
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory
;
import
org.springframework.boot.web.servlet.server.ServletWebServerFactory
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.convert.converter.Converter
;
import
org.springframework.core.convert.converter.Converter
;
import
org.springframework.data.convert.Jsr310Converters
;
import
org.springframework.data.convert.Jsr310Converters
;
import
org.springframework.data.mongodb.core.convert.MongoCustomConversions
;
import
org.springframework.data.mongodb.core.convert.MongoCustomConversions
;
import
org.springframework.scheduling.TaskScheduler
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler
;
import
org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity
;
import
org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity
;
import
org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer
;
import
org.springframework.security.oauth2.provider.token.AuthenticationKeyGenerator
;
import
org.springframework.security.oauth2.provider.token.AuthenticationKeyGenerator
;
import
org.springframework.security.oauth2.provider.token.DefaultAuthenticationKeyGenerator
;
import
org.springframework.security.oauth2.provider.token.DefaultAuthenticationKeyGenerator
;
import
org.springframework.web.cors.CorsConfiguration
;
import
org.springframework.web.cors.CorsConfiguration
;
...
@@ -35,10 +24,8 @@ import java.time.LocalDate;
...
@@ -35,10 +24,8 @@ import java.time.LocalDate;
import
java.time.ZoneId
;
import
java.time.ZoneId
;
import
java.time.ZonedDateTime
;
import
java.time.ZonedDateTime
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.concurrent.CompletableFuture
;
@SpringBootApplication
@SpringBootApplication
@EnableGlobalMethodSecurity
(
prePostEnabled
=
true
)
@EnableGlobalMethodSecurity
(
prePostEnabled
=
true
)
...
...
src/main/java/com/edgec/browserbackend/account/controller/AccountController.java
View file @
e90964d0
...
@@ -33,7 +33,7 @@ import java.time.format.DateTimeFormatter;
...
@@ -33,7 +33,7 @@ import java.time.format.DateTimeFormatter;
import
java.util.*
;
import
java.util.*
;
@RestController
@RestController
@RequestMapping
(
"user"
)
@RequestMapping
(
"
/
user"
)
public
class
AccountController
{
public
class
AccountController
{
public
static
final
String
WECHAT_PAY_CALLBACK_URL
=
"https://cloudam.cn/accounts/0xwxpaycallback/"
;
public
static
final
String
WECHAT_PAY_CALLBACK_URL
=
"https://cloudam.cn/accounts/0xwxpaycallback/"
;
...
...
src/main/java/com/edgec/browserbackend/account/exception/AccountErrorCode.java
View file @
e90964d0
...
@@ -7,37 +7,37 @@ public enum AccountErrorCode implements ErrorCode {
...
@@ -7,37 +7,37 @@ public enum AccountErrorCode implements ErrorCode {
/* client errors */
/* client errors */
UNKNOWN
(
ErrorCode
.
COMMON_UNKNOWN
,
"unknown"
),
UNKNOWN
(
ErrorCode
.
COMMON_UNKNOWN
,
"unknown"
),
NAMEEXIST
(
ACCOUNT_BASE
+
100
,
"Username exists"
),
NAMEEXIST
(
ACCOUNT_BASE
+
100
,
"Username exists"
),
NAMENOTEXIST
(
ACCOUNT_BASE
+
102
,
"Username does not exist"
),
NAMENOTEXIST
(
ACCOUNT_BASE
+
102
,
"Username does not exist"
),
EMAILEXIST
(
ACCOUNT_BASE
+
101
,
"Email exists"
),
EMAILEXIST
(
ACCOUNT_BASE
+
101
,
"Email exists"
),
EMAILNOTEXIST
(
ACCOUNT_BASE
+
103
,
"Email does not exist"
),
EMAILNOTEXIST
(
ACCOUNT_BASE
+
103
,
"Email does not exist"
),
NAMEOREMAILNOTEXIST
(
ACCOUNT_BASE
+
104
,
"Username or Email does not exist"
),
NAMEOREMAILNOTEXIST
(
ACCOUNT_BASE
+
104
,
"Username or Email does not exist"
),
NOTALLOWEDTOCREATESUBUSER
(
ACCOUNT_BASE
+
105
,
"The account isn't allowed to create sub user"
),
NOTALLOWEDTOCREATESUBUSER
(
ACCOUNT_BASE
+
105
,
"The account isn't allowed to create sub user"
),
PHONEEXIST
(
ACCOUNT_BASE
+
106
,
"Phone number exists"
),
PHONEEXIST
(
ACCOUNT_BASE
+
106
,
"Phone number exists"
),
OTPWRONG
(
ACCOUNT_BASE
+
107
,
"otp invalid or expires"
),
OTPWRONG
(
ACCOUNT_BASE
+
107
,
"otp invalid or expires"
),
OTPSENDFAILS
(
ACCOUNT_BASE
+
108
,
"otp sends failure"
),
OTPSENDFAILS
(
ACCOUNT_BASE
+
108
,
"otp sends failure"
),
PHONENOTEXIST
(
ACCOUNT_BASE
+
109
,
"Can not find account with phone number"
),
PHONENOTEXIST
(
ACCOUNT_BASE
+
109
,
"Can not find account with phone number"
),
INVALIDTOKEN
(
ErrorCode
.
COMMON_INVALID_TOKEN
,
"Invalid token"
),
INVALIDTOKEN
(
ErrorCode
.
COMMON_INVALID_TOKEN
,
"Invalid token"
),
UNAUTHORIZED
(
ErrorCode
.
COMMON_UNAUTHRORIZED
,
"Unauthorized operation"
),
UNAUTHORIZED
(
ErrorCode
.
COMMON_UNAUTHRORIZED
,
"Unauthorized operation"
),
NAMEEMPTY
(
ACCOUNT_BASE
+
110
,
"Username connot be empty"
),
NAMEEMPTY
(
ACCOUNT_BASE
+
110
,
"Username connot be empty"
),
EMAILEMPTY
(
ACCOUNT_BASE
+
111
,
"Email connot be empty"
),
EMAILEMPTY
(
ACCOUNT_BASE
+
111
,
"Email connot be empty"
),
PHONEEMPTY
(
ACCOUNT_BASE
+
112
,
"PhoneNumber connot be empty"
),
PHONEEMPTY
(
ACCOUNT_BASE
+
112
,
"PhoneNumber connot be empty"
),
AGENCYNOEXIST
(
ACCOUNT_BASE
+
113
,
"uuid dose not exists"
),
AGENCYNOEXIST
(
ACCOUNT_BASE
+
113
,
"uuid dose not exists"
),
CHILDSCALINGSTATEUNABATED
(
ACCOUNT_BASE
+
114
,
"Can't delete child whose still have scaling group "
),
CHILDSCALINGSTATEUNABATED
(
ACCOUNT_BASE
+
114
,
"Can't delete child whose still have scaling group "
),
BINDORDERERROR_NOTEXIST
(
ACCOUNT_BASE
+
115
,
"This order is not exist"
),
BINDORDERERROR_NOTEXIST
(
ACCOUNT_BASE
+
115
,
"This order is not exist"
),
BINDORDERERROR_BINDBYOTHERS
(
ACCOUNT_BASE
+
116
,
"This order has been bind by others"
),
BINDORDERERROR_BINDBYOTHERS
(
ACCOUNT_BASE
+
116
,
"This order has been bind by others"
),
BINDORDERERROR_NOTQUALIFIED
(
ACCOUNT_BASE
+
117
,
"You don't have free qualified"
),
BINDORDERERROR_NOTQUALIFIED
(
ACCOUNT_BASE
+
117
,
"You don't have free qualified"
),
BINDORDERERROR_HAVEORDER
(
ACCOUNT_BASE
+
118
,
"You have an unpaid order"
),
BINDORDERERROR_HAVEORDER
(
ACCOUNT_BASE
+
118
,
"You have an unpaid order"
),
BINDORDERERROR_NOTKNOW
(
ACCOUNT_BASE
+
119
,
"Order generate error,please try again"
),
BINDORDERERROR_NOTKNOW
(
ACCOUNT_BASE
+
119
,
"Order generate error,please try again"
),
/* http request error */
/* http request error */
OTHERS
(
ErrorCode
.
COMMON_OTHERS
,
"http request error"
),
OTHERS
(
ErrorCode
.
COMMON_OTHERS
,
"http request error"
),
...
@@ -45,19 +45,22 @@ public enum AccountErrorCode implements ErrorCode {
...
@@ -45,19 +45,22 @@ public enum AccountErrorCode implements ErrorCode {
/* server errors */
/* server errors */
EMAILSENTERROR
(
ErrorCode
.
COMMON_SERVER_ERROR
,
"email sending error"
),
EMAILSENTERROR
(
ErrorCode
.
COMMON_SERVER_ERROR
,
"email sending error"
),
/** wechat errors */
/**
WECHATERROR
(
ACCOUNT_BASE
+
120
,
"Wechat order generation error"
),
* wechat errors
*/
WECHATERROR
(
ACCOUNT_BASE
+
120
,
"Wechat order generation error"
),
/** alipay errors */
/**
ALIPAYERROR
(
ACCOUNT_BASE
+
130
,
"Alipay order generation error"
),
* alipay errors
*/
ALIPAYERROR
(
ACCOUNT_BASE
+
130
,
"Alipay order generation error"
),
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
+
142
,
"You can not have more shops"
),
SHOPMAX
(
ACCOUNT_BASE
+
142
,
"You can not have more shops"
),
CHILDMAX
(
ACCOUNT_BASE
+
143
,
"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"
);
NOTENOUGHBALANCE
(
ErrorCode
.
ACCOUNT_BASE
+
150
,
"Your balance is not enough"
);
private
final
int
code
;
private
final
int
code
;
...
@@ -68,10 +71,12 @@ public enum AccountErrorCode implements ErrorCode {
...
@@ -68,10 +71,12 @@ public enum AccountErrorCode implements ErrorCode {
this
.
reason
=
reasonPhrase
;
this
.
reason
=
reasonPhrase
;
}
}
@Override
public
int
value
()
{
public
int
value
()
{
return
this
.
code
;
return
this
.
code
;
}
}
@Override
@JsonValue
@JsonValue
public
int
getCode
()
{
public
int
getCode
()
{
return
code
;
return
code
;
...
@@ -82,6 +87,7 @@ public enum AccountErrorCode implements ErrorCode {
...
@@ -82,6 +87,7 @@ public enum AccountErrorCode implements ErrorCode {
return
Integer
.
toString
(
this
.
code
);
return
Integer
.
toString
(
this
.
code
);
}
}
@Override
public
String
getReason
()
{
public
String
getReason
()
{
return
reason
;
return
reason
;
}
}
...
...
src/main/java/com/edgec/browserbackend/account/service/impl/AccountServiceImpl.java
View file @
e90964d0
package
com
.
edgec
.
browserbackend
.
account
.
service
.
impl
;
package
com
.
edgec
.
browserbackend
.
account
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.edgec.browserbackend.account.dto.*
;
import
com.edgec.browserbackend.account.service.AccountService
;
import
com.edgec.browserbackend.account.service.PaymentService
;
import
com.edgec.browserbackend.account.domain.*
;
import
com.edgec.browserbackend.account.domain.*
;
import
com.edgec.browserbackend.account.dto.*
;
import
com.edgec.browserbackend.account.exception.AccountErrorCode
;
import
com.edgec.browserbackend.account.exception.AccountErrorCode
;
import
com.edgec.browserbackend.account.repository.*
;
import
com.edgec.browserbackend.account.repository.*
;
import
com.edgec.browserbackend.account.service.AccountService
;
import
com.edgec.browserbackend.account.service.EmailService
;
import
com.edgec.browserbackend.account.service.EmailService
;
import
com.edgec.browserbackend.account.service.PaymentService
;
import
com.edgec.browserbackend.account.service.SmsUtils
;
import
com.edgec.browserbackend.account.service.SmsUtils
;
import
com.edgec.browserbackend.account.utils.AccountServicePool
;
import
com.edgec.browserbackend.account.utils.AccountServicePool
;
import
com.edgec.browserbackend.auth.exception.AuthErrorCode
;
import
com.edgec.browserbackend.auth.exception.AuthErrorCode
;
...
@@ -33,7 +33,7 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -33,7 +33,7 @@ import org.springframework.transaction.annotation.Transactional;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
org.thymeleaf.util.StringUtils
;
import
org.thymeleaf.util.StringUtils
;
import
java.io.
*
;
import
java.io.
File
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.time.Instant
;
import
java.time.Instant
;
import
java.time.YearMonth
;
import
java.time.YearMonth
;
...
@@ -322,7 +322,8 @@ public class AccountServiceImpl implements AccountService {
...
@@ -322,7 +322,8 @@ public class AccountServiceImpl implements AccountService {
@Override
@Override
public
ResultDto
getAccountByName
(
String
name
)
{
public
ResultDto
getAccountByName
(
String
name
)
{
Assert
.
hasLength
(
name
);
Assert
.
hasLength
(
name
,
"账户名不能为空"
);
ResultDto
resultDto
=
new
ResultDto
();
ResultDto
resultDto
=
new
ResultDto
();
try
{
try
{
Account
account
=
this
.
findByName
(
name
);
Account
account
=
this
.
findByName
(
name
);
...
@@ -398,6 +399,7 @@ public class AccountServiceImpl implements AccountService {
...
@@ -398,6 +399,7 @@ public class AccountServiceImpl implements AccountService {
return
resultDto
;
return
resultDto
;
}
}
@Override
public
void
deleteByName
(
String
name
)
{
public
void
deleteByName
(
String
name
)
{
userService
.
deleteUser
(
name
);
userService
.
deleteUser
(
name
);
repository
.
deleteById
(
name
);
repository
.
deleteById
(
name
);
...
@@ -411,6 +413,7 @@ public class AccountServiceImpl implements AccountService {
...
@@ -411,6 +413,7 @@ public class AccountServiceImpl implements AccountService {
return
create
(
user
,
null
);
return
create
(
user
,
null
);
}
}
@Override
public
void
deleteSub
(
String
parent
,
String
child
)
{
public
void
deleteSub
(
String
parent
,
String
child
)
{
Assert
.
hasText
(
parent
);
Assert
.
hasText
(
parent
);
Account
childAccount
=
repository
.
findByName
(
child
);
Account
childAccount
=
repository
.
findByName
(
child
);
...
@@ -1177,8 +1180,7 @@ public class AccountServiceImpl implements AccountService {
...
@@ -1177,8 +1180,7 @@ public class AccountServiceImpl implements AccountService {
CompanyAuthorize
companyAuthorize
=
companyAuthorizeRepository
.
findByUsername
(
username
);
CompanyAuthorize
companyAuthorize
=
companyAuthorizeRepository
.
findByUsername
(
username
);
account
.
setCompanyName
(
companyAuthorize
.
getCompanyName
());
account
.
setCompanyName
(
companyAuthorize
.
getCompanyName
());
repository
.
save
(
account
);
repository
.
save
(
account
);
}
}
else
{
else
{
account
.
setAuthorized
(
3
);
account
.
setAuthorized
(
3
);
account
.
setCompanyName
(
null
);
account
.
setCompanyName
(
null
);
repository
.
save
(
account
);
repository
.
save
(
account
);
...
...
src/main/java/com/edgec/browserbackend/auth/config/WebSecurityConfig.java
View file @
e90964d0
...
@@ -30,9 +30,10 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
...
@@ -30,9 +30,10 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.
csrf
().
disable
();
.
csrf
().
disable
();
}
}
@Override
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/forgot**"
,
"/0xadministrator/getconfig**"
);
"/user/forgot**"
,
"/0xadministrator/getconfig**"
);
}
}
...
...
src/main/java/com/edgec/browserbackend/auth/exception/AuthErrorCode.java
View file @
e90964d0
...
@@ -8,16 +8,16 @@ public enum AuthErrorCode implements ErrorCode {
...
@@ -8,16 +8,16 @@ public enum AuthErrorCode implements ErrorCode {
/* http request error */
/* http request error */
OTHERS
(
ErrorCode
.
COMMON_OTHERS
,
"http request error"
),
OTHERS
(
ErrorCode
.
COMMON_OTHERS
,
"http request error"
),
AUTHENTICATION_ERROR
(
ErrorCode
.
AUTH_BASE
+
100
,
"authentication failure"
),
AUTHENTICATION_ERROR
(
ErrorCode
.
AUTH_BASE
+
100
,
"authentication failure"
),
AUTHORIZATION_ERROR
(
ErrorCode
.
AUTH_BASE
+
200
,
"authorization failure"
),
AUTHORIZATION_ERROR
(
ErrorCode
.
AUTH_BASE
+
200
,
"authorization failure"
),
NAMEEXIST
(
AUTH_BASE
+
106
,
"Username exists"
),
NAMEEXIST
(
AUTH_BASE
+
106
,
"Username exists"
),
NAMENOTEXIST
(
AUTH_BASE
+
102
,
"Username does not exist"
),
NAMENOTEXIST
(
AUTH_BASE
+
102
,
"Username does not exist"
),
EMAILEXIST
(
AUTH_BASE
+
101
,
"Email exists"
),
EMAILEXIST
(
AUTH_BASE
+
101
,
"Email exists"
),
EMAILNOTEXIST
(
AUTH_BASE
+
103
,
"Email does not exist"
),
EMAILNOTEXIST
(
AUTH_BASE
+
103
,
"Email does not exist"
),
NAMEOREMAILNOTEXIST
(
AUTH_BASE
+
104
,
"Username or Email does not exist"
),
NAMEOREMAILNOTEXIST
(
AUTH_BASE
+
104
,
"Username or Email does not exist"
),
WRONGEMAILCODE
(
AUTH_BASE
+
105
,
"Wrong verification code"
),
WRONGEMAILCODE
(
AUTH_BASE
+
105
,
"Wrong verification code"
),
LOGINTIMESEXCEEDED
(
AUTH_BASE
+
107
,
"Login times exceeded"
),
LOGINTIMESEXCEEDED
(
AUTH_BASE
+
107
,
"Login times exceeded"
),
/* server errors */
/* server errors */
INTERNALSERVERERROR
(
ErrorCode
.
COMMON_SERVER_ERROR
,
"internal server error"
);
INTERNALSERVERERROR
(
ErrorCode
.
COMMON_SERVER_ERROR
,
"internal server error"
);
...
@@ -31,11 +31,13 @@ public enum AuthErrorCode implements ErrorCode {
...
@@ -31,11 +31,13 @@ public enum AuthErrorCode implements ErrorCode {
this
.
reason
=
reasonPhrase
;
this
.
reason
=
reasonPhrase
;
}
}
@Override
public
int
value
()
{
public
int
value
()
{
return
this
.
code
;
return
this
.
code
;
}
}
@JsonValue
@JsonValue
@Override
public
int
getCode
()
{
public
int
getCode
()
{
return
code
;
return
code
;
}
}
...
@@ -45,6 +47,7 @@ public enum AuthErrorCode implements ErrorCode {
...
@@ -45,6 +47,7 @@ public enum AuthErrorCode implements ErrorCode {
return
Integer
.
toString
(
this
.
code
);
return
Integer
.
toString
(
this
.
code
);
}
}
@Override
public
String
getReason
()
{
public
String
getReason
()
{
return
reason
;
return
reason
;
}
}
...
...
src/main/java/com/edgec/browserbackend/auth/service/security/AuthenticationSuccessEventListener.java
View file @
e90964d0
...
@@ -12,8 +12,6 @@ import org.springframework.context.ApplicationListener;
...
@@ -12,8 +12,6 @@ import org.springframework.context.ApplicationListener;
import
org.springframework.security.authentication.event.AuthenticationSuccessEvent
;
import
org.springframework.security.authentication.event.AuthenticationSuccessEvent
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.util.Date
;
@Component
@Component
public
class
AuthenticationSuccessEventListener
implements
ApplicationListener
<
AuthenticationSuccessEvent
>
{
public
class
AuthenticationSuccessEventListener
implements
ApplicationListener
<
AuthenticationSuccessEvent
>
{
...
@@ -30,9 +28,9 @@ public class AuthenticationSuccessEventListener implements ApplicationListener<A
...
@@ -30,9 +28,9 @@ public class AuthenticationSuccessEventListener implements ApplicationListener<A
User
user
=
userRepository
.
findById
(
username
).
orElse
(
null
);
User
user
=
userRepository
.
findById
(
username
).
orElse
(
null
);
if
(
user
!=
null
)
{
if
(
user
!=
null
)
{
UserAttemptsLogin
userAttempts
=
userAttemptsLoginRepository
.
findById
(
username
).
orElse
(
null
);
UserAttemptsLogin
userAttempts
=
userAttemptsLoginRepository
.
findById
(
username
).
orElse
(
null
);
if
(
userAttempts
!=
null
)
{
if
(
userAttempts
!=
null
)
{
if
(
userAttempts
.
getAttempts
()
>=
20
)
{
if
(
userAttempts
.
getAttempts
()
>=
20
)
{
if
(
userAttempts
.
getDate
().
getTime
()
>=
(
new
Date
().
getTime
()
-
600000
))
if
(
userAttempts
.
getDate
().
getTime
()
>=
(
System
.
currentTimeMillis
()
-
600000
))
throw
new
ClientRequestException
(
AuthErrorCode
.
LOGINTIMESEXCEEDED
,
"Login times exceeded"
);
throw
new
ClientRequestException
(
AuthErrorCode
.
LOGINTIMESEXCEEDED
,
"Login times exceeded"
);
}
else
if
(
userAttempts
.
getAttempts
()
!=
0
)
{
}
else
if
(
userAttempts
.
getAttempts
()
!=
0
)
{
saveUserAttemptsLogin
(
username
,
0
);
saveUserAttemptsLogin
(
username
,
0
);
...
...
src/main/java/com/edgec/browserbackend/browser/ErrorCode/BrowserErrorCode.java
View file @
e90964d0
...
@@ -7,20 +7,20 @@ public enum BrowserErrorCode implements ErrorCode {
...
@@ -7,20 +7,20 @@ public enum BrowserErrorCode implements ErrorCode {
/* client errors */
/* client errors */
UNKNOWN
(
ErrorCode
.
COMMON_UNKNOWN
,
"unknown"
),
UNKNOWN
(
ErrorCode
.
COMMON_UNKNOWN
,
"unknown"
),
INFORMATIONNOTCOMPELETE
(
BROWSER_BASE
+
100
,
"The information about shop does not complete"
),
INFORMATIONNOTCOMPELETE
(
BROWSER_BASE
+
100
,
"The information about shop does not complete"
),
SHOPNOTEXIST
(
BROWSER_BASE
+
101
,
"The shop does not exist"
),
SHOPNOTEXIST
(
BROWSER_BASE
+
101
,
"The shop does not exist"
),
SHOP_BINDED
(
BROWSER_BASE
+
102
,
"The shop has bind with ip"
),
IPNOTEXIST
(
BROWSER_BASE
+
201
,
"The ip do not exist"
),
IPNOTEXIST
(
BROWSER_BASE
+
201
,
"The ip do not exist"
),
IPNOTBINDTOSHOP
(
BROWSER_BASE
+
202
,
"The ip does not bind this shop."
),
IPNOTBINDTOSHOP
(
BROWSER_BASE
+
202
,
"The ip does not bind this shop."
),
GROUPNOTEXIST
(
BROWSER_BASE
+
301
,
"The group does not exist"
),
GROUPNOTEXIST
(
BROWSER_BASE
+
301
,
"The group does not exist"
),
IPTRANSACTIONNOTEXIST
(
BROWSER_BASE
+
401
,
"The ipTransaction does not exist"
),
IPTRANSACTIONNOTEXIST
(
BROWSER_BASE
+
401
,
"The ipTransaction does not exist"
),
COMPANYAUTHORIZEEXIST
(
BROWSER_BASE
+
501
,
"The authority exists"
),
COMPANYAUTHORIZENOTEXIST
(
BROWSER_BASE
+
502
,
"The authority dose not exist"
);
COMPANYAUTHORIZEEXIST
(
BROWSER_BASE
+
501
,
"The authority exists"
),
COMPANYAUTHORIZENOTEXIST
(
BROWSER_BASE
+
502
,
"The authority dose not exist"
);
private
final
int
code
;
private
final
int
code
;
...
@@ -31,11 +31,13 @@ public enum BrowserErrorCode implements ErrorCode {
...
@@ -31,11 +31,13 @@ public enum BrowserErrorCode implements ErrorCode {
this
.
reason
=
reasonPhrase
;
this
.
reason
=
reasonPhrase
;
}
}
@Override
public
int
value
()
{
public
int
value
()
{
return
this
.
code
;
return
this
.
code
;
}
}
@JsonValue
@JsonValue
@Override
public
int
getCode
()
{
public
int
getCode
()
{
return
code
;
return
code
;
}
}
...
@@ -45,6 +47,7 @@ public enum BrowserErrorCode implements ErrorCode {
...
@@ -45,6 +47,7 @@ public enum BrowserErrorCode implements ErrorCode {
return
Integer
.
toString
(
this
.
code
);
return
Integer
.
toString
(
this
.
code
);
}
}
@Override
public
String
getReason
()
{
public
String
getReason
()
{
return
reason
;
return
reason
;
}
}
...
...
src/main/java/com/edgec/browserbackend/browser/controller/HistoryController.java
View file @
e90964d0
package
com
.
edgec
.
browserbackend
.
browser
.
controller
;
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.domain.OperationHistory
;
import
com.edgec.browserbackend.browser.dto.HistoryListRequestDto
;
import
com.edgec.browserbackend.browser.dto.HistoryListRequestDto
;
import
com.edgec.browserbackend.browser.dto.IpResourceRequestDto
;
import
com.edgec.browserbackend.browser.dto.LoginHistoryDto
;
import
com.edgec.browserbackend.browser.dto.LoginHistoryDto
;
import
com.edgec.browserbackend.browser.dto.OperationHistoryDto
;
import
com.edgec.browserbackend.browser.dto.OperationHistoryDto
;
import
com.edgec.browserbackend.browser.service.HistoryService
;
import
com.edgec.browserbackend.browser.service.HistoryService
;
...
@@ -32,11 +30,7 @@ public class HistoryController {
...
@@ -32,11 +30,7 @@ public class HistoryController {
historyService
.
addLoginHistory
(
principal
.
getName
(),
loginHistoryDto
);
historyService
.
addLoginHistory
(
principal
.
getName
(),
loginHistoryDto
);
resultDto
.
setStatus
(
0
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
dealClientRequestException
(
resultDto
,
e
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
resultDto
.
setStatusInfo
(
statusInfo
);
}
}
return
resultDto
;
return
resultDto
;
}
}
...
@@ -48,11 +42,7 @@ public class HistoryController {
...
@@ -48,11 +42,7 @@ public class HistoryController {
historyService
.
addOperationHistory
(
principal
.
getName
(),
operationHistoryDto
);
historyService
.
addOperationHistory
(
principal
.
getName
(),
operationHistoryDto
);
resultDto
.
setStatus
(
0
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
dealClientRequestException
(
resultDto
,
e
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
resultDto
.
setStatusInfo
(
statusInfo
);
}
}
return
resultDto
;
return
resultDto
;
}
}
...
@@ -64,11 +54,7 @@ public class HistoryController {
...
@@ -64,11 +54,7 @@ public class HistoryController {
resultDto
.
setData
(
historyService
.
getLoginHistories
(
principal
.
getName
(),
historyListRequestDto
));
resultDto
.
setData
(
historyService
.
getLoginHistories
(
principal
.
getName
(),
historyListRequestDto
));
resultDto
.
setStatus
(
0
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
dealClientRequestException
(
resultDto
,
e
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
resultDto
.
setStatusInfo
(
statusInfo
);
}
}
return
resultDto
;
return
resultDto
;
}
}
...
@@ -80,12 +66,16 @@ public class HistoryController {
...
@@ -80,12 +66,16 @@ public class HistoryController {
resultDto
.
setData
(
historyService
.
getOperationHistories
(
principal
.
getName
(),
historyListRequestDto
));
resultDto
.
setData
(
historyService
.
getOperationHistories
(
principal
.
getName
(),
historyListRequestDto
));
resultDto
.
setStatus
(
0
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
dealClientRequestException
(
resultDto
,
e
);
}
return
resultDto
;
}
private
void
dealClientRequestException
(
ResultDto
resultDto
,
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
resultDto
.
setStatusInfo
(
statusInfo
);
resultDto
.
setStatusInfo
(
statusInfo
);
}
}
return
resultDto
;
}
}
}
src/main/java/com/edgec/browserbackend/browser/controller/IpControlloer.java
View file @
e90964d0
package
com
.
edgec
.
browserbackend
.
browser
.
controller
;
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.IpListRequestDto
;
import
com.edgec.browserbackend.browser.dto.IpPageResultDto
;
import
com.edgec.browserbackend.browser.dto.IpResourceRequestDto
;
import
com.edgec.browserbackend.browser.dto.IpResourceUpdateDto
;
import
com.edgec.browserbackend.browser.service.IpResourceService
;
import
com.edgec.browserbackend.browser.service.IpResourceService
;
import
com.edgec.browserbackend.common.auth.Securitys
;
import
com.edgec.browserbackend.common.auth.Securitys
;
import
com.edgec.browserbackend.common.commons.error.ClientRequestException
;
import
com.edgec.browserbackend.common.commons.error.ClientRequestException
;
...
@@ -25,7 +28,7 @@ public class IpControlloer {
...
@@ -25,7 +28,7 @@ public class IpControlloer {
private
IpResourceService
ipResourceService
;
private
IpResourceService
ipResourceService
;
@RequestMapping
(
value
=
"/buy"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/buy"
,
method
=
RequestMethod
.
POST
)
public
ResultDto
buyIp
(
Principal
principal
,
@RequestBody
IpResourceRequestDto
ipResourceRequestDto
){
public
ResultDto
buyIp
(
Principal
principal
,
@RequestBody
IpResourceRequestDto
ipResourceRequestDto
)
{
ResultDto
resultDto
=
new
ResultDto
();
ResultDto
resultDto
=
new
ResultDto
();
try
{
try
{
List
<
String
>
ipResourceDto
=
ipResourceService
.
buyIp
(
principal
.
getName
(),
ipResourceRequestDto
);
List
<
String
>
ipResourceDto
=
ipResourceService
.
buyIp
(
principal
.
getName
(),
ipResourceRequestDto
);
...
@@ -93,7 +96,7 @@ public class IpControlloer {
...
@@ -93,7 +96,7 @@ public class IpControlloer {
ipListRequestDto
.
getAmount
(),
ipListRequestDto
.
getFilter
());
ipListRequestDto
.
getAmount
(),
ipListRequestDto
.
getFilter
());
resultDto
.
setData
(
ipResourceDto
);
resultDto
.
setData
(
ipResourceDto
);
resultDto
.
setStatus
(
0
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
...
@@ -110,6 +113,12 @@ public class IpControlloer {
...
@@ -110,6 +113,12 @@ public class IpControlloer {
try
{
try
{
ipResourceService
.
updateIp
(
principal
.
getName
(),
ipResourceUpdateDto
);
ipResourceService
.
updateIp
(
principal
.
getName
(),
ipResourceUpdateDto
);
resultDto
.
setStatus
(
0
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
().
getCode
());
statusInfo
.
put
(
"message"
,
e
.
getErrorCode
().
getReason
());
resultDto
.
setStatusInfo
(
statusInfo
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
resultDto
.
setStatus
(-
1
);
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
...
...
src/main/java/com/edgec/browserbackend/browser/controller/ShopController.java
View file @
e90964d0
...
@@ -43,11 +43,7 @@ public class ShopController {
...
@@ -43,11 +43,7 @@ public class ShopController {
resultDto
.
setData
(
shopStringResultDto
);
resultDto
.
setData
(
shopStringResultDto
);
resultDto
.
setStatus
(
0
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
dealClientRequestException
(
resultDto
,
e
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
resultDto
.
setStatusInfo
(
statusInfo
);
}
}
return
resultDto
;
return
resultDto
;
}
}
...
@@ -73,10 +69,7 @@ public class ShopController {
...
@@ -73,10 +69,7 @@ public class ShopController {
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
resultDto
.
setStatusInfo
(
statusInfo
);
resultDto
.
setStatusInfo
(
statusInfo
);
}
}
return
resultDto
;
return
resultDto
;
}
}
@RequestMapping
(
value
=
"/update"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/update"
,
method
=
RequestMethod
.
POST
)
...
@@ -88,11 +81,7 @@ public class ShopController {
...
@@ -88,11 +81,7 @@ public class ShopController {
resultDto
.
setData
(
shopStringResultDto
);
resultDto
.
setData
(
shopStringResultDto
);
resultDto
.
setStatus
(
0
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
dealClientRequestException
(
resultDto
,
e
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
resultDto
.
setStatusInfo
(
statusInfo
);
}
}
return
resultDto
;
return
resultDto
;
}
}
...
@@ -104,11 +93,7 @@ public class ShopController {
...
@@ -104,11 +93,7 @@ public class ShopController {
shopService
.
deleteShop
(
principal
.
getName
(),
shopRequestDto
.
getShopId
());
shopService
.
deleteShop
(
principal
.
getName
(),
shopRequestDto
.
getShopId
());
resultDto
.
setStatus
(
0
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
dealClientRequestException
(
resultDto
,
e
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
resultDto
.
setStatusInfo
(
statusInfo
);
}
}
return
resultDto
;
return
resultDto
;
}
}
...
@@ -121,11 +106,7 @@ public class ShopController {
...
@@ -121,11 +106,7 @@ public class ShopController {
resultDto
.
setStatus
(
0
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
logger
.
error
(
"fail to bind shop"
,
e
);
logger
.
error
(
"fail to bind shop"
,
e
);
resultDto
.
setStatus
(-
1
);
dealClientRequestException
(
resultDto
,
e
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
resultDto
.
setStatusInfo
(
statusInfo
);
}
}
return
resultDto
;
return
resultDto
;
}
}
...
@@ -137,11 +118,7 @@ public class ShopController {
...
@@ -137,11 +118,7 @@ public class ShopController {
ipAndShopService
.
unBindShop
(
principal
.
getName
(),
shopRequestDto
);
ipAndShopService
.
unBindShop
(
principal
.
getName
(),
shopRequestDto
);
resultDto
.
setStatus
(
0
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
dealClientRequestException
(
resultDto
,
e
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
resultDto
.
setStatusInfo
(
statusInfo
);
}
}
return
resultDto
;
return
resultDto
;
}
}
...
@@ -153,11 +130,7 @@ public class ShopController {
...
@@ -153,11 +130,7 @@ public class ShopController {
shopService
.
transferShop
(
principal
.
getName
(),
shopRequestDto
.
getShopId
(),
shopRequestDto
.
getToGroup
());
shopService
.
transferShop
(
principal
.
getName
(),
shopRequestDto
.
getShopId
(),
shopRequestDto
.
getToGroup
());
resultDto
.
setStatus
(
0
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
dealClientRequestException
(
resultDto
,
e
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
resultDto
.
setStatusInfo
(
statusInfo
);
}
}
return
resultDto
;
return
resultDto
;
}
}
...
@@ -169,11 +142,7 @@ public class ShopController {
...
@@ -169,11 +142,7 @@ public class ShopController {
shopService
.
assignShops
(
principal
.
getName
(),
shopRequestDto
.
getShopIds
(),
shopRequestDto
.
getToUsers
());
shopService
.
assignShops
(
principal
.
getName
(),
shopRequestDto
.
getShopIds
(),
shopRequestDto
.
getToUsers
());
resultDto
.
setStatus
(
0
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
dealClientRequestException
(
resultDto
,
e
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
resultDto
.
setStatusInfo
(
statusInfo
);
}
}
return
resultDto
;
return
resultDto
;
}
}
...
@@ -182,16 +151,11 @@ public class ShopController {
...
@@ -182,16 +151,11 @@ public class ShopController {
public
ResultDto
getShopList
(
Principal
principal
,
@RequestBody
ShopRequestDto
shopRequestDto
)
{
public
ResultDto
getShopList
(
Principal
principal
,
@RequestBody
ShopRequestDto
shopRequestDto
)
{
ResultDto
resultDto
=
new
ResultDto
();
ResultDto
resultDto
=
new
ResultDto
();
try
{
try
{
ShopPageResultDto
shopDtos
=
shopService
.
getShopList
(
principal
.
getName
(),
shopRequestDto
.
getGroup
(),
shopRequestDto
.
getPage
(),
ShopPageResultDto
shopDtos
=
shopService
.
getShopList
(
principal
.
getName
(),
shopRequestDto
.
getGroup
(),
shopRequestDto
.
getPage
(),
shopRequestDto
.
getAmount
(),
shopRequestDto
.
getFilter
());
shopRequestDto
.
getAmount
(),
shopRequestDto
.
getFilter
());
resultDto
.
setData
(
shopDtos
);
resultDto
.
setData
(
shopDtos
);
resultDto
.
setStatus
(
0
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
dealClientRequestException
(
resultDto
,
e
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
resultDto
.
setStatusInfo
(
statusInfo
);
}
}
logger
.
error
(
JSONObject
.
toJSONString
(
resultDto
));
logger
.
error
(
JSONObject
.
toJSONString
(
resultDto
));
return
resultDto
;
return
resultDto
;
...
@@ -205,11 +169,7 @@ public class ShopController {
...
@@ -205,11 +169,7 @@ public class ShopController {
resultDto
.
setData
(
subUsers
);
resultDto
.
setData
(
subUsers
);
resultDto
.
setStatus
(
0
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
dealClientRequestException
(
resultDto
,
e
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
resultDto
.
setStatusInfo
(
statusInfo
);
}
}
return
resultDto
;
return
resultDto
;
}
}
...
@@ -222,11 +182,7 @@ public class ShopController {
...
@@ -222,11 +182,7 @@ public class ShopController {
resultDto
.
setData
(
subUsers
);
resultDto
.
setData
(
subUsers
);
resultDto
.
setStatus
(
0
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
dealClientRequestException
(
resultDto
,
e
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
resultDto
.
setStatusInfo
(
statusInfo
);
}
}
return
resultDto
;
return
resultDto
;
}
}
...
@@ -239,12 +195,16 @@ public class ShopController {
...
@@ -239,12 +195,16 @@ public class ShopController {
resultDto
.
setData
(
shopDto
);
resultDto
.
setData
(
shopDto
);
resultDto
.
setStatus
(
0
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
dealClientRequestException
(
resultDto
,
e
);
}
return
resultDto
;
}
private
void
dealClientRequestException
(
ResultDto
resultDto
,
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
resultDto
.
setStatusInfo
(
statusInfo
);
resultDto
.
setStatusInfo
(
statusInfo
);
}
}
return
resultDto
;
}
}
}
src/main/java/com/edgec/browserbackend/browser/service/Impl/HistoryServiceImpl.java
View file @
e90964d0
...
@@ -36,39 +36,44 @@ public class HistoryServiceImpl implements HistoryService {
...
@@ -36,39 +36,44 @@ public class HistoryServiceImpl implements HistoryService {
@Override
@Override
public
void
addLoginHistory
(
String
username
,
LoginHistoryDto
loginHistoryDto
)
{
public
void
addLoginHistory
(
String
username
,
LoginHistoryDto
loginHistoryDto
)
{
Account
account
=
accountRepository
.
findById
(
username
)
.
orElse
(
null
);
Account
account
=
accountRepository
.
findById
(
username
)
if
(
account
==
null
)
.
orElseThrow
(()
->
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
));
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
int
num
=
loginHistoryRepository
.
countByUsername
(
username
);
int
num
=
loginHistoryRepository
.
countByUsername
(
username
);
if
(
num
>
10000
)
if
(
num
>
10000
)
{
loginHistoryRepository
.
delete
(
loginHistoryRepository
.
findFirstByUsername
(
username
));
loginHistoryRepository
.
delete
(
loginHistoryRepository
.
findFirstByUsername
(
username
));
}
LoginHistory
loginHistory
=
new
LoginHistory
(
loginHistoryDto
);
LoginHistory
loginHistory
=
new
LoginHistory
(
loginHistoryDto
);
loginHistory
.
setLoginTime
(
Instant
.
now
().
toEpochMilli
());
loginHistory
.
setLoginTime
(
Instant
.
now
().
toEpochMilli
());
loginHistory
.
setUsername
(
username
);
loginHistory
.
setUsername
(
username
);
if
(
account
.
getParent
()
==
null
)
if
(
account
.
getParent
()
==
null
)
{
loginHistory
.
setAdministrator
(
username
);
loginHistory
.
setAdministrator
(
username
);
else
}
else
{
loginHistory
.
setAdministrator
(
account
.
getParent
());
loginHistory
.
setAdministrator
(
account
.
getParent
());
}
loginHistory
.
setNickname
(
account
.
getNickname
());
loginHistory
.
setNickname
(
account
.
getNickname
());
loginHistoryRepository
.
save
(
loginHistory
);
loginHistoryRepository
.
save
(
loginHistory
);
}
}
@Override
@Override
public
void
addOperationHistory
(
String
username
,
OperationHistoryDto
operationHistoryDto
)
{
public
void
addOperationHistory
(
String
username
,
OperationHistoryDto
operationHistoryDto
)
{
Account
account
=
accountRepository
.
findById
(
username
).
orElse
(
null
);
Account
account
=
accountRepository
.
findById
(
username
).
orElseThrow
(()
->
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
));
if
(
account
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
int
num
=
operationHistoryRepository
.
countByUsername
(
username
);
int
num
=
operationHistoryRepository
.
countByUsername
(
username
);
if
(
num
>
10000
)
if
(
num
>
10000
)
{
operationHistoryRepository
.
delete
(
operationHistoryRepository
.
findFirstByUsername
(
username
));
operationHistoryRepository
.
delete
(
operationHistoryRepository
.
findFirstByUsername
(
username
));
}
OperationHistory
operationHistory
=
new
OperationHistory
(
operationHistoryDto
);
OperationHistory
operationHistory
=
new
OperationHistory
(
operationHistoryDto
);
operationHistory
.
setOperationTime
(
Instant
.
now
().
toEpochMilli
());
operationHistory
.
setOperationTime
(
Instant
.
now
().
toEpochMilli
());
operationHistory
.
setUsername
(
username
);
operationHistory
.
setUsername
(
username
);
operationHistory
.
setNickname
(
account
.
getNickname
());
operationHistory
.
setNickname
(
account
.
getNickname
());
if
(
account
.
getParent
()
==
null
)
if
(
account
.
getParent
()
==
null
)
{
operationHistory
.
setAdministrator
(
username
);
operationHistory
.
setAdministrator
(
username
);
else
}
else
{
operationHistory
.
setAdministrator
(
account
.
getParent
());
operationHistory
.
setAdministrator
(
account
.
getParent
());
}
operationHistoryRepository
.
save
(
operationHistory
);
operationHistoryRepository
.
save
(
operationHistory
);
}
}
...
@@ -99,7 +104,7 @@ public class HistoryServiceImpl implements HistoryService {
...
@@ -99,7 +104,7 @@ public class HistoryServiceImpl implements HistoryService {
PageInfo
pageInfo
=
new
PageInfo
();
PageInfo
pageInfo
=
new
PageInfo
();
pageInfo
.
setCurrentPage
(
loginHistoryPage
.
getNumber
());
pageInfo
.
setCurrentPage
(
loginHistoryPage
.
getNumber
());
pageInfo
.
setTotalPages
(
loginHistoryPage
.
getTotalPages
());
pageInfo
.
setTotalPages
(
loginHistoryPage
.
getTotalPages
());
pageInfo
.
setTotalItems
((
int
)
loginHistoryPage
.
getTotalElements
());
pageInfo
.
setTotalItems
((
int
)
loginHistoryPage
.
getTotalElements
());
historyPageResultDto
.
setHistoryPage
(
pageInfo
);
historyPageResultDto
.
setHistoryPage
(
pageInfo
);
return
historyPageResultDto
;
return
historyPageResultDto
;
}
}
...
@@ -131,7 +136,7 @@ public class HistoryServiceImpl implements HistoryService {
...
@@ -131,7 +136,7 @@ public class HistoryServiceImpl implements HistoryService {
PageInfo
pageInfo
=
new
PageInfo
();
PageInfo
pageInfo
=
new
PageInfo
();
pageInfo
.
setCurrentPage
(
operationHistories
.
getNumber
());
pageInfo
.
setCurrentPage
(
operationHistories
.
getNumber
());
pageInfo
.
setTotalPages
(
operationHistories
.
getTotalPages
());
pageInfo
.
setTotalPages
(
operationHistories
.
getTotalPages
());
pageInfo
.
setTotalItems
((
int
)
operationHistories
.
getTotalElements
());
pageInfo
.
setTotalItems
((
int
)
operationHistories
.
getTotalElements
());
historyPageResultDto
.
setHistoryPage
(
pageInfo
);
historyPageResultDto
.
setHistoryPage
(
pageInfo
);
return
historyPageResultDto
;
return
historyPageResultDto
;
}
}
...
...
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpAndShopServiceImpl.java
View file @
e90964d0
...
@@ -43,18 +43,22 @@ public class IpAndShopServiceImpl implements IpAndShopService {
...
@@ -43,18 +43,22 @@ public class IpAndShopServiceImpl implements IpAndShopService {
@Override
@Override
public
void
bindShop
(
String
username
,
ShopRequestDto
shopRequestDto
)
{
public
void
bindShop
(
String
username
,
ShopRequestDto
shopRequestDto
)
{
String
shopId
=
shopRequestDto
.
getShopId
();
// 1. 根据id 来获取账户
Account
account
=
accountRepository
.
findByName
(
username
);
Account
account
=
accountRepository
.
findByName
(
username
);
if
(
account
==
null
)
{
if
(
account
==
null
)
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
}
}
String
shopId
=
shopRequestDto
.
getShopId
();
// 2.获取当前账户下指定的商铺
UserShop
userShop
=
userShopRepository
.
findByUsernameAndShopId
(
username
,
shopId
);
UserShop
userShop
=
userShopRepository
.
findByUsernameAndShopId
(
username
,
shopId
);
if
(
account
.
getPermission
()
<
4
||
userShop
==
null
)
{
if
(
account
.
getPermission
()
<
4
||
userShop
==
null
)
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
);
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
);
}
}
Shop
shop
=
shopRepository
.
findById
(
shopId
).
orElse
(
null
);
// 3.根据shopId获取商铺的详情
if
(
shop
==
null
)
Shop
shop
=
shopRepository
.
findById
(
shopId
).
orElseThrow
(()
->
new
ClientRequestException
(
BrowserErrorCode
.
SHOPNOTEXIST
));
throw
new
ClientRequestException
(
BrowserErrorCode
.
SHOPNOTEXIST
);
// 4.根据传入的id或者addr查询是否有指定的 ip 资源
IpResource
ipResource
=
null
;
IpResource
ipResource
=
null
;
if
(
StringUtils
.
isNotBlank
(
shopRequestDto
.
getIpAddr
()))
{
if
(
StringUtils
.
isNotBlank
(
shopRequestDto
.
getIpAddr
()))
{
ipResource
=
ipResourceRepository
.
findByAddrAndIsDeleted
(
shopRequestDto
.
getIpAddr
(),
false
);
ipResource
=
ipResourceRepository
.
findByAddrAndIsDeleted
(
shopRequestDto
.
getIpAddr
(),
false
);
...
@@ -62,14 +66,18 @@ public class IpAndShopServiceImpl implements IpAndShopService {
...
@@ -62,14 +66,18 @@ public class IpAndShopServiceImpl implements IpAndShopService {
ipResource
=
ipResourceRepository
.
findByIdAndIsDeleted
(
shopRequestDto
.
getIpId
(),
false
);
ipResource
=
ipResourceRepository
.
findByIdAndIsDeleted
(
shopRequestDto
.
getIpId
(),
false
);
}
}
if
(
ipResource
==
null
)
if
(
ipResource
==
null
)
{
throw
new
ClientRequestException
(
BrowserErrorCode
.
IPNOTEXIST
);
throw
new
ClientRequestException
(
BrowserErrorCode
.
IPNOTEXIST
);
}
// 5.根据shopId来查询指定 isDeleted 为 false 的 ip资源
IpResource
bind
=
ipResourceRepository
.
findFirstByShopIdsIsAndIsDeleted
(
shopId
,
false
);
IpResource
bind
=
ipResourceRepository
.
findFirstByShopIdsIsAndIsDeleted
(
shopId
,
false
);
if
(
bind
!=
null
)
{
if
(
bind
!=
null
)
{
return
;
throw
new
ClientRequestException
(
BrowserErrorCode
.
SHOP_BINDED
)
;
}
}
try
{
try
{
// 6.绑定ip,将shopId添加到ip资源中,且将 bind 状态设置为 true
ipResourceRepository
.
addShopId
(
ipResource
.
getId
(),
shopId
);
ipResourceRepository
.
addShopId
(
ipResource
.
getId
(),
shopId
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"fail to bind shop and ip"
,
e
);
logger
.
error
(
"fail to bind shop and ip"
,
e
);
...
...
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpResourceServiceImpl.java
View file @
e90964d0
...
@@ -47,33 +47,11 @@ public class IpResourceServiceImpl implements IpResourceService {
...
@@ -47,33 +47,11 @@ public class IpResourceServiceImpl implements IpResourceService {
private
static
String
USERNAME
=
"fangguanlianbrowser"
;
private
static
String
USERNAME
=
"fangguanlianbrowser"
;
public
static
List
<
String
>
region
=
Arrays
.
asList
(
public
static
List
<
String
>
region
=
Arrays
.
asList
(
"asiapa"
,
"asiapa"
,
"hongkong"
,
"japan"
,
"s-korea"
,
"us"
,
"malaysia"
,
"hongkong"
,
"yajiada"
,
"singapore"
,
"australia"
,
"germany"
,
"uk"
,
"brazil"
,
"japan"
,
"moscow"
,
"canada"
,
"france"
,
"sweden"
,
"s-korea"
,
"india"
,
"meast"
,
"s-korea"
,
"brazil"
,
"virginia"
,
"ohio"
,
"california"
,
"oregon"
,
"ireland"
,
"london"
,
"ireland"
"us"
,
);
"malaysia"
,
"yajiada"
,
"singapore"
,
"australia"
,
"germany"
,
"uk"
,
"brazil"
,
"moscow"
,
"canada"
,
"france"
,
"sweden"
,
"s-korea"
,
"india"
,
"meast"
,
"brazil"
,
"virginia"
,
"ohio"
,
"california"
,
"oregon"
,
"ireland"
,
"london"
,
"ireland"
);
private
static
List
<
String
>
port
=
Arrays
.
asList
(
"20000"
,
"20001"
);
private
static
List
<
String
>
port
=
Arrays
.
asList
(
"20000"
,
"20001"
);
...
@@ -734,24 +712,41 @@ public class IpResourceServiceImpl implements IpResourceService {
...
@@ -734,24 +712,41 @@ public class IpResourceServiceImpl implements IpResourceService {
@Override
@Override
public
void
updateIp
(
String
username
,
IpResourceUpdateDto
ipResourceUpdateDto
)
{
public
void
updateIp
(
String
username
,
IpResourceUpdateDto
ipResourceUpdateDto
)
{
// 1. 根据id 来获取账户
Account
account
=
accountRepository
.
findByName
(
username
);
Account
account
=
accountRepository
.
findByName
(
username
);
if
(
account
==
null
)
if
(
account
==
null
)
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
if
(
account
.
getPermission
()
<
8
)
}
/// 这个地方本来是8,现在由于更新ip失败,改为和绑定店铺时一样的 4
if
(
account
.
getPermission
()
<
4
)
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
);
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
);
}
// 2.根据传入的id查询是否有指定的 isDelete 为 false的 ip 资源
IpResource
ipResource
=
ipResourceRepository
.
findByIdAndIsDeleted
(
ipResourceUpdateDto
.
getIpId
(),
false
);
IpResource
ipResource
=
ipResourceRepository
.
findByIdAndIsDeleted
(
ipResourceUpdateDto
.
getIpId
(),
false
);
if
(
ipResource
==
null
)
if
(
ipResource
==
null
)
{
throw
new
ClientRequestException
(
BrowserErrorCode
.
IPNOTEXIST
);
throw
new
ClientRequestException
(
BrowserErrorCode
.
IPNOTEXIST
);
}
// 封装 ipResource 部分信息
dealIpResource
(
ipResourceUpdateDto
,
ipResource
);
// 3.更新ip资源
ipResourceRepository
.
save
(
ipResource
);
}
private
void
dealIpResource
(
IpResourceUpdateDto
ipResourceUpdateDto
,
IpResource
ipResource
)
{
if
(
StringUtils
.
isNotBlank
(
ipResourceUpdateDto
.
getAddr
()))
{
if
(
StringUtils
.
isNotBlank
(
ipResourceUpdateDto
.
getAddr
()))
{
ipResource
.
setAddr
(
ipResourceUpdateDto
.
getAddr
());
ipResource
.
setAddr
(
ipResourceUpdateDto
.
getAddr
());
}
}
if
(
StringUtils
.
isNotBlank
(
ipResource
.
getRegion
())
&&
region
.
contains
(
ipResource
.
getRegion
()))
{
if
(
StringUtils
.
isNotBlank
(
ipResource
.
getRegion
())
&&
region
.
contains
(
ipResource
.
getRegion
()))
{
ipResource
.
setProxyUsername
(
ipResource
.
getAddr
());
ipResource
.
setProxyUsername
(
ipResource
.
getAddr
());
ipResource
.
setProxyPassword
(
genRandom
(
3
,
12
));
ipResource
.
setProxyPassword
(
genRandom
(
3
,
12
));
ipResource
.
setSpecialLine
(
true
);
ipResource
.
setSpecialLine
(
true
);
}
}
ipResource
.
setStatus
(
ipResourceUpdateDto
.
getStatus
());
ipResource
.
setStatus
(
ipResourceUpdateDto
.
getStatus
());
ipResourceRepository
.
save
(
ipResource
);
}
}
@Override
@Override
...
...
src/main/java/com/edgec/browserbackend/browser/service/Impl/ShopServiceImpl.java
View file @
e90964d0
...
@@ -296,7 +296,7 @@ public class ShopServiceImpl implements ShopService {
...
@@ -296,7 +296,7 @@ public class ShopServiceImpl implements ShopService {
throw
new
ClientRequestException
(
BrowserErrorCode
.
UNKNOWN
);
throw
new
ClientRequestException
(
BrowserErrorCode
.
UNKNOWN
);
}
}
}
else
{
}
else
{
shops
.
stream
().
forEach
(
shop
->
{
shops
.
forEach
(
shop
->
{
try
{
try
{
for
(
Account
account1
:
accounts
)
{
for
(
Account
account1
:
accounts
)
{
UserShop
userShop1
=
userShopRepository
.
findByUsernameAndShopId
(
account1
.
getName
(),
shop
.
getShopId
());
UserShop
userShop1
=
userShopRepository
.
findByUsernameAndShopId
(
account1
.
getName
(),
shop
.
getShopId
());
...
@@ -341,35 +341,36 @@ public class ShopServiceImpl implements ShopService {
...
@@ -341,35 +341,36 @@ public class ShopServiceImpl implements ShopService {
}
}
@Override
@Override
public
ShopPageResultDto
getShopList
(
String
username
,
String
groupId
,
int
page
,
int
amount
,
ShopFilterDto
shopFilterDto
)
{
public
ShopPageResultDto
getShopList
(
String
username
,
String
groupId
,
int
pageNum
,
int
amount
,
ShopFilterDto
shopFilterDto
)
{
if
(
amount
>
100
)
amount
=
100
;
Pageable
pageable
=
PageRequest
.
of
(
page
,
amount
);
Account
account
=
accountRepository
.
findByName
(
username
);
Account
account
=
accountRepository
.
findByName
(
username
);
if
(
account
==
null
)
{
if
(
account
==
null
)
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
}
}
Group
group
=
null
;
Group
group
=
null
;
if
(
groupId
!=
null
)
if
(
groupId
!=
null
)
{
group
=
groupRepository
.
findById
(
groupId
).
orElse
(
null
);
group
=
groupRepository
.
findById
(
groupId
).
orElse
(
null
);
if
(
group
==
null
)
}
if
(
group
==
null
)
{
throw
new
ClientRequestException
(
BrowserErrorCode
.
GROUPNOTEXIST
);
throw
new
ClientRequestException
(
BrowserErrorCode
.
GROUPNOTEXIST
);
if
(
group
!=
null
&&
group
.
getOwner
()
!=
null
&&
!
group
.
getOwner
().
equals
(
username
))
{
}
if
(
group
.
getOwner
()
!=
null
&&
!
group
.
getOwner
().
equals
(
username
))
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
);
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
);
}
}
List
<
String
>
shopIds
=
new
ArrayList
<>();
List
<
String
>
shopIds
=
new
ArrayList
<>();
if
(
groupId
.
equals
(
"-1"
))
{
if
(
"-1"
.
equals
(
groupId
))
{
if
(
shopFilterDto
.
getBindIp
()
==
0
)
if
(
shopFilterDto
.
getBindIp
()
==
0
)
{
shopIds
=
userShopRepository
.
findByUsername
(
username
).
stream
().
// 获取当前用户下所有的商铺id
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
shopIds
=
userShopRepository
.
findByUsername
(
username
).
stream
()
else
if
(
shopFilterDto
.
getBindIp
()
==
1
)
{
.
map
(
UserShop:
:
getShopId
).
collect
(
Collectors
.
toList
());
}
else
if
(
shopFilterDto
.
getBindIp
()
==
1
)
{
List
<
String
>
allIds
=
userShopRepository
.
findByUsername
(
username
).
stream
()
List
<
String
>
allIds
=
userShopRepository
.
findByUsername
(
username
).
stream
()
.
map
(
x
->
x
.
getShopId
()
).
collect
(
Collectors
.
toList
());
.
map
(
UserShop:
:
getShopId
).
collect
(
Collectors
.
toList
());
shopIds
=
ipResourceRepository
.
findShopIdInList
(
allIds
,
false
)
shopIds
=
ipResourceRepository
.
findShopIdInList
(
allIds
,
false
)
.
stream
()
.
stream
()
.
flatMap
((
x
->
x
.
getShopIds
().
stream
())).
collect
(
Collectors
.
toList
());
.
flatMap
((
x
->
x
.
getShopIds
().
stream
())).
collect
(
Collectors
.
toList
());
}
else
{
}
else
{
List
<
String
>
allIds
=
userShopRepository
.
findByUsername
(
username
).
stream
()
List
<
String
>
allIds
=
userShopRepository
.
findByUsername
(
username
).
stream
()
.
map
(
x
->
x
.
getShopId
()
).
collect
(
Collectors
.
toList
());
.
map
(
UserShop:
:
getShopId
).
collect
(
Collectors
.
toList
());
for
(
String
id
:
allIds
)
{
for
(
String
id
:
allIds
)
{
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdsIsAndIsDeleted
(
id
,
false
);
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdsIsAndIsDeleted
(
id
,
false
);
if
(
ipResource
==
null
)
{
if
(
ipResource
==
null
)
{
...
@@ -378,42 +379,52 @@ public class ShopServiceImpl implements ShopService {
...
@@ -378,42 +379,52 @@ public class ShopServiceImpl implements ShopService {
}
}
}
}
}
else
{
}
else
{
if
(
shopFilterDto
.
getBindIp
()
==
0
)
if
(
shopFilterDto
.
getBindIp
()
==
0
)
{
shopIds
=
userShopRepository
.
findByUsernameAndGroupId
(
username
,
groupId
).
stream
().
shopIds
=
userShopRepository
.
findByUsernameAndGroupId
(
username
,
groupId
).
stream
().
map
(
x
->
x
.
getShopId
()
).
collect
(
Collectors
.
toList
());
map
(
UserShop:
:
getShopId
).
collect
(
Collectors
.
toList
());
else
if
(
shopFilterDto
.
getBindIp
()
==
1
)
{
}
else
if
(
shopFilterDto
.
getBindIp
()
==
1
)
{
List
<
String
>
allIds
=
userShopRepository
.
findByUsernameAndGroupId
(
username
,
groupId
).
stream
()
.
List
<
String
>
allIds
=
userShopRepository
.
findByUsernameAndGroupId
(
username
,
groupId
).
stream
()
map
(
x
->
x
.
getShopId
()
).
collect
(
Collectors
.
toList
());
.
map
(
UserShop:
:
getShopId
).
collect
(
Collectors
.
toList
());
shopIds
=
ipResourceRepository
.
findShopIdInList
(
allIds
,
false
)
shopIds
=
ipResourceRepository
.
findShopIdInList
(
allIds
,
false
)
.
stream
()
.
stream
()
.
flatMap
((
x
->
x
.
getShopIds
().
stream
())).
collect
(
Collectors
.
toList
());
.
flatMap
((
x
->
x
.
getShopIds
().
stream
())).
collect
(
Collectors
.
toList
());
}
else
{
}
else
{
List
<
String
>
allIds
=
userShopRepository
.
findByUsernameAndGroupId
(
username
,
groupId
).
stream
()
List
<
String
>
allIds
=
userShopRepository
.
findByUsernameAndGroupId
(
username
,
groupId
).
stream
()
.
map
(
x
->
x
.
getShopId
()
).
collect
(
Collectors
.
toList
());
.
map
(
UserShop:
:
getShopId
).
collect
(
Collectors
.
toList
());
for
(
String
id
:
allIds
)
{
for
(
String
id
:
allIds
)
{
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdsIsAndIsDeleted
(
id
,
false
);
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdsIsAndIsDeleted
(
id
,
false
);
if
(
ipResource
==
null
)
if
(
ipResource
==
null
)
{
shopIds
.
add
(
id
);
shopIds
.
add
(
id
);
}
}
}
}
}
}
}
if
(
amount
>
100
)
{
amount
=
100
;
}
Pageable
pageable
=
PageRequest
.
of
(
pageNum
,
amount
);
Page
<
Shop
>
shops
;
Page
<
Shop
>
shops
;
if
(
shopFilterDto
!=
null
&&
StringUtils
.
isNotBlank
(
shopFilterDto
.
getIpRegion
()))
{
if
(
StringUtils
.
isNotBlank
(
shopFilterDto
.
getIpRegion
()))
{
List
<
String
>
filter
=
ipResourceRepository
.
findShopIdInListAndRegionLike
(
shopIds
,
false
,
shopFilterDto
.
getIpRegion
())
List
<
String
>
filter
=
ipResourceRepository
.
findShopIdInListAndRegionLike
(
shopIds
,
false
,
shopFilterDto
.
getIpRegion
())
.
stream
().
flatMap
((
x
->
x
.
getShopIds
().
stream
())).
collect
(
Collectors
.
toList
());
.
stream
().
flatMap
((
x
->
x
.
getShopIds
().
stream
())).
collect
(
Collectors
.
toList
());
shops
=
shopRepository
.
findByShopIdInOrderByCreateTimeDesc
(
filter
,
pageable
);
shops
=
shopRepository
.
findByShopIdInOrderByCreateTimeDesc
(
filter
,
pageable
);
}
else
if
(
shopFilterDto
!=
null
&&
StringUtils
.
isNotBlank
(
shopFilterDto
.
getShopAccount
()))
}
else
if
(
StringUtils
.
isNotBlank
(
shopFilterDto
.
getShopAccount
()))
{
shops
=
shopRepository
.
findByShopIdInAndShopAccountLikeOrderByCreateTimeDesc
(
shopIds
,
shopFilterDto
.
getShopAccount
(),
pageable
);
shops
=
shopRepository
.
findByShopIdInAndShopAccountLikeOrderByCreateTimeDesc
(
shopIds
,
shopFilterDto
.
getShopAccount
(),
pageable
);
else
if
(
shopFilterDto
!=
null
&&
StringUtils
.
isNotBlank
(
shopFilterDto
.
getShopName
()))
}
else
if
(
StringUtils
.
isNotBlank
(
shopFilterDto
.
getShopName
()))
{
shops
=
shopRepository
.
findByShopIdInAndShopNameLikeOrderByCreateTimeDesc
(
shopIds
,
shopFilterDto
.
getShopName
(),
pageable
);
shops
=
shopRepository
.
findByShopIdInAndShopNameLikeOrderByCreateTimeDesc
(
shopIds
,
shopFilterDto
.
getShopName
(),
pageable
);
else
}
else
{
shops
=
shopRepository
.
findByShopIdInOrderByCreateTimeDesc
(
shopIds
,
pageable
);
shops
=
shopRepository
.
findByShopIdInOrderByCreateTimeDesc
(
shopIds
,
pageable
);
if
(
shops
==
null
||
shops
.
getNumberOfElements
()
<
1
)
}
return
new
ShopPageResultDto
();
ShopPageResultDto
<
ShopResultDto
>
shopPageResultDto
=
new
ShopPageResultDto
<>();
if
(
shops
==
null
||
shops
.
getNumberOfElements
()
<
1
)
{
return
shopPageResultDto
;
}
else
{
List
<
ShopResultDto
>
shopResultDtos
=
new
ArrayList
<>();
List
<
ShopResultDto
>
shopResultDtos
=
new
ArrayList
<>();
shops
.
getContent
().
stream
().
forEach
(
x
->
{
shops
.
getContent
().
stream
().
forEach
(
x
->
{
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdsIsAndIsDeleted
(
x
.
getShopId
(),
false
);
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdsIsAndIsDeleted
(
x
.
getShopId
(),
false
);
if
(
ipResource
!=
null
)
{
if
(
ipResource
!=
null
&&
StringUtils
.
isNotBlank
(
ipResource
.
getAddr
()))
{
if
(
StringUtils
.
isNotBlank
(
ipResource
.
getAddr
()))
{
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
ipResource
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
ipResource
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
if
(
ipResource
.
getStatus
()
!=
5
&&
ipResource
.
getStatus
()
!=
3
&&
ipResource
.
getStatus
()
!=
6
)
{
if
(
ipResource
.
getStatus
()
!=
5
&&
ipResource
.
getStatus
()
!=
3
&&
ipResource
.
getStatus
()
!=
6
)
{
ipResource
.
setStatus
(
2
);
ipResource
.
setStatus
(
2
);
...
@@ -451,20 +462,23 @@ public class ShopServiceImpl implements ShopService {
...
@@ -451,20 +462,23 @@ public class ShopServiceImpl implements ShopService {
}
}
}
}
}
}
}
if
(
ipResource
==
null
)
{
if
(
ipResource
==
null
)
ipResource
=
new
IpResource
();
ipResource
=
new
IpResource
();
}
String
group1
=
userShopRepository
.
findByUsernameAndShopId
(
username
,
x
.
getShopId
()).
getGroupId
();
String
group1
=
userShopRepository
.
findByUsernameAndShopId
(
username
,
x
.
getShopId
()).
getGroupId
();
ShopResultDto
shopResultDto
=
null
;
ShopResultDto
shopResultDto
=
null
;
if
(
ipResource
.
isSpecialLine
())
{
if
(
ipResource
.
isSpecialLine
())
{
SpecialLine
specialLine
=
specialLineRepository
.
findAll
().
get
(
0
);
SpecialLine
specialLine
=
specialLineRepository
.
findAll
().
get
(
0
);
shopResultDto
=
ShopResultDto
.
of
(
x
,
group1
,
new
IpResourceDto
(
ipResource
,
null
,
false
,
specialLine
));
shopResultDto
=
ShopResultDto
.
of
(
x
,
group1
,
new
IpResourceDto
(
ipResource
,
null
,
false
,
specialLine
));
}
else
}
else
{
shopResultDto
=
ShopResultDto
.
of
(
x
,
group1
,
new
IpResourceDto
(
ipResource
,
null
,
false
));
shopResultDto
=
ShopResultDto
.
of
(
x
,
group1
,
new
IpResourceDto
(
ipResource
,
null
,
false
));
}
shopResultDtos
.
add
(
shopResultDto
);
shopResultDtos
.
add
(
shopResultDto
);
});
});
Page
<
ShopResultDto
>
shopDtoPage
=
new
PageImpl
<>(
shopResultDtos
,
pageable
,
shopIds
.
size
());
Page
<
ShopResultDto
>
shopDtoPage
=
new
PageImpl
<>(
shopResultDtos
,
pageable
,
shopIds
.
size
());
ShopPageResultDto
shopPageResultDto
=
new
ShopPageResultDto
();
shopPageResultDto
.
setShopList
(
shopDtoPage
.
getContent
());
shopPageResultDto
.
setShopList
(
shopDtoPage
.
getContent
());
PageInfo
pageInfo
=
new
PageInfo
();
PageInfo
pageInfo
=
new
PageInfo
();
pageInfo
.
setCurrentPage
(
shopDtoPage
.
getPageable
().
getPageNumber
());
pageInfo
.
setCurrentPage
(
shopDtoPage
.
getPageable
().
getPageNumber
());
...
@@ -473,16 +487,20 @@ public class ShopServiceImpl implements ShopService {
...
@@ -473,16 +487,20 @@ public class ShopServiceImpl implements ShopService {
shopPageResultDto
.
setShopPage
(
pageInfo
);
shopPageResultDto
.
setShopPage
(
pageInfo
);
return
shopPageResultDto
;
return
shopPageResultDto
;
}
}
}
@Override
@Override
public
ShopSummary
getShopSummary
(
String
username
)
{
public
ShopSummary
getShopSummary
(
String
username
)
{
Account
account
=
accountRepository
.
findByName
(
username
);
Account
account
=
accountRepository
.
findByName
(
username
);
if
(
account
==
null
)
if
(
account
==
null
)
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
}
ShopSummary
shopSummary
=
new
ShopSummary
();
ShopSummary
shopSummary
=
new
ShopSummary
();
List
<
String
>
allShopIds
=
userShopRepository
.
findByUsername
(
username
).
stream
().
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
List
<
String
>
allShopIds
=
userShopRepository
.
findByUsername
(
username
).
stream
()
.
map
(
UserShop:
:
getShopId
).
collect
(
Collectors
.
toList
());
List
<
String
>
unbind
=
new
ArrayList
<>();
List
<
String
>
unbind
=
new
ArrayList
<>();
if
(
allShopIds
!=
null
&&
allShopIds
.
size
()
>
0
)
{
if
(
!
allShopIds
.
isEmpty
()
)
{
for
(
String
id
:
allShopIds
)
{
for
(
String
id
:
allShopIds
)
{
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdsIsAndIsDeleted
(
id
,
false
);
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdsIsAndIsDeleted
(
id
,
false
);
if
(
ipResource
==
null
)
{
if
(
ipResource
==
null
)
{
...
@@ -491,8 +509,11 @@ public class ShopServiceImpl implements ShopService {
...
@@ -491,8 +509,11 @@ public class ShopServiceImpl implements ShopService {
}
}
}
}
shopSummary
.
setUnbind
(
unbind
.
size
());
shopSummary
.
setUnbind
(
unbind
.
size
());
List
<
String
>
shopIds
=
userShopRepository
.
findByUsername
(
username
).
stream
().
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
List
<
String
>
bind
=
ipResourceRepository
.
findShopIdInList
(
shopIds
,
false
).
stream
().
map
(
x
->
x
.
getId
()).
collect
(
Collectors
.
toList
());
List
<
String
>
shopIds
=
userShopRepository
.
findByUsername
(
username
).
stream
()
.
map
(
UserShop:
:
getShopId
).
collect
(
Collectors
.
toList
());
List
<
String
>
bind
=
ipResourceRepository
.
findShopIdInList
(
shopIds
,
false
).
stream
()
.
map
(
IpResource:
:
getId
).
collect
(
Collectors
.
toList
());
int
expired
=
ipResourceRepository
.
countByStatusAndIdInAndIsDeleted
(
1
,
bind
,
false
);
int
expired
=
ipResourceRepository
.
countByStatusAndIdInAndIsDeleted
(
1
,
bind
,
false
);
int
willexpired
=
ipResourceRepository
.
countByStatusAndIdInAndIsDeleted
(
2
,
bind
,
false
);
int
willexpired
=
ipResourceRepository
.
countByStatusAndIdInAndIsDeleted
(
2
,
bind
,
false
);
shopSummary
.
setExpired
(
expired
);
shopSummary
.
setExpired
(
expired
);
...
...
src/main/java/com/edgec/browserbackend/common/commons/error/ClientRequestException.java
View file @
e90964d0
...
@@ -26,7 +26,7 @@ public class ClientRequestException extends IllegalArgumentException {
...
@@ -26,7 +26,7 @@ public class ClientRequestException extends IllegalArgumentException {
this
.
errorCode
=
errorCode
;
this
.
errorCode
=
errorCode
;
}
}
public
ClientRequestException
(
int
errorCode
,
String
message
){
public
ClientRequestException
(
int
errorCode
,
String
message
)
{
super
(
message
);
super
(
message
);
}
}
...
...
src/main/java/com/edgec/browserbackend/common/commons/error/ErrorCode.java
View file @
e90964d0
...
@@ -12,7 +12,6 @@ public interface ErrorCode {
...
@@ -12,7 +12,6 @@ public interface ErrorCode {
public
static
final
int
COMMON_UNAUTHRORIZED
=
100004
;
public
static
final
int
COMMON_UNAUTHRORIZED
=
100004
;
public
static
final
int
ACCOUNT_BASE
=
400000
;
public
static
final
int
ACCOUNT_BASE
=
400000
;
public
static
final
int
AUTH_BASE
=
500000
;
public
static
final
int
AUTH_BASE
=
500000
;
...
@@ -20,9 +19,11 @@ public interface ErrorCode {
...
@@ -20,9 +19,11 @@ public interface ErrorCode {
public
static
final
int
BROWSER_BASE
=
600000
;
public
static
final
int
BROWSER_BASE
=
600000
;
int
value
()
;
int
value
();
@JsonValue
@JsonValue
int
getCode
()
;
int
getCode
();
String
getReason
();
}
}
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