feign 调用 wvp 接口测试
This commit is contained in:
parent
f1b68f4b87
commit
aa5e2da7af
@ -27,5 +27,58 @@
|
||||
<groupId>cn.skcks.docking</groupId>
|
||||
<artifactId>zlmediakit-service</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/**</include>
|
||||
</includes>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>src/test/resources</directory>
|
||||
<includes>
|
||||
<include>**/**</include>
|
||||
</includes>
|
||||
<filtering>true</filtering>
|
||||
</testResource>
|
||||
</testResources>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1,14 @@
|
||||
package cn.skcks.docking.gb28181.wvp.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "proxy.wvp")
|
||||
@Data
|
||||
public class WvpProxyConfig {
|
||||
private String url;
|
||||
private String user;
|
||||
private String passwd;
|
||||
}
|
@ -0,0 +1,250 @@
|
||||
package cn.skcks.docking.gb28181.wvp.dto.device;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Schema(description = "通道信息")
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class DeviceChannel {
|
||||
/**
|
||||
* 数据库自增ID
|
||||
*/
|
||||
@Schema(description = "数据库自增ID")
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* 通道国标编号
|
||||
*/
|
||||
@Schema(description = "通道国标编号")
|
||||
private String channelId;
|
||||
|
||||
/**
|
||||
* 设备国标编号
|
||||
*/
|
||||
@Schema(description = "设备国标编号")
|
||||
private String deviceId;
|
||||
|
||||
/**
|
||||
* 通道名
|
||||
*/
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 生产厂商
|
||||
*/
|
||||
@Schema(description = "生产厂商")
|
||||
private String manufacture;
|
||||
|
||||
/**
|
||||
* 型号
|
||||
*/
|
||||
@Schema(description = "型号")
|
||||
private String model;
|
||||
|
||||
/**
|
||||
* 设备归属
|
||||
*/
|
||||
@Schema(description = "设备归属")
|
||||
private String owner;
|
||||
|
||||
/**
|
||||
* 行政区域
|
||||
*/
|
||||
@Schema(description = "行政区域")
|
||||
private String civilCode;
|
||||
|
||||
/**
|
||||
* 警区
|
||||
*/
|
||||
@Schema(description = "警区")
|
||||
private String block;
|
||||
|
||||
/**
|
||||
* 安装地址
|
||||
*/
|
||||
@Schema(description = "安装地址")
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 是否有子设备 1有, 0没有
|
||||
*/
|
||||
@Schema(description = "是否有子设备 1有, 0没有")
|
||||
private int parental;
|
||||
|
||||
/**
|
||||
* 父级id
|
||||
*/
|
||||
@Schema(description = "父级id")
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 信令安全模式 缺省为0; 0:不采用; 2: S/MIME签名方式; 3: S/ MIME加密签名同时采用方式; 4:数字摘要方式
|
||||
*/
|
||||
@Schema(description = "信令安全模式 缺省为0; 0:不采用; 2: S/MIME签名方式; 3: S/ MIME加密签名同时采用方式; 4:数字摘要方式")
|
||||
private int safetyWay;
|
||||
|
||||
/**
|
||||
* 注册方式 缺省为1;1:符合IETFRFC3261标准的认证注册模 式; 2:基于口令的双向认证注册模式; 3:基于数字证书的双向认证注册模式
|
||||
*/
|
||||
@Schema(description = "注册方式 缺省为1;1:符合IETFRFC3261标准的认证注册模 式; 2:基于口令的双向认证注册模式; 3:基于数字证书的双向认证注册模式")
|
||||
private int registerWay;
|
||||
|
||||
/**
|
||||
* 证书序列号
|
||||
*/
|
||||
@Schema(description = "证书序列号")
|
||||
private String certNum;
|
||||
|
||||
/**
|
||||
* 证书有效标识 缺省为0;证书有效标识:0:无效1: 有效
|
||||
*/
|
||||
@Schema(description = "证书有效标识 缺省为0;证书有效标识:0:无效1: 有效")
|
||||
private int certifiable;
|
||||
|
||||
/**
|
||||
* 证书无效原因码
|
||||
*/
|
||||
@Schema(description = "证书无效原因码")
|
||||
private int errCode;
|
||||
|
||||
/**
|
||||
* 证书终止有效期
|
||||
*/
|
||||
@Schema(description = "证书终止有效期")
|
||||
private String endTime;
|
||||
|
||||
/**
|
||||
* 保密属性 缺省为0; 0:不涉密, 1:涉密
|
||||
*/
|
||||
@Schema(description = "保密属性 缺省为0; 0:不涉密, 1:涉密")
|
||||
private String secrecy;
|
||||
|
||||
/**
|
||||
* IP地址
|
||||
*/
|
||||
@Schema(description = "IP地址")
|
||||
private String ipAddress;
|
||||
|
||||
/**
|
||||
* 端口号
|
||||
*/
|
||||
@Schema(description = "端口号")
|
||||
private int port;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@Schema(description = "密码")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 云台类型
|
||||
*/
|
||||
@Schema(description = "云台类型")
|
||||
private int PTZType;
|
||||
|
||||
/**
|
||||
* 云台类型描述字符串
|
||||
*/
|
||||
@Schema(description = "云台类型描述字符串")
|
||||
private String PTZTypeText;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间")
|
||||
private String updateTime;
|
||||
|
||||
/**
|
||||
* 在线/离线
|
||||
* 1在线,0离线
|
||||
* 默认在线
|
||||
* 信令:
|
||||
* <Status>ON</Status>
|
||||
* <Status>OFF</Status>
|
||||
* 遇到过NVR下的IPC下发信令可以推流, 但是 Status 响应 OFF
|
||||
*/
|
||||
@Schema(description = "在线/离线, 1在线,0离线")
|
||||
private boolean status;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
@Schema(description = "经度")
|
||||
private double longitude;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
@Schema(description = "纬度")
|
||||
private double latitude;
|
||||
|
||||
/**
|
||||
* 经度 GCJ02
|
||||
*/
|
||||
@Schema(description = "GCJ02坐标系经度")
|
||||
private double longitudeGcj02;
|
||||
|
||||
/**
|
||||
* 纬度 GCJ02
|
||||
*/
|
||||
@Schema(description = "GCJ02坐标系纬度")
|
||||
private double latitudeGcj02;
|
||||
|
||||
/**
|
||||
* 经度 WGS84
|
||||
*/
|
||||
@Schema(description = "WGS84坐标系经度")
|
||||
private double longitudeWgs84;
|
||||
|
||||
/**
|
||||
* 纬度 WGS84
|
||||
*/
|
||||
@Schema(description = "WGS84坐标系纬度")
|
||||
private double latitudeWgs84;
|
||||
|
||||
/**
|
||||
* 子设备数
|
||||
*/
|
||||
@Schema(description = "子设备数")
|
||||
private int subCount;
|
||||
|
||||
/**
|
||||
* 流唯一编号,存在表示正在直播
|
||||
*/
|
||||
@Schema(description = "流唯一编号,存在表示正在直播")
|
||||
private String streamId;
|
||||
|
||||
/**
|
||||
* 是否含有音频
|
||||
*/
|
||||
@Schema(description = "是否含有音频")
|
||||
private boolean hasAudio;
|
||||
|
||||
/**
|
||||
* 标记通道的类型,0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划
|
||||
*/
|
||||
@Schema(description = "标记通道的类型,0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划")
|
||||
private int channelType;
|
||||
|
||||
/**
|
||||
* 业务分组
|
||||
*/
|
||||
@Schema(description = "业务分组")
|
||||
private String businessGroupId;
|
||||
|
||||
/**
|
||||
* GPS的更新时间
|
||||
*/
|
||||
@Schema(description = "GPS的更新时间")
|
||||
private String gpsTime;
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package cn.skcks.docking.gb28181.wvp.dto.device;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class GetDeviceChannelsReq {
|
||||
@Builder.Default
|
||||
private int page = 1;
|
||||
|
||||
@Builder.Default
|
||||
private int count = 100;
|
||||
|
||||
private String query;
|
||||
|
||||
private Boolean online;
|
||||
|
||||
private Boolean channelType;
|
||||
|
||||
private Boolean catalogUnderDevice;
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package cn.skcks.docking.gb28181.wvp.dto.device;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class GetDeviceChannelsResp {
|
||||
private Integer total;
|
||||
private List<DeviceChannel> list;
|
||||
private Integer pageNum;
|
||||
private Integer pageSize;
|
||||
private Integer size;
|
||||
private Integer startRow;
|
||||
private Integer endRow;
|
||||
private Integer pages;
|
||||
private Integer prePage;
|
||||
private Integer nextPage;
|
||||
private Boolean isFirstPage;
|
||||
private Boolean isLastPage;
|
||||
private Boolean hasPreviousPage;
|
||||
private Boolean hasNextPage;
|
||||
private Integer navigatePages;
|
||||
private List<?> navigatepageNums;
|
||||
private Integer navigateFirstPage;
|
||||
private Integer navigateLastPage;
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package cn.skcks.docking.gb28181.wvp.dto.device;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class GetDeviceTreeReq {
|
||||
@Builder.Default
|
||||
private int page = 1;
|
||||
|
||||
@Builder.Default
|
||||
private int count = 100;
|
||||
|
||||
private String parentId;
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package cn.skcks.docking.gb28181.wvp.dto.device;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class GetDeviceTreeResp {
|
||||
private Integer total;
|
||||
private List<DeviceChannel> list;
|
||||
private Integer pageNum;
|
||||
private Integer pageSize;
|
||||
private Integer size;
|
||||
private Integer startRow;
|
||||
private Integer endRow;
|
||||
private Integer pages;
|
||||
private Integer prePage;
|
||||
private Integer nextPage;
|
||||
private Boolean isFirstPage;
|
||||
private Boolean isLastPage;
|
||||
private Boolean hasPreviousPage;
|
||||
private Boolean hasNextPage;
|
||||
private Integer navigatePages;
|
||||
private List<?> navigatepageNums;
|
||||
private Integer navigateFirstPage;
|
||||
private Integer navigateLastPage;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package cn.skcks.docking.gb28181.wvp.dto.login;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class WvpLoginReq {
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
/**
|
||||
* 密码(32位md5加密)
|
||||
*/
|
||||
private String password;
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package cn.skcks.docking.gb28181.wvp.dto.login;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class WvpLoginResp {
|
||||
|
||||
private String accessToken;
|
||||
private Boolean accountNonExpired;
|
||||
private Boolean credentialsNonExpired;
|
||||
private Boolean accountNonLocked;
|
||||
private String password;
|
||||
private Boolean enabled;
|
||||
private RoleDTO role;
|
||||
private List<AuthoritiesDTO> authorities;
|
||||
private String username;
|
||||
private Integer id;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class RoleDTO {
|
||||
private Integer id;
|
||||
private String name;
|
||||
private String authority;
|
||||
private String createTime;
|
||||
private String updateTime;
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class AuthoritiesDTO {
|
||||
private String authority;
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package cn.skcks.docking.gb28181.wvp.proxy;
|
||||
|
||||
import cn.skcks.docking.gb28181.common.json.JsonResponse;
|
||||
import cn.skcks.docking.gb28181.wvp.dto.device.GetDeviceChannelsReq;
|
||||
import cn.skcks.docking.gb28181.wvp.dto.device.GetDeviceChannelsResp;
|
||||
import cn.skcks.docking.gb28181.wvp.dto.device.GetDeviceTreeReq;
|
||||
import cn.skcks.docking.gb28181.wvp.dto.device.GetDeviceTreeResp;
|
||||
import cn.skcks.docking.gb28181.wvp.dto.login.WvpLoginReq;
|
||||
import cn.skcks.docking.gb28181.wvp.dto.login.WvpLoginResp;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.cloud.openfeign.SpringQueryMap;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
|
||||
@FeignClient(name="wvpProxyClient", url = "${proxy.wvp.url}")
|
||||
public interface WvpProxyClient {
|
||||
@GetMapping(value = "/api/user/login", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
|
||||
JsonResponse<WvpLoginResp> login(@SpringQueryMap WvpLoginReq req);
|
||||
|
||||
@GetMapping(value = "/api/device/query/tree/channel/{deviceId}")
|
||||
JsonResponse<GetDeviceTreeResp> getDeviceTree(@RequestHeader("access-token") String token, @PathVariable String deviceId, @SpringQueryMap GetDeviceTreeReq req);
|
||||
|
||||
@GetMapping(value = "/api/device/query/devices/{deviceId}/channels")
|
||||
JsonResponse<GetDeviceChannelsResp> getDeviceChannels(@RequestHeader("access-token") String token, @PathVariable String deviceId, @SpringQueryMap GetDeviceChannelsReq req);
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
proxy:
|
||||
wvp:
|
||||
url: http://192.168.3.12:18978
|
||||
user: admin
|
||||
passwd: admin
|
@ -0,0 +1,15 @@
|
||||
package cn.skcks.docking.gb28181.wvp;
|
||||
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
@EnableFeignClients
|
||||
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
|
||||
public class WvpProxyTestApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(WvpProxyTestApplication.class, args);
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package cn.skcks.docking.gb28181.wvp.test;
|
||||
|
||||
import cn.hutool.crypto.digest.MD5;
|
||||
import cn.skcks.docking.gb28181.common.json.JsonResponse;
|
||||
import cn.skcks.docking.gb28181.wvp.config.WvpProxyConfig;
|
||||
import cn.skcks.docking.gb28181.wvp.dto.device.GetDeviceChannelsReq;
|
||||
import cn.skcks.docking.gb28181.wvp.dto.device.GetDeviceChannelsResp;
|
||||
import cn.skcks.docking.gb28181.wvp.dto.device.GetDeviceTreeReq;
|
||||
import cn.skcks.docking.gb28181.wvp.dto.device.GetDeviceTreeResp;
|
||||
import cn.skcks.docking.gb28181.wvp.dto.login.WvpLoginReq;
|
||||
import cn.skcks.docking.gb28181.wvp.dto.login.WvpLoginResp;
|
||||
import cn.skcks.docking.gb28181.wvp.proxy.WvpProxyClient;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
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.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
@Slf4j
|
||||
@SpringBootTest
|
||||
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
|
||||
@ExtendWith(SpringExtension.class)
|
||||
public class WvpProxyTest {
|
||||
@Autowired
|
||||
private WvpProxyClient wvpProxyClient;
|
||||
|
||||
@Autowired
|
||||
private WvpProxyConfig config;
|
||||
|
||||
@Test
|
||||
void test(){
|
||||
String passwdMd5 = MD5.create().digestHex(config.getPasswd());
|
||||
WvpLoginReq loginReq = WvpLoginReq.builder()
|
||||
.username(config.getUser())
|
||||
.password(passwdMd5)
|
||||
.build();
|
||||
log.info("{}", loginReq);
|
||||
JsonResponse<WvpLoginResp> loginResp = wvpProxyClient.login(loginReq);
|
||||
log.info("{}", loginResp);
|
||||
|
||||
String token = loginResp.getData().getAccessToken();
|
||||
String deviceId = "44050100001180000001";
|
||||
GetDeviceTreeReq getDeviceTreeReq = GetDeviceTreeReq.builder().build();
|
||||
JsonResponse<GetDeviceTreeResp> deviceTreeResp = wvpProxyClient.getDeviceTree(token, deviceId, getDeviceTreeReq);
|
||||
log.info("{}", deviceTreeResp);
|
||||
|
||||
GetDeviceChannelsReq getDeviceChannelsReq = GetDeviceChannelsReq.builder().build();
|
||||
JsonResponse<GetDeviceChannelsResp> getDeviceChannelsResp = wvpProxyClient.getDeviceChannels(token, deviceId, getDeviceChannelsReq);
|
||||
log.info("{}", getDeviceChannelsResp);
|
||||
}
|
||||
}
|
@ -6,7 +6,10 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
@EnableFeignClients(basePackages = "cn.skcks.docking.gb28181.media")
|
||||
@EnableFeignClients(basePackages = {
|
||||
"cn.skcks.docking.gb28181.media",
|
||||
"cn.skcks.docking.gb28181.wvp.proxy"
|
||||
})
|
||||
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
|
||||
@ComponentScan(basePackages = {
|
||||
"cn.skcks.docking.gb28181.annotation",
|
||||
|
Loading…
Reference in New Issue
Block a user