Explorar el Código

去除不用的流媒体服务

xucaiqin hace 4 meses
padre
commit
3d14724f4d

+ 10 - 2
src/main/java/com/sckw/robot/controller/ApiController.java

@@ -3,6 +3,7 @@ package com.sckw.robot.controller;
 import com.sckw.robot.pojo.dto.*;
 import com.sckw.robot.service.ApiService;
 import com.sckw.robot.service.BusinessService;
+import com.sckw.robot.service.SsoService;
 import com.sckw.robot.util.R;
 import jakarta.annotation.Resource;
 import org.springframework.web.bind.annotation.*;
@@ -21,6 +22,13 @@ public class ApiController {
     private BusinessService businessService;
     @Resource
     private ApiService apiService;
+    @Resource
+    private SsoService ssoService;
+
+    @GetMapping("/getToken")
+    public R<String> getToken() {
+        return R.ok(ssoService.encrypt("{\"account\":\"test\",\"time\":" + System.currentTimeMillis() + "}"));
+    }
 
     /**
      * 校验token,轨道机器人三方调用
@@ -49,8 +57,8 @@ public class ApiController {
     }
 
     @GetMapping("/task/plan/list")
-    public R<TaskPlanListDto> getTaskPlanList(@RequestParam String deviceId,  @RequestParam(required = false) Integer pageNum, @RequestParam(required = false) Integer pageSize) {
-        return apiService.getTaskPlanList(deviceId,  pageNum, pageSize);
+    public R<TaskPlanListDto> getTaskPlanList(@RequestParam String deviceId, @RequestParam(required = false) Integer pageNum, @RequestParam(required = false) Integer pageSize) {
+        return apiService.getTaskPlanList(deviceId, pageNum, pageSize);
     }
 
 //    @PostMapping("/task/plan/execNow")

+ 11 - 10
src/main/java/com/sckw/robot/service/SsoService.java

@@ -1,5 +1,9 @@
 package com.sckw.robot.service;
 
+import jakarta.annotation.PostConstruct;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
 import javax.crypto.Cipher;
 import javax.crypto.spec.IvParameterSpec;
 import javax.crypto.spec.SecretKeySpec;
@@ -9,13 +13,17 @@ import java.util.Base64;
  * @author xucaiqin
  * @date 2025-07-28 10:41:11
  */
+@Service
 public class SsoService {
 
     private IvParameterSpec ivSpec;
     private SecretKeySpec keySpec;
+    @Value("${srcKey}")
+    private String srcKey;
 
-    public SsoService(String srckey) {
-        String key = paddingkey(srckey);
+    @PostConstruct
+    public void init() {
+        String key = paddingkey(srcKey);
         try {
             byte[] keyBytes = key.getBytes();
             byte[] buf = new byte[16];
@@ -51,7 +59,7 @@ public class SsoService {
         return new String(re);
     }
 
-    private static String paddingkey(String liu) {
+    private String paddingkey(String liu) {
         StringBuffer sb = new StringBuffer(liu);
         for (int i = liu.length(); i < 16; i++) {
             sb.append("0");
@@ -60,11 +68,4 @@ public class SsoService {
 
     }
 
-    public static void main(String[] args) {
-        SsoService test = new SsoService("jindingsecrekey");
-        System.out.println(test.encrypt("{\"account\":\"test\",\"time\":" + System.currentTimeMillis() + "}"));
-        // outPut:  5SOZ33f22XAIqPNiiy3aFVa7+nELOf/a/eJ27oN7q4i7WXvuFPragDPsCHiE5fXK
-    }
-
-
 }

+ 3 - 6
src/main/java/com/sckw/robot/service/StreamService.java

@@ -4,17 +4,14 @@ import com.aizuda.zlm4j.core.ZLMApi;
 import com.aizuda.zlm4j.structure.MK_EVENTS;
 import com.aizuda.zlm4j.structure.MK_INI;
 import com.sun.jna.Native;
-import jakarta.annotation.PostConstruct;
-import jakarta.annotation.PreDestroy;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
 
 /**
  * @author xucaiqin
  * @date 2025-07-09 13:01:48
  */
 @Slf4j
-@Component
+//@Component
 public class StreamService {
     //动态链接库放在/resource/win32-x86-64&/resource/linux-x86-64下JNA会自动查找目录
     public static ZLMApi ZLM_API = Native.load("mk_api", ZLMApi.class);
@@ -28,7 +25,7 @@ public class StreamService {
         return osName.contains("linux");
     }
 
-    @PostConstruct
+//    @PostConstruct
     public void start() {
         //初始化sdk配置
         ZLM_API.mk_env_init2(1, 1, 1, null, 0, 0, null, 0, null, null);
@@ -112,7 +109,7 @@ public class StreamService {
         short rtc_server_port = ZLM_API.mk_rtc_server_start((short) 8000);
     }
 
-    @PreDestroy
+//    @PreDestroy
     public void stop() {
         log.info("ZLMediaKit 服务关闭中...");
         ZLM_API.mk_stop_all_server();

+ 2 - 0
src/main/resources/application.yml

@@ -17,3 +17,5 @@ spring:
     multipart:
       max-file-size: 20MB
       max-request-size: 100MB
+
+srcKey: jindingsecrekey