@cpzxrobot/sdk 1.0.38 → 1.0.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/camera_gateway.ts CHANGED
@@ -7,31 +7,36 @@ export class CameraGateway extends Object {
7
7
  this.context = context;
8
8
  }
9
9
  //搜索摄像头,传入unit对象或者unit的id
10
- async search(data: Unit): Promise<any> {
10
+ async search(
11
+ data:
12
+ | Unit
13
+ | {
14
+ workshop_id: number;
15
+ factory_id: number;
16
+ unit_id: number;
17
+ }
18
+ ): Promise<any> {
11
19
  var axios = await this.context.ready;
12
- var id = data.id;
20
+ var params = {};
13
21
 
14
- if (!id) {
15
- //if data is string
16
- if (typeof data === "string") {
17
- id = data;
18
- }else{
19
- throw new Error("请传入正确的Unit对象");
20
- }
22
+ if (!("id" in data)) {
23
+ params = data as {
24
+ workshop_id: number;
25
+ factory_id: number;
26
+ unit_id: number;
27
+ };
28
+ }else{
29
+ params = {unit_id:data.id}
21
30
  }
22
31
 
23
- const response = await axios.post("/api/v1/camera/search", {
24
- unit_id: id,
25
- });
32
+ const response = await axios.post("/api/v1/camera/search", params);
26
33
  return response.data;
27
34
  }
28
35
 
29
36
  //获得摄像头的播放地址
30
37
  async getUrl(data: Camera): Promise<any> {
31
38
  var axios = await this.context.ready;
32
- const response = await axios.get(
33
- `/api/v1/camera/${data.id}/url/wss`
34
- );
39
+ const response = await axios.get(`/api/v1/camera/${data.id}/url/wss`);
35
40
  return response.data;
36
41
  }
37
42
  //获取工厂天气
@@ -9,19 +9,14 @@ class CameraGateway extends Object {
9
9
  //搜索摄像头,传入unit对象或者unit的id
10
10
  async search(data) {
11
11
  var axios = await this.context.ready;
12
- var id = data.id;
13
- if (!id) {
14
- //if data is string
15
- if (typeof data === "string") {
16
- id = data;
17
- }
18
- else {
19
- throw new Error("请传入正确的Unit对象");
20
- }
12
+ var params = {};
13
+ if (!("id" in data)) {
14
+ params = data;
21
15
  }
22
- const response = await axios.post("/api/v1/camera/search", {
23
- unit_id: id,
24
- });
16
+ else {
17
+ params = { unit_id: data.id };
18
+ }
19
+ const response = await axios.post("/api/v1/camera/search", params);
25
20
  return response.data;
26
21
  }
27
22
  //获得摄像头的播放地址
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/types.d.ts CHANGED
@@ -77,6 +77,8 @@ type Unit = {
77
77
  id?: number;
78
78
  type?: string;
79
79
  workshopName?: string;
80
+ workshopId?: number;
81
+ factoryId?: number;
80
82
  };
81
83
 
82
84
  type HeatLamp = {