parent
8fa78111db
commit
80a0e5c0db
|
@ -219,7 +219,19 @@ public enum ErrorCode {
|
||||||
/**
|
/**
|
||||||
* The Err no device by areaCode.
|
* The Err no device by areaCode.
|
||||||
*/
|
*/
|
||||||
ERR_NODEVICE_AREACODE(111, "区域无该设备"),
|
ERR_NODEVICE_AREACODE(112, "区域无该设备"),
|
||||||
|
/**
|
||||||
|
* The Err specified IP already exists.
|
||||||
|
*/
|
||||||
|
ERR_SPECIFIEDIP_EXISTS(113, "指定的IP已经存在"),
|
||||||
|
/**
|
||||||
|
* The Err specified IP does not exists.
|
||||||
|
*/
|
||||||
|
ERR_SPECIFIEDIP_NOTEXISTS(114, "指定的IP地址不存在"),
|
||||||
|
/**
|
||||||
|
* The Err server processing request.
|
||||||
|
*/
|
||||||
|
ERR_SERVER_PROCESSREQ(115, "服务器处理请求错误"),
|
||||||
;
|
;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.huawei.dispose.common;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type Hua wei login req.
|
||||||
|
*
|
||||||
|
* @author <chenlinghy@cmhi.chinamoblie.com>
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@JsonPropertyOrder({"zone_ip"})
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public class HuaWeiCreatDivertReq {
|
||||||
|
/**
|
||||||
|
* The array zone ip.
|
||||||
|
*/
|
||||||
|
private String[] zone_ip;
|
||||||
|
}
|
|
@ -1,10 +1,14 @@
|
||||||
package com.huawei.dispose.protocol;
|
package com.huawei.dispose.protocol;
|
||||||
|
|
||||||
import cn.hutool.http.HttpResponse;
|
import cn.hutool.http.HttpResponse;
|
||||||
|
import com.dispose.common.ErrorCode;
|
||||||
import com.dispose.restful.RestfulInterface;
|
import com.dispose.restful.RestfulInterface;
|
||||||
|
import com.huawei.dispose.common.HuaWeiCreatDivertReq;
|
||||||
import com.huawei.dispose.common.HuaWeiLoginReq;
|
import com.huawei.dispose.common.HuaWeiLoginReq;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type Hua Wei interface.
|
* The type Hua Wei interface.
|
||||||
*
|
*
|
||||||
|
@ -25,4 +29,70 @@ public class HuaWeiInterface {
|
||||||
new HuaWeiLoginReq(username, password),
|
new HuaWeiLoginReq(username, password),
|
||||||
RequestMethod.POST);
|
RequestMethod.POST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create divert protocol resp dto.
|
||||||
|
*
|
||||||
|
* @param baseUrlPath the base url path
|
||||||
|
* @param token the token
|
||||||
|
* @param zone_ip zone ip
|
||||||
|
* @return the delete zone status
|
||||||
|
*/
|
||||||
|
public ErrorCode createDivert(String baseUrlPath, String token, String[] zone_ip){
|
||||||
|
//获取HTTP部分
|
||||||
|
HttpResponse response = RestfulInterface.huaWeiProRun(baseUrlPath + "/divert",
|
||||||
|
token,
|
||||||
|
new HuaWeiCreatDivertReq(zone_ip),
|
||||||
|
RequestMethod.POST);
|
||||||
|
|
||||||
|
if (response != null) {
|
||||||
|
if (response.getStatus() == HttpServletResponse.SC_CREATED) {
|
||||||
|
return ErrorCode.ERR_OK;
|
||||||
|
}else if(response.getStatus() == HttpServletResponse.SC_BAD_REQUEST) {
|
||||||
|
return ErrorCode.ERR_PARAMS;
|
||||||
|
}else if(response.getStatus() == HttpServletResponse.SC_CONFLICT){
|
||||||
|
return ErrorCode.ERR_SPECIFIEDIP_EXISTS;
|
||||||
|
} else if (response.getStatus() == HttpServletResponse.SC_PRECONDITION_FAILED) {
|
||||||
|
return ErrorCode.ERR_TOKENNOTFOUND;
|
||||||
|
}else if(response.getStatus() == HttpServletResponse.SC_INTERNAL_SERVER_ERROR){
|
||||||
|
return ErrorCode.ERR_SERVER_PROCESSREQ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ErrorCode.ERR_UNKNOWNCMD;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete divert protocol resp dto.
|
||||||
|
*
|
||||||
|
* @param baseUrlPath the base url path
|
||||||
|
* @param token the token
|
||||||
|
* @param zone_ip zone ip
|
||||||
|
* @return the delete zone status
|
||||||
|
*/
|
||||||
|
public ErrorCode deleteZones(String baseUrlPath, String token, String zone_ip) {
|
||||||
|
//获取HTTP部分
|
||||||
|
HttpResponse response = RestfulInterface.huaWeiProRun(baseUrlPath + "/divert/" + zone_ip,
|
||||||
|
token,
|
||||||
|
null,
|
||||||
|
RequestMethod.DELETE);
|
||||||
|
|
||||||
|
if (response != null) {
|
||||||
|
if (response.getStatus() == HttpServletResponse.SC_OK) {
|
||||||
|
return ErrorCode.ERR_OK;
|
||||||
|
}else if(response.getStatus() == HttpServletResponse.SC_BAD_REQUEST){
|
||||||
|
return ErrorCode.ERR_PARAMS;
|
||||||
|
}else if(response.getStatus() == HttpServletResponse.SC_NOT_FOUND){
|
||||||
|
return ErrorCode.ERR_SPECIFIEDIP_NOTEXISTS;
|
||||||
|
} else if (response.getStatus() == HttpServletResponse.SC_PRECONDITION_FAILED) {
|
||||||
|
return ErrorCode.ERR_TOKENNOTFOUND;
|
||||||
|
}else if(response.getStatus() == HttpServletResponse.SC_INTERNAL_SERVER_ERROR){
|
||||||
|
return ErrorCode.ERR_SERVER_PROCESSREQ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ErrorCode.ERR_UNKNOWNCMD;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue