updates
This commit is contained in:
parent
0e0b01055c
commit
00efbf53f9
|
|
@ -9,7 +9,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
/**
|
||||
* IP地址
|
||||
*
|
||||
*
|
||||
* @Author scott
|
||||
* @email jeecgos@163.com
|
||||
* @Date 2019年01月14日
|
||||
|
|
@ -19,7 +19,7 @@ public class IpUtils {
|
|||
|
||||
/**
|
||||
* 获取IP地址
|
||||
*
|
||||
*
|
||||
* 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址
|
||||
* 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址
|
||||
*/
|
||||
|
|
@ -30,7 +30,7 @@ public class IpUtils {
|
|||
if (StringUtils.isEmpty(ip) || CommonConstant.UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
}
|
||||
if (StringUtils.isEmpty(ip) || ip.length() == 0 ||CommonConstant.UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
if (StringUtils.isEmpty(ip) || ip.isEmpty() ||CommonConstant.UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (StringUtils.isEmpty(ip) || CommonConstant.UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
|
|
@ -45,15 +45,15 @@ public class IpUtils {
|
|||
} catch (Exception e) {
|
||||
logger.error("IPUtils ERROR ", e);
|
||||
}
|
||||
|
||||
|
||||
// //使用代理,则获取第一个IP地址
|
||||
// if(StringUtils.isEmpty(ip) && ip.length() > 15) {
|
||||
// if(ip.indexOf(",") > 0) {
|
||||
// ip = ip.substring(0, ip.indexOf(","));
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
return ip;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ public class BaseCommonServiceImpl implements BaseCommonService {
|
|||
HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
|
||||
//设置IP地址
|
||||
sysLog.setIp(IpUtils.getIpAddr(request));
|
||||
System.out.println("IP地址:"+ sysLog.getIp());
|
||||
} catch (Exception e) {
|
||||
sysLog.setIp("127.0.0.1");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ public class WebUserController {
|
|||
|
||||
@RequestMapping(value = "register",method = RequestMethod.POST)
|
||||
@ApiOperation(value = "账号注册")
|
||||
@AutoLog(value = "网站前台-账号注册")
|
||||
public Result<?> register(@RequestBody SysLoginModel sysLoginModel, HttpServletRequest request){
|
||||
String ipAddr = IpUtils.getIpAddr(request);
|
||||
String phone = sysLoginModel.getPhone();
|
||||
|
|
@ -80,7 +79,6 @@ public class WebUserController {
|
|||
|
||||
@RequestMapping(value = "passwordChanger",method = RequestMethod.POST)
|
||||
@ApiOperation(value = "更改密码")
|
||||
@AutoLog(value = "网站前台-更改密码")
|
||||
public Result<?> passwordChanger(@RequestBody SysLoginModel sysLoginModel, HttpServletRequest request){
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String oldPassword = sysLoginModel.getOldPassword();//输入的旧密码
|
||||
|
|
@ -113,7 +111,6 @@ public class WebUserController {
|
|||
|
||||
@RequestMapping(value = "/login/passwd", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "手机号密码登录")
|
||||
@AutoLog(value = "网站前台-账号登录")
|
||||
public Result<?> loginPasswd(@RequestBody SysLoginModel sysLoginModel){
|
||||
return webUserService.loginPasswd(sysLoginModel);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import org.jeecg.common.system.vo.LoginUser;
|
|||
import org.jeecg.common.util.AssertUtils;
|
||||
import org.jeecg.common.util.PasswordUtil;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.modules.base.service.BaseCommonService;
|
||||
import org.jeecg.modules.mini.dto.VipDTO;
|
||||
import org.jeecg.modules.mini.service.MiniUserService;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
|
|
@ -37,6 +38,8 @@ public class WebUserService {
|
|||
@Resource
|
||||
private MiniUserService miniUserService;
|
||||
@Resource
|
||||
private BaseCommonService baseCommonService;
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
/**
|
||||
|
|
@ -64,6 +67,8 @@ public class WebUserService {
|
|||
JSONObject obj = new JSONObject();
|
||||
LoginUser loginUser = new LoginUser();
|
||||
BeanUtils.copyProperties(sysUser, loginUser);
|
||||
//添加日志
|
||||
baseCommonService.addLog("前台用户登录:用户名: " + sysUser.getUsername() + ",登录成功!", CommonConstant.LOG_TYPE_1, null);
|
||||
//获取vip信息
|
||||
VipDTO vipDTO = miniUserService.getUserVip(sysUser.getId());
|
||||
if (vipDTO != null) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue