mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-01 02:38:43 +08:00 
			
		
		
		
	将 LoginUser 重构到 UserSessionService 模块汇总
This commit is contained in:
		| @@ -1,30 +0,0 @@ | ||||
| package com.ruoyi; | ||||
|  | ||||
| import org.springframework.boot.SpringApplication; | ||||
| import org.springframework.boot.autoconfigure.SpringBootApplication; | ||||
| import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; | ||||
|  | ||||
| /** | ||||
|  * 启动程序 | ||||
|  *  | ||||
|  * @author ruoyi | ||||
|  */ | ||||
| @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) | ||||
| public class RuoYiApplication | ||||
| { | ||||
|     public static void main(String[] args) | ||||
|     { | ||||
|         // System.setProperty("spring.devtools.restart.enabled", "false"); | ||||
|         SpringApplication.run(RuoYiApplication.class, args); | ||||
|         System.out.println("(♥◠‿◠)ノ゙  若依启动成功   ლ(´ڡ`ლ)゙  \n" + | ||||
|                 " .-------.       ____     __        \n" + | ||||
|                 " |  _ _   \\      \\   \\   /  /    \n" + | ||||
|                 " | ( ' )  |       \\  _. /  '       \n" + | ||||
|                 " |(_ o _) /        _( )_ .'         \n" + | ||||
|                 " | (_,_).' __  ___(_ o _)'          \n" + | ||||
|                 " |  |\\ \\  |  ||   |(_,_)'         \n" + | ||||
|                 " |  | \\ `'   /|   `-'  /           \n" + | ||||
|                 " |  |  \\    /  \\      /           \n" + | ||||
|                 " ''-'   `'-'    `-..-'              "); | ||||
|     } | ||||
| } | ||||
| @@ -1,92 +0,0 @@ | ||||
| package com.ruoyi.web.controller.monitor; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collection; | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.security.access.prepost.PreAuthorize; | ||||
| import org.springframework.web.bind.annotation.DeleteMapping; | ||||
| import org.springframework.web.bind.annotation.GetMapping; | ||||
| import org.springframework.web.bind.annotation.PathVariable; | ||||
| import org.springframework.web.bind.annotation.RequestMapping; | ||||
| import org.springframework.web.bind.annotation.RestController; | ||||
| import com.ruoyi.common.annotation.Log; | ||||
| import com.ruoyi.common.constant.Constants; | ||||
| import com.ruoyi.common.core.controller.BaseController; | ||||
| import com.ruoyi.common.core.domain.AjaxResult; | ||||
| import com.ruoyi.common.core.domain.model.LoginUser; | ||||
| import com.ruoyi.common.core.page.TableDataInfo; | ||||
| import com.ruoyi.common.core.redis.RedisCache; | ||||
| import com.ruoyi.common.enums.BusinessType; | ||||
| import com.ruoyi.common.utils.StringUtils; | ||||
| import com.ruoyi.system.domain.SysUserOnline; | ||||
| import com.ruoyi.system.service.ISysUserOnlineService; | ||||
|  | ||||
| /** | ||||
|  * 在线用户监控 | ||||
|  *  | ||||
|  * @author ruoyi | ||||
|  */ | ||||
| @RestController | ||||
| @RequestMapping("/monitor/online") | ||||
| public class SysUserOnlineController extends BaseController | ||||
| { | ||||
|     @Autowired | ||||
|     private ISysUserOnlineService userOnlineService; | ||||
|  | ||||
|     @Autowired | ||||
|     private RedisCache redisCache; | ||||
|  | ||||
|     @PreAuthorize("@ss.hasPermi('monitor:online:list')") | ||||
|     @GetMapping("/list") | ||||
|     public TableDataInfo list(String ipaddr, String userName) | ||||
|     { | ||||
|         Collection<String> keys = redisCache.keys(Constants.LOGIN_TOKEN_KEY + "*"); | ||||
|         List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>(); | ||||
|         for (String key : keys) | ||||
|         { | ||||
|             LoginUser user = redisCache.getCacheObject(key); | ||||
|             if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) | ||||
|             { | ||||
|                 if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername())) | ||||
|                 { | ||||
|                     userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user)); | ||||
|                 } | ||||
|             } | ||||
|             else if (StringUtils.isNotEmpty(ipaddr)) | ||||
|             { | ||||
|                 if (StringUtils.equals(ipaddr, user.getIpaddr())) | ||||
|                 { | ||||
|                     userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user)); | ||||
|                 } | ||||
|             } | ||||
|             else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser())) | ||||
|             { | ||||
|                 if (StringUtils.equals(userName, user.getUsername())) | ||||
|                 { | ||||
|                     userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user)); | ||||
|                 } | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 userOnlineList.add(userOnlineService.loginUserToUserOnline(user)); | ||||
|             } | ||||
|         } | ||||
|         Collections.reverse(userOnlineList); | ||||
|         userOnlineList.removeAll(Collections.singleton(null)); | ||||
|         return getDataTable(userOnlineList); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 强退用户 | ||||
|      */ | ||||
|     @PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')") | ||||
|     @Log(title = "在线用户", businessType = BusinessType.FORCE) | ||||
|     @DeleteMapping("/{tokenId}") | ||||
|     public AjaxResult forceLogout(@PathVariable String tokenId) | ||||
|     { | ||||
|         redisCache.deleteObject(Constants.LOGIN_TOKEN_KEY + tokenId); | ||||
|         return AjaxResult.success(); | ||||
|     } | ||||
| } | ||||
| @@ -1 +0,0 @@ | ||||
| restart.include.json=/com.alibaba.fastjson.*.jar | ||||
| @@ -34,20 +34,6 @@ logging: | ||||
|     com.ruoyi: debug | ||||
|     org.springframework: warn | ||||
|  | ||||
| # Spring配置 | ||||
| spring: | ||||
|   # 资源信息 | ||||
|   messages: | ||||
|     # 国际化资源文件路径 | ||||
|     basename: i18n/messages | ||||
|   profiles: | ||||
|     active: druid | ||||
|   # 服务模块 | ||||
|   devtools: | ||||
|     restart: | ||||
|       # 热部署开关 | ||||
|       enabled: true | ||||
|  | ||||
| # 防止XSS攻击 | ||||
| xss: | ||||
|   # 过滤开关 | ||||
|   | ||||
| @@ -1,24 +0,0 @@ | ||||
| Application Version: ${ruoyi.version} | ||||
| Spring Boot Version: ${spring-boot.version} | ||||
| //////////////////////////////////////////////////////////////////// | ||||
| //                          _ooOoo_                               // | ||||
| //                         o8888888o                              // | ||||
| //                         88" . "88                              // | ||||
| //                         (| ^_^ |)                              // | ||||
| //                         O\  =  /O                              // | ||||
| //                      ____/`---'\____                           // | ||||
| //                    .'  \\|     |//  `.                         // | ||||
| //                   /  \\|||  :  |||//  \                        // | ||||
| //                  /  _||||| -:- |||||-  \                       // | ||||
| //                  |   | \\\  -  /// |   |                       // | ||||
| //                  | \_|  ''\---/''  |   |                       // | ||||
| //                  \  .-\__  `-`  ___/-. /                       // | ||||
| //                ___`. .'  /--.--\  `. . ___                     // | ||||
| //              ."" '<  `.___\_<|>_/___.'  >'"".                  // | ||||
| //            | | :  `- \`.;`\ _ /`;.`/ - ` : | |                 // | ||||
| //            \  \ `-.   \_ __\ /__ _/   .-` /  /                 // | ||||
| //      ========`-.____`-.___\_____/___.-`____.-'========         // | ||||
| //                           `=---='                              // | ||||
| //      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^        // | ||||
| //             佛祖保佑       永不宕机      永无BUG               // | ||||
| //////////////////////////////////////////////////////////////////// | ||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV