HttpExchange 调用 zlmMediakit api 测试
This commit is contained in:
parent
1cf28de85c
commit
ab5119cd41
@ -2,7 +2,9 @@ package cn.skcks.docking.gb28181.common.json;
|
|||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
@Data
|
@Data
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Schema(title = "返回结果")
|
@Schema(title = "返回结果")
|
||||||
|
@ -4,7 +4,7 @@ import org.springframework.boot.SpringApplication;
|
|||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
||||||
public class Gb28181DockingPlatformApplicationTest {
|
public class Gb28181DockingPlatformApplicationTest {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(Gb28181DockingPlatformApplication.class, args);
|
SpringApplication.run(Gb28181DockingPlatformApplication.class, args);
|
||||||
|
@ -18,6 +18,12 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.skcks.docking.gb28181</groupId>
|
||||||
|
<artifactId>annotation</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
@ -48,5 +54,11 @@
|
|||||||
<artifactId>spring-test</artifactId>
|
<artifactId>spring-test</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.skcks.docking.gb28181</groupId>
|
||||||
|
<artifactId>common</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -1,10 +0,0 @@
|
|||||||
package cn.skcks.docking.gb28181.media;
|
|
||||||
|
|
||||||
import org.springframework.web.service.annotation.GetExchange;
|
|
||||||
import org.springframework.web.service.annotation.HttpExchange;
|
|
||||||
|
|
||||||
@HttpExchange()
|
|
||||||
public interface ZLMediaHttpService {
|
|
||||||
@GetExchange("/")
|
|
||||||
void test();
|
|
||||||
}
|
|
@ -7,6 +7,8 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
@Data
|
@Data
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConfigurationProperties(prefix = "media")
|
@ConfigurationProperties(prefix = "media")
|
||||||
public class MediaConfig {
|
public class ZlmMediaConfig {
|
||||||
private String url;
|
private String url;
|
||||||
|
private String id;
|
||||||
|
private String secret;
|
||||||
}
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package cn.skcks.docking.gb28181.media.dto.config;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ApiConfig {
|
||||||
|
private String apiDebug;
|
||||||
|
private String secret;
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package cn.skcks.docking.gb28181.media.dto.config;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class FFMpegConfig {
|
||||||
|
private String bin;
|
||||||
|
private String cmd;
|
||||||
|
private String log;
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package cn.skcks.docking.gb28181.media.dto.config;
|
||||||
|
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonUnwrapped;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ServerConfig {
|
||||||
|
@JsonUnwrapped(prefix = "api.")
|
||||||
|
private ApiConfig api;
|
||||||
|
|
||||||
|
@JsonUnwrapped(prefix = "ffmpeg.")
|
||||||
|
private FFMpegConfig ffmpeg;
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package cn.skcks.docking.gb28181.media.proxy;
|
||||||
|
|
||||||
|
import cn.skcks.docking.gb28181.common.json.JsonResponse;
|
||||||
|
import cn.skcks.docking.gb28181.media.dto.config.ServerConfig;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.service.annotation.GetExchange;
|
||||||
|
import org.springframework.web.service.annotation.HttpExchange;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@HttpExchange
|
||||||
|
public interface ZlmMediaHttpService {
|
||||||
|
|
||||||
|
@GetExchange("/index/api/getServerConfig")
|
||||||
|
JsonResponse<List<ServerConfig>> getServerConfig(@RequestParam String secret);
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package cn.skcks.docking.gb28181.media.proxy;
|
||||||
|
|
||||||
|
import cn.skcks.docking.gb28181.media.config.ZlmMediaConfig;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
import org.springframework.web.reactive.function.client.support.WebClientAdapter;
|
||||||
|
import org.springframework.web.service.invoker.HttpServiceProxyFactory;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Component
|
||||||
|
public class ZlmProxy {
|
||||||
|
private final ZlmMediaConfig mediaConfig;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public WebClient zlmClient() {
|
||||||
|
return WebClient.builder()
|
||||||
|
.baseUrl(mediaConfig.getUrl())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ZlmMediaHttpService zlMediaHttpService(@Qualifier("zlmClient") WebClient zlmClient){
|
||||||
|
HttpServiceProxyFactory proxyFactory =
|
||||||
|
HttpServiceProxyFactory.builder(WebClientAdapter.forClient(zlmClient))
|
||||||
|
.build();
|
||||||
|
return proxyFactory.createClient(ZlmMediaHttpService.class);
|
||||||
|
}
|
||||||
|
}
|
@ -1,2 +1,4 @@
|
|||||||
media:
|
media:
|
||||||
url: 'http://10.10.10.200:5080'
|
url: 'http://10.10.10.200:5080'
|
||||||
|
id: amrWMKmbKqoBjRQ9
|
||||||
|
secret: 4155cca6-2f9f-11ee-85e6-8de4ce2e7333
|
||||||
|
@ -1,35 +1,31 @@
|
|||||||
package cn.skcks.docking.gb28181.test;
|
package cn.skcks.docking.gb28181.test;
|
||||||
|
|
||||||
import cn.skcks.docking.gb28181.media.config.MediaConfig;
|
import cn.skcks.docking.gb28181.media.config.ZlmMediaConfig;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import cn.skcks.docking.gb28181.media.proxy.ZlmMediaHttpService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||||
import org.springframework.web.reactive.function.client.WebClient;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
|
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
|
||||||
@ExtendWith(SpringExtension.class)
|
@ExtendWith(SpringExtension.class)
|
||||||
public class MediaServiceTest {
|
public class MediaServiceTest {
|
||||||
@Autowired
|
@Autowired
|
||||||
private MediaConfig mediaConfig;
|
private ZlmMediaConfig config;
|
||||||
|
|
||||||
@Bean
|
@Autowired
|
||||||
WebClient webClient(ObjectMapper objectMapper) {
|
private ZlmMediaHttpService zlMediaHttpService;
|
||||||
return WebClient.builder()
|
|
||||||
.baseUrl(mediaConfig.getUrl())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void context(WebClient webClient){
|
void context(){
|
||||||
// log.info("mediaConfig {}", mediaConfig);
|
var test = zlMediaHttpService.getServerConfig(config.getSecret());
|
||||||
// HttpServiceProxyFactory httpServiceProxyFactory =
|
log.info("{}", test);
|
||||||
// HttpServiceProxyFactory.builder(WebClientAdapter.forClient(webClient))
|
|
||||||
// .build();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user