Browse Source

feat:从userapp中分离出websocket

caoliqin 3 days ago
parent
commit
20774cb3fa

+ 120 - 0
fs-websocket/pom.xml

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>fs</artifactId>
+        <groupId>com.fs</groupId>
+        <version>1.1.0</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>fs-websocket</artifactId>
+    <description>
+        WebSocket独立服务
+    </description>
+
+    <dependencies>
+        <!-- Spring Boot WebSocket -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-websocket</artifactId>
+        </dependency>
+
+        <!-- Spring Boot Web -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
+        <!-- FastJSON -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+        </dependency>
+
+        <!-- Lombok -->
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <optional>true</optional>
+        </dependency>
+
+        <!-- Swagger -->
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger2</artifactId>
+        </dependency>
+
+        <!-- swagger2-UI-->
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+        </dependency>
+
+        <!-- 显式添加swagger-annotations依赖,因为父项目中被排除了 -->
+        <dependency>
+            <groupId>io.swagger</groupId>
+            <artifactId>swagger-annotations</artifactId>
+            <version>1.5.21</version>
+        </dependency>
+
+        <!-- 显式添加swagger-models依赖,因为父项目中被排除了 -->
+        <dependency>
+            <groupId>io.swagger</groupId>
+            <artifactId>swagger-models</artifactId>
+            <version>1.5.21</version>
+        </dependency>
+
+        <!-- 通用模块 -->
+        <dependency>
+            <groupId>com.fs</groupId>
+            <artifactId>fs-common</artifactId>
+            <!-- 排除 security -->
+            <exclusions>
+                <exclusion>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-starter-security</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <!-- Spring Boot DevTools -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-devtools</artifactId>
+            <optional>true</optional>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>2.1.1.RELEASE</version>
+                <configuration>
+                    <fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-war-plugin</artifactId>
+                <version>3.1.0</version>
+                <configuration>
+                    <failOnMissingWebXml>false</failOnMissingWebXml>
+                    <warName>${project.artifactId}</warName>
+                </configuration>
+            </plugin>
+        </plugins>
+        <finalName>${project.artifactId}</finalName>
+    </build>
+
+</project>

+ 20 - 0
fs-websocket/src/main/java/com/fs/websocket/FsWebSocketServiceApplication.java

@@ -0,0 +1,20 @@
+package com.fs.websocket;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+
+/**
+ * WebSocket服务启动程序
+ *
+ * @author fs
+ */
+@SpringBootApplication(scanBasePackages = {"com.fs"}, exclude= {DataSourceAutoConfiguration.class})
+public class FsWebSocketServiceApplication extends SpringBootServletInitializer {
+
+    public static void main(String[] args) {
+        SpringApplication.run(FsWebSocketServiceApplication.class, args);
+        System.out.println("(*^_^*)WebSocket服务启动成功");
+    }
+}

+ 0 - 0
fs-user-app/src/main/java/com/fs/websocket/bean/SendMsgVO.java → fs-websocket/src/main/java/com/fs/websocket/bean/SendMsgVO.java


+ 1 - 1
fs-user-app/src/main/java/com/fs/app/config/WebSocketConfig.java → fs-websocket/src/main/java/com/fs/websocket/config/WebSocketConfig.java

@@ -1,4 +1,4 @@
-package com.fs.app.config;
+package com.fs.websocket.config;
 
 
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Configuration;

+ 1 - 1
fs-user-app/src/main/java/com/fs/websocket/service/WebSocketServer.java → fs-websocket/src/main/java/com/fs/websocket/service/WebSocketServer.java

@@ -1,13 +1,13 @@
 package com.fs.websocket.service;
 package com.fs.websocket.service;
 
 
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
-import com.fs.common.core.redis.RedisCache;
 import com.fs.common.exception.base.BaseException;
 import com.fs.common.exception.base.BaseException;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.StringUtils;
 import com.fs.websocket.bean.SendMsgVO;
 import com.fs.websocket.bean.SendMsgVO;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.CollectionUtils;
+
 import javax.websocket.*;
 import javax.websocket.*;
 import javax.websocket.server.PathParam;
 import javax.websocket.server.PathParam;
 import javax.websocket.server.ServerEndpoint;
 import javax.websocket.server.ServerEndpoint;

+ 10 - 0
fs-websocket/src/main/resources/application.yml

@@ -0,0 +1,10 @@
+# 开发环境配置
+server:
+  # 服务器的HTTP端口,默认为8115
+  port: 8115
+
+# Spring配置
+spring:
+  profiles:
+    active: dev
+#    active: druid-sxjz

+ 8 - 0
pom.xml

@@ -234,6 +234,13 @@
                 <artifactId>fs-ipad-task</artifactId>
                 <artifactId>fs-ipad-task</artifactId>
                 <version>${fs.version}</version>
                 <version>${fs.version}</version>
             </dependency>
             </dependency>
+
+            <!-- WebSocket服务-->
+            <dependency>
+                <groupId>com.fs</groupId>
+                <artifactId>fs-websocket</artifactId>
+                <version>${fs.version}</version>
+            </dependency>
         </dependencies>
         </dependencies>
     </dependencyManagement>
     </dependencyManagement>
 
 
@@ -268,6 +275,7 @@
         <module>fs-repeat-api</module>
         <module>fs-repeat-api</module>
         <module>fs-ipad-task</module>
         <module>fs-ipad-task</module>
         <module>fs-user-course</module>
         <module>fs-user-course</module>
+        <module>fs-websocket</module>
     </modules>
     </modules>
 
 
     <packaging>pom</packaging>
     <packaging>pom</packaging>