parent
2da1ca970e
commit
d36aa022d1
|
@ -2,7 +2,7 @@
|
|||
<configuration scan="true">
|
||||
|
||||
<property name="LOG_PATH" value="./logs"/>
|
||||
<property name="LOG_LEVEL" value="info"/>
|
||||
<property name="LOG_LEVEL" value="debug"/>
|
||||
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder charset="UTF-8">
|
||||
|
|
|
@ -11,12 +11,12 @@ public interface BaseEnum {
|
|||
*
|
||||
* @return the value
|
||||
*/
|
||||
Integer getCode();
|
||||
Integer getValue();
|
||||
|
||||
/**
|
||||
* Gets description.
|
||||
*
|
||||
* @return the description
|
||||
*/
|
||||
String getReadme();
|
||||
String getDescription();
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public final class CommonEnumHandler<E extends BaseEnum> extends BaseTypeHandler
|
|||
*/
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement preparedStatement, int i, E e, JdbcType jdbcType) throws SQLException {
|
||||
preparedStatement.setInt(i, e.getCode());
|
||||
preparedStatement.setInt(i, e.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -116,7 +116,7 @@ public final class CommonEnumHandler<E extends BaseEnum> extends BaseTypeHandler
|
|||
*/
|
||||
private E locateEnumStatus(int index) {
|
||||
for (E e : enums) {
|
||||
if (e.getCode() == index) {
|
||||
if (e.getValue() == index) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ public enum DisposeCapacityType implements BaseEnum {
|
|||
* @return the code
|
||||
*/
|
||||
@Override
|
||||
public Integer getCode() {
|
||||
public Integer getValue() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ public enum DisposeCapacityType implements BaseEnum {
|
|||
* @return the readme
|
||||
*/
|
||||
@Override
|
||||
public String getReadme() {
|
||||
public String getDescription() {
|
||||
return this.readme;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public enum DisposeDeviceType implements BaseEnum {
|
|||
* @return the code
|
||||
*/
|
||||
@Override
|
||||
public Integer getCode() {
|
||||
public Integer getValue() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ public enum DisposeDeviceType implements BaseEnum {
|
|||
* @return the readme
|
||||
*/
|
||||
@Override
|
||||
public String getReadme() {
|
||||
public String getDescription() {
|
||||
return this.readme;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public enum DisposeObjectType implements BaseEnum {
|
|||
* @return the code
|
||||
*/
|
||||
@Override
|
||||
public Integer getCode() {
|
||||
public Integer getValue() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ public enum DisposeObjectType implements BaseEnum {
|
|||
* @return the readme
|
||||
*/
|
||||
@Override
|
||||
public String getReadme() {
|
||||
public String getDescription() {
|
||||
return this.readme;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,8 @@ public enum HttpType implements BaseEnum {
|
|||
*
|
||||
* @return the code
|
||||
*/
|
||||
public Integer getCode() {
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
|
@ -51,7 +52,7 @@ public enum HttpType implements BaseEnum {
|
|||
* @return the readme
|
||||
*/
|
||||
@Override
|
||||
public String getReadme() {
|
||||
public String getDescription() {
|
||||
return this.readme;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public enum IpAddrType implements BaseEnum {
|
|||
* @return the code
|
||||
*/
|
||||
@Override
|
||||
public Integer getCode() {
|
||||
public Integer getValue() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ public enum IpAddrType implements BaseEnum {
|
|||
* @return the readme
|
||||
*/
|
||||
@Override
|
||||
public String getReadme() {
|
||||
public String getDescription() {
|
||||
return this.readme;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public enum ObjectStatus implements BaseEnum {
|
|||
* @return the code
|
||||
*/
|
||||
@Override
|
||||
public Integer getCode() {
|
||||
public Integer getValue() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ public enum ObjectStatus implements BaseEnum {
|
|||
* @return the readme
|
||||
*/
|
||||
@Override
|
||||
public String getReadme() {
|
||||
public String getDescription() {
|
||||
return this.readme;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
package com.dispose.controller;
|
||||
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.pojo.dto.protocol.base.BaseRespStatus;
|
||||
import com.dispose.pojo.dto.protocol.base.ProtocolReqDTO;
|
||||
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
||||
import com.dispose.pojo.dto.protocol.device.manager.AddDeviceReq;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.service.DisposeDeviceManagerService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -15,6 +19,10 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The type Dispose device manager controller.
|
||||
*
|
||||
|
@ -27,6 +35,10 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|||
@Component
|
||||
@Validated
|
||||
public class DisposeDeviceManagerController {
|
||||
|
||||
@Resource
|
||||
private DisposeDeviceManagerService disposeDeviceManagerService;
|
||||
|
||||
/**
|
||||
* Add dispose device protocol resp dto.
|
||||
*
|
||||
|
@ -39,6 +51,32 @@ public class DisposeDeviceManagerController {
|
|||
public ProtocolRespDTO<? extends BaseRespStatus> addDisposeDevice(
|
||||
@Validated
|
||||
@RequestBody ProtocolReqDTO<AddDeviceReq> mr) {
|
||||
return null;
|
||||
|
||||
List<DisposeDevice> devs = new ArrayList<>();
|
||||
|
||||
mr.getMsgContent().getItems().forEach(v -> {
|
||||
DisposeDevice dev = DisposeDevice.builder()
|
||||
.ipAddr(v.getIpAddr())
|
||||
.ipPort(v.getIpPort())
|
||||
.deviceType(v.getDeviceType())
|
||||
.areaCode(v.getAreaCode())
|
||||
.deviceName(v.getDeviceName())
|
||||
.manufacturer(v.getManufacturer())
|
||||
.model(v.getModel())
|
||||
.version(v.getVersion())
|
||||
.userName(v.getUserName())
|
||||
.password(v.getPassword())
|
||||
.urlPath(v.getUrlPath())
|
||||
.urlType(v.getUrlType())
|
||||
.readme(v.getReadme())
|
||||
.build();
|
||||
devs.add(dev);
|
||||
});
|
||||
|
||||
List<MulReturnType<ErrorCode, DisposeDevice>> ret = disposeDeviceManagerService.addDisposeDevice(devs);
|
||||
|
||||
|
||||
|
||||
return ProtocolRespDTO.result(ErrorCode.ERR_OK);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
package com.dispose.pojo.dto.protocol.base;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* The type Base id resp.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@JsonPropertyOrder({"id", "devId", "status", "message"})
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class BaseIdResp extends BaseRespStatus {
|
||||
/**
|
||||
* The Id.
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* The Dev id.
|
||||
*/
|
||||
private String devId;
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package com.dispose.pojo.dto.protocol.device.manager;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* The type Add capacity info.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class AddCapacityInfo {
|
||||
/**
|
||||
* The Capacity type.
|
||||
*/
|
||||
private Integer capacityType;
|
||||
|
||||
/**
|
||||
* The Object type.
|
||||
*/
|
||||
private Integer objectType;
|
||||
|
||||
/**
|
||||
* The Ip type.
|
||||
*/
|
||||
private Integer ipType;
|
||||
|
||||
/**
|
||||
* The Protect ip.
|
||||
*/
|
||||
private String protectIp;
|
||||
}
|
|
@ -8,9 +8,16 @@ import lombok.Builder;
|
|||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The type Add device info.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
|
@ -84,4 +91,11 @@ public class AddDeviceInfo {
|
|||
* The Readme.
|
||||
*/
|
||||
private String readme;
|
||||
|
||||
/**
|
||||
* The Capacity.
|
||||
*/
|
||||
@NotNull(message = "capacity 处置设备能力不能为空")
|
||||
@Valid
|
||||
private List<AddCapacityInfo> capacity;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import lombok.Builder;
|
|||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -24,5 +25,6 @@ public class AddDeviceReq {
|
|||
* The Items.
|
||||
*/
|
||||
@NotNull(message = "items 设备列表不能为空")
|
||||
@Valid
|
||||
private List<AddDeviceInfo> items;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package com.dispose.pojo.dto.protocol.device.manager;
|
||||
|
||||
import com.dispose.pojo.dto.protocol.base.BaseIdResp;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The type Add device rsp.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@JsonPropertyOrder({"ipAddr", "ipPort", "devId", "status", "message"})
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class AddDeviceRsp extends BaseIdResp {
|
||||
/**
|
||||
* The Items.
|
||||
*/
|
||||
private List<AddDeviceInfo> items;
|
||||
|
||||
/**
|
||||
* Instantiates a new Add device rsp.
|
||||
*/
|
||||
public AddDeviceRsp() {
|
||||
this.items = new ArrayList<>();
|
||||
}
|
||||
}
|
|
@ -1,9 +1,16 @@
|
|||
package com.dispose.service;
|
||||
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The interface Dispose device manager service.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public interface DisposeDeviceManagerService {
|
||||
List<MulReturnType<ErrorCode, DisposeDevice>> addDisposeDevice(List<DisposeDevice> devs);
|
||||
}
|
||||
|
|
|
@ -1,15 +1,51 @@
|
|||
package com.dispose.service.impl;
|
||||
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.manager.DisposeDeviceManager;
|
||||
import com.dispose.pojo.entity.DisposeDevice;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.service.DisposeDeviceManagerService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The type Dispose device manager.
|
||||
* The type Dispose device manager service.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class DisposeDeviceManagerServiceImpl implements DisposeDeviceManagerService {
|
||||
|
||||
/**
|
||||
* The Dispose device manager.
|
||||
*/
|
||||
@Resource
|
||||
private DisposeDeviceManager disposeDeviceManager;
|
||||
|
||||
/**
|
||||
* Add dispose device list.
|
||||
*
|
||||
* @param devs the devs
|
||||
* @return the list
|
||||
*/
|
||||
@Override
|
||||
public List<MulReturnType<ErrorCode, DisposeDevice>> addDisposeDevice(List<DisposeDevice> devs) {
|
||||
List<MulReturnType<ErrorCode, DisposeDevice>> rspList = new ArrayList<>();
|
||||
|
||||
devs.forEach(v -> {
|
||||
MulReturnType<ErrorCode, Long> ret = disposeDeviceManager.addDisposeDevice(v);
|
||||
|
||||
v.setId(ret.getSecondParam());
|
||||
rspList.add(new MulReturnType<>(ret.getFirstParam(), v));
|
||||
});
|
||||
|
||||
//AddDeviceRsp rspInfo = AddDeviceRsp.b
|
||||
|
||||
return rspList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ public class DisposeCapacityMapperTest {
|
|||
log.debug(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(capList));
|
||||
|
||||
items = disposeCapacityMapper.delDisposeCapacity(capList.get(0).getDeviceId(),
|
||||
capList.get(0).getCapacityType().getCode());
|
||||
capList.get(0).getCapacityType().getValue());
|
||||
|
||||
Assert.assertEquals(items, 2);
|
||||
|
||||
|
|
Loading…
Reference in New Issue