REM:
1.增加华为设备错误码
2.增加华为设备创建引流、删除引流接口
This commit is contained in:
chenlinghy 2020-11-16 17:02:59 +08:00
parent 8fa78111db
commit 80a0e5c0db
3 changed files with 109 additions and 1 deletions

View File

@ -219,7 +219,19 @@ public enum ErrorCode {
/**
* 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, "服务器处理请求错误"),
;
/**

View File

@ -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;
}

View File

@ -1,10 +1,14 @@
package com.huawei.dispose.protocol;
import cn.hutool.http.HttpResponse;
import com.dispose.common.ErrorCode;
import com.dispose.restful.RestfulInterface;
import com.huawei.dispose.common.HuaWeiCreatDivertReq;
import com.huawei.dispose.common.HuaWeiLoginReq;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.http.HttpServletResponse;
/**
* The type Hua Wei interface.
*
@ -25,4 +29,70 @@ public class HuaWeiInterface {
new HuaWeiLoginReq(username, password),
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;
}
}