@cpzxrobot/sdk 1.3.106 → 1.3.108

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.
@@ -149,17 +149,22 @@ class FactoryGateway extends Object {
149
149
  return __awaiter(this, void 0, void 0, function* () {
150
150
  var axios = yield this.context.ready;
151
151
  var baseUrl = `/api/v1/factory/${id}/workshops`;
152
+ var response = null;
152
153
  if (!tags) {
153
- const response = yield axios.get(baseUrl);
154
- return response.data;
154
+ response = yield axios.get(baseUrl);
155
+ }
156
+ else {
157
+ response = yield axios.get(`${baseUrl}?tags=${tags === null || tags === void 0 ? void 0 : tags.join(',')}`);
155
158
  }
156
- const response = yield axios.get(`${baseUrl}?tags=${tags === null || tags === void 0 ? void 0 : tags.join(',')}`);
157
159
  const body = response.data;
158
- if (body.code === 200) {
159
- return body.data;
160
+ if (response.status !== 200) {
161
+ throw new Error(`获取车间信息失败,状态码:${response.status}`);
162
+ }
163
+ else if (body.Error) {
164
+ throw new Error(body.Error);
160
165
  }
161
166
  else {
162
- throw new Error(body.message);
167
+ return body;
163
168
  }
164
169
  });
165
170
  }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.WorkshopGateway = void 0;
13
+ class WorkshopGateway {
14
+ constructor(context) {
15
+ this.context = context;
16
+ }
17
+ /**
18
+ * 获取栋舍列表
19
+ * @returns Promise 包含栋舍列表
20
+ */
21
+ list() {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const axios = yield this.context.ready;
24
+ return axios.get('/api/v2/workshop/list').then((res) => {
25
+ if (res.data.code !== 200) {
26
+ throw new Error(res.data.message || '获取栋舍列表失败');
27
+ }
28
+ return res.data.data;
29
+ });
30
+ });
31
+ }
32
+ }
33
+ exports.WorkshopGateway = WorkshopGateway;
@@ -132,16 +132,19 @@ export class FactoryGateway extends Object {
132
132
  async workshops(id: number, tags?: string[]): Promise<any> {
133
133
  var axios = await this.context.ready;
134
134
  var baseUrl = `/api/v1/factory/${id}/workshops`;
135
+ var response = null;
135
136
  if (!tags) {
136
- const response = await axios.get(baseUrl);
137
- return response.data;
137
+ response = await axios.get(baseUrl);
138
+ }else{
139
+ response = await axios.get(`${baseUrl}?tags=${tags?.join(',')}`);
138
140
  }
139
- const response = await axios.get(`${baseUrl}?tags=${tags?.join(',')}`);
140
141
  const body = response.data;
141
- if (body.code === 200) {
142
- return body.data;
142
+ if (response.status !== 200 ) {
143
+ throw new Error(`获取车间信息失败,状态码:${response.status}`);
144
+ } else if (body.Error) {
145
+ throw new Error(body.Error);
143
146
  }else{
144
- throw new Error(body.message);
147
+ return body;
145
148
  }
146
149
  }
147
150
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.3.106",
3
+ "version": "1.3.108",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {