继续简化 MANSCDPUtils.XMLBuilder
This commit is contained in:
parent
6efb97875f
commit
f92c9a70f0
@ -0,0 +1,24 @@
|
||||
package cn.skcks.docking.gb28181.sip.manscdp.deviceinfo.request;
|
||||
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@JacksonXmlRootElement(localName = "Query")
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DeviceInfoRequestDTO {
|
||||
@Builder.Default
|
||||
private String cmdType = "DeviceInfo";
|
||||
|
||||
@JacksonXmlProperty(localName = "SN")
|
||||
private String sn;
|
||||
|
||||
@JacksonXmlProperty(localName = "DeviceID")
|
||||
private String deviceId;
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package cn.skcks.docking.gb28181.sip.manscdp.deviceinfo.response;
|
||||
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@JacksonXmlRootElement(localName = "Response")
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Data
|
||||
public class DeviceInfoResponseDTO {
|
||||
@Builder.Default
|
||||
private String cmdType = "DeviceInfo";
|
||||
@JacksonXmlProperty(localName = "SN")
|
||||
private String sn;
|
||||
|
||||
@JacksonXmlProperty(localName = "DeviceID")
|
||||
private String deviceId;
|
||||
|
||||
private String deviceName;
|
||||
|
||||
@Builder.Default
|
||||
private String Result = "OK";
|
||||
|
||||
/**
|
||||
* 设备生产商
|
||||
*/
|
||||
private String manufacturer;
|
||||
|
||||
/**
|
||||
* 设备型号(可选)
|
||||
*/
|
||||
private String model;
|
||||
|
||||
/**
|
||||
* 设备固件版本(可选)
|
||||
*/
|
||||
private String firmware;
|
||||
|
||||
/**
|
||||
* 视频输入通道数(可选)
|
||||
*/
|
||||
private Integer channel;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cn.skcks.docking.gb28181.sip.manscdp.keepalive;
|
||||
package cn.skcks.docking.gb28181.sip.manscdp.keepalive.notify;
|
||||
|
||||
import cn.skcks.docking.gb28181.constant.CmdType;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
@ -54,6 +54,10 @@ public class MANSCDPUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> XMLBuilder<T> build(T data){
|
||||
return new XMLBuilder<>(data);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static byte[] writeXmlWithEncoding(Object obj, String charset){
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
|
@ -4,14 +4,14 @@ import cn.skcks.docking.gb28181.sip.manscdp.catalog.query.CatalogDeviceListDTO;
|
||||
import cn.skcks.docking.gb28181.sip.manscdp.catalog.query.CatalogItemDTO;
|
||||
import cn.skcks.docking.gb28181.sip.manscdp.catalog.query.CatalogQueryDTO;
|
||||
import cn.skcks.docking.gb28181.sip.manscdp.catalog.response.CatalogResponseDTO;
|
||||
import cn.skcks.docking.gb28181.sip.manscdp.keepalive.KeepaliveNotifyDTO;
|
||||
import cn.skcks.docking.gb28181.sip.manscdp.deviceinfo.request.DeviceInfoRequestDTO;
|
||||
import cn.skcks.docking.gb28181.sip.manscdp.keepalive.notify.KeepaliveNotifyDTO;
|
||||
import cn.skcks.docking.gb28181.sip.utils.MANSCDPUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@ -86,4 +86,14 @@ public class MANSCDPTest {
|
||||
responseDTO = MANSCDPUtils.parse(serialize, CatalogResponseDTO.class);
|
||||
log.info("{}",responseDTO);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deviceInfo(){
|
||||
DeviceInfoRequestDTO deviceInfoRequestDTO = DeviceInfoRequestDTO.builder()
|
||||
.deviceId(deviceId)
|
||||
.sn(sn)
|
||||
.build();
|
||||
MANSCDPUtils.XMLBuilder<DeviceInfoRequestDTO> xmlBuilder = MANSCDPUtils.build(deviceInfoRequestDTO);
|
||||
log.info("\n{}", MANSCDPUtils.toXml(xmlBuilder));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user