|
@@ -0,0 +1,103 @@
|
|
|
+package com.jpsoft.smart.modules.common.utils;
|
|
|
+
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author 墨鱼_mo
|
|
|
+ * @date 2020-3-14 16:43
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class IApiUtil {
|
|
|
+
|
|
|
+
|
|
|
+ /* public JSONObject PostRequest(String url){
|
|
|
+
|
|
|
+ String body = HttpRequest.post(url).header("referer",referer).form(map).execute().body();
|
|
|
+ JSONObject jsonbody = JSONObject.parseObject(body);
|
|
|
+ return jsonbody;
|
|
|
+
|
|
|
+
|
|
|
+ }*/
|
|
|
+
|
|
|
+ public static JSONObject GetRequest(String url) throws Exception{
|
|
|
+
|
|
|
+ String body = HttpRequest.get(url).execute().body();
|
|
|
+ JSONObject jsonbody = JSONObject.parseObject(body);
|
|
|
+ return jsonbody;
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static JSONObject getResponse(JSONObject dataJson) throws Exception{
|
|
|
+
|
|
|
+ if (dataJson.getInteger("ResponseCode") == 1){
|
|
|
+ throw new Exception("通用错误");
|
|
|
+ }
|
|
|
+ if (dataJson.getInteger("ResponseCode") == 2){
|
|
|
+ throw new Exception("参数非法");
|
|
|
+ }
|
|
|
+ if (dataJson.getInteger("ResponseCode") == 3){
|
|
|
+ throw new Exception("用户无权限");
|
|
|
+ }
|
|
|
+ if (dataJson.getInteger("ResponseCode") == 4){
|
|
|
+ throw new Exception("设备不支持");
|
|
|
+ }
|
|
|
+ if (dataJson.getInteger("ResponseCode") == 5){
|
|
|
+ throw new Exception("用户状态异常");
|
|
|
+ }
|
|
|
+ if (dataJson.getInteger("StatusCode") == 1){
|
|
|
+ throw new Exception("执行失败");
|
|
|
+ }
|
|
|
+ if (dataJson.getInteger("StatusCode") == 2){
|
|
|
+ throw new Exception("输入参数非法");
|
|
|
+ }
|
|
|
+ if (dataJson.getInteger("StatusCode") == 3){
|
|
|
+ throw new Exception("系统内存不足");
|
|
|
+ }
|
|
|
+ if (dataJson.getInteger("StatusCode") == 8){
|
|
|
+ throw new Exception("功能不支持");
|
|
|
+ }
|
|
|
+ if (dataJson.getInteger("StatusCode") == 10){
|
|
|
+ throw new Exception("序列化执行失败");
|
|
|
+ }
|
|
|
+ if (dataJson.getInteger("StatusCode") == 11){
|
|
|
+ throw new Exception("Basic 鉴权失败");
|
|
|
+ }
|
|
|
+ if (dataJson.getInteger("StatusCode") == 12){
|
|
|
+ throw new Exception("Digest 鉴权失败");
|
|
|
+ }
|
|
|
+ if (dataJson.getInteger("StatusCode") == 13){
|
|
|
+ throw new Exception("订阅已满");
|
|
|
+ }
|
|
|
+ if (dataJson.getInteger("StatusCode") == 14){
|
|
|
+ throw new Exception("重复订阅");
|
|
|
+ }
|
|
|
+ return dataJson.getJSONObject("Data");
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getMatchMsg(Integer matchStatus){
|
|
|
+ String matchMsg = "";
|
|
|
+ if (matchStatus ==1){
|
|
|
+ matchMsg = "核验成功";
|
|
|
+ }
|
|
|
+ else if (matchStatus == 2){
|
|
|
+ matchMsg = "对比失败";
|
|
|
+ }
|
|
|
+ else if (matchStatus == 3){
|
|
|
+ matchMsg = "对比成功,不在布控时间";
|
|
|
+ }
|
|
|
+ else if (matchStatus == 10){
|
|
|
+ matchMsg = "对比成功,人脸属性异常";
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ matchMsg = "未知匹配消息";
|
|
|
+ }
|
|
|
+
|
|
|
+ return matchMsg;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|