feat:修改用户记录

dev
wangxy 3 weeks ago
parent 464ac600d4
commit f97d25ef69

@ -2,106 +2,122 @@
;
import com.archive.common.constant.Constants;
import com.archive.common.utils.AddressUtils;
import com.archive.common.utils.LogUtils;
import com.archive.common.utils.ServletUtils;
import com.archive.common.utils.StringUtils;
import com.archive.common.utils.security.ShiroUtils;
import com.archive.common.utils.spring.SpringUtils;
import com.archive.project.monitor.logininfor.domain.Logininfor;
import com.archive.project.monitor.logininfor.service.LogininforServiceImpl;
import com.archive.project.monitor.online.domain.OnlineSession;
import com.archive.project.monitor.online.domain.UserOnline;
import com.archive.project.monitor.online.service.IUserOnlineService;
import com.archive.project.monitor.operlog.domain.OperLog;
import com.archive.project.monitor.operlog.service.IOperLogService;
import eu.bitwalker.useragentutils.UserAgent;
import java.util.TimerTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AsyncFactory
{
public class AsyncFactory {
private static final Logger sys_user_logger = LoggerFactory.getLogger("sys-user");
/**
* session
*
* @param session 线
* @return task
*/
public static TimerTask syncSessionToDb(final OnlineSession session) {
return new TimerTask() {
@Override
public void run() {
UserOnline online = new UserOnline();
online.setSessionId(String.valueOf(session.getId()));
online.setDeptName(session.getDeptName());
online.setLoginName(session.getLoginName());
online.setStartTimestamp(session.getStartTimestamp());
online.setLastAccessTime(session.getLastAccessTime());
online.setExpireTime(session.getTimeout());
online.setIpaddr(session.getHost());
online.setLoginLocation(AddressUtils.getRealAddressByIP(session.getHost()));
online.setBrowser(session.getBrowser());
online.setOs(session.getOs());
online.setStatus(session.getStatus());
online.setSession(session);
SpringUtils.getBean(IUserOnlineService.class).saveOnline(online);
public static TimerTask syncSessionToDb(OnlineSession session) {
return null;
}
public static TimerTask recordOper(OperLog operLog) {
return null;
};
}
public static TimerTask recordLogininfor(String username, String status, String message, Object... args) {
UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent"));
String ip = ShiroUtils.getIp();
return null;
/**
*
*
* @param operLog
* @return task
*/
public static TimerTask recordOper(final OperLog operLog) {
return new TimerTask() {
@Override
public void run() {
// 远程查询操作地点
operLog.setOperLocation(AddressUtils.getRealAddressByIP(operLog.getOperIp()));
SpringUtils.getBean(IOperLogService.class).insertOperlog(operLog);
}
};
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\framework\manager\factory\AsyncFactory.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
/**
*
*
* @param username
* @param status
* @param message
* @param args
* @return task
*/
public static TimerTask recordLogininfor(final String username, final String status, final String message, final Object... args) {
final UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent"));
final String ip = ShiroUtils.getIp();
return new TimerTask() {
@Override
public void run() {
String address = AddressUtils.getRealAddressByIP(ip);
StringBuilder s = new StringBuilder();
s.append(LogUtils.getBlock(ip));
s.append(address);
s.append(LogUtils.getBlock(username));
s.append(LogUtils.getBlock(status));
s.append(LogUtils.getBlock(message));
// 打印信息到日志
sys_user_logger.info(s.toString(), args);
// 获取客户端操作系统
String os = userAgent.getOperatingSystem().getName();
// 获取客户端浏览器
String browser = userAgent.getBrowser().getName();
// 封装对象
Logininfor logininfor = new Logininfor();
logininfor.setLoginName(username);
logininfor.setIpaddr(ip);
logininfor.setLoginLocation(address);
logininfor.setBrowser(browser);
logininfor.setOs(os);
logininfor.setMsg(message);
// 日志状态
if (StringUtils.equalsAny(status, Constants.LOGIN_SUCCESS, Constants.LOGOUT, Constants.REGISTER)) {
logininfor.setStatus(Constants.SUCCESS);
} else if (Constants.LOGIN_FAIL.equals(status)) {
logininfor.setStatus(Constants.FAIL);
}
// 插入数据
SpringUtils.getBean(LogininforServiceImpl.class).insertLogininfor(logininfor);
}
};
}
}

@ -38,8 +38,7 @@
public class UserRealm
extends AuthorizingRealm
public class UserRealm extends AuthorizingRealm
{
private static final Logger log = LoggerFactory.getLogger(com.archive.framework.shiro.realm.UserRealm.class);
@ -56,7 +55,7 @@
private LoginService loginService;
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection arg0) {
User user = ShiroUtils.getSysUser();
@ -79,14 +78,14 @@
info.setStringPermissions(menus);
}
return (AuthorizationInfo)info;
return info;
}
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
UsernamePasswordToken upToken = (UsernamePasswordToken)token;
String username = upToken.getUsername();
@ -130,8 +129,7 @@
log.info("对用户[" + username + "]进行登录验证..验证未通过{}", e.getMessage());
throw new AuthenticationException(e.getMessage(), e);
}
SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(user, password, getName());
return (AuthenticationInfo)info;
return new SimpleAuthenticationInfo(user, password, getName());
}

@ -72,19 +72,6 @@
User user = this.userService.selectUserByLoginName(username);
if (user == null) {
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, "Error", MessageUtils.message("user.not.exists", new Object[0]), new Object[0]));

@ -45,27 +45,24 @@
public void validate(User user, String password) {
String loginName = user.getLoginName();
AtomicInteger retryCount = (AtomicInteger)this.loginRecordCache.get(loginName);
AtomicInteger retryCount = loginRecordCache.get(loginName);
if (retryCount == null) {
retryCount = new AtomicInteger(0);
this.loginRecordCache.put(loginName, retryCount);
}
if (retryCount.incrementAndGet() > Integer.valueOf(this.maxRetryCount).intValue()) {
if (retryCount.incrementAndGet() > Integer.valueOf(maxRetryCount).intValue()){
AsyncManager.me().execute(AsyncFactory.recordLogininfor(loginName, "Error", MessageUtils.message("user.password.retry.limit.exceed", new Object[] { this.maxRetryCount }), new Object[0]));
throw new UserPasswordRetryLimitExceedException(Integer.valueOf(this.maxRetryCount).intValue());
}
if (!matches(user, password)) {
AsyncManager.me().execute(AsyncFactory.recordLogininfor(loginName, "Error", MessageUtils.message("user.password.retry.limit.count", new Object[] { retryCount }), new Object[0]));
this.loginRecordCache.put(loginName, retryCount);
throw new UserPasswordNotMatchException();
}
clearLoginRecordCache(loginName);
}

@ -10,7 +10,6 @@ import com.archive.common.utils.StringUtils;
import com.archive.common.utils.security.ShiroUtils;
import com.archive.common.utils.sql.SqlUtil;
import com.archive.framework.web.domain.AjaxResult;
import com.archive.framework.web.domain.Type;
import com.archive.framework.web.page.PageDomain;
import com.archive.framework.web.page.TableDataInfo;
import com.archive.framework.web.page.TableSupport;
@ -213,7 +212,7 @@ import java.util.Date;
public AjaxResult error(Type type, String message) {
public AjaxResult error(AjaxResult.Type type, String message) {
return new AjaxResult(type, message);

@ -1,204 +1,198 @@
package com.archive.framework.web.domain
;
package com.archive.framework.web.domain;
import com.archive.common.utils.StringUtils;
import java.util.HashMap;
import java.util.HashMap;
public class AjaxResult
extends HashMap<String, Object>
/**
*
*
* @author ruoyi
*/
public class AjaxResult extends HashMap<String, Object>
{
private static final long serialVersionUID = 1L;
/** 状态码 */
public static final String CODE_TAG = "code";
/** 返回内容 */
public static final String MSG_TAG = "msg";
public static final String DATA_TAG = "data";
public AjaxResult() {}
/** 数据对象 */
public static final String DATA_TAG = "data";
public AjaxResult(Type type, String msg) {
super.put("code", type);
super.put("msg", msg);
/**
*
*/
public enum Type
{
/** 成功 */
SUCCESS(0),
/** 警告 */
WARN(301),
/** 错误 */
ERROR(500);
private final int value;
Type(int value)
{
this.value = value;
}
public int value()
{
return this.value;
}
}
/**
* AjaxResult 使
*/
public AjaxResult()
{
}
/**
* AjaxResult
*
* @param type
* @param msg
*/
public AjaxResult(Type type, String msg)
{
super.put(CODE_TAG, type.value);
super.put(MSG_TAG, msg);
}
public AjaxResult(Type type, String msg, Object data) {
super.put("code", type);
super.put("msg", msg);
/**
* AjaxResult
*
* @param type
* @param msg
* @param data
*/
public AjaxResult(Type type, String msg, Object data)
{
super.put(CODE_TAG, type.value);
super.put(MSG_TAG, msg);
if (StringUtils.isNotNull(data))
{
super.put("data", data);
super.put(DATA_TAG, data);
}
}
/**
* 便
*
* @param key
* @param value
* @return
*/
@Override
public com.archive.framework.web.domain.AjaxResult put(String key, Object value) {
public AjaxResult put(String key, Object value)
{
super.put(key, value);
return this;
}
public static com.archive.framework.web.domain.AjaxResult success() {
return success("操作成功");
/**
*
*
* @return
*/
public static AjaxResult success()
{
return AjaxResult.success("操作成功");
}
public static com.archive.framework.web.domain.AjaxResult success(Object data) {
return success("操作成功", data);
/**
*
*
* @return
*/
public static AjaxResult success(Object data)
{
return AjaxResult.success("操作成功", data);
}
public static com.archive.framework.web.domain.AjaxResult success(String msg) {
return success(msg, null);
/**
*
*
* @param msg
* @return
*/
public static AjaxResult success(String msg)
{
return AjaxResult.success(msg, null);
}
public static com.archive.framework.web.domain.AjaxResult success(String msg, Object data) {
return new com.archive.framework.web.domain.AjaxResult(Type.SUCCESS, msg, data);
/**
*
*
* @param msg
* @param data
* @return
*/
public static AjaxResult success(String msg, Object data)
{
return new AjaxResult(Type.SUCCESS, msg, data);
}
public static com.archive.framework.web.domain.AjaxResult warn(String msg) {
return warn(msg, null);
/**
*
*
* @param msg
* @return
*/
public static AjaxResult warn(String msg)
{
return AjaxResult.warn(msg, null);
}
public static com.archive.framework.web.domain.AjaxResult warn(String msg, Object data) {
return new com.archive.framework.web.domain.AjaxResult(Type.WARN, msg, data);
/**
*
*
* @param msg
* @param data
* @return
*/
public static AjaxResult warn(String msg, Object data)
{
return new AjaxResult(Type.WARN, msg, data);
}
public static com.archive.framework.web.domain.AjaxResult error() {
return error("操作失败");
/**
*
*
* @return
*/
public static AjaxResult error()
{
return AjaxResult.error("操作失败");
}
public static com.archive.framework.web.domain.AjaxResult error(String msg) {
return error(msg, null);
/**
*
*
* @param msg
* @return
*/
public static AjaxResult error(String msg)
{
return AjaxResult.error(msg, null);
}
public static com.archive.framework.web.domain.AjaxResult error(String msg, Object data) {
return new com.archive.framework.web.domain.AjaxResult(Type.ERROR, msg, data);
/**
*
*
* @param msg
* @param data
* @return
*/
public static AjaxResult error(String msg, Object data)
{
return new AjaxResult(Type.ERROR, msg, data);
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\framework\web\domain\AjaxResult.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

@ -1,31 +1,10 @@
package com.archive.framework.web.domain
;
import com.archive.framework.web.domain.AjaxResult;
/**
* @author Administrator
*/
public enum Type
{
@ -47,8 +26,3 @@
}
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\framework\web\domain\AjaxResult$Type.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

@ -13,6 +13,8 @@ import org.springframework.stereotype.Repository;
@Repository
public interface IMenuService {
List<Menu> selectMenusByUser(User paramUser);
List<Menu> selectMenuList(Menu paramMenu);
@ -42,8 +44,3 @@ public interface IMenuService {
String checkMenuNameUnique(Menu paramMenu);
}
/* Location: C:\Users\Administrator\Desktop\extracted.zip!\extracted\BOOT-INF\classes\com\archive\project\system\menu\service\IMenuService.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/

@ -8,7 +8,6 @@
import com.archive.framework.web.domain.Ztree;
import com.archive.project.system.menu.domain.Menu;
import com.archive.project.system.menu.mapper.MenuMapper;
import com.archive.project.system.menu.service.IMenuService;
import com.archive.project.system.role.domain.Role;
import com.archive.project.system.role.mapper.RoleMenuMapper;
import com.archive.project.system.user.domain.User;
@ -26,20 +25,11 @@
/**
* @author Administrator
*/
@Service
public class MenuServiceImpl
implements IMenuService
public class MenuServiceImpl implements IMenuService
{
public static final String PREMISSION_STRING = "perms[\"{0}\"]";
@Autowired
@ -47,6 +37,7 @@
@Autowired
private RoleMenuMapper roleMenuMapper;
@Override
public List<Menu> selectMenusByUser(User user) {
List<Menu> menus = new LinkedList<>();
@ -67,7 +58,7 @@
@Override
public List<Menu> selectMenuList(Menu menu) {
List<Menu> menuList = null;
User user = ShiroUtils.getSysUser();
@ -89,7 +80,7 @@
@Override
public List<Menu> selectMenuAll() {
List<Menu> menuList = null;
User user = ShiroUtils.getSysUser();
@ -111,7 +102,7 @@
@Override
public Set<String> selectPermsByUserId(Long userId) {
List<String> perms = this.menuMapper.selectPermsByUserId(userId);
Set<String> permsSet = new HashSet<>();
@ -132,7 +123,7 @@
@Override
public List<Ztree> roleMenuTreeData(Role role) {
Long roleId = role.getRoleId();
List<Ztree> ztrees = new ArrayList<>();
@ -155,7 +146,7 @@
@Override
public List<Ztree> menuTreeData() {
List<Menu> menuList = selectMenuAll();
List<Ztree> ztrees = initZtree(menuList);
@ -168,7 +159,7 @@
@Override
public LinkedHashMap<String, String> selectPermsAll() {
LinkedHashMap<String, String> section = new LinkedHashMap<>();
List<Menu> permissions = selectMenuAll();
@ -239,7 +230,7 @@
@Override
public int deleteMenuById(Long menuId) {
return this.menuMapper.deleteMenuById(menuId);
}
@ -251,7 +242,7 @@
@Override
public Menu selectMenuById(Long menuId) {
return this.menuMapper.selectMenuById(menuId);
}
@ -263,7 +254,7 @@
@Override
public int selectCountMenuByParentId(Long parentId) {
return this.menuMapper.selectCountMenuByParentId(parentId);
}
@ -275,7 +266,7 @@
@Override
public int selectCountRoleMenuByMenuId(Long menuId) {
return this.roleMenuMapper.selectCountRoleMenuByMenuId(menuId);
}
@ -287,7 +278,7 @@
@Override
public int insertMenu(Menu menu) {
menu.setCreateBy(ShiroUtils.getLoginName());
return this.menuMapper.insertMenu(menu);
@ -300,7 +291,7 @@
@Override
public int updateMenu(Menu menu) {
menu.setUpdateBy(ShiroUtils.getLoginName());
return this.menuMapper.updateMenu(menu);
@ -312,7 +303,7 @@
@Override
public String checkMenuNameUnique(Menu menu) {
Long menuId = Long.valueOf(StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId().longValue());

@ -17,6 +17,7 @@
import com.archive.project.system.user.domain.User;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
@ -41,7 +42,7 @@
public class IndexController
extends BaseController
{
@Autowired
@Resource
private IMenuService menuService;
@Autowired
private IConfigService configService;

@ -51,11 +51,11 @@
@PostMapping({"/login"})
@ResponseBody
public AjaxResult ajaxLogin(String username, String password, Boolean rememberMe) {
UsernamePasswordToken token = new UsernamePasswordToken(username, password, rememberMe.booleanValue());
UsernamePasswordToken token = new UsernamePasswordToken(username, password, rememberMe);
Subject subject = SecurityUtils.getSubject();
try {
subject.login((AuthenticationToken)token);
subject.login(token);
return success();
}
catch (AuthenticationException e) {

@ -73,7 +73,7 @@
@Autowired
private ArchiveConfig archiveConfig;
@Override
@DataScope(deptAlias = "d", userAlias = "u")
public List<User> selectUserList(User user) {
if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
@ -94,7 +94,7 @@
@Override
@DataScope(deptAlias = "d", userAlias = "u")
public List<User> selectAllocatedList(User user) {
if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
@ -115,7 +115,7 @@
@Override
@DataScope(deptAlias = "d", userAlias = "u")
public List<User> selectUnallocatedList(User user) {
if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
@ -135,7 +135,7 @@
@Override
public User selectUserByLoginName(String userName) {
return this.userMapper.selectUserByLoginName(userName);
@ -148,7 +148,7 @@
@Override
public User selectUserByPhoneNumber(String phoneNumber) {
return this.userMapper.selectUserByPhoneNumber(phoneNumber);
}
@ -160,7 +160,7 @@
@Override
public User selectUserByEmail(String email) {
return this.userMapper.selectUserByEmail(email);
}
@ -172,7 +172,7 @@
@Override
public User selectUserById(Long userId) {
return this.userMapper.selectUserById(userId);
}
@ -184,7 +184,7 @@
@Override
public List<UserRole> selectUserRoleByUserId(Long userId) {
return this.userRoleMapper.selectUserRoleByUserId(userId);
}
@ -197,7 +197,7 @@
@Override
@Transactional
public int deleteUserById(Long userId) {
this.userRoleMapper.deleteUserRoleByUserId(userId);
@ -213,7 +213,7 @@
@Override
@Transactional
public int deleteUserByIds(String ids) {
Long[] userIds = Convert.toLongArray(ids);
@ -235,7 +235,7 @@
@Override
@Transactional
public int insertUser(User user) {
user.randomSalt();
@ -266,7 +266,7 @@
@Override
public boolean registerUser(User user) {
user.setUserType("01");
user.randomSalt();
@ -281,7 +281,7 @@
@Override
@Transactional
public int updateUser(User user) {
Long userId = user.getUserId();
@ -310,7 +310,7 @@
@Override
public int updateUserInfo(User user) {
if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
return this.userMapper.updateUser(user);
@ -327,8 +327,7 @@
@Override
public void insertUserAuth(Long userId, Long[] roleIds) {
this.userRoleMapper.deleteUserRoleByUserId(userId);
insertUserRole(userId, roleIds);
@ -341,7 +340,7 @@
@Override
public int resetUserPwd(User user) {
user.randomSalt();
user.setPassword(this.passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
@ -406,7 +405,7 @@
@Override
public String checkLoginNameUnique(String loginName) {
int count = this.userMapper.checkLoginNameUnique(loginName);
if (count > 0)
@ -423,7 +422,7 @@
@Override
public String checkPhoneUnique(User user) {
Long userId = Long.valueOf(StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId().longValue());
User info = this.userMapper.checkPhoneUnique(user.getPhonenumber());
@ -441,7 +440,7 @@
@Override
public String checkEmailUnique(User user) {
Long userId = Long.valueOf(StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId().longValue());
User info = this.userMapper.checkEmailUnique(user.getEmail());
@ -458,7 +457,7 @@
@Override
public void checkUserAllowed(User user) {
if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin())
{
@ -473,7 +472,7 @@
@Override
public String selectUserRoleGroup(Long userId) {
List<Role> list = this.roleMapper.selectRolesByUserId(userId);
StringBuffer idsStr = new StringBuffer();
@ -495,7 +494,7 @@
@Override
public String selectUserPostGroup(Long userId) {
List<Post> list = this.postMapper.selectPostsByUserId(userId);
StringBuffer idsStr = new StringBuffer();
@ -518,7 +517,7 @@
@Override
public String importUser(List<User> userList, Boolean isUpdateSupport) {
if (StringUtils.isNull(userList) || userList.size() == 0)
{
@ -584,7 +583,7 @@
@Override
public int changeStatus(User user) {
if ("mysql".equals(this.archiveConfig.getDatabaseType())) {
return this.userMapper.updateUser(user);

@ -5,7 +5,7 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:sqlite:D://archive_sqlite.db?date_string_format=yyyy-MM-dd HH:mm:ss
url: jdbc:sqlite:D:/archive_sqlite.db?date_string_format=yyyy-MM-dd HH:mm:ss
username:
password:
# 从库数据源

@ -24,7 +24,7 @@ archive:
# 开发环境配置
server:
# 服务器的HTTP端口默认为80
port: 8080
port: 8082
servlet:
# 应用的访问路径
context-path: /
@ -36,7 +36,7 @@ server:
# Tomcat启动初始化的线程数默认值25
min-spare-threads: 30
# 配置为127.0.0.1只能本机访问配置为0.0.0.0则所有机器都能访问
address: 0.0.0.0
address: 127.0.0.1
# 日志配置
logging:
level:
@ -88,7 +88,7 @@ mybatis:
# 搜索指定包别名
typeAliasesPackage: com.archive.project.**.domain
# 配置mapper的扫描找到所有的mapper.xml映射文件
mapperLocations: classpath:mybatis*Mapper.xml
mapperLocations: classpath:mybatis/**/*Mapper.xml
# 加载全局的配置文件
configLocation: classpath:mybatis/mybatis-config.xml

Loading…
Cancel
Save