Commit fe89cc89 by java-李谡

Merge remote-tracking branch 'origin/develop' into develop

# Conflicts:
#	src/com/ejweb/modules/user/api/UserController.java
parents cbf8478b 5fd530f7
...@@ -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>
......
...@@ -75,6 +75,21 @@ public class RedisUtils { ...@@ -75,6 +75,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
* *
...@@ -109,9 +124,11 @@ public class RedisUtils { ...@@ -109,9 +124,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 {
...@@ -190,4 +207,5 @@ public class RedisUtils { ...@@ -190,4 +207,5 @@ public class RedisUtils {
jedisPool.returnResource(jedis); jedisPool.returnResource(jedis);
} }
} }
} }
\ No newline at end of file
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 {
......
...@@ -11,6 +11,7 @@ import com.ejweb.core.fetcher.HCFetcher; ...@@ -11,6 +11,7 @@ import com.ejweb.core.fetcher.HCFetcher;
import com.ejweb.core.util.IdWorker; import com.ejweb.core.util.IdWorker;
import com.ejweb.core.util.PropertiesUtils; import com.ejweb.core.util.PropertiesUtils;
import com.ejweb.core.util.RedisUtils; import com.ejweb.core.util.RedisUtils;
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;
...@@ -26,6 +27,7 @@ import com.jdair.util.http.client.HTTPClientUtil; ...@@ -26,6 +27,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;
...@@ -51,17 +53,15 @@ public class UserController { ...@@ -51,17 +53,15 @@ 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;
@Autowired @Autowired
private HuaweiInterfaseService huaweiInterfaseService; private HuaweiInterfaseService huaweiInterfaseService;
@Autowired
private RedisUtils redisUtils;
/** /**
* 根据用户CODE查询用户信息 * 根据用户CODE查询用户信息
* *
...@@ -141,6 +141,24 @@ public class UserController { ...@@ -141,6 +141,24 @@ 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) {
LoginIpInfo loginIpInfo = userService.findByIp(userIp); LoginIpInfo loginIpInfo = userService.findByIp(userIp);
...@@ -157,8 +175,7 @@ public class UserController { ...@@ -157,8 +175,7 @@ public class UserController {
if(userEntity == null){ if(userEntity == null){
responseBean.setStatus(ErrorCode.STATUS_CODE_4102); responseBean.setStatus(ErrorCode.STATUS_CODE_4102);
responseBean.setMessage("用户名不存在"); responseBean.setMessage("用户名不存在");
//判断ip限制
checkIpLimit(redisUtils,userIp,indexDb,responseBean);
long endTime = System.nanoTime(); long endTime = System.nanoTime();
long duration = endTime - startTime; long duration = endTime - startTime;
LOG.debug("[UserController login][STATUS_CODE_4102]总共用时:"+Util.getDurationTime(duration)); LOG.debug("[UserController login][STATUS_CODE_4102]总共用时:"+Util.getDurationTime(duration));
...@@ -197,8 +214,7 @@ public class UserController { ...@@ -197,8 +214,7 @@ public class UserController {
if (passwordError){ if (passwordError){
responseBean.setStatus(ErrorCode.STATUS_CODE_4103); responseBean.setStatus(ErrorCode.STATUS_CODE_4103);
responseBean.setMessage("用户名密码不匹配!"); responseBean.setMessage("用户名密码不匹配!");
//判断ip限制
checkIpLimit(redisUtils,userIp,indexDb,responseBean);
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));
...@@ -219,7 +235,7 @@ public class UserController { ...@@ -219,7 +235,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("校验码已失效");
//判断ip限制 //判断ip限制
...@@ -236,7 +252,7 @@ public class UserController { ...@@ -236,7 +252,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());
...@@ -353,8 +369,6 @@ public class UserController { ...@@ -353,8 +369,6 @@ public class UserController {
responseBean.setMessage(message); responseBean.setMessage(message);
return responseBean; return responseBean;
} }
public boolean sendVerifyCode(String telephone, String verifyCode) { public boolean sendVerifyCode(String telephone, String verifyCode) {
try { try {
HCFetcher fetcher = HCFetcher.getInstance(); HCFetcher fetcher = HCFetcher.getInstance();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment