新增用户登陆IP,登陆时间
parent
e009cf9708
commit
95fc2f2d83
|
@ -51,6 +51,8 @@ create table sys_user (
|
|||
user_type char(1) default 'N' comment '类型:Y默认用户,N非默认用户',
|
||||
status int(1) default 0 comment '帐号状态:0正常,1禁用',
|
||||
refuse_des varchar(500) default '' comment '拒绝登录描述',
|
||||
login_ip varchar(100) default '' comment '最后登陆IP',
|
||||
login_date datetime comment '最后登陆时间',
|
||||
create_by varchar(64) default '' comment '创建者',
|
||||
create_time datetime comment '创建时间',
|
||||
update_by varchar(64) default '' comment '更新者',
|
||||
|
@ -61,8 +63,8 @@ create table sys_user (
|
|||
-- ----------------------------
|
||||
-- 初始化-用户信息表数据
|
||||
-- ----------------------------
|
||||
insert into sys_user values(1, 106, 'admin', '若依', 'ry@163.com', '15888888888', '1', '', '29c67a30398638269fe600f73a054934', '111111', 'Y', 0, '正常', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
|
||||
insert into sys_user values(2, 108, 'ry', '若依', 'ry@qq.com', '15666666666', '1', '', '8e6d98b90472783cc73c17047ddccf36', '222222', 'N', 0, '正常', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
|
||||
insert into sys_user values(1, 106, 'admin', '若依', 'ry@163.com', '15888888888', '1', '', '29c67a30398638269fe600f73a054934', '111111', 'Y', 0, '正常', '127.0.0.1', '2018-03-16 11-33-00', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
|
||||
insert into sys_user values(2, 108, 'ry', '若依', 'ry@qq.com', '15666666666', '1', '', '8e6d98b90472783cc73c17047ddccf36', '222222', 'N', 0, '正常', '127.0.0.1', '2018-03-16 11-33-00', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00');
|
||||
|
||||
-- ----------------------------
|
||||
-- 3、岗位信息表
|
|
@ -3,7 +3,6 @@ package com.ruoyi.common.utils;
|
|||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
|
||||
/**
|
||||
|
@ -23,6 +22,16 @@ public class DateUtils
|
|||
|
||||
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
/**
|
||||
* 获取当前Date型日期
|
||||
*
|
||||
* @return Date() 当前日期
|
||||
*/
|
||||
public static Date getNowDate()
|
||||
{
|
||||
return new Date();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期, 默认格式为yyyy-MM-dd
|
||||
*
|
||||
|
|
|
@ -32,7 +32,6 @@ import com.ruoyi.project.system.user.domain.User;
|
|||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
@EnableAsync
|
||||
|
|
|
@ -10,9 +10,11 @@ import com.ruoyi.common.exception.user.CaptchaException;
|
|||
import com.ruoyi.common.exception.user.UserBlockedException;
|
||||
import com.ruoyi.common.exception.user.UserNotExistsException;
|
||||
import com.ruoyi.common.exception.user.UserPasswordNotMatchException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.MessageUtils;
|
||||
import com.ruoyi.common.utils.ServletUtils;
|
||||
import com.ruoyi.common.utils.SystemLogUtils;
|
||||
import com.ruoyi.common.utils.security.ShiroUtils;
|
||||
import com.ruoyi.project.system.user.domain.User;
|
||||
import com.ruoyi.project.system.user.service.IUserService;
|
||||
|
||||
|
@ -70,12 +72,12 @@ public class LoginService
|
|||
{
|
||||
user = userService.selectUserByPhoneNumber(username);
|
||||
}
|
||||
|
||||
|
||||
if (user == null && maybeEmail(username))
|
||||
{
|
||||
user = userService.selectUserByEmail(username);
|
||||
}
|
||||
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
SystemLogUtils.log(username, CommonConstant.LOGIN_FAIL, MessageUtils.message("user.not.exists"));
|
||||
|
@ -89,8 +91,8 @@ public class LoginService
|
|||
SystemLogUtils.log(username, CommonConstant.LOGIN_FAIL, MessageUtils.message("user.blocked", user.getRefuseDes()));
|
||||
throw new UserBlockedException(user.getRefuseDes());
|
||||
}
|
||||
|
||||
SystemLogUtils.log(username, CommonConstant.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
|
||||
recordLoginInfo(user);
|
||||
return user;
|
||||
}
|
||||
|
||||
|
@ -112,4 +114,14 @@ public class LoginService
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录登录信息
|
||||
*/
|
||||
public void recordLoginInfo(User user)
|
||||
{
|
||||
user.setLoginIp(ShiroUtils.getIp());
|
||||
user.setLoginDate(DateUtils.getNowDate());
|
||||
userService.updateUser(user);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public interface ConfigMapper
|
|||
/**
|
||||
* 根据键名查询参数配置信息
|
||||
*
|
||||
* @param configName 参数名称
|
||||
* @param configKey 参数键名
|
||||
* @return 参数配置信息
|
||||
*/
|
||||
public Config selectConfigByKey(String configKey);
|
||||
|
|
|
@ -22,7 +22,7 @@ public interface IConfigService
|
|||
/**
|
||||
* 根据键名查询参数配置信息
|
||||
*
|
||||
* @param configName 参数名称
|
||||
* @param configKey 参数键名
|
||||
* @return 参数键值
|
||||
*/
|
||||
public String selectConfigByKey(String configKey);
|
||||
|
@ -78,7 +78,7 @@ public interface IConfigService
|
|||
/**
|
||||
* 校验参数键名是否唯一
|
||||
*
|
||||
* @param dept 部门信息
|
||||
* @param config 参数信息
|
||||
* @return 结果
|
||||
*/
|
||||
public String checkConfigKeyUnique(Config config);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.ruoyi.project.system.user.domain;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import org.apache.shiro.crypto.SecureRandomNumberGenerator;
|
||||
import com.ruoyi.framework.web.domain.BaseEntity;
|
||||
import com.ruoyi.project.system.dept.domain.Dept;
|
||||
|
@ -41,6 +42,10 @@ public class User extends BaseEntity
|
|||
private int status;
|
||||
/** 拒绝登录描述 */
|
||||
private String refuseDes;
|
||||
/** 最后登陆IP */
|
||||
private String loginIp;
|
||||
/** 最后登陆时间 */
|
||||
private Date loginDate;
|
||||
/** 部门对象 */
|
||||
private Dept dept;
|
||||
/** 角色组 */
|
||||
|
@ -199,6 +204,26 @@ public class User extends BaseEntity
|
|||
this.refuseDes = refuseDes;
|
||||
}
|
||||
|
||||
public String getLoginIp()
|
||||
{
|
||||
return loginIp;
|
||||
}
|
||||
|
||||
public void setLoginIp(String loginIp)
|
||||
{
|
||||
this.loginIp = loginIp;
|
||||
}
|
||||
|
||||
public Date getLoginDate()
|
||||
{
|
||||
return loginDate;
|
||||
}
|
||||
|
||||
public void setLoginDate(Date loginDate)
|
||||
{
|
||||
this.loginDate = loginDate;
|
||||
}
|
||||
|
||||
public Dept getDept()
|
||||
{
|
||||
return dept;
|
||||
|
|
|
@ -30,7 +30,7 @@ public interface UserMapper
|
|||
/**
|
||||
* 通过手机号码查询用户
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @param phoneNumber 手机号码
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public User selectUserByPhoneNumber(String phoneNumber);
|
||||
|
|
|
@ -30,7 +30,7 @@ public interface IUserService
|
|||
/**
|
||||
* 通过手机号码查询用户
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @param phoneNumber 手机号码
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
public User selectUserByPhoneNumber(String phoneNumber);
|
||||
|
@ -103,7 +103,7 @@ public interface IUserService
|
|||
/**
|
||||
* 校验手机号码是否唯一
|
||||
*
|
||||
* @param phonenumber 登录名称
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public String checkPhoneUnique(User user);
|
||||
|
@ -112,7 +112,7 @@ public interface IUserService
|
|||
/**
|
||||
* 校验email是否唯一
|
||||
*
|
||||
* @param email 登录名称
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
public String checkEmailUnique(User user);
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.security.ShiroUtils;
|
||||
import com.ruoyi.framework.shiro.service.PasswordService;
|
||||
|
@ -152,7 +153,7 @@ public class UserServiceImpl implements IUserService
|
|||
{
|
||||
user.setUpdateBy(ShiroUtils.getLoginName());
|
||||
// 修改用户信息
|
||||
count = userMapper.updateUser(user);
|
||||
count = updateUser(user);
|
||||
// 删除用户与角色关联
|
||||
userRoleMapper.deleteUserRoleByUserId(userId);
|
||||
// 新增用户与角色管理
|
||||
|
@ -201,7 +202,7 @@ public class UserServiceImpl implements IUserService
|
|||
{
|
||||
user.randomSalt();
|
||||
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
|
||||
return userMapper.updateUser(user);
|
||||
return updateUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="userType" column="user_type" />
|
||||
<result property="status" column="status" />
|
||||
<result property="refuseDes" column="refuse_des" />
|
||||
<result property="loginIp" column="login_ip" />
|
||||
<result property="loginDate" column="login_date" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
|
@ -46,7 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<select id="selectUserByLoginName" parameterType="String" resultMap="UserResult">
|
||||
select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.sex, u.avatar, u.password, u.salt, u.status, u.refuse_des, u.create_time,
|
||||
select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.sex, u.avatar, u.password, u.salt, u.status, u.refuse_des, u.login_ip, u.login_date, u.create_time,
|
||||
d.dept_id, d.parent_id, d.dept_name, d.order_num, d.status as dept_status
|
||||
from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
|
@ -55,7 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<select id="selectUserByPhoneNumber" parameterType="String" resultMap="UserResult">
|
||||
select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.sex, u.avatar, u.password, u.salt, u.status, u.refuse_des, u.create_time,
|
||||
select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.sex, u.avatar, u.password, u.salt, u.status, u.refuse_des, u.login_ip, u.login_date, u.create_time,
|
||||
d.dept_id, d.parent_id, d.dept_name, d.order_num, d.status as dept_status
|
||||
from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
|
@ -64,7 +66,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<select id="selectUserByEmail" parameterType="String" resultMap="UserResult">
|
||||
select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.sex, u.avatar, u.password, u.salt, u.status, u.refuse_des, u.create_time,
|
||||
select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.sex, u.avatar, u.password, u.salt, u.status, u.refuse_des, u.login_ip, u.login_date, u.create_time,
|
||||
d.dept_id, d.parent_id, d.dept_name, d.order_num, d.status as dept_status
|
||||
from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
|
@ -85,7 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<select id="selectUserById" parameterType="Long" resultMap="UserResult">
|
||||
select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.sex, u.avatar, u.password, u.salt, u.status, u.refuse_des, u.create_time,
|
||||
select u.user_id, u.dept_id, u.login_name, u.user_name, u.email, u.phonenumber, u.sex, u.avatar, u.password, u.salt, u.status, u.refuse_des, u.login_ip, u.login_date, u.create_time,
|
||||
d.dept_id, d.parent_id, d.dept_name, d.order_num, d.status as dept_status
|
||||
from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
|
@ -118,6 +120,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="salt != null and salt != ''">salt = #{salt},</if>
|
||||
<if test="status !=null">status = #{status},</if>
|
||||
<if test="refuseDes != null and refuseDes != ''">refuse_des = #{refuseDes},</if>
|
||||
<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
|
||||
<if test="loginDate != null">login_date = #{loginDate},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
|
|
|
@ -345,6 +345,7 @@ $(function() {
|
|||
}
|
||||
}
|
||||
|
||||
// 点击选项卡菜单
|
||||
$('.menuTabs').on('click', '.menuTab', activeTab);
|
||||
|
||||
//刷新iframe
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
<div class="col-sm-4">
|
||||
<div class="text-center">
|
||||
<img alt="image" class="img-circle m-t-xs img-responsive" th:src="(${user.avatar} == '') ? '/img/profile.jpg' : '/profile/' + ${user.avatar}">
|
||||
<div class="m-t-xs font-bold">CEO</div>
|
||||
<div class="m-t-xs font-bold">[[${user.loginIp}]]</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
|
@ -46,7 +46,7 @@
|
|||
<p><i class="fa fa-group"></i> [[${user.dept.deptName}]] / [[${#strings.defaultString(postGroup,'无岗位')}]]</p>
|
||||
<p><i class="fa fa-transgender"></i> [[${user.sex}]]</p>
|
||||
<p><i class="fa fa-envelope-o"></i> [[${user.email}]]</p>
|
||||
<p><i class="fa fa-calendar"></i> [[${user.createDateTimeStr}]]</p>
|
||||
<p><i class="fa fa-calendar"></i> [[${#dates.format(user.loginDate, 'yyyy-MM-dd HH:mm:ss')}]]</p>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</a>
|
||||
|
|
Loading…
Reference in New Issue