@cpzxrobot/sdk 1.1.5 → 1.1.7

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/device_filter.ts CHANGED
@@ -330,22 +330,22 @@ export abstract class DeviceFilter<T extends { id: number }> {
330
330
  options:
331
331
  | undefined
332
332
  | {
333
- id?: Number | null | undefined;
334
- data?:
335
- | "diffPerDay"
336
- | "sumPerDay"
337
- | "latest"
338
- | "weekoverweek"
339
- | "last"
340
- | "rangeOfDay"
341
- | "rangeToday"
342
- | null; //如果data为null,则不获取数据,只获取设备列表,否则获取设备列表和数据
343
- status?: string;
344
- unit?: Number;
345
- detail?: boolean;
346
- type?: string;
347
- supplier?: string; //供应商,可用于过滤设备
348
- } = undefined
333
+ id?: Number | null | undefined;
334
+ data?:
335
+ | "diffPerDay"
336
+ | "sumPerDay"
337
+ | "latest"
338
+ | "weekoverweek"
339
+ | "last"
340
+ | "rangeOfDay"
341
+ | "rangeToday"
342
+ | null; //如果data为null,则不获取数据,只获取设备列表,否则获取设备列表和数据
343
+ status?: string;
344
+ unit?: Number;
345
+ detail?: boolean;
346
+ type?: string;
347
+ supplier?: string; //供应商,可用于过滤设备
348
+ } = undefined
349
349
  ): Promise<T[]> {
350
350
  // if (this.devices.length > 0) {
351
351
  // return Promise.resolve(this.devices)
@@ -23,6 +23,29 @@ class FactoryGateway extends Object {
23
23
  const response = await axios.get(`/api/v1/workshop/unit/${id}`);
24
24
  return response.data;
25
25
  }
26
+ //获得工厂的应用信息, 如果指定withRoles为true,则返回app和app的详细角色信息
27
+ async apps(id, withRoles = false) {
28
+ var axios = await this.context.ready;
29
+ var url = `/api/v2/factory/${id}/apps`;
30
+ if (withRoles) {
31
+ url += "/roles";
32
+ }
33
+ const response = await axios.get(url);
34
+ return response.data;
35
+ }
36
+ async roles(id) {
37
+ var axios = await this.context.ready;
38
+ return axios.get("/api/v2/factory/" + id + "/roles");
39
+ }
40
+ async addRole(id, data) {
41
+ data.factoryId = id;
42
+ var axios = await this.context.ready;
43
+ return axios.post("/api/v2/factory/role", data);
44
+ }
45
+ async users(id) {
46
+ var axios = await this.context.ready;
47
+ return axios.get("/api/v2/factory/" + id + "/users");
48
+ }
26
49
  //获得工厂的车间信息
27
50
  get workshop() {
28
51
  return {
@@ -207,7 +207,7 @@ class PigfarmGateway extends Object {
207
207
  //增加模板
208
208
  add: (factory, name, data) => {
209
209
  return this.context.ready.then((axios) => {
210
- return axios.post(`/api/v1/pigfarm/heatLamp/config/add`, Object.assign(Object.assign({}, data), { factoryId: factory.id, templateName: name }));
210
+ return axios.post(`/api/v1/pigfarm/heatLamp/config/template`, Object.assign(Object.assign({}, data), { factoryId: factory.id, templateName: name }));
211
211
  });
212
212
  },
213
213
  },
@@ -105,11 +105,7 @@ class UserGateway extends Object {
105
105
  }
106
106
  async list(factory) {
107
107
  var axios = await this.context.ready;
108
- return axios.get("/api/v2/user/list/" + factory.id);
109
- }
110
- async roles() {
111
- var axios = await this.context.ready;
112
- return axios.get("/api/v2/user/role/list");
108
+ return axios.get("/api/v2/" + factory.id + "/users");
113
109
  }
114
110
  async mypermission() {
115
111
  var axios = await this.context.ready;
@@ -28,6 +28,33 @@ export class FactoryGateway extends Object {
28
28
  return response.data;
29
29
  }
30
30
 
31
+ //获得工厂的应用信息, 如果指定withRoles为true,则返回app和app的详细角色信息
32
+ async apps(id: number, withRoles = false): Promise<any> {
33
+ var axios = await this.context.ready;
34
+ var url = `/api/v2/factory/${id}/apps`;
35
+ if (withRoles) {
36
+ url += "/roles";
37
+ }
38
+ const response = await axios.get(url);
39
+ return response.data;
40
+ }
41
+
42
+ async roles(id: number) {
43
+ var axios = await this.context.ready;
44
+ return axios.get("/api/v2/factory/" + id+"/roles");
45
+ }
46
+
47
+ async addRole(id: number, data: any) {
48
+ data.factoryId = id;
49
+ var axios = await this.context.ready;
50
+ return axios.post("/api/v2/factory/role", data);
51
+ }
52
+
53
+ async users(id: number) {
54
+ var axios = await this.context.ready;
55
+ return axios.get("/api/v2/factory/" + id+"/users");
56
+ }
57
+
31
58
  //获得工厂的车间信息
32
59
  get workshop() {
33
60
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -258,7 +258,7 @@ export class PigfarmGateway extends Object {
258
258
  //增加模板
259
259
  add: (factory: Factory, name:String,data: HeatLamp) => {
260
260
  return this.context.ready.then((axios) => {
261
- return axios.post(`/api/v1/pigfarm/heatLamp/config/add`, {
261
+ return axios.post(`/api/v1/pigfarm/heatLamp/config/template`, {
262
262
  ...data,
263
263
  factoryId: factory.id,
264
264
  templateName: name,
package/readme.md CHANGED
@@ -87,6 +87,9 @@ baseURL: "/"
87
87
  | cpzxrobot().camera.xxx | 获得摄像头的相关信息 |
88
88
  | cpzxrobot().camera.control | 控制摄像头,例如:左移,右移,上移,下移等,如果传输start为true,则开始控制,如果传输stop为true,则停止控制,如果都没传输,则执行3秒后自动停止,传输start为true时,前端必须在需要停止时自行发送stop为true的消息 |
89
89
  | cpzxrobot().factory.entry | 获得工厂的可显示动态信息 |
90
+ | cpzxrobot().factory.apps | 获得工厂的应用列表,如果指定withRoles为true,则返回app和app的详细角色信息 |
91
+ | cpzxrobot().factory.roles | 获得工厂的角色列表 |
92
+ | cpzxrobot().factory.addRole | 添加工厂的角色 |
90
93
  | cpzxrobot().factory.info.get | 获得工厂的附加信息 |
91
94
  | cpzxrobot().factory.info.post | 更新或更新工厂的附加信息 |
92
95
  | cpzxrobot().factory.banner.add | 添加工厂的banner图片,提交formdata,需要传入file参数 |
package/user_gateway.ts CHANGED
@@ -113,12 +113,7 @@ export class UserGateway extends Object {
113
113
 
114
114
  async list(factory: Factory) {
115
115
  var axios = await this.context.ready;
116
- return axios.get("/api/v2/user/list/" + factory.id);
117
- }
118
-
119
- async roles() {
120
- var axios = await this.context.ready;
121
- return axios.get("/api/v2/user/role/list");
116
+ return axios.get("/api/v2/" + factory.id+"/users");
122
117
  }
123
118
 
124
119
  async mypermission() {