Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
api
Overview
Overview
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
首航-临时账号
api
Commits
3613b61a
Commit
3613b61a
authored
Sep 24, 2019
by
zhangyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登陆修改
parent
49d72078
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
14 deletions
+57
-14
spring-mvc.xml
resources/spring-mvc.xml
+1
-0
RedisUtils.java
src/com/ejweb/core/util/RedisUtils.java
+22
-3
VerifyStatusBean.java
src/com/ejweb/modules/route/bean/VerifyStatusBean.java
+3
-4
UserController.java
src/com/ejweb/modules/user/api/UserController.java
+31
-7
No files found.
resources/spring-mvc.xml
View file @
3613b61a
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
<list>
<list>
<value>
classpath:jdbc.properties
</value>
<value>
classpath:jdbc.properties
</value>
<value>
classpath:ejweb.properties
</value>
<value>
classpath:ejweb.properties
</value>
<value>
classpath:redis.properties
</value>
</list>
</list>
</property>
</property>
</bean>
</bean>
...
...
src/com/ejweb/core/util/RedisUtils.java
View file @
3613b61a
...
@@ -41,6 +41,21 @@ public class RedisUtils {
...
@@ -41,6 +41,21 @@ public class RedisUtils {
return
value
;
return
value
;
}
}
public
Long
del
(
String
key
,
int
indexDb
)
{
Jedis
jedis
=
null
;
Long
value
=
null
;
try
{
jedis
=
jedisPool
.
getResource
();
jedis
.
select
(
indexDb
);
value
=
jedis
.
del
(
key
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
}
finally
{
returnResource
(
jedisPool
,
jedis
);
}
return
value
;
}
/**
/**
* 通过key 对value进行加值+1操作,当value不是int类型时会返回错误,当key不存在是则value为1
* 通过key 对value进行加值+1操作,当value不是int类型时会返回错误,当key不存在是则value为1
*
*
...
@@ -75,9 +90,11 @@ public class RedisUtils {
...
@@ -75,9 +90,11 @@ public class RedisUtils {
try
{
try
{
jedis
=
jedisPool
.
getResource
();
jedis
=
jedisPool
.
getResource
();
jedis
.
select
(
indexDb
);
jedis
.
select
(
indexDb
);
Long
expireTime
=
jedis
.
pttl
(
key
);
Integer
expireTime
=
jedis
.
ttl
(
key
).
intValue
(
);
res
=
jedis
.
incr
(
key
);
res
=
jedis
.
incr
(
key
);
jedis
.
expireAt
(
key
,
expireTime
);
// jedis.expireAt(key, expireTime);
res
=
jedis
.
expire
(
key
,
expireTime
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
log
.
error
(
e
.
getMessage
());
}
finally
{
}
finally
{
...
@@ -156,4 +173,5 @@ public class RedisUtils {
...
@@ -156,4 +173,5 @@ public class RedisUtils {
jedisPool
.
returnResource
(
jedis
);
jedisPool
.
returnResource
(
jedis
);
}
}
}
}
}
}
\ No newline at end of file
src/com/ejweb/modules/route/bean/VerifyStatusBean.java
View file @
3613b61a
package
com
.
ejweb
.
modules
.
route
.
bean
;
package
com
.
ejweb
.
modules
.
route
.
bean
;
import
java.util.List
;
import
com.ejweb.core.base.GenericBean
;
import
java.util.Map
;
import
org.hibernate.validator.constraints.NotEmpty
;
import
org.hibernate.validator.constraints.NotEmpty
;
import
com.ejweb.core.base.GenericBean
;
import
java.util.List
;
import
java.util.Map
;
public
class
VerifyStatusBean
extends
GenericBean
{
public
class
VerifyStatusBean
extends
GenericBean
{
...
...
src/com/ejweb/modules/user/api/UserController.java
View file @
3613b61a
...
@@ -9,6 +9,7 @@ import com.ejweb.core.conf.GConstants;
...
@@ -9,6 +9,7 @@ import com.ejweb.core.conf.GConstants;
import
com.ejweb.core.fetcher.FetchEntity
;
import
com.ejweb.core.fetcher.FetchEntity
;
import
com.ejweb.core.fetcher.HCFetcher
;
import
com.ejweb.core.fetcher.HCFetcher
;
import
com.ejweb.core.util.IdWorker
;
import
com.ejweb.core.util.IdWorker
;
import
com.ejweb.core.util.RedisUtils
;
import
com.ejweb.core.util.Util
;
import
com.ejweb.core.util.Util
;
import
com.ejweb.modules.im.service.HuaweiInterfaseService
;
import
com.ejweb.modules.im.service.HuaweiInterfaseService
;
import
com.ejweb.modules.mobile.verify.entity.MobileVerifyEntity
;
import
com.ejweb.modules.mobile.verify.entity.MobileVerifyEntity
;
...
@@ -24,6 +25,7 @@ import com.jdair.util.http.client.HTTPClientUtil;
...
@@ -24,6 +25,7 @@ import com.jdair.util.http.client.HTTPClientUtil;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.log4j.Logger
;
import
org.apache.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.validation.BindingResult
;
...
@@ -36,6 +38,7 @@ import java.net.URLDecoder;
...
@@ -36,6 +38,7 @@ import java.net.URLDecoder;
import
java.util.*
;
import
java.util.*
;
@Controller
@Controller
@RequestMapping
(
"/api/user"
)
@RequestMapping
(
"/api/user"
)
public
class
UserController
{
public
class
UserController
{
...
@@ -49,7 +52,10 @@ public class UserController {
...
@@ -49,7 +52,10 @@ public class UserController {
@Autowired
@Autowired
private
MobileVerifyService
mobileVerifyService
;
private
MobileVerifyService
mobileVerifyService
;
@Value
(
"${redis.dbIndex}"
)
private
int
indexDb
;
@Autowired
private
RedisUtils
RedisUtils
;
@Autowired
@Autowired
private
UserRolesService
userRolesService
;
private
UserRolesService
userRolesService
;
...
@@ -131,13 +137,31 @@ public class UserController {
...
@@ -131,13 +137,31 @@ public class UserController {
ResponseBean
responseBean
=
new
ResponseBean
();
ResponseBean
responseBean
=
new
ResponseBean
();
String
message
=
userService
.
validate
(
requestBean
);
String
message
=
userService
.
validate
(
requestBean
);
LoginBean
loginBean
=
requestBean
.
getObjectBean
(
LoginBean
.
class
);
LoginBean
loginBean
=
requestBean
.
getObjectBean
(
LoginBean
.
class
);
int
a
=
indexDb
;
String
s
=
RedisUtils
.
get
(
loginBean
.
getLoginName
(),
indexDb
);
if
(
null
!=
s
&&
Integer
.
parseInt
(
s
)
>=
6
){
RedisUtils
.
expire
(
"black_username"
+
loginBean
.
getLoginName
(),
300
,
indexDb
);
responseBean
.
setStatus
(
ErrorCode
.
STATUS_CODE_4101
);
responseBean
.
setMessage
(
"该帐号已禁止登录"
);
return
responseBean
;
}
if
(
StringUtils
.
isEmpty
(
s
)){
RedisUtils
.
set
(
loginBean
.
getLoginName
(),
1
,
indexDb
);
RedisUtils
.
expire
(
loginBean
.
getLoginName
(),
360
,
indexDb
);
RedisUtils
.
incrNotResetExpireTime
(
loginBean
.
getLoginName
(),
indexDb
);
}
else
{
RedisUtils
.
incrNotResetExpireTime
(
loginBean
.
getLoginName
(),
indexDb
);
}
message
=
userService
.
validate
(
loginBean
);
message
=
userService
.
validate
(
loginBean
);
if
(
message
==
null
)
{
if
(
message
==
null
)
{
LoginUserEntity
userEntity
=
userService
.
findUserByLoginName
(
loginBean
);
LoginUserEntity
userEntity
=
userService
.
findUserByLoginName
(
loginBean
);
if
(
userEntity
==
null
){
// 查询不到用户信息
if
(
userEntity
==
null
){
// 查询不到用户信息
responseBean
.
setStatus
(
ErrorCode
.
STATUS_CODE_4102
);
responseBean
.
setStatus
(
ErrorCode
.
STATUS_CODE_4102
);
responseBean
.
setMessage
(
"用户名
不存在
"
);
responseBean
.
setMessage
(
"用户名
或密码错误
"
);
long
endTime
=
System
.
nanoTime
();
long
endTime
=
System
.
nanoTime
();
long
duration
=
endTime
-
startTime
;
long
duration
=
endTime
-
startTime
;
...
@@ -175,8 +199,8 @@ public class UserController {
...
@@ -175,8 +199,8 @@ public class UserController {
}
}
if
(
passwordError
){
if
(
passwordError
){
responseBean
.
setStatus
(
ErrorCode
.
STATUS_CODE_4103
);
responseBean
.
setStatus
(
ErrorCode
.
STATUS_CODE_4103
);
responseBean
.
setMessage
(
"用户名
密码不匹配!
"
);
responseBean
.
setMessage
(
"用户名
或密码错误
"
);
long
endTime
=
System
.
nanoTime
();
long
endTime
=
System
.
nanoTime
();
long
duration
=
endTime
-
startTime
;
long
duration
=
endTime
-
startTime
;
LOG
.
debug
(
"[UserController login][STATUS_CODE_4103]总共用时:"
+
Util
.
getDurationTime
(
duration
));
LOG
.
debug
(
"[UserController login][STATUS_CODE_4103]总共用时:"
+
Util
.
getDurationTime
(
duration
));
...
@@ -185,7 +209,7 @@ public class UserController {
...
@@ -185,7 +209,7 @@ public class UserController {
if
(
StringUtils
.
isNotBlank
(
loginBean
.
getVerifyCode
())){
// 校验码登录
if
(
StringUtils
.
isNotBlank
(
loginBean
.
getVerifyCode
())){
// 校验码登录
MobileVerifyEntity
entity
=
mobileVerifyService
.
getVerifyCode
(
loginBean
.
getLoginName
(),
loginBean
.
getVerifyCode
());
MobileVerifyEntity
entity
=
mobileVerifyService
.
getVerifyCode
(
loginBean
.
getLoginName
(),
loginBean
.
getVerifyCode
());
if
(
entity
==
null
){
// 校验码不存在
if
(
entity
==
null
){
// 校验码不存在
RedisUtils
.
del
(
loginBean
.
getLoginName
(),
indexDb
);
responseBean
.
setStatus
(
ErrorCode
.
STATUS_CODE_4104
);
responseBean
.
setStatus
(
ErrorCode
.
STATUS_CODE_4104
);
responseBean
.
setMessage
(
"校验码错误"
);
responseBean
.
setMessage
(
"校验码错误"
);
...
@@ -194,7 +218,7 @@ public class UserController {
...
@@ -194,7 +218,7 @@ public class UserController {
LOG
.
debug
(
"[UserController login][STATUS_CODE_4104]总共用时:"
+
Util
.
getDurationTime
(
duration
));
LOG
.
debug
(
"[UserController login][STATUS_CODE_4104]总共用时:"
+
Util
.
getDurationTime
(
duration
));
return
responseBean
;
return
responseBean
;
}
else
if
(
entity
.
getExpireTime
().
getTime
()>
System
.
currentTimeMillis
()){
// 校验码已经失效
}
else
if
(
entity
.
getExpireTime
().
getTime
()>
System
.
currentTimeMillis
()){
// 校验码已经失效
RedisUtils
.
del
(
loginBean
.
getLoginName
(),
indexDb
);
responseBean
.
setStatus
(
ErrorCode
.
STATUS_CODE_4105
);
responseBean
.
setStatus
(
ErrorCode
.
STATUS_CODE_4105
);
responseBean
.
setMessage
(
"校验码已失效"
);
responseBean
.
setMessage
(
"校验码已失效"
);
...
@@ -210,7 +234,7 @@ public class UserController {
...
@@ -210,7 +234,7 @@ public class UserController {
// loginInfo.setUserId(userEntity.getId());
// loginInfo.setUserId(userEntity.getId());
// loginInfo.setLoginDate(new Date());
// loginInfo.setLoginDate(new Date());
// loginInfo.setLoginIp(clientip);
// loginInfo.setLoginIp(clientip);
RedisUtils
.
del
(
loginBean
.
getLoginName
(),
indexDb
);
UserLoginLogEntity
deviceInfoEntity
=
new
UserLoginLogEntity
();
UserLoginLogEntity
deviceInfoEntity
=
new
UserLoginLogEntity
();
deviceInfoEntity
.
setUserId
(
userEntity
.
getId
());
deviceInfoEntity
.
setUserId
(
userEntity
.
getId
());
...
...
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