|
@@ -8,6 +8,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
/**
|
|
|
* EBA大屏工具类
|
|
|
*
|
|
@@ -22,6 +26,8 @@ public class EbaUtils {
|
|
|
|
|
|
private static MongoTemplate mongoTemplate;
|
|
|
|
|
|
+ private static Levi PARAMS = Levi.by("clientId", EbaSystemConstants.cliendId).set("clientSecret", EbaSystemConstants.clientSecret);
|
|
|
+
|
|
|
@Autowired
|
|
|
public void setMongoTemplate(MongoTemplate mongoTemplate) {
|
|
|
EbaUtils.mongoTemplate = mongoTemplate;
|
|
@@ -43,12 +49,38 @@ public class EbaUtils {
|
|
|
* @return
|
|
|
*/
|
|
|
public static String getToken() {
|
|
|
- Levi params = Levi.by("clientId", EbaSystemConstants.cliendId).set("clientSecret", EbaSystemConstants.clientSecret);
|
|
|
String result = HttpRequest.post(EbaSystemConstants.tokenGetInfo)
|
|
|
.header("content-type", "application/json")
|
|
|
- .body(JSON.toJSONString(params))
|
|
|
+ .body(JSON.toJSONString(PARAMS))
|
|
|
.execute().body();
|
|
|
- log.info("#########> 获取token:{} 参数:{}", result, JSON.toJSONString(params));
|
|
|
+ log.info("#########> 获取token:{} 参数:{}", result, JSON.toJSONString(PARAMS));
|
|
|
return LeviUtils.getJsonFieldOne(result, "data.token", String.class);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 当前用户下项目列表
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static List<Map> getProjectList(){
|
|
|
+ String result = HttpRequest.post(EbaSystemConstants.projectGetList)
|
|
|
+ .header("token", getToken())
|
|
|
+ .body(JSON.toJSONString(PARAMS))
|
|
|
+ .execute().body();
|
|
|
+ log.info("#########> 获取token:{} 参数:{}", result, JSON.toJSONString(PARAMS));
|
|
|
+ return LeviUtils.getJsonFieldMany(result, "data.projectList",Map.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 项目下所有设备列表
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static List<Map> getDeviceList(){
|
|
|
+ String result = HttpRequest.post(EbaSystemConstants.deviceGetDevice)
|
|
|
+ .body("{\n\t\"projectId\":1250\n}")
|
|
|
+ .header("token", getToken())
|
|
|
+ .body(JSON.toJSONString(PARAMS))
|
|
|
+ .execute().body();
|
|
|
+ log.info("#########> 获取token:{} 参数:{}", result, JSON.toJSONString(PARAMS));
|
|
|
+ return LeviUtils.getJsonFieldMany(result, "data.projectList",Map.class);
|
|
|
+ }
|
|
|
}
|