@cpzxrobot/sdk 1.1.19 → 1.1.21

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.
@@ -0,0 +1,35 @@
1
+ import { Cpzxrobot, Factory, Unit } from "./types";
2
+
3
+ export class ContractGateway extends Object {
4
+ context: Cpzxrobot;
5
+
6
+ constructor(context: Cpzxrobot) {
7
+ super();
8
+ this.context = context;
9
+ }
10
+
11
+ list(args: {
12
+ pageNo: number;
13
+ pageSize: number;
14
+ name: string;
15
+ factory_id: number;
16
+ }) {
17
+
18
+ return this.context.ready.then((axios) => {
19
+ return axios.post(`/api/v2/coremde-sale/contract/list`, args);
20
+ });
21
+ }
22
+
23
+ get(id: number) {
24
+ return this.context.ready.then((axios) => {
25
+ return axios.get(`/api/v2/coremde-sale/contract/get?id=${id}`);
26
+ });
27
+ }
28
+
29
+ add(args: any) {
30
+ return this.context.ready.then((axios) => {
31
+ return axios.post(`/api/v2/coremde-sale/contract/add`, args);
32
+ });
33
+ }
34
+
35
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContractGateway = void 0;
4
+ class ContractGateway extends Object {
5
+ constructor(context) {
6
+ super();
7
+ this.context = context;
8
+ }
9
+ list(args) {
10
+ return this.context.ready.then((axios) => {
11
+ return axios.post(`/api/v2/coremde-sale/contract/list`, args);
12
+ });
13
+ }
14
+ get(id) {
15
+ return this.context.ready.then((axios) => {
16
+ return axios.get(`/api/v2/coremde-sale/contract/get?id=${id}`);
17
+ });
18
+ }
19
+ add(args) {
20
+ return this.context.ready.then((axios) => {
21
+ return axios.post(`/api/v2/coremde-sale/contract/add`, args);
22
+ });
23
+ }
24
+ }
25
+ exports.ContractGateway = ContractGateway;
@@ -23,6 +23,10 @@ class FactoryGateway extends Object {
23
23
  const response = await axios.get(`/api/v1/workshop/unit/${id}`);
24
24
  return response.data;
25
25
  }
26
+ async add(factory) {
27
+ var axios = await this.context.ready;
28
+ return axios.post("/api/v2/company/factory", factory);
29
+ }
26
30
  //获得工厂的应用信息, 如果指定withRoles为true,则返回app和app的详细角色信息
27
31
  async apps(id, withRoles = false) {
28
32
  var axios = await this.context.ready;
package/dist/index.js CHANGED
@@ -17,6 +17,9 @@ const pigfarm_gateway_1 = require("./pigfarm_gateway");
17
17
  const unit_gateway_1 = require("./unit_gateway");
18
18
  const chickenfarm_gateway_1 = require("./chickenfarm_gateway");
19
19
  const car_gateway_1 = require("./car_gateway");
20
+ const project_gateway_1 = require("./project_gateway");
21
+ const product_gateway_1 = require("./product_gateway");
22
+ const contract_gateway_1 = require("./contract_gateway");
20
23
  class Cpzxrobot {
21
24
  constructor(appCode) {
22
25
  this.pigfarm = new pigfarm_gateway_1.PigfarmGateway(this);
@@ -26,6 +29,9 @@ class Cpzxrobot {
26
29
  this.auth = "";
27
30
  this.token = "";
28
31
  this.car = new car_gateway_1.CarGateway(this);
32
+ this.project = new project_gateway_1.ProjectGateway(this);
33
+ this.product = new product_gateway_1.ProductGateway(this);
34
+ this.contract = new contract_gateway_1.ContractGateway(this);
29
35
  //获取当前浏览器的域名
30
36
  this.ready = new Promise((resolve, reject) => {
31
37
  this.resolveReady = resolve;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProductGateway = void 0;
4
+ class ProductGateway extends Object {
5
+ constructor(context) {
6
+ super();
7
+ this.context = context;
8
+ }
9
+ list(args) {
10
+ return this.context.ready.then((axios) => {
11
+ return axios.post(`/api/v2/coremde-sale/product/list`, args);
12
+ });
13
+ }
14
+ get(id) {
15
+ return this.context.ready.then((axios) => {
16
+ return axios.get(`/api/v2/coremde-sale/product/get?id=${id}`);
17
+ });
18
+ }
19
+ }
20
+ exports.ProductGateway = ProductGateway;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProjectGateway = void 0;
4
+ class ProjectGateway extends Object {
5
+ constructor(context) {
6
+ super();
7
+ this.context = context;
8
+ }
9
+ list(args) {
10
+ return this.context.ready.then((axios) => {
11
+ return axios.post(`/api/v2/coremde-sale/project/list`, args);
12
+ });
13
+ }
14
+ get(id) {
15
+ return this.context.ready.then((axios) => {
16
+ return axios.get(`/api/v2/coremde-sale/project/get?id=${id}`);
17
+ });
18
+ }
19
+ get feedback() {
20
+ return {
21
+ add: (userId, address) => {
22
+ return this.context.ready.then((axios) => {
23
+ return axios.post(`/api/v2/coremde-sale/checkin/add`, {
24
+ userId,
25
+ address
26
+ });
27
+ });
28
+ },
29
+ //date 传入格式为2019-8或者Date类型对象
30
+ list: (projectId) => {
31
+ return this.context.ready.then((axios) => {
32
+ return axios.post(`/api/v2/coremde-sale/project/feedback/list`, {
33
+ projectId,
34
+ });
35
+ });
36
+ }
37
+ };
38
+ }
39
+ }
40
+ exports.ProjectGateway = ProjectGateway;
@@ -168,5 +168,25 @@ class UserGateway extends Object {
168
168
  }
169
169
  };
170
170
  }
171
+ searchHistory() {
172
+ return {
173
+ list: (type) => {
174
+ return this.context.ready.then((axios) => {
175
+ return axios.post(`/api/v2/coremde-sale/search/list`, {
176
+ type
177
+ });
178
+ });
179
+ },
180
+ //添加搜索历史,type 1:合同,2:项目
181
+ add: (keyword, type) => {
182
+ return this.context.ready.then((axios) => {
183
+ return axios.post(`/api/v2/coremde-sale/search/add`, {
184
+ name: keyword,
185
+ type
186
+ });
187
+ });
188
+ }
189
+ };
190
+ }
171
191
  }
172
192
  exports.UserGateway = UserGateway;
@@ -28,6 +28,11 @@ export class FactoryGateway extends Object {
28
28
  return response.data;
29
29
  }
30
30
 
31
+ async add(factory: Factory) {
32
+ var axios = await this.context.ready;
33
+ return axios.post("/api/v2/company/factory", factory);
34
+ }
35
+
31
36
  //获得工厂的应用信息, 如果指定withRoles为true,则返回app和app的详细角色信息
32
37
  async apps(id: number, withRoles = false): Promise<any> {
33
38
  var axios = await this.context.ready;
package/index.ts CHANGED
@@ -12,6 +12,9 @@ import { Device, Factory, MyAxiosInstance, Unit } from "./types";
12
12
  import { UnitGateway } from "./unit_gateway";
13
13
  import { ChickenFarmGateway } from "./chickenfarm_gateway";
14
14
  import { CarGateway } from "./car_gateway";
15
+ import { ProjectGateway } from "./project_gateway";
16
+ import { ProductGateway } from "./product_gateway";
17
+ import { ContractGateway } from "./contract_gateway";
15
18
 
16
19
  export class Cpzxrobot {
17
20
  device: DeviceGateway;
@@ -45,6 +48,9 @@ export class Cpzxrobot {
45
48
  camera: CameraGateway;
46
49
  unit: UnitGateway;
47
50
  car: CarGateway = new CarGateway(this);
51
+ project: ProjectGateway = new ProjectGateway(this);
52
+ product: ProductGateway = new ProductGateway(this);
53
+ contract: ContractGateway = new ContractGateway(this);
48
54
 
49
55
  constructor(appCode: string) {
50
56
  //获取当前浏览器的域名
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpzxrobot/sdk",
3
- "version": "1.1.19",
3
+ "version": "1.1.21",
4
4
  "description": "提供给上海正芯数智APP第三方H5应用使用的SDK",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -0,0 +1,29 @@
1
+ import { Cpzxrobot, Factory, Unit } from "./types";
2
+
3
+ export class ProductGateway extends Object {
4
+ context: Cpzxrobot;
5
+
6
+ constructor(context: Cpzxrobot) {
7
+ super();
8
+ this.context = context;
9
+ }
10
+
11
+ list(args: {
12
+ pageNo: number;
13
+ pageSize: number;
14
+ name: string;
15
+ factory_id: number;
16
+ }) {
17
+
18
+ return this.context.ready.then((axios) => {
19
+ return axios.post(`/api/v2/coremde-sale/product/list`, args);
20
+ });
21
+ }
22
+
23
+ get(id: number) {
24
+ return this.context.ready.then((axios) => {
25
+ return axios.get(`/api/v2/coremde-sale/product/get?id=${id}`);
26
+ });
27
+ }
28
+
29
+ }
@@ -0,0 +1,50 @@
1
+ import { Cpzxrobot, Factory, Unit } from "./types";
2
+
3
+ export class ProjectGateway extends Object {
4
+ context: Cpzxrobot;
5
+
6
+ constructor(context: Cpzxrobot) {
7
+ super();
8
+ this.context = context;
9
+ }
10
+
11
+ list(args: {
12
+ pageNo: number;
13
+ pageSize: number;
14
+ name: string;
15
+ factory_id: number;
16
+ }) {
17
+
18
+ return this.context.ready.then((axios) => {
19
+ return axios.post(`/api/v2/coremde-sale/project/list`, args);
20
+ });
21
+ }
22
+
23
+ get(id: number) {
24
+ return this.context.ready.then((axios) => {
25
+ return axios.get(`/api/v2/coremde-sale/project/get?id=${id}`);
26
+ });
27
+ }
28
+
29
+ get feedback() {
30
+ return {
31
+ add: (userId: number,address: String) => {
32
+ return this.context.ready.then((axios) => {
33
+ return axios.post(`/api/v2/coremde-sale/checkin/add`, {
34
+ userId,
35
+ address
36
+ });
37
+ });
38
+ },
39
+ //date 传入格式为2019-8或者Date类型对象
40
+ list: (projectId: number) => {
41
+ return this.context.ready.then((axios) => {
42
+ return axios.post(`/api/v2/coremde-sale/project/feedback/list`, {
43
+ projectId,
44
+ });
45
+ });
46
+ }
47
+ };
48
+ }
49
+
50
+ }
package/readme.md CHANGED
@@ -143,6 +143,16 @@ baseURL: "/"
143
143
  | cpzxrobot().user.approval.count | 获取用户审批列表的数量,传入userId和status参数 |
144
144
  | cpzxrobot().user.checkin.add | 添加用户签到记录,传入userId和address参数 |
145
145
  | cpzxrobot().user.checkin.list | 列出用户签到记录,传入userId和date参数 |
146
+ | cpzxrobot().user.searchHistoy.list | 列出用户搜索历史记录,传入type参数 |
147
+ | cpzxrobot().user.searchHistoy.add | 添加用户搜索历史记录,传入type参数和搜索内容 |
148
+ | cpzxrobot().product.list | 获得产品列表,传入factory_id和必要的分页参数 |
149
+ | cpzxrobot().product.get | 获得产品信息,传入id参数 |
150
+ | cpzxrobot().project.list | 获得项目列表,传入factory_id和必要的分页参数 |
151
+ | cpzxrobot().project.feedback.list | 获得项目反馈列表,传入project_id参数 |
152
+ | cpzxrobot().project.get | 获得项目信息,传入id参数 |
153
+ | cpzxrobot().contract.list | 获得合同列表,传入factory_id和必要的分页参数 |
154
+ | cpzxrobot().contract.get | 获得合同信息,传入id参数 |
155
+ | cpzxrobot().contract.add | 添加合同 |
146
156
 
147
157
  ### 工厂信息接口
148
158
 
package/types.d.ts CHANGED
@@ -8,6 +8,9 @@ import { ChickenFarmGateway } from "@cpzxrobot/sdk/chickenfarm_gateway";
8
8
  import { UnitGateway } from "@cpzxrobot/sdk/unit_gateway";
9
9
  import { CarGateway } from "@cpzxrobot/sdk/car_gateway";
10
10
  import { FieldDatas } from "./sensor_datas";
11
+ import { ProjectGateway } from "@cpzxrobot/sdk/project_gateway";
12
+ import { ProductGateway } from "@cpzxrobot/sdk/product_gateway";
13
+ import { ContractGateway } from "@cpzxrobot/sdk/contract_gateway";
11
14
 
12
15
  type Device = {
13
16
  id: number;
@@ -307,6 +310,9 @@ class Cpzxrobot {
307
310
  pigfarm: PigfarmGateway;
308
311
  chickenfarm: ChickenfarmGateway;
309
312
  car: CarGateway;
313
+ product: ProductGateway;
314
+ project: ProjectGateway;
315
+ contract: ContractGateway;
310
316
  dict: (key: string) => any;
311
317
  _getSelectedFarmFromMiniApp: () => Promise<Factory>;
312
318
  _getSelectedUnitFromMiniApp: () => Promise<Unit>;
package/user_gateway.ts CHANGED
@@ -181,4 +181,25 @@ export class UserGateway extends Object {
181
181
  }
182
182
  };
183
183
  }
184
+
185
+ searchHistory() {
186
+ return {
187
+ list: (type:number) => {
188
+ return this.context.ready.then((axios) => {
189
+ return axios.post(`/api/v2/coremde-sale/search/list`,{
190
+ type
191
+ });
192
+ });
193
+ },
194
+ //添加搜索历史,type 1:合同,2:项目
195
+ add: (keyword: string, type: number) => {
196
+ return this.context.ready.then((axios) => {
197
+ return axios.post(`/api/v2/coremde-sale/search/add`,{
198
+ name: keyword,
199
+ type
200
+ });
201
+ });
202
+ }
203
+ }
204
+ }
184
205
  }