refactor(device): 重构 ArmCloudApiClient 类
- 格式化代码,提高可读性 - 优化 JSON 构建和解析逻辑 - 统一异常处理方式 - 简化部分代码结构,提高维护性
This commit is contained in:
parent
237f07f968
commit
c3467add0e
|
@ -235,7 +235,7 @@ public class ArmCloudApiClient {
|
||||||
LogFileUtil.logAndWrite(Log.ERROR, "ArmCloudApiClient", "updateInstanceProperties: 接口返回错误码 " + code + ", 错误信息: " + errorMsg, null);
|
LogFileUtil.logAndWrite(Log.ERROR, "ArmCloudApiClient", "updateInstanceProperties: 接口返回错误码 " + code + ", 错误信息: " + errorMsg, null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LogFileUtil.logAndWrite(Log.ERROR, "ArmCloudApiClient", "updateInstanceProperties: 响应中缺少 'code' 字段",null);
|
LogFileUtil.logAndWrite(Log.ERROR, "ArmCloudApiClient", "updateInstanceProperties: 响应中缺少 'code' 字段", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return responseBodyString;
|
return responseBodyString;
|
||||||
|
@ -302,15 +302,21 @@ public class ArmCloudApiClient {
|
||||||
json.put("page", page);
|
json.put("page", page);
|
||||||
json.put("rows", rows);
|
json.put("rows", rows);
|
||||||
|
|
||||||
if (armServerCode != null) json.put("armServerCode", armServerCode);
|
if (armServerCode != null) {
|
||||||
if (deviceCode != null) json.put("deviceCode", deviceCode);
|
json.put("armServerCode", armServerCode);
|
||||||
|
}
|
||||||
|
if (deviceCode != null) {
|
||||||
|
json.put("deviceCode", deviceCode);
|
||||||
|
}
|
||||||
if (padCodes != null && padCodes.length > 0) {
|
if (padCodes != null && padCodes.length > 0) {
|
||||||
json.put("padCodes", new JSONArray(Arrays.asList(padCodes)));
|
json.put("padCodes", new JSONArray(Arrays.asList(padCodes)));
|
||||||
}
|
}
|
||||||
if (groupIds != null && groupIds.length > 0) {
|
if (groupIds != null && groupIds.length > 0) {
|
||||||
json.put("groupIds", new JSONArray(Arrays.asList(groupIds)));
|
json.put("groupIds", new JSONArray(Arrays.asList(groupIds)));
|
||||||
}
|
}
|
||||||
if (idc != null) json.put("idc", idc);
|
if (idc != null) {
|
||||||
|
json.put("idc", idc);
|
||||||
|
}
|
||||||
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
LogFileUtil.logAndWrite(Log.ERROR, "ArmCloudApiClient", "getInstanceListInfo: JSON 构建失败", e);
|
LogFileUtil.logAndWrite(Log.ERROR, "ArmCloudApiClient", "getInstanceListInfo: JSON 构建失败", e);
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue