From f97d25ef691916631f81457f8fd2d77d9093da59 Mon Sep 17 00:00:00 2001 From: wangxy <1481820854@qq.com> Date: Wed, 21 May 2025 10:47:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manager/factory/AsyncFactory.java | 224 +++++----- .../framework/shiro/realm/UserRealm.java | 12 +- .../framework/shiro/service/LoginService.java | 13 - .../shiro/service/PasswordService.java | 7 +- .../web/controller/BaseController.java | 3 +- .../framework/web/domain/AjaxResult.java | 402 +++++++++--------- .../archive/framework/web/domain/Type.java | 32 +- .../system/menu/service/IMenuService.java | 7 +- .../system/menu/service/MenuServiceImpl.java | 45 +- .../user/controller/IndexController.java | 3 +- .../user/controller/LoginController.java | 4 +- .../system/user/service/UserServiceImpl.java | 49 ++- src/main/resources/application-druid.yml | 2 +- src/main/resources/application.yml | 6 +- 14 files changed, 381 insertions(+), 428 deletions(-) diff --git a/src/main/java/com/archive/framework/manager/factory/AsyncFactory.java b/src/main/java/com/archive/framework/manager/factory/AsyncFactory.java index 9e55ca1..ef32fc2 100644 --- a/src/main/java/com/archive/framework/manager/factory/AsyncFactory.java +++ b/src/main/java/com/archive/framework/manager/factory/AsyncFactory.java @@ -1,107 +1,123 @@ - package com.archive.framework.manager.factory +package com.archive.framework.manager.factory -; - - import com.archive.common.utils.ServletUtils; - import com.archive.common.utils.security.ShiroUtils; - import com.archive.project.monitor.online.domain.OnlineSession; - import com.archive.project.monitor.operlog.domain.OperLog; - import eu.bitwalker.useragentutils.UserAgent; - import java.util.TimerTask; - import org.slf4j.Logger; - import org.slf4j.LoggerFactory; - - - - - - - - - - - - - - - - - - public class AsyncFactory - { - private static final Logger sys_user_logger = LoggerFactory.getLogger("sys-user"); - - - - - - - - - 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; - } - } + ; +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; -/* 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 - */ \ No newline at end of file +import java.util.TimerTask; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +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); + + } + }; + } + + /** + * 操作日志记录 + * + * @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); + } + }; + } + + /** + * 记录登录信息 + * + * @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); + } + }; + } +} diff --git a/src/main/java/com/archive/framework/shiro/realm/UserRealm.java b/src/main/java/com/archive/framework/shiro/realm/UserRealm.java index 6600d3a..35f25b7 100644 --- a/src/main/java/com/archive/framework/shiro/realm/UserRealm.java +++ b/src/main/java/com/archive/framework/shiro/realm/UserRealm.java @@ -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()); } diff --git a/src/main/java/com/archive/framework/shiro/service/LoginService.java b/src/main/java/com/archive/framework/shiro/service/LoginService.java index 9438a36..ed176af 100644 --- a/src/main/java/com/archive/framework/shiro/service/LoginService.java +++ b/src/main/java/com/archive/framework/shiro/service/LoginService.java @@ -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])); diff --git a/src/main/java/com/archive/framework/shiro/service/PasswordService.java b/src/main/java/com/archive/framework/shiro/service/PasswordService.java index 42b22e7..a41380c 100644 --- a/src/main/java/com/archive/framework/shiro/service/PasswordService.java +++ b/src/main/java/com/archive/framework/shiro/service/PasswordService.java @@ -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); } diff --git a/src/main/java/com/archive/framework/web/controller/BaseController.java b/src/main/java/com/archive/framework/web/controller/BaseController.java index 02906f8..6ed74fe 100644 --- a/src/main/java/com/archive/framework/web/controller/BaseController.java +++ b/src/main/java/com/archive/framework/web/controller/BaseController.java @@ -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); diff --git a/src/main/java/com/archive/framework/web/domain/AjaxResult.java b/src/main/java/com/archive/framework/web/domain/AjaxResult.java index be073b1..0258dcb 100644 --- a/src/main/java/com/archive/framework/web/domain/AjaxResult.java +++ b/src/main/java/com/archive/framework/web/domain/AjaxResult.java @@ -1,204 +1,198 @@ - package com.archive.framework.web.domain - -; - - import com.archive.common.utils.StringUtils; - import java.util.HashMap; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public class AjaxResult - extends HashMap - { - 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 AjaxResult(Type type, String msg) { - super.put("code", type); - super.put("msg", msg); - } - - - - - - - - - - public AjaxResult(Type type, String msg, Object data) { - super.put("code", type); - super.put("msg", msg); - if (StringUtils.isNotNull(data)) - { - super.put("data", data); - } - } - - - - - - - - - - @Override - public com.archive.framework.web.domain.AjaxResult put(String key, Object value) { - super.put(key, value); - return this; - } - - - - - - - - public static com.archive.framework.web.domain.AjaxResult success() { - return success("操作成功"); - } - - - - - - - - public static com.archive.framework.web.domain.AjaxResult success(Object data) { - return success("操作成功", data); - } - - - - - - - - - public static com.archive.framework.web.domain.AjaxResult success(String msg) { - return 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); - } - - - - - - - - - public static com.archive.framework.web.domain.AjaxResult warn(String msg) { - return 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); - } - - - - - - - - public static com.archive.framework.web.domain.AjaxResult error() { - return error("操作失败"); - } - - - - - - - - - public static com.archive.framework.web.domain.AjaxResult error(String msg) { - return 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); - } - } - - -/* 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 - */ \ No newline at end of file +package com.archive.framework.web.domain; + +import com.archive.common.utils.StringUtils; + +import java.util.HashMap; + + +/** + * 操作消息提醒 + * + * @author ruoyi + */ +public class AjaxResult extends HashMap +{ + 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 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); + } + + /** + * 初始化一个新创建的 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_TAG, data); + } + } + + /** + * 方便链式调用 + * + * @param key 键 + * @param value 值 + * @return 数据对象 + */ + @Override + public AjaxResult put(String key, Object value) + { + super.put(key, value); + return this; + } + + /** + * 返回成功消息 + * + * @return 成功消息 + */ + public static AjaxResult success() + { + return AjaxResult.success("操作成功"); + } + + /** + * 返回成功数据 + * + * @return 成功消息 + */ + public static AjaxResult success(Object data) + { + return AjaxResult.success("操作成功", data); + } + + /** + * 返回成功消息 + * + * @param msg 返回内容 + * @return 成功消息 + */ + public static AjaxResult success(String msg) + { + return AjaxResult.success(msg, null); + } + + /** + * 返回成功消息 + * + * @param msg 返回内容 + * @param data 数据对象 + * @return 成功消息 + */ + public static AjaxResult success(String msg, Object data) + { + return new AjaxResult(Type.SUCCESS, msg, data); + } + + /** + * 返回警告消息 + * + * @param msg 返回内容 + * @return 警告消息 + */ + public static AjaxResult warn(String msg) + { + return AjaxResult.warn(msg, null); + } + + /** + * 返回警告消息 + * + * @param msg 返回内容 + * @param data 数据对象 + * @return 警告消息 + */ + public static AjaxResult warn(String msg, Object data) + { + return new AjaxResult(Type.WARN, msg, data); + } + + /** + * 返回错误消息 + * + * @return + */ + public static AjaxResult error() + { + return AjaxResult.error("操作失败"); + } + + /** + * 返回错误消息 + * + * @param msg 返回内容 + * @return 警告消息 + */ + public static AjaxResult error(String msg) + { + return AjaxResult.error(msg, null); + } + + /** + * 返回错误消息 + * + * @param msg 返回内容 + * @param data 数据对象 + * @return 警告消息 + */ + public static AjaxResult error(String msg, Object data) + { + return new AjaxResult(Type.ERROR, msg, data); + } +} diff --git a/src/main/java/com/archive/framework/web/domain/Type.java b/src/main/java/com/archive/framework/web/domain/Type.java index dffdc0f..631e7de 100644 --- a/src/main/java/com/archive/framework/web/domain/Type.java +++ b/src/main/java/com/archive/framework/web/domain/Type.java @@ -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 - */ \ No newline at end of file diff --git a/src/main/java/com/archive/project/system/menu/service/IMenuService.java b/src/main/java/com/archive/project/system/menu/service/IMenuService.java index d83d8c6..2fc3424 100644 --- a/src/main/java/com/archive/project/system/menu/service/IMenuService.java +++ b/src/main/java/com/archive/project/system/menu/service/IMenuService.java @@ -13,6 +13,8 @@ import org.springframework.stereotype.Repository; @Repository public interface IMenuService { + + List selectMenusByUser(User paramUser); List 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 - */ \ No newline at end of file diff --git a/src/main/java/com/archive/project/system/menu/service/MenuServiceImpl.java b/src/main/java/com/archive/project/system/menu/service/MenuServiceImpl.java index 88446e8..106eb91 100644 --- a/src/main/java/com/archive/project/system/menu/service/MenuServiceImpl.java +++ b/src/main/java/com/archive/project/system/menu/service/MenuServiceImpl.java @@ -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 selectMenusByUser(User user) { List menus = new LinkedList<>(); @@ -67,7 +58,7 @@ - +@Override public List selectMenuList(Menu menu) { List menuList = null; User user = ShiroUtils.getSysUser(); @@ -89,7 +80,7 @@ - +@Override public List selectMenuAll() { List menuList = null; User user = ShiroUtils.getSysUser(); @@ -111,7 +102,7 @@ - +@Override public Set selectPermsByUserId(Long userId) { List perms = this.menuMapper.selectPermsByUserId(userId); Set permsSet = new HashSet<>(); @@ -132,7 +123,7 @@ - +@Override public List roleMenuTreeData(Role role) { Long roleId = role.getRoleId(); List ztrees = new ArrayList<>(); @@ -155,7 +146,7 @@ - +@Override public List menuTreeData() { List menuList = selectMenuAll(); List ztrees = initZtree(menuList); @@ -168,7 +159,7 @@ - +@Override public LinkedHashMap selectPermsAll() { LinkedHashMap section = new LinkedHashMap<>(); List 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()); diff --git a/src/main/java/com/archive/project/system/user/controller/IndexController.java b/src/main/java/com/archive/project/system/user/controller/IndexController.java index e9ee2b9..8d62ba0 100644 --- a/src/main/java/com/archive/project/system/user/controller/IndexController.java +++ b/src/main/java/com/archive/project/system/user/controller/IndexController.java @@ -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; diff --git a/src/main/java/com/archive/project/system/user/controller/LoginController.java b/src/main/java/com/archive/project/system/user/controller/LoginController.java index ef1c6ba..5c02347 100644 --- a/src/main/java/com/archive/project/system/user/controller/LoginController.java +++ b/src/main/java/com/archive/project/system/user/controller/LoginController.java @@ -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) { diff --git a/src/main/java/com/archive/project/system/user/service/UserServiceImpl.java b/src/main/java/com/archive/project/system/user/service/UserServiceImpl.java index 6d9cdde..db20774 100644 --- a/src/main/java/com/archive/project/system/user/service/UserServiceImpl.java +++ b/src/main/java/com/archive/project/system/user/service/UserServiceImpl.java @@ -73,7 +73,7 @@ @Autowired private ArchiveConfig archiveConfig; - + @Override @DataScope(deptAlias = "d", userAlias = "u") public List selectUserList(User user) { if ("mysql".equals(this.archiveConfig.getDatabaseType())) { @@ -94,7 +94,7 @@ - +@Override @DataScope(deptAlias = "d", userAlias = "u") public List selectAllocatedList(User user) { if ("mysql".equals(this.archiveConfig.getDatabaseType())) { @@ -115,7 +115,7 @@ - +@Override @DataScope(deptAlias = "d", userAlias = "u") public List 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 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 list = this.roleMapper.selectRolesByUserId(userId); StringBuffer idsStr = new StringBuffer(); @@ -495,7 +494,7 @@ - +@Override public String selectUserPostGroup(Long userId) { List list = this.postMapper.selectPostsByUserId(userId); StringBuffer idsStr = new StringBuffer(); @@ -518,7 +517,7 @@ - +@Override public String importUser(List 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); diff --git a/src/main/resources/application-druid.yml b/src/main/resources/application-druid.yml index ddd1261..ebb50b6 100644 --- a/src/main/resources/application-druid.yml +++ b/src/main/resources/application-druid.yml @@ -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: # 从库数据源 diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 11c0667..8073098 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -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