Browse Source

统一海康与后台响应

longan 1 year ago
parent
commit
25cb8c0661
1 changed files with 10 additions and 3 deletions
  1. 10 3
      isapi/client.go

+ 10 - 3
isapi/client.go

@@ -44,11 +44,18 @@ func TouChuan(host string, o Operation, data []byte, c *gin.Context) (resp any,
 		response.FailWithDetailed(resp.(ResponseStatus), err.Error(), c)
 		return
 	}
-	_, ok := resp.(ResponseStatus)
+	//断言成功,说明是配置响应,检查配置结果
+	r, ok := resp.(ResponseStatus)
 	if ok {
-		response.OkWithDetailed(resp, "操作成功", c)
-		return
+		if r.StatusCode == 0 || r.StatusCode == 1 {
+			response.OkWithDetailed(resp, "操作成功", c)
+			return
+		} else {
+			response.FailWithDetailed(resp, "操作失败,请联系管理员", c)
+			return
+		}
 	}
+	//断言失败,说明是查询响应,直接返回数据
 	response.OkWithData(resp, c)
 	return
 }