Commit 9e7baafb authored by zhouzihao's avatar zhouzihao

dev-添加banner和userInfo接口

parent 3e0b690d
......@@ -42,18 +42,24 @@ public class Tmp {
log.info("we run it {} times", ++times);
Case case1 = null;
// 上线前使用这段代码
// case1 = new EmptyCase(sId,uid);
// 登录
case1 = new LoginCase(mobile, pwd);
// 查询用户信息
case1 = new UserInfoDecorator(case1);
case1 = new CarListDecorator(case1);
case1 = new CarInfoDecorator(case1);
case1 = new CarDetectDecorator(case1);
case1 = new CarStatusDecorator(case1);
case1.check();
// 注释掉这段代码
// banner接口
Case case2 = null;
case2 = new TestCase();
case2 = new EmptyCase(sId,uid);
case2 = new BannerListDecorator(case2);
case2.check();
log.info("over!");
}
......
package com.vandyo.sentry.core.cases;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.vandyo.sentry.core.dto.Res;
import com.vandyo.sentry.core.tools.Signature;
import java.util.HashMap;
import java.util.Map;
/**
* 获取Banner列表接口
*/
public class BannerListDecorator extends CaseDecorator {
private final static String bannerListUrl = "/user/banner/list";
public BannerListDecorator(Case aCase) {
super(aCase);
}
@Override
public Res<Map<String, String>> check() {
Res<Map<String, String>> oldRes = super.check();
if (oldRes.getSuccess()) {
Map<String, String> carMap = oldRes.getData();
Res<Map<String, String>> newRes = new Res<>();
newRes.setSId(oldRes.getSId());
newRes.setUId(oldRes.getUId());
Map<String, String> paramMap = new HashMap<>();
paramMap.put("uid", oldRes.getUId());
paramMap.put("type", "1");
HttpResponse response = HttpRequest.post(Signature.host + bannerListUrl)
.body(JSONUtil.parseFromMap(paramMap).toString())
.execute();
if (response.isOk()) {
JSONObject jsonObject = JSONUtil.parseObj(response.body());
//todo 检测 返回值可用性
newRes.setData(carMap);
newRes.setSuccess(true);
} else {
newRes.setKey(bannerListUrl);
newRes.setStatus(Signature.matchStatus(response.getStatus()));
newRes.setSuccess(false);
}
return newRes;
} else {
oldRes.setIgnore(true);
return oldRes;
}
}
}
package com.vandyo.sentry.core.cases;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.vandyo.sentry.core.collectionMachine.CollectionMachine;
import com.vandyo.sentry.core.dto.Res;
import com.vandyo.sentry.core.tools.Signature;
import java.util.HashMap;
import java.util.Map;
/**
* 获取用户信息接口
*/
public class UserInfoDecorator extends CaseDecorator {
private final static String UserInfoUrl = "/user/info/get";
public UserInfoDecorator(Case aCase) {
super(aCase);
}
@Override
public Res<Map<String, String>> check() {
Res<Map<String, String>> oldRes = super.check();
if (oldRes.getSuccess()) {
Map<String, String> data = new HashMap<>();
data.put("uid", oldRes.getUId());
HttpResponse response = HttpRequest.get(Signature.host + UserInfoUrl + "?"
+ Signature.getUrlParamsByMap(Signature.sign(data, oldRes.getSId())))
.execute();
Res<Map<String, String>> newRes = new Res<>();
newRes.setSId(oldRes.getSId());
newRes.setUId(oldRes.getUId());
if (response.isOk()) {
JSONObject json = JSONUtil.parseObj(response.body());
newRes.setSuccess(true);
} else {
newRes.setKey(UserInfoUrl);
newRes.setStatus(Signature.matchStatus(response.getStatus()));
newRes.setSuccess(false);
}
CollectionMachine.post(newRes);
return newRes;
} else {
oldRes.setIgnore(true);
return oldRes;
}
}
}
\ No newline at end of file
......@@ -20,7 +20,7 @@ public class CollectionMachine {
public static void post(Res<Map<String, String>> log) {
// 应该对于不同的请求统一管理 还是 每个单独管理呢?
logger.info("temp long is {}", temp.size());
// logger.info("temp long is {}", temp.size());
if (log.getIgnore() || log.getSuccess()) {
//pass
} else {
......
......@@ -10,12 +10,16 @@ checkmeta:
"[/car/car_detect]": 车体检
"[/car/my_car/list]": 车列表
"[/carDynamic/api/status/car/state/get]": 车动态
"[/user/banner/list]": 首页获取banner
"[/user/info/get]": 获取用户信息
test: 测试接口
timeMap:
"[/car/my_car/info]": 6
"[/car/car_detect]": 6
"[/car/my_car/list]": 6
"[/carDynamic/api/status/car/state/get]": 6
"[/user/banner/list]": 6
"[/user/info/get]": 6
test: 2
emailList[0]: "1042181618@qq.com"
......
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