Commit a44aa406 authored by zhouzihao's avatar zhouzihao

dev-完善获取车辆列表

parent 2652c92f
Pipeline #76 failed with stages
...@@ -5,6 +5,7 @@ import cn.hutool.http.HttpResponse; ...@@ -5,6 +5,7 @@ import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.vandyo.sentry.core.dto.ErrStatus;
import com.vandyo.sentry.core.dto.Res; import com.vandyo.sentry.core.dto.Res;
import com.vandyo.sentry.core.tools.Signature; import com.vandyo.sentry.core.tools.Signature;
...@@ -35,9 +36,16 @@ public class CarListDecorator extends CaseDecorator { ...@@ -35,9 +36,16 @@ public class CarListDecorator extends CaseDecorator {
if (response.isOk()){ if (response.isOk()){
JSONObject json = JSONUtil.parseObj(response.body()); JSONObject json = JSONUtil.parseObj(response.body());
JSONArray list = json.getJSONArray("result"); JSONArray list = json.getJSONArray("result");
if(list.size() < 1){
//todo newRes.setSuccess(false);
newRes.setStatus(ErrStatus.ErrUnexpected);
}else {
Map<String,String> carMap = new HashMap<>();
JSONObject car = (JSONObject) list.get(0);
carMap.put("cid",car.getStr("cid"));
newRes.setData(carMap);
newRes.setSuccess(true); newRes.setSuccess(true);
}
}else { }else {
newRes.setSuccess(false); newRes.setSuccess(false);
} }
......
...@@ -9,9 +9,16 @@ public enum ErrStatus { ...@@ -9,9 +9,16 @@ public enum ErrStatus {
* 400错误 * 400错误
*/ */
Err4xx, Err4xx,
/**
* 超时错误
*/
ErrTimeout,
/**
* 没有预期的返回值
*/
ErrUnexpected,
/** /**
* 未知错误 * 未知错误
*/ */
ErrUnknown; ErrUnknown;
//TODO 扩展数据 错误类型:超时错误
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment