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;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.vandyo.sentry.core.dto.ErrStatus;
import com.vandyo.sentry.core.dto.Res;
import com.vandyo.sentry.core.tools.Signature;
......@@ -35,9 +36,16 @@ public class CarListDecorator extends CaseDecorator {
if (response.isOk()){
JSONObject json = JSONUtil.parseObj(response.body());
JSONArray list = json.getJSONArray("result");
//todo
newRes.setSuccess(true);
if(list.size() < 1){
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);
}
}else {
newRes.setSuccess(false);
}
......
......@@ -9,9 +9,16 @@ public enum ErrStatus {
* 400错误
*/
Err4xx,
/**
* 超时错误
*/
ErrTimeout,
/**
* 没有预期的返回值
*/
ErrUnexpected,
/**
* 未知错误
*/
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