zlm version api

This commit is contained in:
shikong 2023-08-20 16:37:34 +08:00
parent d6960a64c4
commit ed86050014
5 changed files with 37 additions and 2 deletions

View File

@ -1,8 +1,6 @@
package cn.skcks.docking.gb28181.media.dto.rtp;
import cn.skcks.docking.gb28181.media.dto.status.ResponseStatus;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.Data;
@Data

View File

@ -0,0 +1,15 @@
package cn.skcks.docking.gb28181.media.dto.version;
import cn.hutool.core.date.DatePattern;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
@Data
public class VersionResp {
private String branchName;
@JsonFormat(pattern = DatePattern.UTC_SIMPLE_PATTERN)
private Date buildTime;
private String commitHash;
}

View File

@ -6,6 +6,7 @@ import cn.skcks.docking.gb28181.media.dto.rtp.CloseRtpServer;
import cn.skcks.docking.gb28181.media.dto.rtp.CloseRtpServerResp;
import cn.skcks.docking.gb28181.media.dto.rtp.OpenRtpServer;
import cn.skcks.docking.gb28181.media.dto.rtp.OpenRtpServerResp;
import cn.skcks.docking.gb28181.media.dto.version.VersionResp;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
@ -36,4 +37,7 @@ public interface ZlmMediaHttpClient {
@PostMapping("/index/api/closeRtpServer")
CloseRtpServerResp closeRtpServer(@RequestParam String secret, @RequestBody CloseRtpServer params);
@GetMapping("/index/api/version")
ZlmResponse<VersionResp> version(@RequestParam String secret);
}

View File

@ -7,9 +7,11 @@ import cn.skcks.docking.gb28181.media.dto.rtp.CloseRtpServer;
import cn.skcks.docking.gb28181.media.dto.rtp.CloseRtpServerResp;
import cn.skcks.docking.gb28181.media.dto.rtp.OpenRtpServer;
import cn.skcks.docking.gb28181.media.dto.rtp.OpenRtpServerResp;
import cn.skcks.docking.gb28181.media.dto.version.VersionResp;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.Builder;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
@ -44,4 +46,8 @@ public class ZlmMediaService {
public CloseRtpServerResp closeRtpServer(CloseRtpServer params){
return exchange.closeRtpServer(secret, params);
}
public ZlmResponse<VersionResp> version(){
return exchange.version(secret);
}
}

View File

@ -1,5 +1,6 @@
package cn.skcks.docking.gb28181.test;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.skcks.docking.gb28181.common.json.JsonResponse;
import cn.skcks.docking.gb28181.media.dto.config.ServerConfig;
@ -7,6 +8,7 @@ import cn.skcks.docking.gb28181.media.dto.response.ZlmResponse;
import cn.skcks.docking.gb28181.media.dto.response.ZlmResponseConvertor;
import cn.skcks.docking.gb28181.media.dto.rtp.CloseRtpServer;
import cn.skcks.docking.gb28181.media.dto.rtp.OpenRtpServer;
import cn.skcks.docking.gb28181.media.dto.version.VersionResp;
import cn.skcks.docking.gb28181.media.proxy.ZlmMediaService;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
@ -73,6 +75,16 @@ public class MediaServiceTest {
log.info("{}", zlMediaHttpService.closeRtpServer(closeRtpServer));
}
@Test
void version(){
ZlmResponse<VersionResp> versionResp = zlMediaHttpService.version();
log.info("{}", versionResp);
Date date = versionResp.getData().getBuildTime();
log.info("{}", date);
log.info("{}", LocalDateTimeUtil.of(date.toInstant(), TimeZone.getTimeZone("GMT+8")));
log.info("{}", LocalDateTimeUtil.of(date.toInstant(), TimeZone.getTimeZone("UTC")));
}
@Test
void configTest(){
ZlmResponse<List<ServerConfig>> resp = zlMediaHttpService.getServerConfig();