├── .gitignore ├── README.md ├── mq-websocket ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── zifangsky │ │ │ └── mqwebsocket │ │ │ ├── MqWebsocketApplication.java │ │ │ ├── common │ │ │ ├── Constants.java │ │ │ └── SpringContextUtils.java │ │ │ ├── config │ │ │ ├── RedisConfig.java │ │ │ ├── WebMvcConfig.java │ │ │ └── WebSocketConfig.java │ │ │ ├── controller │ │ │ ├── RedisMessageController.java │ │ │ └── UserController.java │ │ │ ├── enums │ │ │ ├── ExpireEnum.java │ │ │ └── WebSocketChannelEnum.java │ │ │ ├── interceptor │ │ │ ├── LoginInterceptor.java │ │ │ └── websocket │ │ │ │ ├── AuthHandshakeInterceptor.java │ │ │ │ ├── MyChannelInterceptor.java │ │ │ │ ├── MyHandshakeHandler.java │ │ │ │ └── MyPrincipal.java │ │ │ ├── mapper │ │ │ ├── FuncMapper.java │ │ │ ├── RoleFuncMapper.java │ │ │ ├── RoleMapper.java │ │ │ ├── UserMapper.java │ │ │ ├── UserRoleMapper.java │ │ │ └── xml │ │ │ │ ├── FuncMapper.xml │ │ │ │ ├── RoleFuncMapper.xml │ │ │ │ ├── RoleMapper.xml │ │ │ │ ├── UserMapper.xml │ │ │ │ └── UserRoleMapper.xml │ │ │ ├── model │ │ │ ├── Func.java │ │ │ ├── Role.java │ │ │ ├── RoleFunc.java │ │ │ ├── User.java │ │ │ ├── UserRole.java │ │ │ └── websocket │ │ │ │ ├── HelloMessage.java │ │ │ │ └── RedisWebsocketMsg.java │ │ │ ├── mq │ │ │ └── MessageReceiver.java │ │ │ ├── service │ │ │ ├── RedisService.java │ │ │ ├── UserService.java │ │ │ └── impl │ │ │ │ ├── RedisServiceImpl.java │ │ │ │ └── UserServiceImpl.java │ │ │ └── utils │ │ │ ├── AesUtils.java │ │ │ ├── DateUtils.java │ │ │ ├── EncryptUtils.java │ │ │ └── JsonUtils.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application.yml │ │ ├── banner.txt │ │ ├── mybatis-generator │ │ └── generatorConfig.xml │ │ ├── static │ │ ├── css │ │ │ └── style.css │ │ ├── favicon.ico │ │ ├── img │ │ │ ├── 1.jpg │ │ │ ├── 2.jpg │ │ │ ├── 3.jpg │ │ │ ├── 4.jpg │ │ │ ├── 5.jpg │ │ │ └── 6.jpg │ │ └── layui │ │ │ ├── css │ │ │ ├── layui.css │ │ │ ├── layui.mobile.css │ │ │ └── modules │ │ │ │ ├── code.css │ │ │ │ ├── laydate │ │ │ │ └── default │ │ │ │ │ └── laydate.css │ │ │ │ └── layer │ │ │ │ └── default │ │ │ │ ├── icon-ext.png │ │ │ │ ├── icon.png │ │ │ │ ├── layer.css │ │ │ │ ├── loading-0.gif │ │ │ │ ├── loading-1.gif │ │ │ │ └── loading-2.gif │ │ │ ├── font │ │ │ ├── iconfont.eot │ │ │ ├── iconfont.svg │ │ │ ├── iconfont.ttf │ │ │ └── iconfont.woff │ │ │ ├── images │ │ │ └── face │ │ │ │ ├── 0.gif │ │ │ │ ├── 1.gif │ │ │ │ ├── 10.gif │ │ │ │ ├── 11.gif │ │ │ │ ├── 12.gif │ │ │ │ ├── 13.gif │ │ │ │ ├── 14.gif │ │ │ │ ├── 15.gif │ │ │ │ ├── 16.gif │ │ │ │ ├── 17.gif │ │ │ │ ├── 18.gif │ │ │ │ ├── 19.gif │ │ │ │ ├── 2.gif │ │ │ │ ├── 20.gif │ │ │ │ ├── 21.gif │ │ │ │ ├── 22.gif │ │ │ │ ├── 23.gif │ │ │ │ ├── 24.gif │ │ │ │ ├── 25.gif │ │ │ │ ├── 26.gif │ │ │ │ ├── 27.gif │ │ │ │ ├── 28.gif │ │ │ │ ├── 29.gif │ │ │ │ ├── 3.gif │ │ │ │ ├── 30.gif │ │ │ │ ├── 31.gif │ │ │ │ ├── 32.gif │ │ │ │ ├── 33.gif │ │ │ │ ├── 34.gif │ │ │ │ ├── 35.gif │ │ │ │ ├── 36.gif │ │ │ │ ├── 37.gif │ │ │ │ ├── 38.gif │ │ │ │ ├── 39.gif │ │ │ │ ├── 4.gif │ │ │ │ ├── 40.gif │ │ │ │ ├── 41.gif │ │ │ │ ├── 42.gif │ │ │ │ ├── 43.gif │ │ │ │ ├── 44.gif │ │ │ │ ├── 45.gif │ │ │ │ ├── 46.gif │ │ │ │ ├── 47.gif │ │ │ │ ├── 48.gif │ │ │ │ ├── 49.gif │ │ │ │ ├── 5.gif │ │ │ │ ├── 50.gif │ │ │ │ ├── 51.gif │ │ │ │ ├── 52.gif │ │ │ │ ├── 53.gif │ │ │ │ ├── 54.gif │ │ │ │ ├── 55.gif │ │ │ │ ├── 56.gif │ │ │ │ ├── 57.gif │ │ │ │ ├── 58.gif │ │ │ │ ├── 59.gif │ │ │ │ ├── 6.gif │ │ │ │ ├── 60.gif │ │ │ │ ├── 61.gif │ │ │ │ ├── 62.gif │ │ │ │ ├── 63.gif │ │ │ │ ├── 64.gif │ │ │ │ ├── 65.gif │ │ │ │ ├── 66.gif │ │ │ │ ├── 67.gif │ │ │ │ ├── 68.gif │ │ │ │ ├── 69.gif │ │ │ │ ├── 7.gif │ │ │ │ ├── 70.gif │ │ │ │ ├── 71.gif │ │ │ │ ├── 8.gif │ │ │ │ └── 9.gif │ │ │ ├── lay │ │ │ └── modules │ │ │ │ ├── carousel.js │ │ │ │ ├── code.js │ │ │ │ ├── colorpicker.js │ │ │ │ ├── element.js │ │ │ │ ├── flow.js │ │ │ │ ├── form.js │ │ │ │ ├── jquery.js │ │ │ │ ├── laydate.js │ │ │ │ ├── layedit.js │ │ │ │ ├── layer.js │ │ │ │ ├── laypage.js │ │ │ │ ├── laytpl.js │ │ │ │ ├── mobile.js │ │ │ │ ├── rate.js │ │ │ │ ├── slider.js │ │ │ │ ├── table.js │ │ │ │ ├── tree.js │ │ │ │ ├── upload.js │ │ │ │ └── util.js │ │ │ ├── layui.all.js │ │ │ └── layui.js │ │ └── templates │ │ ├── index.html │ │ ├── login.html │ │ ├── userIndex.html │ │ └── websocket │ │ └── chat.html │ └── test │ └── java │ └── cn │ └── zifangsky │ └── mqwebsocket │ ├── MqWebsocketApplicationTests.java │ ├── TestRedis.java │ └── TestSQL.java ├── pom.xml ├── sample-websocket ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── cn │ │ │ └── zifangsky │ │ │ └── samplewebsocket │ │ │ ├── SampleWebsocketApplication.java │ │ │ ├── common │ │ │ ├── Constants.java │ │ │ └── SpringContextUtils.java │ │ │ ├── config │ │ │ ├── WebMvcConfig.java │ │ │ └── WebSocketConfig.java │ │ │ ├── controller │ │ │ └── GreetingController.java │ │ │ ├── model │ │ │ └── websocket │ │ │ │ └── HelloMessage.java │ │ │ ├── service │ │ │ ├── EchoService.java │ │ │ └── impl │ │ │ │ └── EchoServiceImpl.java │ │ │ ├── utils │ │ │ ├── AesUtils.java │ │ │ ├── DateUtils.java │ │ │ ├── EncryptUtils.java │ │ │ └── JsonUtils.java │ │ │ └── websocket │ │ │ ├── EchoWebSocketHandler.java │ │ │ └── ReverseWebSocketEndpoint.java │ └── resources │ │ ├── application-dev.yml │ │ ├── application-prod.yml │ │ ├── application.properties │ │ ├── application.yml │ │ ├── banner.txt │ │ ├── mybatis-generator │ │ └── generatorConfig.xml │ │ ├── static │ │ ├── favicon.ico │ │ └── layui │ │ │ ├── css │ │ │ ├── layui.css │ │ │ ├── layui.mobile.css │ │ │ └── modules │ │ │ │ ├── code.css │ │ │ │ ├── laydate │ │ │ │ └── default │ │ │ │ │ └── laydate.css │ │ │ │ └── layer │ │ │ │ └── default │ │ │ │ ├── icon-ext.png │ │ │ │ ├── icon.png │ │ │ │ ├── layer.css │ │ │ │ ├── loading-0.gif │ │ │ │ ├── loading-1.gif │ │ │ │ └── loading-2.gif │ │ │ ├── font │ │ │ ├── iconfont.eot │ │ │ ├── iconfont.svg │ │ │ ├── iconfont.ttf │ │ │ └── iconfont.woff │ │ │ ├── images │ │ │ └── face │ │ │ │ ├── 0.gif │ │ │ │ ├── 1.gif │ │ │ │ ├── 10.gif │ │ │ │ ├── 11.gif │ │ │ │ ├── 12.gif │ │ │ │ ├── 13.gif │ │ │ │ ├── 14.gif │ │ │ │ ├── 15.gif │ │ │ │ ├── 16.gif │ │ │ │ ├── 17.gif │ │ │ │ ├── 18.gif │ │ │ │ ├── 19.gif │ │ │ │ ├── 2.gif │ │ │ │ ├── 20.gif │ │ │ │ ├── 21.gif │ │ │ │ ├── 22.gif │ │ │ │ ├── 23.gif │ │ │ │ ├── 24.gif │ │ │ │ ├── 25.gif │ │ │ │ ├── 26.gif │ │ │ │ ├── 27.gif │ │ │ │ ├── 28.gif │ │ │ │ ├── 29.gif │ │ │ │ ├── 3.gif │ │ │ │ ├── 30.gif │ │ │ │ ├── 31.gif │ │ │ │ ├── 32.gif │ │ │ │ ├── 33.gif │ │ │ │ ├── 34.gif │ │ │ │ ├── 35.gif │ │ │ │ ├── 36.gif │ │ │ │ ├── 37.gif │ │ │ │ ├── 38.gif │ │ │ │ ├── 39.gif │ │ │ │ ├── 4.gif │ │ │ │ ├── 40.gif │ │ │ │ ├── 41.gif │ │ │ │ ├── 42.gif │ │ │ │ ├── 43.gif │ │ │ │ ├── 44.gif │ │ │ │ ├── 45.gif │ │ │ │ ├── 46.gif │ │ │ │ ├── 47.gif │ │ │ │ ├── 48.gif │ │ │ │ ├── 49.gif │ │ │ │ ├── 5.gif │ │ │ │ ├── 50.gif │ │ │ │ ├── 51.gif │ │ │ │ ├── 52.gif │ │ │ │ ├── 53.gif │ │ │ │ ├── 54.gif │ │ │ │ ├── 55.gif │ │ │ │ ├── 56.gif │ │ │ │ ├── 57.gif │ │ │ │ ├── 58.gif │ │ │ │ ├── 59.gif │ │ │ │ ├── 6.gif │ │ │ │ ├── 60.gif │ │ │ │ ├── 61.gif │ │ │ │ ├── 62.gif │ │ │ │ ├── 63.gif │ │ │ │ ├── 64.gif │ │ │ │ ├── 65.gif │ │ │ │ ├── 66.gif │ │ │ │ ├── 67.gif │ │ │ │ ├── 68.gif │ │ │ │ ├── 69.gif │ │ │ │ ├── 7.gif │ │ │ │ ├── 70.gif │ │ │ │ ├── 71.gif │ │ │ │ ├── 8.gif │ │ │ │ └── 9.gif │ │ │ ├── lay │ │ │ └── modules │ │ │ │ ├── carousel.js │ │ │ │ ├── code.js │ │ │ │ ├── colorpicker.js │ │ │ │ ├── element.js │ │ │ │ ├── flow.js │ │ │ │ ├── form.js │ │ │ │ ├── jquery.js │ │ │ │ ├── laydate.js │ │ │ │ ├── layedit.js │ │ │ │ ├── layer.js │ │ │ │ ├── laypage.js │ │ │ │ ├── laytpl.js │ │ │ │ ├── mobile.js │ │ │ │ ├── rate.js │ │ │ │ ├── slider.js │ │ │ │ ├── table.js │ │ │ │ ├── tree.js │ │ │ │ ├── upload.js │ │ │ │ └── util.js │ │ │ ├── layui.all.js │ │ │ └── layui.js │ │ └── templates │ │ └── websocket │ │ ├── echo.html │ │ ├── echo_sockjs.html │ │ └── reverse.html │ └── test │ └── java │ └── cn │ └── zifangsky │ └── samplewebsocket │ └── SampleWebsocketApplicationTests.java └── stomp-websocket ├── .gitignore ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src ├── main ├── java │ └── cn │ │ └── zifangsky │ │ └── stompwebsocket │ │ ├── StompWebsocketApplication.java │ │ ├── common │ │ ├── Constants.java │ │ └── SpringContextUtils.java │ │ ├── config │ │ ├── RedisConfig.java │ │ ├── WebMvcConfig.java │ │ └── WebSocketConfig.java │ │ ├── controller │ │ ├── GreetingController.java │ │ ├── MessageTemplateController.java │ │ └── UserController.java │ │ ├── enums │ │ └── ExpireEnum.java │ │ ├── interceptor │ │ ├── LoginInterceptor.java │ │ └── websocket │ │ │ ├── AuthHandshakeInterceptor.java │ │ │ ├── MyChannelInterceptor.java │ │ │ ├── MyHandshakeHandler.java │ │ │ └── MyPrincipal.java │ │ ├── mapper │ │ ├── FuncMapper.java │ │ ├── RoleFuncMapper.java │ │ ├── RoleMapper.java │ │ ├── UserMapper.java │ │ ├── UserRoleMapper.java │ │ └── xml │ │ │ ├── FuncMapper.xml │ │ │ ├── RoleFuncMapper.xml │ │ │ ├── RoleMapper.xml │ │ │ ├── UserMapper.xml │ │ │ └── UserRoleMapper.xml │ │ ├── model │ │ ├── Func.java │ │ ├── Role.java │ │ ├── RoleFunc.java │ │ ├── User.java │ │ ├── UserRole.java │ │ └── websocket │ │ │ ├── Greeting.java │ │ │ └── HelloMessage.java │ │ ├── service │ │ ├── EchoService.java │ │ ├── RedisService.java │ │ ├── UserService.java │ │ └── impl │ │ │ ├── EchoServiceImpl.java │ │ │ ├── RedisServiceImpl.java │ │ │ └── UserServiceImpl.java │ │ ├── utils │ │ ├── AesUtils.java │ │ ├── DateUtils.java │ │ ├── EncryptUtils.java │ │ └── JsonUtils.java │ │ └── websocket │ │ ├── EchoWebSocketHandler.java │ │ └── ReverseWebSocketEndpoint.java └── resources │ ├── application-dev.yml │ ├── application-prod.yml │ ├── application.yml │ ├── banner.txt │ ├── mybatis-generator │ └── generatorConfig.xml │ ├── static │ ├── css │ │ └── style.css │ ├── favicon.ico │ ├── img │ │ ├── 1.jpg │ │ ├── 2.jpg │ │ ├── 3.jpg │ │ ├── 4.jpg │ │ ├── 5.jpg │ │ └── 6.jpg │ └── layui │ │ ├── css │ │ ├── layui.css │ │ ├── layui.mobile.css │ │ └── modules │ │ │ ├── code.css │ │ │ ├── laydate │ │ │ └── default │ │ │ │ └── laydate.css │ │ │ └── layer │ │ │ └── default │ │ │ ├── icon-ext.png │ │ │ ├── icon.png │ │ │ ├── layer.css │ │ │ ├── loading-0.gif │ │ │ ├── loading-1.gif │ │ │ └── loading-2.gif │ │ ├── font │ │ ├── iconfont.eot │ │ ├── iconfont.svg │ │ ├── iconfont.ttf │ │ └── iconfont.woff │ │ ├── images │ │ └── face │ │ │ ├── 0.gif │ │ │ ├── 1.gif │ │ │ ├── 10.gif │ │ │ ├── 11.gif │ │ │ ├── 12.gif │ │ │ ├── 13.gif │ │ │ ├── 14.gif │ │ │ ├── 15.gif │ │ │ ├── 16.gif │ │ │ ├── 17.gif │ │ │ ├── 18.gif │ │ │ ├── 19.gif │ │ │ ├── 2.gif │ │ │ ├── 20.gif │ │ │ ├── 21.gif │ │ │ ├── 22.gif │ │ │ ├── 23.gif │ │ │ ├── 24.gif │ │ │ ├── 25.gif │ │ │ ├── 26.gif │ │ │ ├── 27.gif │ │ │ ├── 28.gif │ │ │ ├── 29.gif │ │ │ ├── 3.gif │ │ │ ├── 30.gif │ │ │ ├── 31.gif │ │ │ ├── 32.gif │ │ │ ├── 33.gif │ │ │ ├── 34.gif │ │ │ ├── 35.gif │ │ │ ├── 36.gif │ │ │ ├── 37.gif │ │ │ ├── 38.gif │ │ │ ├── 39.gif │ │ │ ├── 4.gif │ │ │ ├── 40.gif │ │ │ ├── 41.gif │ │ │ ├── 42.gif │ │ │ ├── 43.gif │ │ │ ├── 44.gif │ │ │ ├── 45.gif │ │ │ ├── 46.gif │ │ │ ├── 47.gif │ │ │ ├── 48.gif │ │ │ ├── 49.gif │ │ │ ├── 5.gif │ │ │ ├── 50.gif │ │ │ ├── 51.gif │ │ │ ├── 52.gif │ │ │ ├── 53.gif │ │ │ ├── 54.gif │ │ │ ├── 55.gif │ │ │ ├── 56.gif │ │ │ ├── 57.gif │ │ │ ├── 58.gif │ │ │ ├── 59.gif │ │ │ ├── 6.gif │ │ │ ├── 60.gif │ │ │ ├── 61.gif │ │ │ ├── 62.gif │ │ │ ├── 63.gif │ │ │ ├── 64.gif │ │ │ ├── 65.gif │ │ │ ├── 66.gif │ │ │ ├── 67.gif │ │ │ ├── 68.gif │ │ │ ├── 69.gif │ │ │ ├── 7.gif │ │ │ ├── 70.gif │ │ │ ├── 71.gif │ │ │ ├── 8.gif │ │ │ └── 9.gif │ │ ├── lay │ │ └── modules │ │ │ ├── carousel.js │ │ │ ├── code.js │ │ │ ├── colorpicker.js │ │ │ ├── element.js │ │ │ ├── flow.js │ │ │ ├── form.js │ │ │ ├── jquery.js │ │ │ ├── laydate.js │ │ │ ├── layedit.js │ │ │ ├── layer.js │ │ │ ├── laypage.js │ │ │ ├── laytpl.js │ │ │ ├── mobile.js │ │ │ ├── rate.js │ │ │ ├── slider.js │ │ │ ├── table.js │ │ │ ├── tree.js │ │ │ ├── upload.js │ │ │ └── util.js │ │ ├── layui.all.js │ │ └── layui.js │ └── templates │ ├── index.html │ ├── login.html │ ├── userIndex.html │ └── websocket │ ├── chat.html │ └── stomp.html └── test └── java └── cn └── zifangsky └── stompwebsocket ├── StompWebsocketApplicationTests.java ├── TestRedis.java └── TestSQL.java /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | logs/* 6 | *.log 7 | 8 | # BlueJ files 9 | *.ctxt 10 | 11 | # Mobile Tools for Java (J2ME) 12 | .mtj.tmp/ 13 | 14 | # Package Files # 15 | *.jar 16 | *.war 17 | *.nar 18 | *.ear 19 | *.zip 20 | *.tar.gz 21 | *.rar 22 | 23 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 24 | hs_err_pid* 25 | 26 | # IDEA 27 | *.iml 28 | .idea -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WebSocketDemo # 2 | 3 | #### 项目介绍 4 | 在Spring Boot中使用`WebSocket`的Demo项目,这个示例包括简单模式、STOMP模式消息、处理对方不在线情况、分布式WebSocket等。 5 | 6 | #### 技术依赖 #### 7 | 8 | - `Spring Boot`:项目基础架构 9 | - `thymeleaf`:用于构建测试页面模板 10 | - `MyBatis`:用于访问`MySQL`数据库,实现用户登录功能 11 | 12 | #### 环境依赖 #### 13 | 14 | - `JDK8+` 15 | - `MySQL5.7+` 16 | - `Redis集群` 17 | 18 | #### 三个子项目说明 #### 19 | 20 | - `sample-websocket`:最基础的demo项目,包含:使用Java提供的@ServerEndpoint注解实现`WebSocket`、使用Spring提供的低层级WebSocket API实现`WebSocket` 21 | - `stomp-websocket`:这个demo项目包含:**使用STOMP消息实现`WebSocket`**、**向指定用户发送WebSocket消息并处理对方不在线的情况**等代码。 22 | - `mq-websocket`:这个demo项目包含:**使用消息队列实现分布式`WebSocket`**等代码 23 | 24 | ------ 25 | 26 | 有关这个项目代码的详细开发思路,可以参考我的这三篇文章: 27 | 28 | 1. [Spring Boot中使用WebSocket总结(一):几种实现方式详解](https://www.zifangsky.cn/1355.html) 29 | 2. [Spring Boot中使用WebSocket总结(二):向指定用户发送WebSocket消息并处理对方不在线的情况](https://www.zifangsky.cn/1359.html) 30 | 3. [Spring Boot中使用WebSocket总结(三):使用消息队列实现分布式WebSocket](https://www.zifangsky.cn/1364.html) -------------------------------------------------------------------------------- /mq-websocket/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /mq-websocket/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /mq-websocket/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip 2 | -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/MqWebsocketApplication.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.web.servlet.ServletComponentScan; 7 | import org.springframework.scheduling.annotation.EnableAsync; 8 | 9 | @SpringBootApplication 10 | @ServletComponentScan 11 | @EnableAsync 12 | @MapperScan("cn.zifangsky.mqwebsocket.mapper") 13 | public class MqWebsocketApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(MqWebsocketApplication.class, args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/common/Constants.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.common; 2 | 3 | /** 4 | * 公共常量类 5 | * 6 | * @author zifangsky 7 | * @date 2018/7/25 8 | * @since 1.0.0 9 | */ 10 | public class Constants { 11 | /** 12 | * 用户信息在session中存储的变量名 13 | */ 14 | public static final String SESSION_USER = "SESSION_USER"; 15 | 16 | /** 17 | * 登录页面的回调地址在session中存储的变量名 18 | */ 19 | public static final String SESSION_LOGIN_REDIRECT_URL = "LOGIN_REDIRECT_URL"; 20 | 21 | /** 22 | * 用户未读的WebSocket消息在Redis中存储的变量名的前缀 23 | */ 24 | public static final String REDIS_UNREAD_MSG_PREFIX = "mq-websocket:unread_msg:"; 25 | 26 | /** 27 | * 已经建立连接的WebSocket用户在Redis中存储的SET的KEY值 28 | */ 29 | public static final String REDIS_WEBSOCKET_USER_SET = "mq-websocket:websocket_user_set"; 30 | } 31 | -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/config/WebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.config; 2 | 3 | import cn.zifangsky.mqwebsocket.interceptor.LoginInterceptor; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 6 | import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; 7 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 8 | 9 | /** 10 | * Web相关配置 11 | * @author zifangsky 12 | * @date 2018/7/9 13 | * @since 1.0.0 14 | */ 15 | @Configuration 16 | public class WebMvcConfig implements WebMvcConfigurer { 17 | 18 | /** 19 | * 视图控制器 20 | */ 21 | @Override 22 | public void addViewControllers(ViewControllerRegistry registry) { 23 | registry.addViewController("/index").setViewName("index"); 24 | registry.addViewController("/chat").setViewName("websocket/chat"); 25 | } 26 | 27 | /** 28 | * 添加拦截器 29 | */ 30 | @Override 31 | public void addInterceptors(InterceptorRegistry registry) { 32 | registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/user/**","/chat","/sendToUser","/pullUnreadMessage"); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/config/WebSocketConfig.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.config; 2 | 3 | import cn.zifangsky.mqwebsocket.interceptor.websocket.MyHandshakeHandler; 4 | import cn.zifangsky.mqwebsocket.interceptor.websocket.AuthHandshakeInterceptor; 5 | import cn.zifangsky.mqwebsocket.interceptor.websocket.MyChannelInterceptor; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.messaging.simp.config.ChannelRegistration; 9 | import org.springframework.messaging.simp.config.MessageBrokerRegistry; 10 | import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker; 11 | import org.springframework.web.socket.config.annotation.StompEndpointRegistry; 12 | import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; 13 | 14 | /** 15 | * WebSocket相关配置 16 | * 17 | * @author zifangsky 18 | * @date 2018/9/30 19 | * @since 1.0.0 20 | */ 21 | @Configuration 22 | @EnableWebSocketMessageBroker 23 | public class WebSocketConfig implements WebSocketMessageBrokerConfigurer{ 24 | @Autowired 25 | private AuthHandshakeInterceptor authHandshakeInterceptor; 26 | 27 | @Autowired 28 | private MyHandshakeHandler myHandshakeHandler; 29 | 30 | @Autowired 31 | private MyChannelInterceptor myChannelInterceptor; 32 | 33 | @Override 34 | public void registerStompEndpoints(StompEndpointRegistry registry) { 35 | registry.addEndpoint("/chat-websocket") 36 | .addInterceptors(authHandshakeInterceptor) 37 | .setHandshakeHandler(myHandshakeHandler) 38 | .withSockJS(); 39 | } 40 | 41 | @Override 42 | public void configureMessageBroker(MessageBrokerRegistry registry) { 43 | //客户端需要把消息发送到/message/xxx地址 44 | registry.setApplicationDestinationPrefixes("/message"); 45 | //服务端广播消息的路径前缀,客户端需要相应订阅/topic/yyy这个地址的消息 46 | registry.enableSimpleBroker("/topic"); 47 | //给指定用户发送消息的路径前缀,默认值是/user/ 48 | registry.setUserDestinationPrefix("/user/"); 49 | } 50 | 51 | @Override 52 | public void configureClientInboundChannel(ChannelRegistration registration) { 53 | registration.interceptors(myChannelInterceptor); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/enums/ExpireEnum.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.enums; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | 5 | /** 6 | * 过期时间相关枚举 7 | * 8 | * @author zifangsky 9 | * @date 2018/10/11 10 | * @since 1.0.0 11 | */ 12 | public enum ExpireEnum { 13 | //未读消息的有效期为30天 14 | UNREAD_MSG(30L, TimeUnit.DAYS) 15 | ; 16 | 17 | /** 18 | * 过期时间 19 | */ 20 | private Long time; 21 | /** 22 | * 时间单位 23 | */ 24 | private TimeUnit timeUnit; 25 | 26 | ExpireEnum(Long time, TimeUnit timeUnit) { 27 | this.time = time; 28 | this.timeUnit = timeUnit; 29 | } 30 | 31 | public Long getTime() { 32 | return time; 33 | } 34 | 35 | public TimeUnit getTimeUnit() { 36 | return timeUnit; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/enums/WebSocketChannelEnum.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.enums; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | /** 6 | * WebSocket Channel枚举类 7 | * 8 | * @author zifangsky 9 | * @date 2018/10/16 10 | * @since 1.0.0 11 | */ 12 | public enum WebSocketChannelEnum { 13 | //测试使用的简易点对点聊天 14 | CHAT("CHAT", "测试使用的简易点对点聊天", "/topic/reply"); 15 | 16 | WebSocketChannelEnum(String code, String description, String subscribeUrl) { 17 | this.code = code; 18 | this.description = description; 19 | this.subscribeUrl = subscribeUrl; 20 | } 21 | 22 | /** 23 | * 唯一CODE 24 | */ 25 | private String code; 26 | /** 27 | * 描述 28 | */ 29 | private String description; 30 | /** 31 | * WebSocket客户端订阅的URL 32 | */ 33 | private String subscribeUrl; 34 | 35 | public String getCode() { 36 | return code; 37 | } 38 | 39 | public String getDescription() { 40 | return description; 41 | } 42 | 43 | public String getSubscribeUrl() { 44 | return subscribeUrl; 45 | } 46 | 47 | /** 48 | * 通过CODE查找枚举类 49 | */ 50 | public static WebSocketChannelEnum fromCode(String code){ 51 | if(StringUtils.isNoneBlank(code)){ 52 | for(WebSocketChannelEnum channelEnum : values()){ 53 | if(channelEnum.code.equals(code)){ 54 | return channelEnum; 55 | } 56 | } 57 | } 58 | 59 | return null; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/interceptor/LoginInterceptor.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.interceptor; 2 | 3 | import cn.zifangsky.mqwebsocket.common.Constants; 4 | import cn.zifangsky.mqwebsocket.common.SpringContextUtils; 5 | import cn.zifangsky.mqwebsocket.model.User; 6 | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; 7 | 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | import javax.servlet.http.HttpSession; 11 | 12 | /** 13 | * 定义一些页面需要做登录检查 14 | * 15 | * @author zifangsky 16 | * @date 2018/7/26 17 | * @since 1.0.0 18 | */ 19 | public class LoginInterceptor extends HandlerInterceptorAdapter{ 20 | 21 | /** 22 | * 检查是否已经登录 23 | */ 24 | @Override 25 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 26 | HttpSession session = request.getSession(); 27 | 28 | //获取session中存储的token 29 | User user = (User) session.getAttribute(Constants.SESSION_USER); 30 | 31 | if(user != null){ 32 | return true; 33 | }else{ 34 | //如果token不存在,则跳转到登录页面 35 | response.sendRedirect(request.getContextPath() + "/login?redirectUri=" + SpringContextUtils.getRequestUrl(request)); 36 | 37 | return false; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/interceptor/websocket/AuthHandshakeInterceptor.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.interceptor.websocket; 2 | 3 | import cn.zifangsky.mqwebsocket.common.Constants; 4 | import cn.zifangsky.mqwebsocket.common.SpringContextUtils; 5 | import cn.zifangsky.mqwebsocket.model.User; 6 | import cn.zifangsky.mqwebsocket.service.RedisService; 7 | import org.apache.commons.lang3.StringUtils; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.springframework.http.server.ServerHttpRequest; 11 | import org.springframework.http.server.ServerHttpResponse; 12 | import org.springframework.stereotype.Component; 13 | import org.springframework.web.socket.WebSocketHandler; 14 | import org.springframework.web.socket.server.HandshakeInterceptor; 15 | 16 | import javax.annotation.Resource; 17 | import javax.servlet.http.HttpSession; 18 | import java.text.MessageFormat; 19 | import java.util.Map; 20 | 21 | /** 22 | * 自定义{@link org.springframework.web.socket.server.HandshakeInterceptor},实现“需要登录才允许连接WebSocket” 23 | * 24 | * @author zifangsky 25 | * @date 2018/10/11 26 | * @since 1.0.0 27 | */ 28 | @Component 29 | public class AuthHandshakeInterceptor implements HandshakeInterceptor { 30 | private final Logger logger = LoggerFactory.getLogger(getClass()); 31 | 32 | @Resource(name = "redisServiceImpl") 33 | private RedisService redisService; 34 | 35 | @Override 36 | public boolean beforeHandshake(ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse, WebSocketHandler webSocketHandler, Map map) throws Exception { 37 | HttpSession session = SpringContextUtils.getSession(); 38 | User loginUser = (User) session.getAttribute(Constants.SESSION_USER); 39 | 40 | if(redisService.isSetMember(Constants.REDIS_WEBSOCKET_USER_SET, loginUser.getUsername())){ 41 | logger.error("同一个用户不准建立多个连接WebSocket"); 42 | return false; 43 | }else if(loginUser == null || StringUtils.isBlank(loginUser.getUsername())){ 44 | logger.error("未登录系统,禁止连接WebSocket"); 45 | return false; 46 | }else{ 47 | logger.debug(MessageFormat.format("用户{0}请求建立WebSocket连接", loginUser.getUsername())); 48 | return true; 49 | } 50 | } 51 | 52 | @Override 53 | public void afterHandshake(ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse, WebSocketHandler webSocketHandler, Exception e) { 54 | 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/interceptor/websocket/MyChannelInterceptor.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.interceptor.websocket; 2 | 3 | import cn.zifangsky.mqwebsocket.common.Constants; 4 | import cn.zifangsky.mqwebsocket.service.RedisService; 5 | import org.apache.commons.lang3.StringUtils; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.messaging.Message; 9 | import org.springframework.messaging.MessageChannel; 10 | import org.springframework.messaging.simp.stomp.StompCommand; 11 | import org.springframework.messaging.simp.stomp.StompHeaderAccessor; 12 | import org.springframework.messaging.support.ChannelInterceptor; 13 | import org.springframework.stereotype.Component; 14 | 15 | import javax.annotation.Resource; 16 | import java.security.Principal; 17 | import java.text.MessageFormat; 18 | 19 | /** 20 | * 自定义{@link org.springframework.messaging.support.ChannelInterceptor},实现断开连接的处理 21 | * 22 | * @author zifangsky 23 | * @date 2018/10/10 24 | * @since 1.0.0 25 | */ 26 | @Component 27 | public class MyChannelInterceptor implements ChannelInterceptor{ 28 | private final Logger logger = LoggerFactory.getLogger(getClass()); 29 | 30 | @Resource(name = "redisServiceImpl") 31 | private RedisService redisService; 32 | 33 | @Override 34 | public void afterSendCompletion(Message message, MessageChannel channel, boolean sent, Exception ex) { 35 | StompHeaderAccessor accessor = StompHeaderAccessor.wrap(message); 36 | StompCommand command = accessor.getCommand(); 37 | 38 | //用户已经断开连接 39 | if(StompCommand.DISCONNECT.equals(command)){ 40 | String user = ""; 41 | Principal principal = accessor.getUser(); 42 | if(principal != null && StringUtils.isNoneBlank(principal.getName())){ 43 | user = principal.getName(); 44 | 45 | //从Redis中移除用户 46 | redisService.removeFromSet(Constants.REDIS_WEBSOCKET_USER_SET, user); 47 | }else{ 48 | user = accessor.getSessionId(); 49 | } 50 | 51 | logger.debug(MessageFormat.format("用户{0}的WebSocket连接已经断开", user)); 52 | } 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/interceptor/websocket/MyHandshakeHandler.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.interceptor.websocket; 2 | 3 | import cn.zifangsky.mqwebsocket.common.Constants; 4 | import cn.zifangsky.mqwebsocket.common.SpringContextUtils; 5 | import cn.zifangsky.mqwebsocket.model.User; 6 | import cn.zifangsky.mqwebsocket.service.RedisService; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.http.server.ServerHttpRequest; 10 | import org.springframework.stereotype.Component; 11 | import org.springframework.web.socket.WebSocketHandler; 12 | import org.springframework.web.socket.server.support.DefaultHandshakeHandler; 13 | 14 | import javax.annotation.Resource; 15 | import javax.servlet.http.HttpSession; 16 | import java.security.Principal; 17 | import java.text.MessageFormat; 18 | import java.util.Map; 19 | 20 | /** 21 | * 自定义{@link org.springframework.web.socket.server.support.DefaultHandshakeHandler},实现“生成自定义的{@link java.security.Principal}” 22 | * 23 | * @author zifangsky 24 | * @date 2018/10/11 25 | * @since 1.0.0 26 | */ 27 | @Component 28 | public class MyHandshakeHandler extends DefaultHandshakeHandler{ 29 | private final Logger logger = LoggerFactory.getLogger(getClass()); 30 | 31 | @Resource(name = "redisServiceImpl") 32 | private RedisService redisService; 33 | 34 | @Override 35 | protected Principal determineUser(ServerHttpRequest request, WebSocketHandler wsHandler, Map attributes) { 36 | HttpSession session = SpringContextUtils.getSession(); 37 | User loginUser = (User) session.getAttribute(Constants.SESSION_USER); 38 | 39 | if(loginUser != null){ 40 | logger.debug(MessageFormat.format("WebSocket连接开始创建Principal,用户:{0}", loginUser.getUsername())); 41 | //1. 将用户名存到Redis中 42 | redisService.addToSet(Constants.REDIS_WEBSOCKET_USER_SET, loginUser.getUsername()); 43 | 44 | //2. 返回自定义的Principal 45 | return new MyPrincipal(loginUser.getUsername()); 46 | }else{ 47 | logger.error("未登录系统,禁止连接WebSocket"); 48 | return null; 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/interceptor/websocket/MyPrincipal.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.interceptor.websocket; 2 | 3 | import java.security.Principal; 4 | 5 | /** 6 | * 自定义{@link java.security.Principal} 7 | * 8 | * @author zifangsky 9 | * @date 2018/10/11 10 | * @since 1.0.0 11 | */ 12 | public class MyPrincipal implements Principal { 13 | private String loginName; 14 | 15 | public MyPrincipal(String loginName) { 16 | this.loginName = loginName; 17 | } 18 | 19 | @Override 20 | public String getName() { 21 | return loginName; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/mapper/FuncMapper.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.mapper; 2 | 3 | import cn.zifangsky.mqwebsocket.model.Func; 4 | 5 | public interface FuncMapper { 6 | int deleteByPrimaryKey(Integer id); 7 | 8 | int insert(Func record); 9 | 10 | int insertSelective(Func record); 11 | 12 | Func selectByPrimaryKey(Integer id); 13 | 14 | int updateByPrimaryKeySelective(Func record); 15 | 16 | int updateByPrimaryKey(Func record); 17 | } -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/mapper/RoleFuncMapper.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.mapper; 2 | 3 | import cn.zifangsky.mqwebsocket.model.RoleFunc; 4 | 5 | public interface RoleFuncMapper { 6 | int deleteByPrimaryKey(Integer id); 7 | 8 | int insert(RoleFunc record); 9 | 10 | int insertSelective(RoleFunc record); 11 | 12 | RoleFunc selectByPrimaryKey(Integer id); 13 | 14 | int updateByPrimaryKeySelective(RoleFunc record); 15 | 16 | int updateByPrimaryKey(RoleFunc record); 17 | } -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/mapper/RoleMapper.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.mapper; 2 | 3 | import cn.zifangsky.mqwebsocket.model.Role; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | public interface RoleMapper { 7 | int deleteByPrimaryKey(Integer id); 8 | 9 | int insert(Role record); 10 | 11 | int insertSelective(Role record); 12 | 13 | Role selectByPrimaryKey(Integer id); 14 | 15 | int updateByPrimaryKeySelective(Role record); 16 | 17 | int updateByPrimaryKey(Role record); 18 | 19 | Role selectByRoleName(@Param("roleName") String roleName); 20 | 21 | } -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.mapper; 2 | 3 | import cn.zifangsky.mqwebsocket.model.User; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | public interface UserMapper { 7 | int deleteByPrimaryKey(Integer id); 8 | 9 | int insert(User user); 10 | 11 | int insertSelective(User user); 12 | 13 | User selectByPrimaryKey(Integer id); 14 | 15 | int updateByPrimaryKeySelective(User user); 16 | 17 | int updateByPrimaryKey(User user); 18 | 19 | User selectByUsername(@Param("username") String username); 20 | 21 | } -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/mapper/UserRoleMapper.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.mapper; 2 | 3 | import cn.zifangsky.mqwebsocket.model.UserRole; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | import java.util.List; 7 | 8 | public interface UserRoleMapper { 9 | int deleteByPrimaryKey(Integer id); 10 | 11 | int insert(UserRole record); 12 | 13 | int insertSelective(UserRole record); 14 | 15 | UserRole selectByPrimaryKey(Integer id); 16 | 17 | int updateByPrimaryKeySelective(UserRole record); 18 | 19 | int updateByPrimaryKey(UserRole record); 20 | 21 | /** 22 | * 通过用户ID和角色ID查询用户角色信息 23 | * @author zifangsky 24 | * @date 2018/8/18 11:10 25 | * @since 1.0.0 26 | * @param userId 用户ID 27 | * @param roleId 角色ID 28 | * @return cn.zifangsky.model.UserRole 29 | */ 30 | UserRole selectByUserIdRoleId(@Param("userId") Integer userId, @Param("roleId") Integer roleId); 31 | 32 | /** 33 | * 通过角色名查询用户角色信息 34 | * @author zifangsky 35 | * @date 2018/8/18 11:10 36 | * @since 1.0.0 37 | * @param roleName 角色名 38 | * @return cn.zifangsky.model.UserRole 39 | */ 40 | UserRole selectByRoleName(@Param("roleName") String roleName); 41 | 42 | /** 43 | * 通过用户ID查询用户角色信息 44 | * @author zifangsky 45 | * @date 2018/8/18 11:10 46 | * @since 1.0.0 47 | * @param userId 用户ID 48 | * @return cn.zifangsky.model.UserRole 49 | */ 50 | List selectByUserId(@Param("userId") Integer userId); 51 | } -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/model/Func.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.model; 2 | 3 | import java.util.Objects; 4 | 5 | public class Func { 6 | private Integer id; 7 | 8 | private String name; 9 | 10 | private String description; 11 | 12 | private String code; 13 | 14 | private String url; 15 | 16 | private Integer status; 17 | 18 | public Integer getId() { 19 | return id; 20 | } 21 | 22 | public void setId(Integer id) { 23 | this.id = id; 24 | } 25 | 26 | public String getName() { 27 | return name; 28 | } 29 | 30 | public void setName(String name) { 31 | this.name = name == null ? null : name.trim(); 32 | } 33 | 34 | public String getDescription() { 35 | return description; 36 | } 37 | 38 | public void setDescription(String description) { 39 | this.description = description == null ? null : description.trim(); 40 | } 41 | 42 | public String getCode() { 43 | return code; 44 | } 45 | 46 | public void setCode(String code) { 47 | this.code = code == null ? null : code.trim(); 48 | } 49 | 50 | public String getUrl() { 51 | return url; 52 | } 53 | 54 | public void setUrl(String url) { 55 | this.url = url == null ? null : url.trim(); 56 | } 57 | 58 | public Integer getStatus() { 59 | return status; 60 | } 61 | 62 | public void setStatus(Integer status) { 63 | this.status = status; 64 | } 65 | 66 | @Override 67 | public boolean equals(Object o) { 68 | if (this == o) return true; 69 | if (o == null || getClass() != o.getClass()) return false; 70 | Func func = (Func) o; 71 | return Objects.equals(id, func.id) && 72 | Objects.equals(name, func.name) && 73 | Objects.equals(description, func.description) && 74 | Objects.equals(code, func.code) && 75 | Objects.equals(url, func.url) && 76 | Objects.equals(status, func.status); 77 | } 78 | 79 | @Override 80 | public int hashCode() { 81 | 82 | return Objects.hash(id, name, description, code, url, status); 83 | } 84 | } -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/model/Role.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.model; 2 | 3 | import java.util.Objects; 4 | 5 | public class Role { 6 | private Integer id; 7 | 8 | private String roleName; 9 | 10 | private String description; 11 | 12 | public Integer getId() { 13 | return id; 14 | } 15 | 16 | public void setId(Integer id) { 17 | this.id = id; 18 | } 19 | 20 | public String getRoleName() { 21 | return roleName; 22 | } 23 | 24 | public void setRoleName(String roleName) { 25 | this.roleName = roleName == null ? null : roleName.trim(); 26 | } 27 | 28 | public String getDescription() { 29 | return description; 30 | } 31 | 32 | public void setDescription(String description) { 33 | this.description = description == null ? null : description.trim(); 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return "Role{" + 39 | "id=" + id + 40 | ", roleName='" + roleName + '\'' + 41 | ", description='" + description + '\'' + 42 | '}'; 43 | } 44 | 45 | @Override 46 | public boolean equals(Object o) { 47 | if (this == o) return true; 48 | if (o == null || getClass() != o.getClass()) return false; 49 | Role role = (Role) o; 50 | return Objects.equals(id, role.id) && 51 | Objects.equals(roleName, role.roleName) && 52 | Objects.equals(description, role.description); 53 | } 54 | 55 | @Override 56 | public int hashCode() { 57 | return Objects.hash(id, roleName, description); 58 | } 59 | } -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/model/RoleFunc.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.model; 2 | 3 | public class RoleFunc { 4 | private Integer id; 5 | 6 | private Integer roleId; 7 | 8 | private Integer funcId; 9 | 10 | public Integer getId() { 11 | return id; 12 | } 13 | 14 | public void setId(Integer id) { 15 | this.id = id; 16 | } 17 | 18 | public Integer getRoleId() { 19 | return roleId; 20 | } 21 | 22 | public void setRoleId(Integer roleId) { 23 | this.roleId = roleId; 24 | } 25 | 26 | public Integer getFuncId() { 27 | return funcId; 28 | } 29 | 30 | public void setFuncId(Integer funcId) { 31 | this.funcId = funcId; 32 | } 33 | } -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/model/User.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.model; 2 | 3 | import java.util.Date; 4 | 5 | public class User { 6 | private Integer id; 7 | 8 | private String username; 9 | 10 | private String password; 11 | 12 | private String mobile; 13 | 14 | private String email; 15 | 16 | private Date createTime; 17 | 18 | private Date updateTime; 19 | 20 | private Integer status; 21 | 22 | public Integer getId() { 23 | return id; 24 | } 25 | 26 | public void setId(Integer id) { 27 | this.id = id; 28 | } 29 | 30 | public String getUsername() { 31 | return username; 32 | } 33 | 34 | public void setUsername(String username) { 35 | this.username = username == null ? null : username.trim(); 36 | } 37 | 38 | public String getPassword() { 39 | return password; 40 | } 41 | 42 | public void setPassword(String password) { 43 | this.password = password == null ? null : password.trim(); 44 | } 45 | 46 | public String getMobile() { 47 | return mobile; 48 | } 49 | 50 | public void setMobile(String mobile) { 51 | this.mobile = mobile == null ? null : mobile.trim(); 52 | } 53 | 54 | public String getEmail() { 55 | return email; 56 | } 57 | 58 | public void setEmail(String email) { 59 | this.email = email == null ? null : email.trim(); 60 | } 61 | 62 | public Date getCreateTime() { 63 | return createTime; 64 | } 65 | 66 | public void setCreateTime(Date createTime) { 67 | this.createTime = createTime; 68 | } 69 | 70 | public Date getUpdateTime() { 71 | return updateTime; 72 | } 73 | 74 | public void setUpdateTime(Date updateTime) { 75 | this.updateTime = updateTime; 76 | } 77 | 78 | public Integer getStatus() { 79 | return status; 80 | } 81 | 82 | public void setStatus(Integer status) { 83 | this.status = status; 84 | } 85 | 86 | @Override 87 | public String toString() { 88 | return "User{" + 89 | "id=" + id + 90 | ", username='" + username + '\'' + 91 | ", password='" + password + '\'' + 92 | ", mobile='" + mobile + '\'' + 93 | ", email='" + email + '\'' + 94 | ", createTime=" + createTime + 95 | ", updateTime=" + updateTime + 96 | ", status=" + status + 97 | '}'; 98 | } 99 | } -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/model/UserRole.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.model; 2 | 3 | public class UserRole { 4 | public UserRole() { 5 | } 6 | 7 | public UserRole(Integer userId, Integer roleId) { 8 | this.userId = userId; 9 | this.roleId = roleId; 10 | } 11 | 12 | private Integer id; 13 | 14 | private Integer userId; 15 | 16 | private Integer roleId; 17 | 18 | public Integer getId() { 19 | return id; 20 | } 21 | 22 | public void setId(Integer id) { 23 | this.id = id; 24 | } 25 | 26 | public Integer getUserId() { 27 | return userId; 28 | } 29 | 30 | public void setUserId(Integer userId) { 31 | this.userId = userId; 32 | } 33 | 34 | public Integer getRoleId() { 35 | return roleId; 36 | } 37 | 38 | public void setRoleId(Integer roleId) { 39 | this.roleId = roleId; 40 | } 41 | } -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/model/websocket/HelloMessage.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.model.websocket; 2 | 3 | /** 4 | * Greeting 5 | * 6 | * @author zifangsky 7 | * @date 2018/9/30 8 | * @since 1.0.0 9 | */ 10 | public class HelloMessage { 11 | private String content; 12 | 13 | public HelloMessage() { 14 | 15 | } 16 | 17 | public HelloMessage(String content) { 18 | this.content = content; 19 | } 20 | 21 | public String getContent() { 22 | return content; 23 | } 24 | 25 | public void setContent(String content) { 26 | this.content = content; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/model/websocket/RedisWebsocketMsg.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.model.websocket; 2 | 3 | /** 4 | * Redis中存储WebSocket消息 5 | * 6 | * @author zifangsky 7 | * @date 2018/10/16 8 | * @since 1.0.0 9 | */ 10 | public class RedisWebsocketMsg { 11 | /** 12 | * 消息接收者的username 13 | */ 14 | private String receiver; 15 | /** 16 | * 消息对应的订阅频道的CODE,参考{@link cn.zifangsky.mqwebsocket.enums.WebSocketChannelEnum}的code字段 17 | */ 18 | private String channelCode; 19 | /** 20 | * 消息正文 21 | */ 22 | private T content; 23 | 24 | public RedisWebsocketMsg() { 25 | 26 | } 27 | 28 | public RedisWebsocketMsg(String receiver, String channelCode, T content) { 29 | this.receiver = receiver; 30 | this.channelCode = channelCode; 31 | this.content = content; 32 | } 33 | 34 | public String getReceiver() { 35 | return receiver; 36 | } 37 | 38 | public void setReceiver(String receiver) { 39 | this.receiver = receiver; 40 | } 41 | 42 | public T getContent() { 43 | return content; 44 | } 45 | 46 | public void setContent(T content) { 47 | this.content = content; 48 | } 49 | 50 | public String getChannelCode() { 51 | return channelCode; 52 | } 53 | 54 | public void setChannelCode(String channelCode) { 55 | this.channelCode = channelCode; 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | return "RedisWebsocketMsg{" + 61 | "receiver='" + receiver + '\'' + 62 | ", channelCode='" + channelCode + '\'' + 63 | ", content=" + content + 64 | '}'; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/mq/MessageReceiver.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.mq; 2 | 3 | import cn.zifangsky.mqwebsocket.enums.WebSocketChannelEnum; 4 | import cn.zifangsky.mqwebsocket.model.websocket.RedisWebsocketMsg; 5 | import org.apache.commons.lang3.StringUtils; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.messaging.simp.SimpMessagingTemplate; 10 | import org.springframework.messaging.simp.user.SimpUser; 11 | import org.springframework.messaging.simp.user.SimpUserRegistry; 12 | import org.springframework.stereotype.Component; 13 | 14 | import java.text.MessageFormat; 15 | 16 | /** 17 | * Redis中的WebSocket消息的处理者 18 | * 19 | * @author zifangsky 20 | * @date 2018/10/16 21 | * @since 1.0.0 22 | */ 23 | @Component 24 | public class MessageReceiver { 25 | private final Logger logger = LoggerFactory.getLogger(getClass()); 26 | 27 | @Autowired 28 | private SimpMessagingTemplate messagingTemplate; 29 | 30 | @Autowired 31 | private SimpUserRegistry userRegistry; 32 | 33 | /** 34 | * 处理WebSocket消息 35 | */ 36 | public void receiveMessage(RedisWebsocketMsg redisWebsocketMsg) { 37 | logger.info(MessageFormat.format("Received Message: {0}", redisWebsocketMsg)); 38 | //1. 取出用户名并判断是否连接到当前应用节点的WebSocket 39 | SimpUser simpUser = userRegistry.getUser(redisWebsocketMsg.getReceiver()); 40 | 41 | if(simpUser != null && StringUtils.isNoneBlank(simpUser.getName())){ 42 | //2. 获取WebSocket客户端的订阅地址 43 | WebSocketChannelEnum channelEnum = WebSocketChannelEnum.fromCode(redisWebsocketMsg.getChannelCode()); 44 | 45 | if(channelEnum != null){ 46 | //3. 给WebSocket客户端发送消息 47 | messagingTemplate.convertAndSendToUser(redisWebsocketMsg.getReceiver(), channelEnum.getSubscribeUrl(), redisWebsocketMsg.getContent()); 48 | } 49 | } 50 | 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/service/UserService.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.service; 2 | 3 | import cn.zifangsky.mqwebsocket.model.User; 4 | 5 | import java.util.Map; 6 | 7 | /** 8 | * 用于相关Service 9 | * @author zifangsky 10 | * @date 2018/7/27 11 | * @since 1.0.0 12 | */ 13 | public interface UserService { 14 | /** 15 | * 通过用户ID查询用户信息 16 | * @author zifangsky 17 | * @date 2018/8/23 15:07 18 | * @since 1.0.0 19 | * @param userId 用户ID 20 | * @return cn.zifangsky.model.User 21 | */ 22 | User selectByUserId(Integer userId); 23 | 24 | /** 25 | * 注册 26 | * @author zifangsky 27 | * @date 2018/7/27 10:48 28 | * @since 1.0.0 29 | * @param user 用户详情 30 | * @return boolean 31 | */ 32 | boolean register(User user); 33 | 34 | /** 35 | * 登录校验 36 | * @author zifangsky 37 | * @date 2018/7/27 10:48 38 | * @since 1.0.0 39 | * @param username 用户名 40 | * @param password 密码 41 | * @return java.util.Map 42 | */ 43 | Map checkLogin(String username, String password); 44 | 45 | /** 46 | * 给用户添加角色信息 47 | * @author zifangsky 48 | * @date 2018/8/10 17:30 49 | * @since 1.0.0 50 | * @param userId 用户ID 51 | * @param roleName 角色名 52 | */ 53 | void addUserRole(Integer userId, String roleName); 54 | 55 | } 56 | -------------------------------------------------------------------------------- /mq-websocket/src/main/java/cn/zifangsky/mqwebsocket/utils/JsonUtils.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket.utils; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | 5 | /** 6 | * JSON相关公共方法(通过Fastjson实现) 7 | * 8 | * @author zifangsky 9 | * @date 2017/5/2 10 | * @since 1.0.0 11 | */ 12 | public class JsonUtils { 13 | 14 | /** 15 | * 将对象转化为json字符串 16 | * @param source Java对象 17 | * @return java.lang.String 18 | */ 19 | public static String toJson(K source){ 20 | return JSON.toJSON(source).toString(); 21 | } 22 | 23 | /** 24 | * 将json字符串还原为目标对象 25 | * @param source json字符串 26 | * @return K 27 | */ 28 | public static T fromJson(String source, Class clazz){ 29 | return JSON.parseObject(source, clazz); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 7002 3 | servlet: 4 | session.timeout: 300 5 | 6 | logging: 7 | level: 8 | #日志优先级(只会输出指定优先级及以上的日志信息):trace_/___.' >'"". 16 | | | : `- \`.;`\ _ /`;.`/ - ` : | | 17 | \ \ `-. \_ __\ /__ _/ .-` / / 18 | ========`-.____`-.___\_____/___.-`____.-'======== 19 | `=---=' 20 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | 佛祖保佑 永无BUG 22 | -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/favicon.ico -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/img/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/img/1.jpg -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/img/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/img/2.jpg -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/img/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/img/3.jpg -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/img/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/img/4.jpg -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/img/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/img/5.jpg -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/img/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/img/6.jpg -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/css/modules/code.css: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.3 MIT License By https://www.layui.com */ 2 | html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-h3,.layui-code-view{position:relative;font-size:12px}.layui-code-view{display:block;margin:10px 0;padding:0;border:1px solid #e2e2e2;border-left-width:6px;background-color:#F2F2F2;color:#333;font-family:Courier New}.layui-code-h3{padding:0 10px;height:32px;line-height:32px;border-bottom:1px solid #e2e2e2}.layui-code-h3 a{position:absolute;right:10px;top:0;color:#999}.layui-code-view .layui-code-ol{position:relative;overflow:auto}.layui-code-view .layui-code-ol li{position:relative;margin-left:45px;line-height:20px;padding:0 5px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view pre{margin:0}.layui-code-notepad{border:1px solid #0C0C0C;border-left-color:#3F3F3F;background-color:#0C0C0C;color:#C2BE9E}.layui-code-notepad .layui-code-h3{border-bottom:none}.layui-code-notepad .layui-code-ol li{background-color:#3F3F3F;border-left:none} -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/css/modules/layer/default/icon-ext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/css/modules/layer/default/icon-ext.png -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/css/modules/layer/default/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/css/modules/layer/default/icon.png -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/css/modules/layer/default/loading-0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/css/modules/layer/default/loading-0.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/css/modules/layer/default/loading-1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/css/modules/layer/default/loading-1.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/css/modules/layer/default/loading-2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/css/modules/layer/default/loading-2.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/font/iconfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/font/iconfont.eot -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/font/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/font/iconfont.ttf -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/font/iconfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/font/iconfont.woff -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/0.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/1.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/10.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/10.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/11.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/11.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/12.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/12.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/13.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/13.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/14.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/14.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/15.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/15.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/16.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/17.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/17.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/18.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/18.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/19.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/19.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/2.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/20.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/20.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/21.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/21.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/22.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/22.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/23.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/23.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/24.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/24.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/25.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/25.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/26.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/26.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/27.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/27.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/28.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/28.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/29.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/29.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/3.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/30.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/30.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/31.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/31.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/32.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/33.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/33.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/34.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/34.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/35.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/35.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/36.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/36.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/37.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/37.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/38.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/38.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/39.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/39.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/4.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/40.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/40.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/41.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/41.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/42.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/42.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/43.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/43.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/44.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/44.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/45.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/45.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/46.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/46.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/47.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/47.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/48.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/48.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/49.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/49.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/5.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/50.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/50.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/51.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/51.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/52.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/52.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/53.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/53.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/54.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/54.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/55.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/55.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/56.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/56.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/57.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/57.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/58.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/58.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/59.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/59.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/6.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/60.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/60.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/61.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/61.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/62.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/62.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/63.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/63.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/64.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/64.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/65.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/65.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/66.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/66.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/67.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/67.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/68.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/68.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/69.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/69.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/7.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/70.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/70.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/71.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/71.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/8.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/8.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/images/face/9.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/mq-websocket/src/main/resources/static/layui/images/face/9.gif -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/lay/modules/code.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.3 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(e){"use strict";var a=layui.$,l="http://www.layui.com/doc/modules/code.html";e("code",function(e){var t=[];e=e||{},e.elem=a(e.elem||".layui-code"),e.about=!("about"in e)||e.about,e.elem.each(function(){t.push(this)}),layui.each(t.reverse(),function(t,i){var c=a(i),o=c.html();(c.attr("lay-encode")||e.encode)&&(o=o.replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")),c.html('
  1. '+o.replace(/[\r\t\n]+/g,"
  2. ")+"
"),c.find(">.layui-code-h3")[0]||c.prepend('

'+(c.attr("lay-title")||e.title||"code")+(e.about?'layui.code':"")+"

");var d=c.find(">.layui-code-ol");c.addClass("layui-box layui-code-view"),(c.attr("lay-skin")||e.skin)&&c.addClass("layui-code-"+(c.attr("lay-skin")||e.skin)),(d.find("li").length/100|0)>0&&d.css("margin-left",(d.find("li").length/100|0)+"px"),(c.attr("lay-height")||e.height)&&d.css("max-height",c.attr("lay-height")||e.height)})})}).addcss("modules/code.css","skincodecss"); -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/lay/modules/flow.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.3 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(e){"use strict";var l=layui.$,o=function(e){},t='';o.prototype.load=function(e){var o,i,n,r,a=this,c=0;e=e||{};var f=l(e.elem);if(f[0]){var m=l(e.scrollElem||document),u=e.mb||50,s=!("isAuto"in e)||e.isAuto,v=e.end||"没有更多了",y=e.scrollElem&&e.scrollElem!==document,d="加载更多",h=l('");f.find(".layui-flow-more")[0]||f.append(h);var p=function(e,t){e=l(e),h.before(e),t=0==t||null,t?h.html(v):h.find("a").html(d),i=t,o=null,n&&n()},g=function(){o=!0,h.find("a").html(t),"function"==typeof e.done&&e.done(++c,p)};if(g(),h.find("a").on("click",function(){l(this);i||o||g()}),e.isLazyimg)var n=a.lazyimg({elem:e.elem+" img",scrollElem:e.scrollElem});return s?(m.on("scroll",function(){var e=l(this),t=e.scrollTop();r&&clearTimeout(r),i||(r=setTimeout(function(){var i=y?e.height():l(window).height(),n=y?e.prop("scrollHeight"):document.documentElement.scrollHeight;n-t-i<=u&&(o||g())},100))}),a):a}},o.prototype.lazyimg=function(e){var o,t=this,i=0;e=e||{};var n=l(e.scrollElem||document),r=e.elem||"img",a=e.scrollElem&&e.scrollElem!==document,c=function(e,l){var o=n.scrollTop(),r=o+l,c=a?function(){return e.offset().top-n.offset().top+o}():e.offset().top;if(c>=o&&c<=r&&!e.attr("src")){var m=e.attr("lay-src");layui.img(m,function(){var l=t.lazyimg.elem.eq(i);e.attr("src",m).removeAttr("lay-src"),l[0]&&f(l),i++})}},f=function(e,o){var f=a?(o||n).height():l(window).height(),m=n.scrollTop(),u=m+f;if(t.lazyimg.elem=l(r),e)c(e,f);else for(var s=0;su)break}};if(f(),!o){var m;n.on("scroll",function(){var e=l(this);m&&clearTimeout(m),m=setTimeout(function(){f(null,e)},50)}),o=!0}return f},e("flow",new o)}); -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/static/layui/lay/modules/laytpl.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.3 MIT License By https://www.layui.com */ 2 | ;layui.define(function(e){"use strict";var r={open:"{{",close:"}}"},c={exp:function(e){return new RegExp(e,"g")},query:function(e,c,t){var o=["#([\\s\\S])+?","([^{#}])*?"][e||0];return n((c||"")+r.open+o+r.close+(t||""))},escape:function(e){return String(e||"").replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")},error:function(e,r){var c="Laytpl Error:";return"object"==typeof console&&console.error(c+e+"\n"+(r||"")),c+e}},n=c.exp,t=function(e){this.tpl=e};t.pt=t.prototype,window.errors=0,t.pt.parse=function(e,t){var o=this,p=e,a=n("^"+r.open+"#",""),l=n(r.close+"$","");e=e.replace(/\s+|\r|\t|\n/g," ").replace(n(r.open+"#"),r.open+"# ").replace(n(r.close+"}"),"} "+r.close).replace(/\\/g,"\\\\").replace(n(r.open+"!(.+?)!"+r.close),function(e){return e=e.replace(n("^"+r.open+"!"),"").replace(n("!"+r.close),"").replace(n(r.open+"|"+r.close),function(e){return e.replace(/(.)/g,"\\$1")})}).replace(/(?="|')/g,"\\").replace(c.query(),function(e){return e=e.replace(a,"").replace(l,""),'";'+e.replace(/\\/g,"")+';view+="'}).replace(c.query(1),function(e){var c='"+(';return e.replace(/\s/g,"")===r.open+r.close?"":(e=e.replace(n(r.open+"|"+r.close),""),/^=/.test(e)&&(e=e.replace(/^=/,""),c='"+_escape_('),c+e.replace(/\\/g,"")+')+"')}),e='"use strict";var view = "'+e+'";return view;';try{return o.cache=e=new Function("d, _escape_",e),e(t,c.escape)}catch(u){return delete o.cache,c.error(u,p)}},t.pt.render=function(e,r){var n,t=this;return e?(n=t.cache?t.cache(e,c.escape):t.parse(t.tpl,e),r?void r(n):n):c.error("no data")};var o=function(e){return"string"!=typeof e?c.error("Template not found"):new t(e)};o.config=function(e){e=e||{};for(var c in e)r[c]=e[c]},o.v="1.2.0",e("laytpl",o)}); -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 首页 8 | 9 | 10 | 11 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /mq-websocket/src/main/resources/templates/userIndex.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 用户首页 8 | 9 | 10 | 11 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /mq-websocket/src/test/java/cn/zifangsky/mqwebsocket/MqWebsocketApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class MqWebsocketApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /mq-websocket/src/test/java/cn/zifangsky/mqwebsocket/TestRedis.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket; 2 | 3 | import cn.zifangsky.mqwebsocket.common.Constants; 4 | import cn.zifangsky.mqwebsocket.enums.ExpireEnum; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.data.redis.core.BoundListOperations; 10 | import org.springframework.data.redis.core.RedisTemplate; 11 | import org.springframework.data.redis.core.SetOperations; 12 | import org.springframework.test.context.junit4.SpringRunner; 13 | 14 | import java.util.List; 15 | import java.util.Set; 16 | 17 | /** 18 | * 测试redis的基本用法 19 | * @author zifangsky 20 | * @date 2018/7/27 21 | * @since 1.0.0 22 | */ 23 | @RunWith(SpringRunner.class) 24 | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 25 | public class TestRedis { 26 | @Autowired 27 | private RedisTemplate redisTemplate; 28 | 29 | @Test 30 | public void testSelect(){ 31 | BoundListOperations boundValueOperations = redisTemplate.boundListOps(Constants.REDIS_UNREAD_MSG_PREFIX + "admin"); 32 | // boundValueOperations.rightPush("a"); 33 | // boundValueOperations.rightPush("b"); 34 | // boundValueOperations.rightPush("c"); 35 | boundValueOperations.leftPushAll("m","n"); 36 | 37 | boundValueOperations.expire(ExpireEnum.UNREAD_MSG.getTime(),ExpireEnum.UNREAD_MSG.getTimeUnit()); 38 | 39 | List list = boundValueOperations.range(0, -1); 40 | list.forEach(System.out::print); 41 | redisTemplate.delete(Constants.REDIS_UNREAD_MSG_PREFIX + "admin"); 42 | } 43 | 44 | @Test 45 | public void testSet(){ 46 | SetOperations opsForSet = redisTemplate.opsForSet(); 47 | 48 | opsForSet.add(Constants.REDIS_WEBSOCKET_USER_SET,"hahaha","admin"); 49 | 50 | //1. 遍历 51 | Set set = opsForSet.members(Constants.REDIS_WEBSOCKET_USER_SET); 52 | 53 | //2. 判断是否是set成员 54 | System.out.println(opsForSet.isMember(Constants.REDIS_WEBSOCKET_USER_SET,"admin")); 55 | System.out.println(opsForSet.isMember(Constants.REDIS_WEBSOCKET_USER_SET,"zifangsky")); 56 | 57 | //3. 移除某个值 58 | opsForSet.remove(Constants.REDIS_WEBSOCKET_USER_SET,"admin"); 59 | 60 | //4. 再次判断 61 | System.out.println(opsForSet.isMember(Constants.REDIS_WEBSOCKET_USER_SET,"admin")); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /mq-websocket/src/test/java/cn/zifangsky/mqwebsocket/TestSQL.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.mqwebsocket; 2 | 3 | import cn.zifangsky.mqwebsocket.mapper.UserMapper; 4 | import cn.zifangsky.mqwebsocket.model.User; 5 | import cn.zifangsky.mqwebsocket.utils.JsonUtils; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.test.context.junit4.SpringRunner; 11 | 12 | /** 13 | * 测试基本数据库连接 14 | * @author zifangsky 15 | * @date 2018/7/27 16 | * @since 1.0.0 17 | */ 18 | @RunWith(SpringRunner.class) 19 | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 20 | public class TestSQL { 21 | @Autowired 22 | private UserMapper userMapper; 23 | 24 | @Test 25 | public void testSelect(){ 26 | User user = userMapper.selectByPrimaryKey(1); 27 | System.out.println(user); 28 | 29 | User user2 = userMapper.selectByUsername("zifangsky"); 30 | System.out.println(JsonUtils.toJson(user2)); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /sample-websocket/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /sample-websocket/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /sample-websocket/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip 2 | -------------------------------------------------------------------------------- /sample-websocket/src/main/java/cn/zifangsky/samplewebsocket/SampleWebsocketApplication.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.samplewebsocket; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.web.servlet.ServletComponentScan; 6 | import org.springframework.scheduling.annotation.EnableAsync; 7 | 8 | @SpringBootApplication 9 | @ServletComponentScan 10 | @EnableAsync 11 | public class SampleWebsocketApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(SampleWebsocketApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /sample-websocket/src/main/java/cn/zifangsky/samplewebsocket/common/Constants.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.samplewebsocket.common; 2 | 3 | /** 4 | * 公共常量类 5 | * 6 | * @author zifangsky 7 | * @date 2018/7/25 8 | * @since 1.0.0 9 | */ 10 | public class Constants { 11 | /** 12 | * 用户信息在session中存储的变量名 13 | */ 14 | public static final String SESSION_USER = "SESSION_USER"; 15 | 16 | /** 17 | * 登录页面的回调地址在session中存储的变量名 18 | */ 19 | public static final String SESSION_LOGIN_REDIRECT_URL = "LOGIN_REDIRECT_URL"; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /sample-websocket/src/main/java/cn/zifangsky/samplewebsocket/config/WebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.samplewebsocket.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 5 | import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 7 | 8 | /** 9 | * Web相关配置 10 | * @author zifangsky 11 | * @date 2018/7/9 12 | * @since 1.0.0 13 | */ 14 | @Configuration 15 | public class WebMvcConfig implements WebMvcConfigurer { 16 | 17 | /** 18 | * 视图控制器 19 | */ 20 | @Override 21 | public void addViewControllers(ViewControllerRegistry registry) { 22 | // registry.addViewController("/index").setViewName("index"); 23 | } 24 | 25 | /** 26 | * 添加拦截器 27 | */ 28 | @Override 29 | public void addInterceptors(InterceptorRegistry registry) { 30 | 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /sample-websocket/src/main/java/cn/zifangsky/samplewebsocket/config/WebSocketConfig.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.samplewebsocket.config; 2 | 3 | import cn.zifangsky.samplewebsocket.websocket.EchoWebSocketHandler; 4 | import cn.zifangsky.samplewebsocket.websocket.ReverseWebSocketEndpoint; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.web.socket.WebSocketHandler; 8 | import org.springframework.web.socket.config.annotation.EnableWebSocket; 9 | import org.springframework.web.socket.config.annotation.WebSocketConfigurer; 10 | import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; 11 | import org.springframework.web.socket.server.standard.ServerEndpointExporter; 12 | 13 | /** 14 | * WebSocket相关配置 15 | * 16 | * @author zifangsky 17 | * @date 2018/9/30 18 | * @since 1.0.0 19 | */ 20 | @Configuration 21 | @EnableWebSocket 22 | public class WebSocketConfig implements WebSocketConfigurer{ 23 | 24 | @Override 25 | public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { 26 | registry.addHandler(echoWebSocketHandler(), "/echoMessage"); 27 | registry.addHandler(echoWebSocketHandler(), "/echoMessage_SockJS").withSockJS(); 28 | } 29 | 30 | /** 31 | * 通过继承 {@link org.springframework.web.socket.handler.AbstractWebSocketHandler} 的示例 32 | */ 33 | @Bean 34 | public WebSocketHandler echoWebSocketHandler(){ 35 | return new EchoWebSocketHandler(); 36 | } 37 | 38 | 39 | @Bean 40 | public ReverseWebSocketEndpoint reverseWebSocketEndpoint() { 41 | return new ReverseWebSocketEndpoint(); 42 | } 43 | 44 | @Bean 45 | public ServerEndpointExporter serverEndpointExporter() { 46 | return new ServerEndpointExporter(); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /sample-websocket/src/main/java/cn/zifangsky/samplewebsocket/controller/GreetingController.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.samplewebsocket.controller; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.servlet.ModelAndView; 6 | 7 | /** 8 | * Greeting 9 | * @author zifangsky 10 | * @date 2018/9/30 11 | * @since 1.0.0 12 | */ 13 | @Controller 14 | public class GreetingController { 15 | 16 | @RequestMapping("/reverse") 17 | public ModelAndView reverse(){ 18 | return new ModelAndView("websocket/reverse"); 19 | } 20 | 21 | @RequestMapping("/echo") 22 | public ModelAndView echo(){ 23 | return new ModelAndView("websocket/echo"); 24 | } 25 | 26 | @RequestMapping("/echo_sockjs") 27 | public ModelAndView echoSockJS(){ 28 | return new ModelAndView("websocket/echo_sockjs"); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /sample-websocket/src/main/java/cn/zifangsky/samplewebsocket/model/websocket/HelloMessage.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.samplewebsocket.model.websocket; 2 | 3 | /** 4 | * Greeting 5 | * 6 | * @author zifangsky 7 | * @date 2018/9/30 8 | * @since 1.0.0 9 | */ 10 | public class HelloMessage { 11 | private String content; 12 | 13 | public HelloMessage() { 14 | 15 | } 16 | 17 | public HelloMessage(String content) { 18 | this.content = content; 19 | } 20 | 21 | public String getContent() { 22 | return content; 23 | } 24 | 25 | public void setContent(String content) { 26 | this.content = content; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /sample-websocket/src/main/java/cn/zifangsky/samplewebsocket/service/EchoService.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.samplewebsocket.service; 2 | 3 | /** 4 | * Echo Demo 5 | * @author zifangsky 6 | * @date 2018/10/9 7 | * @since 1.0.0 8 | */ 9 | public interface EchoService { 10 | String echo(String message); 11 | } 12 | -------------------------------------------------------------------------------- /sample-websocket/src/main/java/cn/zifangsky/samplewebsocket/service/impl/EchoServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.samplewebsocket.service.impl; 2 | 3 | import cn.zifangsky.samplewebsocket.service.EchoService; 4 | import org.springframework.stereotype.Service; 5 | 6 | import java.text.MessageFormat; 7 | 8 | /** 9 | * Echo Demo 10 | * @author zifangsky 11 | * @date 2018/10/9 12 | * @since 1.0.0 13 | */ 14 | @Service("echoServiceImpl") 15 | public class EchoServiceImpl implements EchoService { 16 | 17 | @Override 18 | public String echo(String message) { 19 | return MessageFormat.format("Did you say \"{0}\"?", message); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /sample-websocket/src/main/java/cn/zifangsky/samplewebsocket/utils/JsonUtils.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.samplewebsocket.utils; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | 5 | /** 6 | * JSON相关公共方法(通过Fastjson实现) 7 | * 8 | * @author zifangsky 9 | * @date 2017/5/2 10 | * @since 1.0.0 11 | */ 12 | public class JsonUtils { 13 | 14 | /** 15 | * 将对象转化为json字符串 16 | * @param source Java对象 17 | * @return java.lang.String 18 | */ 19 | public static String toJson(K source){ 20 | return JSON.toJSON(source).toString(); 21 | } 22 | 23 | /** 24 | * 将json字符串还原为目标对象 25 | * @param source json字符串 26 | * @return K 27 | */ 28 | public static T fromJson(String source, Class clazz){ 29 | return JSON.parseObject(source, clazz); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /sample-websocket/src/main/java/cn/zifangsky/samplewebsocket/websocket/EchoWebSocketHandler.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.samplewebsocket.websocket; 2 | 3 | import cn.zifangsky.samplewebsocket.service.EchoService; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.web.socket.CloseStatus; 7 | import org.springframework.web.socket.TextMessage; 8 | import org.springframework.web.socket.WebSocketSession; 9 | import org.springframework.web.socket.handler.TextWebSocketHandler; 10 | 11 | import javax.annotation.Resource; 12 | import java.text.MessageFormat; 13 | 14 | /** 15 | * 通过继承 {@link org.springframework.web.socket.handler.AbstractWebSocketHandler} 的示例 16 | * 17 | * @author zifangsky 18 | * @date 2018/10/9 19 | * @since 1.0.0 20 | */ 21 | public class EchoWebSocketHandler extends TextWebSocketHandler{ 22 | private final Logger logger = LoggerFactory.getLogger(getClass()); 23 | 24 | @Resource(name = "echoServiceImpl") 25 | private EchoService echoService; 26 | 27 | @Override 28 | public void afterConnectionEstablished(WebSocketSession session) throws Exception { 29 | logger.debug("Opened new session in instance " + this); 30 | } 31 | 32 | @Override 33 | protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { 34 | //组装返回的Echo信息 35 | String echoMessage = this.echoService.echo(message.getPayload()); 36 | logger.debug(MessageFormat.format("Echo message \"{0}\"", echoMessage)); 37 | 38 | session.sendMessage(new TextMessage(echoMessage)); 39 | } 40 | 41 | @Override 42 | public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception { 43 | session.close(CloseStatus.SERVER_ERROR); 44 | logger.debug("Info: WebSocket connection closed."); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /sample-websocket/src/main/java/cn/zifangsky/samplewebsocket/websocket/ReverseWebSocketEndpoint.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.samplewebsocket.websocket; 2 | 3 | import javax.websocket.OnMessage; 4 | import javax.websocket.Session; 5 | import javax.websocket.server.ServerEndpoint; 6 | import java.io.IOException; 7 | 8 | /** 9 | * ReverseWebSocketEndpoint 10 | * 11 | * @author zifangsky 12 | * @date 2018/9/30 13 | * @since 1.0.0 14 | */ 15 | @ServerEndpoint("/reverse") 16 | public class ReverseWebSocketEndpoint { 17 | 18 | @OnMessage 19 | public void handleMessage(Session session, String message) throws IOException { 20 | session.getBasicRemote().sendText("Reversed: " + new StringBuilder(message).reverse()); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 7000 3 | servlet: 4 | session.timeout: 300 5 | 6 | logging: 7 | level: 8 | #日志优先级(只会输出指定优先级及以上的日志信息):trace_/___.' >'"". 16 | | | : `- \`.;`\ _ /`;.`/ - ` : | | 17 | \ \ `-. \_ __\ /__ _/ .-` / / 18 | ========`-.____`-.___\_____/___.-`____.-'======== 19 | `=---=' 20 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | 佛祖保佑 永无BUG 22 | -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/favicon.ico -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/css/modules/code.css: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.3 MIT License By https://www.layui.com */ 2 | html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-h3,.layui-code-view{position:relative;font-size:12px}.layui-code-view{display:block;margin:10px 0;padding:0;border:1px solid #e2e2e2;border-left-width:6px;background-color:#F2F2F2;color:#333;font-family:Courier New}.layui-code-h3{padding:0 10px;height:32px;line-height:32px;border-bottom:1px solid #e2e2e2}.layui-code-h3 a{position:absolute;right:10px;top:0;color:#999}.layui-code-view .layui-code-ol{position:relative;overflow:auto}.layui-code-view .layui-code-ol li{position:relative;margin-left:45px;line-height:20px;padding:0 5px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view pre{margin:0}.layui-code-notepad{border:1px solid #0C0C0C;border-left-color:#3F3F3F;background-color:#0C0C0C;color:#C2BE9E}.layui-code-notepad .layui-code-h3{border-bottom:none}.layui-code-notepad .layui-code-ol li{background-color:#3F3F3F;border-left:none} -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/css/modules/layer/default/icon-ext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/css/modules/layer/default/icon-ext.png -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/css/modules/layer/default/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/css/modules/layer/default/icon.png -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/css/modules/layer/default/loading-0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/css/modules/layer/default/loading-0.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/css/modules/layer/default/loading-1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/css/modules/layer/default/loading-1.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/css/modules/layer/default/loading-2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/css/modules/layer/default/loading-2.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/font/iconfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/font/iconfont.eot -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/font/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/font/iconfont.ttf -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/font/iconfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/font/iconfont.woff -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/0.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/1.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/10.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/10.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/11.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/11.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/12.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/12.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/13.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/13.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/14.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/14.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/15.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/15.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/16.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/17.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/17.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/18.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/18.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/19.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/19.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/2.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/20.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/20.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/21.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/21.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/22.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/22.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/23.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/23.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/24.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/24.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/25.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/25.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/26.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/26.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/27.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/27.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/28.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/28.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/29.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/29.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/3.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/30.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/30.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/31.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/31.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/32.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/33.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/33.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/34.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/34.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/35.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/35.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/36.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/36.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/37.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/37.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/38.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/38.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/39.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/39.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/4.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/40.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/40.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/41.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/41.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/42.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/42.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/43.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/43.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/44.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/44.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/45.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/45.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/46.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/46.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/47.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/47.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/48.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/48.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/49.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/49.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/5.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/50.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/50.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/51.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/51.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/52.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/52.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/53.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/53.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/54.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/54.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/55.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/55.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/56.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/56.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/57.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/57.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/58.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/58.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/59.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/59.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/6.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/60.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/60.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/61.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/61.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/62.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/62.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/63.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/63.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/64.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/64.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/65.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/65.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/66.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/66.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/67.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/67.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/68.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/68.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/69.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/69.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/7.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/70.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/70.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/71.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/71.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/8.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/8.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/images/face/9.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/sample-websocket/src/main/resources/static/layui/images/face/9.gif -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/lay/modules/code.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.3 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(e){"use strict";var a=layui.$,l="http://www.layui.com/doc/modules/code.html";e("code",function(e){var t=[];e=e||{},e.elem=a(e.elem||".layui-code"),e.about=!("about"in e)||e.about,e.elem.each(function(){t.push(this)}),layui.each(t.reverse(),function(t,i){var c=a(i),o=c.html();(c.attr("lay-encode")||e.encode)&&(o=o.replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")),c.html('
  1. '+o.replace(/[\r\t\n]+/g,"
  2. ")+"
"),c.find(">.layui-code-h3")[0]||c.prepend('

'+(c.attr("lay-title")||e.title||"code")+(e.about?'layui.code':"")+"

");var d=c.find(">.layui-code-ol");c.addClass("layui-box layui-code-view"),(c.attr("lay-skin")||e.skin)&&c.addClass("layui-code-"+(c.attr("lay-skin")||e.skin)),(d.find("li").length/100|0)>0&&d.css("margin-left",(d.find("li").length/100|0)+"px"),(c.attr("lay-height")||e.height)&&d.css("max-height",c.attr("lay-height")||e.height)})})}).addcss("modules/code.css","skincodecss"); -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/lay/modules/flow.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.3 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(e){"use strict";var l=layui.$,o=function(e){},t='';o.prototype.load=function(e){var o,i,n,r,a=this,c=0;e=e||{};var f=l(e.elem);if(f[0]){var m=l(e.scrollElem||document),u=e.mb||50,s=!("isAuto"in e)||e.isAuto,v=e.end||"没有更多了",y=e.scrollElem&&e.scrollElem!==document,d="加载更多",h=l('");f.find(".layui-flow-more")[0]||f.append(h);var p=function(e,t){e=l(e),h.before(e),t=0==t||null,t?h.html(v):h.find("a").html(d),i=t,o=null,n&&n()},g=function(){o=!0,h.find("a").html(t),"function"==typeof e.done&&e.done(++c,p)};if(g(),h.find("a").on("click",function(){l(this);i||o||g()}),e.isLazyimg)var n=a.lazyimg({elem:e.elem+" img",scrollElem:e.scrollElem});return s?(m.on("scroll",function(){var e=l(this),t=e.scrollTop();r&&clearTimeout(r),i||(r=setTimeout(function(){var i=y?e.height():l(window).height(),n=y?e.prop("scrollHeight"):document.documentElement.scrollHeight;n-t-i<=u&&(o||g())},100))}),a):a}},o.prototype.lazyimg=function(e){var o,t=this,i=0;e=e||{};var n=l(e.scrollElem||document),r=e.elem||"img",a=e.scrollElem&&e.scrollElem!==document,c=function(e,l){var o=n.scrollTop(),r=o+l,c=a?function(){return e.offset().top-n.offset().top+o}():e.offset().top;if(c>=o&&c<=r&&!e.attr("src")){var m=e.attr("lay-src");layui.img(m,function(){var l=t.lazyimg.elem.eq(i);e.attr("src",m).removeAttr("lay-src"),l[0]&&f(l),i++})}},f=function(e,o){var f=a?(o||n).height():l(window).height(),m=n.scrollTop(),u=m+f;if(t.lazyimg.elem=l(r),e)c(e,f);else for(var s=0;su)break}};if(f(),!o){var m;n.on("scroll",function(){var e=l(this);m&&clearTimeout(m),m=setTimeout(function(){f(null,e)},50)}),o=!0}return f},e("flow",new o)}); -------------------------------------------------------------------------------- /sample-websocket/src/main/resources/static/layui/lay/modules/laytpl.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.3 MIT License By https://www.layui.com */ 2 | ;layui.define(function(e){"use strict";var r={open:"{{",close:"}}"},c={exp:function(e){return new RegExp(e,"g")},query:function(e,c,t){var o=["#([\\s\\S])+?","([^{#}])*?"][e||0];return n((c||"")+r.open+o+r.close+(t||""))},escape:function(e){return String(e||"").replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")},error:function(e,r){var c="Laytpl Error:";return"object"==typeof console&&console.error(c+e+"\n"+(r||"")),c+e}},n=c.exp,t=function(e){this.tpl=e};t.pt=t.prototype,window.errors=0,t.pt.parse=function(e,t){var o=this,p=e,a=n("^"+r.open+"#",""),l=n(r.close+"$","");e=e.replace(/\s+|\r|\t|\n/g," ").replace(n(r.open+"#"),r.open+"# ").replace(n(r.close+"}"),"} "+r.close).replace(/\\/g,"\\\\").replace(n(r.open+"!(.+?)!"+r.close),function(e){return e=e.replace(n("^"+r.open+"!"),"").replace(n("!"+r.close),"").replace(n(r.open+"|"+r.close),function(e){return e.replace(/(.)/g,"\\$1")})}).replace(/(?="|')/g,"\\").replace(c.query(),function(e){return e=e.replace(a,"").replace(l,""),'";'+e.replace(/\\/g,"")+';view+="'}).replace(c.query(1),function(e){var c='"+(';return e.replace(/\s/g,"")===r.open+r.close?"":(e=e.replace(n(r.open+"|"+r.close),""),/^=/.test(e)&&(e=e.replace(/^=/,""),c='"+_escape_('),c+e.replace(/\\/g,"")+')+"')}),e='"use strict";var view = "'+e+'";return view;';try{return o.cache=e=new Function("d, _escape_",e),e(t,c.escape)}catch(u){return delete o.cache,c.error(u,p)}},t.pt.render=function(e,r){var n,t=this;return e?(n=t.cache?t.cache(e,c.escape):t.parse(t.tpl,e),r?void r(n):n):c.error("no data")};var o=function(e){return"string"!=typeof e?c.error("Template not found"):new t(e)};o.config=function(e){e=e||{};for(var c in e)r[c]=e[c]},o.v="1.2.0",e("laytpl",o)}); -------------------------------------------------------------------------------- /sample-websocket/src/test/java/cn/zifangsky/samplewebsocket/SampleWebsocketApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.samplewebsocket; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SampleWebsocketApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /stomp-websocket/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /stomp-websocket/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /stomp-websocket/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip 2 | -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/StompWebsocketApplication.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.web.servlet.ServletComponentScan; 7 | import org.springframework.scheduling.annotation.EnableAsync; 8 | 9 | @SpringBootApplication 10 | @ServletComponentScan 11 | @EnableAsync 12 | @MapperScan("cn.zifangsky.stompwebsocket.mapper") 13 | public class StompWebsocketApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(StompWebsocketApplication.class, args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/common/Constants.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.common; 2 | 3 | /** 4 | * 公共常量类 5 | * 6 | * @author zifangsky 7 | * @date 2018/7/25 8 | * @since 1.0.0 9 | */ 10 | public class Constants { 11 | /** 12 | * 用户信息在session中存储的变量名 13 | */ 14 | public static final String SESSION_USER = "SESSION_USER"; 15 | 16 | /** 17 | * 登录页面的回调地址在session中存储的变量名 18 | */ 19 | public static final String SESSION_LOGIN_REDIRECT_URL = "LOGIN_REDIRECT_URL"; 20 | 21 | /** 22 | * 用户未读的WebSocket消息在Redis中存储的变量名的前缀 23 | */ 24 | public static final String REDIS_UNREAD_MSG_PREFIX = "stomp-websocket:unread_msg:"; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/config/WebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.config; 2 | 3 | import cn.zifangsky.stompwebsocket.interceptor.LoginInterceptor; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 6 | import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; 7 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 8 | 9 | /** 10 | * Web相关配置 11 | * @author zifangsky 12 | * @date 2018/7/9 13 | * @since 1.0.0 14 | */ 15 | @Configuration 16 | public class WebMvcConfig implements WebMvcConfigurer { 17 | 18 | /** 19 | * 视图控制器 20 | */ 21 | @Override 22 | public void addViewControllers(ViewControllerRegistry registry) { 23 | registry.addViewController("/index").setViewName("index"); 24 | registry.addViewController("/stomp").setViewName("websocket/stomp"); 25 | registry.addViewController("/chat").setViewName("websocket/chat"); 26 | } 27 | 28 | /** 29 | * 添加拦截器 30 | */ 31 | @Override 32 | public void addInterceptors(InterceptorRegistry registry) { 33 | registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/user/**","/chat","/sendToUser","/pullUnreadMessage"); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/config/WebSocketConfig.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.config; 2 | 3 | import cn.zifangsky.stompwebsocket.interceptor.websocket.AuthHandshakeInterceptor; 4 | import cn.zifangsky.stompwebsocket.interceptor.websocket.MyChannelInterceptor; 5 | import cn.zifangsky.stompwebsocket.interceptor.websocket.MyHandshakeHandler; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.messaging.simp.config.ChannelRegistration; 9 | import org.springframework.messaging.simp.config.MessageBrokerRegistry; 10 | import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker; 11 | import org.springframework.web.socket.config.annotation.StompEndpointRegistry; 12 | import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; 13 | 14 | /** 15 | * WebSocket相关配置 16 | * 17 | * @author zifangsky 18 | * @date 2018/9/30 19 | * @since 1.0.0 20 | */ 21 | @Configuration 22 | @EnableWebSocketMessageBroker 23 | public class WebSocketConfig implements WebSocketMessageBrokerConfigurer{ 24 | @Autowired 25 | private AuthHandshakeInterceptor authHandshakeInterceptor; 26 | 27 | @Autowired 28 | private MyHandshakeHandler myHandshakeHandler; 29 | 30 | @Autowired 31 | private MyChannelInterceptor myChannelInterceptor; 32 | 33 | @Override 34 | public void registerStompEndpoints(StompEndpointRegistry registry) { 35 | registry.addEndpoint("/stomp-websocket").withSockJS(); 36 | 37 | registry.addEndpoint("/chat-websocket") 38 | .addInterceptors(authHandshakeInterceptor) 39 | .setHandshakeHandler(myHandshakeHandler) 40 | .withSockJS(); 41 | } 42 | 43 | @Override 44 | public void configureMessageBroker(MessageBrokerRegistry registry) { 45 | //客户端需要把消息发送到/message/xxx地址 46 | registry.setApplicationDestinationPrefixes("/message"); 47 | //服务端广播消息的路径前缀,客户端需要相应订阅/topic/yyy这个地址的消息 48 | registry.enableSimpleBroker("/topic"); 49 | //给指定用户发送消息的路径前缀,默认值是/user/ 50 | registry.setUserDestinationPrefix("/user/"); 51 | } 52 | 53 | @Override 54 | public void configureClientInboundChannel(ChannelRegistration registration) { 55 | registration.interceptors(myChannelInterceptor); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/controller/GreetingController.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.controller; 2 | 3 | import cn.zifangsky.stompwebsocket.model.websocket.Greeting; 4 | import cn.zifangsky.stompwebsocket.model.websocket.HelloMessage; 5 | import org.springframework.messaging.handler.annotation.MessageMapping; 6 | import org.springframework.messaging.handler.annotation.SendTo; 7 | import org.springframework.stereotype.Controller; 8 | 9 | /** 10 | * Greeting 11 | * @author zifangsky 12 | * @date 2018/9/30 13 | * @since 1.0.0 14 | */ 15 | @Controller 16 | public class GreetingController { 17 | 18 | @MessageMapping("/hello") 19 | @SendTo("/topic/greeting") 20 | public HelloMessage greeting(Greeting greeting) { 21 | return new HelloMessage("Hello," + greeting.getName() + "!"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/enums/ExpireEnum.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.enums; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | 5 | /** 6 | * 过期时间相关枚举 7 | * 8 | * @author zifangsky 9 | * @date 2018/10/11 10 | * @since 1.0.0 11 | */ 12 | public enum ExpireEnum { 13 | //未读消息的有效期为30天 14 | UNREAD_MSG(30L, TimeUnit.DAYS) 15 | ; 16 | 17 | /** 18 | * 过期时间 19 | */ 20 | private Long time; 21 | /** 22 | * 时间单位 23 | */ 24 | private TimeUnit timeUnit; 25 | 26 | ExpireEnum(Long time, TimeUnit timeUnit) { 27 | this.time = time; 28 | this.timeUnit = timeUnit; 29 | } 30 | 31 | public Long getTime() { 32 | return time; 33 | } 34 | 35 | public TimeUnit getTimeUnit() { 36 | return timeUnit; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/interceptor/LoginInterceptor.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.interceptor; 2 | 3 | import cn.zifangsky.stompwebsocket.common.Constants; 4 | import cn.zifangsky.stompwebsocket.common.SpringContextUtils; 5 | import cn.zifangsky.stompwebsocket.model.User; 6 | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; 7 | 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | import javax.servlet.http.HttpSession; 11 | 12 | /** 13 | * 定义一些页面需要做登录检查 14 | * 15 | * @author zifangsky 16 | * @date 2018/7/26 17 | * @since 1.0.0 18 | */ 19 | public class LoginInterceptor extends HandlerInterceptorAdapter{ 20 | 21 | /** 22 | * 检查是否已经登录 23 | */ 24 | @Override 25 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 26 | HttpSession session = request.getSession(); 27 | 28 | //获取session中存储的token 29 | User user = (User) session.getAttribute(Constants.SESSION_USER); 30 | 31 | if(user != null){ 32 | return true; 33 | }else{ 34 | //如果token不存在,则跳转到登录页面 35 | response.sendRedirect(request.getContextPath() + "/login?redirectUri=" + SpringContextUtils.getRequestUrl(request)); 36 | 37 | return false; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/interceptor/websocket/AuthHandshakeInterceptor.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.interceptor.websocket; 2 | 3 | import cn.zifangsky.stompwebsocket.common.Constants; 4 | import cn.zifangsky.stompwebsocket.common.SpringContextUtils; 5 | import cn.zifangsky.stompwebsocket.model.User; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.http.server.ServerHttpRequest; 9 | import org.springframework.http.server.ServerHttpResponse; 10 | import org.springframework.stereotype.Component; 11 | import org.springframework.web.socket.WebSocketHandler; 12 | import org.springframework.web.socket.server.HandshakeInterceptor; 13 | 14 | import javax.servlet.http.HttpSession; 15 | import java.text.MessageFormat; 16 | import java.util.Map; 17 | 18 | /** 19 | * 自定义{@link org.springframework.web.socket.server.HandshakeInterceptor},实现“需要登录才允许连接WebSocket” 20 | * 21 | * @author zifangsky 22 | * @date 2018/10/11 23 | * @since 1.0.0 24 | */ 25 | @Component 26 | public class AuthHandshakeInterceptor implements HandshakeInterceptor { 27 | private final Logger logger = LoggerFactory.getLogger(getClass()); 28 | 29 | @Override 30 | public boolean beforeHandshake(ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse, WebSocketHandler webSocketHandler, Map map) throws Exception { 31 | HttpSession session = SpringContextUtils.getSession(); 32 | User loginUser = (User) session.getAttribute(Constants.SESSION_USER); 33 | 34 | if(loginUser != null){ 35 | logger.debug(MessageFormat.format("用户{0}请求建立WebSocket连接", loginUser.getUsername())); 36 | return true; 37 | }else{ 38 | logger.error("未登录系统,禁止连接WebSocket"); 39 | return false; 40 | } 41 | 42 | } 43 | 44 | @Override 45 | public void afterHandshake(ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse, WebSocketHandler webSocketHandler, Exception e) { 46 | 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/interceptor/websocket/MyChannelInterceptor.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.interceptor.websocket; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.messaging.Message; 7 | import org.springframework.messaging.MessageChannel; 8 | import org.springframework.messaging.simp.stomp.StompCommand; 9 | import org.springframework.messaging.simp.stomp.StompHeaderAccessor; 10 | import org.springframework.messaging.support.ChannelInterceptor; 11 | import org.springframework.stereotype.Component; 12 | 13 | import java.security.Principal; 14 | import java.text.MessageFormat; 15 | 16 | /** 17 | * 自定义{@link org.springframework.messaging.support.ChannelInterceptor},实现断开连接的处理 18 | * 19 | * @author zifangsky 20 | * @date 2018/10/10 21 | * @since 1.0.0 22 | */ 23 | @Component 24 | public class MyChannelInterceptor implements ChannelInterceptor{ 25 | private final Logger logger = LoggerFactory.getLogger(getClass()); 26 | 27 | @Override 28 | public void afterSendCompletion(Message message, MessageChannel channel, boolean sent, Exception ex) { 29 | StompHeaderAccessor accessor = StompHeaderAccessor.wrap(message); 30 | StompCommand command = accessor.getCommand(); 31 | 32 | //用户已经断开连接 33 | if(StompCommand.DISCONNECT.equals(command)){ 34 | String user = ""; 35 | Principal principal = accessor.getUser(); 36 | if(principal != null && StringUtils.isNoneBlank(principal.getName())){ 37 | user = principal.getName(); 38 | }else{ 39 | user = accessor.getSessionId(); 40 | } 41 | 42 | logger.debug(MessageFormat.format("用户{0}的WebSocket连接已经断开", user)); 43 | } 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/interceptor/websocket/MyHandshakeHandler.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.interceptor.websocket; 2 | 3 | import cn.zifangsky.stompwebsocket.common.Constants; 4 | import cn.zifangsky.stompwebsocket.common.SpringContextUtils; 5 | import cn.zifangsky.stompwebsocket.model.User; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.http.server.ServerHttpRequest; 9 | import org.springframework.stereotype.Component; 10 | import org.springframework.web.socket.WebSocketHandler; 11 | import org.springframework.web.socket.server.support.DefaultHandshakeHandler; 12 | 13 | import javax.servlet.http.HttpSession; 14 | import java.security.Principal; 15 | import java.text.MessageFormat; 16 | import java.util.Map; 17 | 18 | /** 19 | * 自定义{@link org.springframework.web.socket.server.support.DefaultHandshakeHandler},实现“生成自定义的{@link java.security.Principal}” 20 | * 21 | * @author zifangsky 22 | * @date 2018/10/11 23 | * @since 1.0.0 24 | */ 25 | @Component 26 | public class MyHandshakeHandler extends DefaultHandshakeHandler{ 27 | private final Logger logger = LoggerFactory.getLogger(getClass()); 28 | 29 | @Override 30 | protected Principal determineUser(ServerHttpRequest request, WebSocketHandler wsHandler, Map attributes) { 31 | HttpSession session = SpringContextUtils.getSession(); 32 | User loginUser = (User) session.getAttribute(Constants.SESSION_USER); 33 | 34 | if(loginUser != null){ 35 | logger.debug(MessageFormat.format("WebSocket连接开始创建Principal,用户:{0}", loginUser.getUsername())); 36 | return new MyPrincipal(loginUser.getUsername()); 37 | }else{ 38 | logger.error("未登录系统,禁止连接WebSocket"); 39 | return null; 40 | } 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/interceptor/websocket/MyPrincipal.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.interceptor.websocket; 2 | 3 | import java.security.Principal; 4 | 5 | /** 6 | * 自定义{@link java.security.Principal} 7 | * 8 | * @author zifangsky 9 | * @date 2018/10/11 10 | * @since 1.0.0 11 | */ 12 | public class MyPrincipal implements Principal { 13 | private String loginName; 14 | 15 | public MyPrincipal(String loginName) { 16 | this.loginName = loginName; 17 | } 18 | 19 | @Override 20 | public String getName() { 21 | return loginName; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/mapper/FuncMapper.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.mapper; 2 | 3 | import cn.zifangsky.stompwebsocket.model.Func; 4 | 5 | public interface FuncMapper { 6 | int deleteByPrimaryKey(Integer id); 7 | 8 | int insert(Func record); 9 | 10 | int insertSelective(Func record); 11 | 12 | Func selectByPrimaryKey(Integer id); 13 | 14 | int updateByPrimaryKeySelective(Func record); 15 | 16 | int updateByPrimaryKey(Func record); 17 | } -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/mapper/RoleFuncMapper.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.mapper; 2 | 3 | import cn.zifangsky.stompwebsocket.model.RoleFunc; 4 | 5 | public interface RoleFuncMapper { 6 | int deleteByPrimaryKey(Integer id); 7 | 8 | int insert(RoleFunc record); 9 | 10 | int insertSelective(RoleFunc record); 11 | 12 | RoleFunc selectByPrimaryKey(Integer id); 13 | 14 | int updateByPrimaryKeySelective(RoleFunc record); 15 | 16 | int updateByPrimaryKey(RoleFunc record); 17 | } -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/mapper/RoleMapper.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.mapper; 2 | 3 | import cn.zifangsky.stompwebsocket.model.Role; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | public interface RoleMapper { 7 | int deleteByPrimaryKey(Integer id); 8 | 9 | int insert(Role record); 10 | 11 | int insertSelective(Role record); 12 | 13 | Role selectByPrimaryKey(Integer id); 14 | 15 | int updateByPrimaryKeySelective(Role record); 16 | 17 | int updateByPrimaryKey(Role record); 18 | 19 | Role selectByRoleName(@Param("roleName") String roleName); 20 | 21 | } -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.mapper; 2 | 3 | import cn.zifangsky.stompwebsocket.model.User; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | public interface UserMapper { 7 | int deleteByPrimaryKey(Integer id); 8 | 9 | int insert(User user); 10 | 11 | int insertSelective(User user); 12 | 13 | User selectByPrimaryKey(Integer id); 14 | 15 | int updateByPrimaryKeySelective(User user); 16 | 17 | int updateByPrimaryKey(User user); 18 | 19 | User selectByUsername(@Param("username") String username); 20 | 21 | } -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/mapper/UserRoleMapper.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.mapper; 2 | 3 | import cn.zifangsky.stompwebsocket.model.UserRole; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | import java.util.List; 7 | 8 | public interface UserRoleMapper { 9 | int deleteByPrimaryKey(Integer id); 10 | 11 | int insert(UserRole record); 12 | 13 | int insertSelective(UserRole record); 14 | 15 | UserRole selectByPrimaryKey(Integer id); 16 | 17 | int updateByPrimaryKeySelective(UserRole record); 18 | 19 | int updateByPrimaryKey(UserRole record); 20 | 21 | /** 22 | * 通过用户ID和角色ID查询用户角色信息 23 | * @author zifangsky 24 | * @date 2018/8/18 11:10 25 | * @since 1.0.0 26 | * @param userId 用户ID 27 | * @param roleId 角色ID 28 | * @return cn.zifangsky.model.UserRole 29 | */ 30 | UserRole selectByUserIdRoleId(@Param("userId") Integer userId, @Param("roleId") Integer roleId); 31 | 32 | /** 33 | * 通过角色名查询用户角色信息 34 | * @author zifangsky 35 | * @date 2018/8/18 11:10 36 | * @since 1.0.0 37 | * @param roleName 角色名 38 | * @return cn.zifangsky.model.UserRole 39 | */ 40 | UserRole selectByRoleName(@Param("roleName") String roleName); 41 | 42 | /** 43 | * 通过用户ID查询用户角色信息 44 | * @author zifangsky 45 | * @date 2018/8/18 11:10 46 | * @since 1.0.0 47 | * @param userId 用户ID 48 | * @return cn.zifangsky.model.UserRole 49 | */ 50 | List selectByUserId(@Param("userId") Integer userId); 51 | } -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/model/Func.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.model; 2 | 3 | import java.util.Objects; 4 | 5 | public class Func { 6 | private Integer id; 7 | 8 | private String name; 9 | 10 | private String description; 11 | 12 | private String code; 13 | 14 | private String url; 15 | 16 | private Integer status; 17 | 18 | public Integer getId() { 19 | return id; 20 | } 21 | 22 | public void setId(Integer id) { 23 | this.id = id; 24 | } 25 | 26 | public String getName() { 27 | return name; 28 | } 29 | 30 | public void setName(String name) { 31 | this.name = name == null ? null : name.trim(); 32 | } 33 | 34 | public String getDescription() { 35 | return description; 36 | } 37 | 38 | public void setDescription(String description) { 39 | this.description = description == null ? null : description.trim(); 40 | } 41 | 42 | public String getCode() { 43 | return code; 44 | } 45 | 46 | public void setCode(String code) { 47 | this.code = code == null ? null : code.trim(); 48 | } 49 | 50 | public String getUrl() { 51 | return url; 52 | } 53 | 54 | public void setUrl(String url) { 55 | this.url = url == null ? null : url.trim(); 56 | } 57 | 58 | public Integer getStatus() { 59 | return status; 60 | } 61 | 62 | public void setStatus(Integer status) { 63 | this.status = status; 64 | } 65 | 66 | @Override 67 | public boolean equals(Object o) { 68 | if (this == o) return true; 69 | if (o == null || getClass() != o.getClass()) return false; 70 | Func func = (Func) o; 71 | return Objects.equals(id, func.id) && 72 | Objects.equals(name, func.name) && 73 | Objects.equals(description, func.description) && 74 | Objects.equals(code, func.code) && 75 | Objects.equals(url, func.url) && 76 | Objects.equals(status, func.status); 77 | } 78 | 79 | @Override 80 | public int hashCode() { 81 | 82 | return Objects.hash(id, name, description, code, url, status); 83 | } 84 | } -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/model/Role.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.model; 2 | 3 | import java.util.Objects; 4 | 5 | public class Role { 6 | private Integer id; 7 | 8 | private String roleName; 9 | 10 | private String description; 11 | 12 | public Integer getId() { 13 | return id; 14 | } 15 | 16 | public void setId(Integer id) { 17 | this.id = id; 18 | } 19 | 20 | public String getRoleName() { 21 | return roleName; 22 | } 23 | 24 | public void setRoleName(String roleName) { 25 | this.roleName = roleName == null ? null : roleName.trim(); 26 | } 27 | 28 | public String getDescription() { 29 | return description; 30 | } 31 | 32 | public void setDescription(String description) { 33 | this.description = description == null ? null : description.trim(); 34 | } 35 | 36 | @Override 37 | public String toString() { 38 | return "Role{" + 39 | "id=" + id + 40 | ", roleName='" + roleName + '\'' + 41 | ", description='" + description + '\'' + 42 | '}'; 43 | } 44 | 45 | @Override 46 | public boolean equals(Object o) { 47 | if (this == o) return true; 48 | if (o == null || getClass() != o.getClass()) return false; 49 | Role role = (Role) o; 50 | return Objects.equals(id, role.id) && 51 | Objects.equals(roleName, role.roleName) && 52 | Objects.equals(description, role.description); 53 | } 54 | 55 | @Override 56 | public int hashCode() { 57 | return Objects.hash(id, roleName, description); 58 | } 59 | } -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/model/RoleFunc.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.model; 2 | 3 | public class RoleFunc { 4 | private Integer id; 5 | 6 | private Integer roleId; 7 | 8 | private Integer funcId; 9 | 10 | public Integer getId() { 11 | return id; 12 | } 13 | 14 | public void setId(Integer id) { 15 | this.id = id; 16 | } 17 | 18 | public Integer getRoleId() { 19 | return roleId; 20 | } 21 | 22 | public void setRoleId(Integer roleId) { 23 | this.roleId = roleId; 24 | } 25 | 26 | public Integer getFuncId() { 27 | return funcId; 28 | } 29 | 30 | public void setFuncId(Integer funcId) { 31 | this.funcId = funcId; 32 | } 33 | } -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/model/User.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.model; 2 | 3 | import java.util.Date; 4 | 5 | public class User { 6 | private Integer id; 7 | 8 | private String username; 9 | 10 | private String password; 11 | 12 | private String mobile; 13 | 14 | private String email; 15 | 16 | private Date createTime; 17 | 18 | private Date updateTime; 19 | 20 | private Integer status; 21 | 22 | public Integer getId() { 23 | return id; 24 | } 25 | 26 | public void setId(Integer id) { 27 | this.id = id; 28 | } 29 | 30 | public String getUsername() { 31 | return username; 32 | } 33 | 34 | public void setUsername(String username) { 35 | this.username = username == null ? null : username.trim(); 36 | } 37 | 38 | public String getPassword() { 39 | return password; 40 | } 41 | 42 | public void setPassword(String password) { 43 | this.password = password == null ? null : password.trim(); 44 | } 45 | 46 | public String getMobile() { 47 | return mobile; 48 | } 49 | 50 | public void setMobile(String mobile) { 51 | this.mobile = mobile == null ? null : mobile.trim(); 52 | } 53 | 54 | public String getEmail() { 55 | return email; 56 | } 57 | 58 | public void setEmail(String email) { 59 | this.email = email == null ? null : email.trim(); 60 | } 61 | 62 | public Date getCreateTime() { 63 | return createTime; 64 | } 65 | 66 | public void setCreateTime(Date createTime) { 67 | this.createTime = createTime; 68 | } 69 | 70 | public Date getUpdateTime() { 71 | return updateTime; 72 | } 73 | 74 | public void setUpdateTime(Date updateTime) { 75 | this.updateTime = updateTime; 76 | } 77 | 78 | public Integer getStatus() { 79 | return status; 80 | } 81 | 82 | public void setStatus(Integer status) { 83 | this.status = status; 84 | } 85 | 86 | @Override 87 | public String toString() { 88 | return "User{" + 89 | "id=" + id + 90 | ", username='" + username + '\'' + 91 | ", password='" + password + '\'' + 92 | ", mobile='" + mobile + '\'' + 93 | ", email='" + email + '\'' + 94 | ", createTime=" + createTime + 95 | ", updateTime=" + updateTime + 96 | ", status=" + status + 97 | '}'; 98 | } 99 | } -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/model/UserRole.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.model; 2 | 3 | public class UserRole { 4 | public UserRole() { 5 | } 6 | 7 | public UserRole(Integer userId, Integer roleId) { 8 | this.userId = userId; 9 | this.roleId = roleId; 10 | } 11 | 12 | private Integer id; 13 | 14 | private Integer userId; 15 | 16 | private Integer roleId; 17 | 18 | public Integer getId() { 19 | return id; 20 | } 21 | 22 | public void setId(Integer id) { 23 | this.id = id; 24 | } 25 | 26 | public Integer getUserId() { 27 | return userId; 28 | } 29 | 30 | public void setUserId(Integer userId) { 31 | this.userId = userId; 32 | } 33 | 34 | public Integer getRoleId() { 35 | return roleId; 36 | } 37 | 38 | public void setRoleId(Integer roleId) { 39 | this.roleId = roleId; 40 | } 41 | } -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/model/websocket/Greeting.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.model.websocket; 2 | 3 | /** 4 | * Hello 5 | * 6 | * @author zifangsky 7 | * @date 2018/9/30 8 | * @since 1.0.0 9 | */ 10 | public class Greeting { 11 | private String name; 12 | 13 | public Greeting() { 14 | 15 | } 16 | 17 | public Greeting(String name) { 18 | this.name = name; 19 | } 20 | 21 | public String getName() { 22 | return name; 23 | } 24 | 25 | public void setName(String name) { 26 | this.name = name; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/model/websocket/HelloMessage.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.model.websocket; 2 | 3 | /** 4 | * Greeting 5 | * 6 | * @author zifangsky 7 | * @date 2018/9/30 8 | * @since 1.0.0 9 | */ 10 | public class HelloMessage { 11 | private String content; 12 | 13 | public HelloMessage() { 14 | 15 | } 16 | 17 | public HelloMessage(String content) { 18 | this.content = content; 19 | } 20 | 21 | public String getContent() { 22 | return content; 23 | } 24 | 25 | public void setContent(String content) { 26 | this.content = content; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/service/EchoService.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.service; 2 | 3 | /** 4 | * Echo Demo 5 | * @author zifangsky 6 | * @date 2018/10/9 7 | * @since 1.0.0 8 | */ 9 | public interface EchoService { 10 | String echo(String message); 11 | } 12 | -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/service/RedisService.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.service; 2 | 3 | import cn.zifangsky.stompwebsocket.enums.ExpireEnum; 4 | 5 | import java.util.List; 6 | import java.util.concurrent.TimeUnit; 7 | 8 | /** 9 | * RedisService 10 | * 11 | * @author zifangsky 12 | * @date 2018/7/30 13 | * @since 1.0.0 14 | */ 15 | public interface RedisService { 16 | 17 | /** 18 | * 向Redis中存储键值对 19 | * @author zifangsky 20 | * @date 2018/7/30 17:02 21 | * @since 1.0.0 22 | * @param key KEY 23 | * @param value VALUE 24 | */ 25 | void set(String key, Object value); 26 | 27 | /** 28 | * 向Redis中存储键值对,并设置过期时间 29 | * @author zifangsky 30 | * @date 2018/7/30 17:02 31 | * @since 1.0.0 32 | * @param key KEY 33 | * @param value VALUE 34 | * @param time 过期时间 35 | * @param timeUnit 时间单位 36 | */ 37 | void setWithExpire(String key, Object value, long time, TimeUnit timeUnit); 38 | 39 | /** 40 | * 从Redis中获取键值对 41 | * @author zifangsky 42 | * @date 2018/7/30 17:04 43 | * @since 1.0.0 44 | * @param key KEY 45 | * @return K 46 | */ 47 | K get(String key); 48 | 49 | /** 50 | * 删除Redis中的某个KEY 51 | * @author zifangsky 52 | * @date 2018/7/30 17:10 53 | * @since 1.0.0 54 | * @param key KEY 55 | * @return boolean 56 | */ 57 | boolean delete(String key); 58 | 59 | /** 60 | * 将数据添加到Redis的list中(从左边添加) 61 | * @author zifangsky 62 | * @date 2018/10/12 10:13 63 | * @since 1.0.0 64 | * @param listKey LIST的key 65 | * @param expireEnum 有效期的枚举类 66 | * @param values 待添加的数据 67 | */ 68 | void addToListLeft(String listKey, ExpireEnum expireEnum, Object... values); 69 | 70 | /** 71 | * 将数据添加到Redis的list中(从右边添加) 72 | * @author zifangsky 73 | * @date 2018/10/12 10:13 74 | * @since 1.0.0 75 | * @param listKey LIST的key 76 | * @param expireEnum 有效期的枚举类 77 | * @param values 待添加的数据 78 | */ 79 | void addToListRight(String listKey, ExpireEnum expireEnum, Object... values); 80 | 81 | /** 82 | * 根据起始结束序号遍历Redis中的list 83 | * @author zifangsky 84 | * @date 2018/10/12 10:15 85 | * @since 1.0.0 86 | * @param listKey LIST的key 87 | * @param start 起始序号 88 | * @param end 结束序号 89 | */ 90 | List rangeList(String listKey, long start, long end); 91 | } 92 | -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/service/UserService.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.service; 2 | 3 | import cn.zifangsky.stompwebsocket.model.User; 4 | 5 | import java.util.Map; 6 | 7 | /** 8 | * 用于相关Service 9 | * @author zifangsky 10 | * @date 2018/7/27 11 | * @since 1.0.0 12 | */ 13 | public interface UserService { 14 | /** 15 | * 通过用户ID查询用户信息 16 | * @author zifangsky 17 | * @date 2018/8/23 15:07 18 | * @since 1.0.0 19 | * @param userId 用户ID 20 | * @return cn.zifangsky.model.User 21 | */ 22 | User selectByUserId(Integer userId); 23 | 24 | /** 25 | * 注册 26 | * @author zifangsky 27 | * @date 2018/7/27 10:48 28 | * @since 1.0.0 29 | * @param user 用户详情 30 | * @return boolean 31 | */ 32 | boolean register(User user); 33 | 34 | /** 35 | * 登录校验 36 | * @author zifangsky 37 | * @date 2018/7/27 10:48 38 | * @since 1.0.0 39 | * @param username 用户名 40 | * @param password 密码 41 | * @return java.util.Map 42 | */ 43 | Map checkLogin(String username, String password); 44 | 45 | /** 46 | * 给用户添加角色信息 47 | * @author zifangsky 48 | * @date 2018/8/10 17:30 49 | * @since 1.0.0 50 | * @param userId 用户ID 51 | * @param roleName 角色名 52 | */ 53 | void addUserRole(Integer userId, String roleName); 54 | 55 | } 56 | -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/service/impl/EchoServiceImpl.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.service.impl; 2 | 3 | import cn.zifangsky.stompwebsocket.service.EchoService; 4 | import org.springframework.stereotype.Service; 5 | 6 | import java.text.MessageFormat; 7 | 8 | /** 9 | * Echo Demo 10 | * @author zifangsky 11 | * @date 2018/10/9 12 | * @since 1.0.0 13 | */ 14 | @Service("echoServiceImpl") 15 | public class EchoServiceImpl implements EchoService{ 16 | 17 | @Override 18 | public String echo(String message) { 19 | return MessageFormat.format("Did you say \"{0}\"?", message); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/utils/JsonUtils.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.utils; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | 5 | /** 6 | * JSON相关公共方法(通过Fastjson实现) 7 | * 8 | * @author zifangsky 9 | * @date 2017/5/2 10 | * @since 1.0.0 11 | */ 12 | public class JsonUtils { 13 | 14 | /** 15 | * 将对象转化为json字符串 16 | * @param source Java对象 17 | * @return java.lang.String 18 | */ 19 | public static String toJson(K source){ 20 | return JSON.toJSON(source).toString(); 21 | } 22 | 23 | /** 24 | * 将json字符串还原为目标对象 25 | * @param source json字符串 26 | * @return K 27 | */ 28 | public static T fromJson(String source, Class clazz){ 29 | return JSON.parseObject(source, clazz); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/websocket/EchoWebSocketHandler.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.websocket; 2 | 3 | import cn.zifangsky.stompwebsocket.service.EchoService; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.web.socket.CloseStatus; 7 | import org.springframework.web.socket.TextMessage; 8 | import org.springframework.web.socket.WebSocketSession; 9 | import org.springframework.web.socket.handler.TextWebSocketHandler; 10 | 11 | import javax.annotation.Resource; 12 | import java.text.MessageFormat; 13 | 14 | /** 15 | * 通过继承 {@link org.springframework.web.socket.handler.AbstractWebSocketHandler} 的示例 16 | * 17 | * @author zifangsky 18 | * @date 2018/10/9 19 | * @since 1.0.0 20 | */ 21 | public class EchoWebSocketHandler extends TextWebSocketHandler{ 22 | private final Logger logger = LoggerFactory.getLogger(getClass()); 23 | 24 | @Resource(name = "echoServiceImpl") 25 | private EchoService echoService; 26 | 27 | @Override 28 | public void afterConnectionEstablished(WebSocketSession session) throws Exception { 29 | logger.debug("Opened new session in instance " + this); 30 | } 31 | 32 | @Override 33 | protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { 34 | //组装返回的Echo信息 35 | String echoMessage = this.echoService.echo(message.getPayload()); 36 | logger.debug(MessageFormat.format("Echo message \"{0}\"", echoMessage)); 37 | 38 | session.sendMessage(new TextMessage(echoMessage)); 39 | } 40 | 41 | @Override 42 | public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception { 43 | session.close(CloseStatus.SERVER_ERROR); 44 | logger.debug("Info: WebSocket connection closed."); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /stomp-websocket/src/main/java/cn/zifangsky/stompwebsocket/websocket/ReverseWebSocketEndpoint.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket.websocket; 2 | 3 | import javax.websocket.OnMessage; 4 | import javax.websocket.Session; 5 | import javax.websocket.server.ServerEndpoint; 6 | import java.io.IOException; 7 | 8 | /** 9 | * ReverseWebSocketEndpoint 10 | * 11 | * @author zifangsky 12 | * @date 2018/9/30 13 | * @since 1.0.0 14 | */ 15 | @ServerEndpoint("/reverse") 16 | public class ReverseWebSocketEndpoint { 17 | 18 | @OnMessage 19 | public void handleMessage(Session session, String message) throws IOException { 20 | session.getBasicRemote().sendText("Reversed: " + new StringBuilder(message).reverse()); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 7001 3 | servlet: 4 | session.timeout: 300 5 | 6 | logging: 7 | level: 8 | #日志优先级(只会输出指定优先级及以上的日志信息):trace_/___.' >'"". 16 | | | : `- \`.;`\ _ /`;.`/ - ` : | | 17 | \ \ `-. \_ __\ /__ _/ .-` / / 18 | ========`-.____`-.___\_____/___.-`____.-'======== 19 | `=---=' 20 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 21 | 佛祖保佑 永无BUG 22 | -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/favicon.ico -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/img/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/img/1.jpg -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/img/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/img/2.jpg -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/img/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/img/3.jpg -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/img/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/img/4.jpg -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/img/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/img/5.jpg -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/img/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/img/6.jpg -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/css/modules/code.css: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.3 MIT License By https://www.layui.com */ 2 | html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-h3,.layui-code-view{position:relative;font-size:12px}.layui-code-view{display:block;margin:10px 0;padding:0;border:1px solid #e2e2e2;border-left-width:6px;background-color:#F2F2F2;color:#333;font-family:Courier New}.layui-code-h3{padding:0 10px;height:32px;line-height:32px;border-bottom:1px solid #e2e2e2}.layui-code-h3 a{position:absolute;right:10px;top:0;color:#999}.layui-code-view .layui-code-ol{position:relative;overflow:auto}.layui-code-view .layui-code-ol li{position:relative;margin-left:45px;line-height:20px;padding:0 5px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view pre{margin:0}.layui-code-notepad{border:1px solid #0C0C0C;border-left-color:#3F3F3F;background-color:#0C0C0C;color:#C2BE9E}.layui-code-notepad .layui-code-h3{border-bottom:none}.layui-code-notepad .layui-code-ol li{background-color:#3F3F3F;border-left:none} -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/css/modules/layer/default/icon-ext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/css/modules/layer/default/icon-ext.png -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/css/modules/layer/default/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/css/modules/layer/default/icon.png -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/css/modules/layer/default/loading-0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/css/modules/layer/default/loading-0.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/css/modules/layer/default/loading-1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/css/modules/layer/default/loading-1.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/css/modules/layer/default/loading-2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/css/modules/layer/default/loading-2.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/font/iconfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/font/iconfont.eot -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/font/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/font/iconfont.ttf -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/font/iconfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/font/iconfont.woff -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/0.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/1.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/10.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/10.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/11.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/11.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/12.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/12.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/13.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/13.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/14.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/14.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/15.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/15.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/16.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/17.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/17.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/18.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/18.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/19.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/19.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/2.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/20.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/20.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/21.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/21.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/22.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/22.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/23.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/23.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/24.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/24.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/25.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/25.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/26.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/26.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/27.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/27.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/28.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/28.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/29.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/29.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/3.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/30.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/30.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/31.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/31.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/32.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/33.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/33.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/34.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/34.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/35.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/35.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/36.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/36.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/37.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/37.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/38.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/38.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/39.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/39.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/4.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/40.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/40.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/41.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/41.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/42.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/42.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/43.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/43.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/44.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/44.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/45.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/45.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/46.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/46.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/47.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/47.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/48.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/48.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/49.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/49.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/5.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/50.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/50.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/51.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/51.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/52.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/52.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/53.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/53.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/54.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/54.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/55.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/55.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/56.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/56.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/57.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/57.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/58.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/58.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/59.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/59.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/6.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/60.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/60.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/61.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/61.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/62.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/62.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/63.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/63.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/64.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/64.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/65.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/65.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/66.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/66.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/67.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/67.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/68.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/68.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/69.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/69.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/7.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/70.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/70.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/71.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/71.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/8.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/8.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/images/face/9.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zifangsky/WebSocketDemo/b2cf323c13ec7f99986611623ce18caaf12adc16/stomp-websocket/src/main/resources/static/layui/images/face/9.gif -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/lay/modules/code.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.3 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(e){"use strict";var a=layui.$,l="http://www.layui.com/doc/modules/code.html";e("code",function(e){var t=[];e=e||{},e.elem=a(e.elem||".layui-code"),e.about=!("about"in e)||e.about,e.elem.each(function(){t.push(this)}),layui.each(t.reverse(),function(t,i){var c=a(i),o=c.html();(c.attr("lay-encode")||e.encode)&&(o=o.replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")),c.html('
  1. '+o.replace(/[\r\t\n]+/g,"
  2. ")+"
"),c.find(">.layui-code-h3")[0]||c.prepend('

'+(c.attr("lay-title")||e.title||"code")+(e.about?'layui.code':"")+"

");var d=c.find(">.layui-code-ol");c.addClass("layui-box layui-code-view"),(c.attr("lay-skin")||e.skin)&&c.addClass("layui-code-"+(c.attr("lay-skin")||e.skin)),(d.find("li").length/100|0)>0&&d.css("margin-left",(d.find("li").length/100|0)+"px"),(c.attr("lay-height")||e.height)&&d.css("max-height",c.attr("lay-height")||e.height)})})}).addcss("modules/code.css","skincodecss"); -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/lay/modules/flow.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.3 MIT License By https://www.layui.com */ 2 | ;layui.define("jquery",function(e){"use strict";var l=layui.$,o=function(e){},t='';o.prototype.load=function(e){var o,i,n,r,a=this,c=0;e=e||{};var f=l(e.elem);if(f[0]){var m=l(e.scrollElem||document),u=e.mb||50,s=!("isAuto"in e)||e.isAuto,v=e.end||"没有更多了",y=e.scrollElem&&e.scrollElem!==document,d="加载更多",h=l('");f.find(".layui-flow-more")[0]||f.append(h);var p=function(e,t){e=l(e),h.before(e),t=0==t||null,t?h.html(v):h.find("a").html(d),i=t,o=null,n&&n()},g=function(){o=!0,h.find("a").html(t),"function"==typeof e.done&&e.done(++c,p)};if(g(),h.find("a").on("click",function(){l(this);i||o||g()}),e.isLazyimg)var n=a.lazyimg({elem:e.elem+" img",scrollElem:e.scrollElem});return s?(m.on("scroll",function(){var e=l(this),t=e.scrollTop();r&&clearTimeout(r),i||(r=setTimeout(function(){var i=y?e.height():l(window).height(),n=y?e.prop("scrollHeight"):document.documentElement.scrollHeight;n-t-i<=u&&(o||g())},100))}),a):a}},o.prototype.lazyimg=function(e){var o,t=this,i=0;e=e||{};var n=l(e.scrollElem||document),r=e.elem||"img",a=e.scrollElem&&e.scrollElem!==document,c=function(e,l){var o=n.scrollTop(),r=o+l,c=a?function(){return e.offset().top-n.offset().top+o}():e.offset().top;if(c>=o&&c<=r&&!e.attr("src")){var m=e.attr("lay-src");layui.img(m,function(){var l=t.lazyimg.elem.eq(i);e.attr("src",m).removeAttr("lay-src"),l[0]&&f(l),i++})}},f=function(e,o){var f=a?(o||n).height():l(window).height(),m=n.scrollTop(),u=m+f;if(t.lazyimg.elem=l(r),e)c(e,f);else for(var s=0;su)break}};if(f(),!o){var m;n.on("scroll",function(){var e=l(this);m&&clearTimeout(m),m=setTimeout(function(){f(null,e)},50)}),o=!0}return f},e("flow",new o)}); -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/static/layui/lay/modules/laytpl.js: -------------------------------------------------------------------------------- 1 | /** layui-v2.4.3 MIT License By https://www.layui.com */ 2 | ;layui.define(function(e){"use strict";var r={open:"{{",close:"}}"},c={exp:function(e){return new RegExp(e,"g")},query:function(e,c,t){var o=["#([\\s\\S])+?","([^{#}])*?"][e||0];return n((c||"")+r.open+o+r.close+(t||""))},escape:function(e){return String(e||"").replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")},error:function(e,r){var c="Laytpl Error:";return"object"==typeof console&&console.error(c+e+"\n"+(r||"")),c+e}},n=c.exp,t=function(e){this.tpl=e};t.pt=t.prototype,window.errors=0,t.pt.parse=function(e,t){var o=this,p=e,a=n("^"+r.open+"#",""),l=n(r.close+"$","");e=e.replace(/\s+|\r|\t|\n/g," ").replace(n(r.open+"#"),r.open+"# ").replace(n(r.close+"}"),"} "+r.close).replace(/\\/g,"\\\\").replace(n(r.open+"!(.+?)!"+r.close),function(e){return e=e.replace(n("^"+r.open+"!"),"").replace(n("!"+r.close),"").replace(n(r.open+"|"+r.close),function(e){return e.replace(/(.)/g,"\\$1")})}).replace(/(?="|')/g,"\\").replace(c.query(),function(e){return e=e.replace(a,"").replace(l,""),'";'+e.replace(/\\/g,"")+';view+="'}).replace(c.query(1),function(e){var c='"+(';return e.replace(/\s/g,"")===r.open+r.close?"":(e=e.replace(n(r.open+"|"+r.close),""),/^=/.test(e)&&(e=e.replace(/^=/,""),c='"+_escape_('),c+e.replace(/\\/g,"")+')+"')}),e='"use strict";var view = "'+e+'";return view;';try{return o.cache=e=new Function("d, _escape_",e),e(t,c.escape)}catch(u){return delete o.cache,c.error(u,p)}},t.pt.render=function(e,r){var n,t=this;return e?(n=t.cache?t.cache(e,c.escape):t.parse(t.tpl,e),r?void r(n):n):c.error("no data")};var o=function(e){return"string"!=typeof e?c.error("Template not found"):new t(e)};o.config=function(e){e=e||{};for(var c in e)r[c]=e[c]},o.v="1.2.0",e("laytpl",o)}); -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 首页 8 | 9 | 10 | 11 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /stomp-websocket/src/main/resources/templates/userIndex.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 用户首页 8 | 9 | 10 | 11 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /stomp-websocket/src/test/java/cn/zifangsky/stompwebsocket/StompWebsocketApplicationTests.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class StompWebsocketApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /stomp-websocket/src/test/java/cn/zifangsky/stompwebsocket/TestRedis.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket; 2 | 3 | import cn.zifangsky.stompwebsocket.common.Constants; 4 | import cn.zifangsky.stompwebsocket.enums.ExpireEnum; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.data.redis.core.BoundListOperations; 10 | import org.springframework.data.redis.core.RedisTemplate; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * 测试redis的基本用法 17 | * @author zifangsky 18 | * @date 2018/7/27 19 | * @since 1.0.0 20 | */ 21 | @RunWith(SpringRunner.class) 22 | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 23 | public class TestRedis { 24 | @Autowired 25 | private RedisTemplate redisTemplate; 26 | 27 | @Test 28 | public void testSelect(){ 29 | BoundListOperations boundValueOperations = redisTemplate.boundListOps(Constants.REDIS_UNREAD_MSG_PREFIX + "admin"); 30 | // boundValueOperations.rightPush("a"); 31 | // boundValueOperations.rightPush("b"); 32 | // boundValueOperations.rightPush("c"); 33 | boundValueOperations.leftPushAll("m","n"); 34 | 35 | boundValueOperations.expire(ExpireEnum.UNREAD_MSG.getTime(),ExpireEnum.UNREAD_MSG.getTimeUnit()); 36 | 37 | List list = boundValueOperations.range(0, -1); 38 | list.forEach(System.out::print); 39 | redisTemplate.delete(Constants.REDIS_UNREAD_MSG_PREFIX + "admin"); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /stomp-websocket/src/test/java/cn/zifangsky/stompwebsocket/TestSQL.java: -------------------------------------------------------------------------------- 1 | package cn.zifangsky.stompwebsocket; 2 | 3 | import cn.zifangsky.stompwebsocket.mapper.UserMapper; 4 | import cn.zifangsky.stompwebsocket.model.User; 5 | import cn.zifangsky.stompwebsocket.utils.JsonUtils; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | import org.springframework.test.context.web.WebAppConfiguration; 13 | 14 | /** 15 | * 测试基本数据库连接 16 | * @author zifangsky 17 | * @date 2018/7/27 18 | * @since 1.0.0 19 | */ 20 | @RunWith(SpringRunner.class) 21 | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 22 | public class TestSQL { 23 | @Autowired 24 | private UserMapper userMapper; 25 | 26 | @Test 27 | public void testSelect(){ 28 | User user = userMapper.selectByPrimaryKey(1); 29 | System.out.println(user); 30 | 31 | User user2 = userMapper.selectByUsername("zifangsky"); 32 | System.out.println(JsonUtils.toJson(user2)); 33 | } 34 | 35 | } 36 | --------------------------------------------------------------------------------