@cpzxrobot/sdk 1.1.96 → 1.1.98
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_gateway.ts +16 -3
- package/dist/device_gateway.js +15 -2
- package/dist/index.js +4 -2
- package/dist/logs_gateway.js +15 -0
- package/dist/user_gateway.js +4 -2
- package/index.ts +4 -2
- package/logs_gateway.ts +17 -0
- package/package.json +1 -1
- package/readme.md +1 -0
- package/types.d.ts +2 -0
- package/user_gateway.ts +4 -2
package/device_gateway.ts
CHANGED
|
@@ -55,10 +55,23 @@ export class DeviceGateway extends Object {
|
|
|
55
55
|
workshopId?: number;
|
|
56
56
|
factoryId?: number;
|
|
57
57
|
companyId?: number;
|
|
58
|
-
}) => {
|
|
58
|
+
},params:any= undefined) => {
|
|
59
59
|
let axios = await this.context.ready;
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
var url = `/api/v2/device/list`;
|
|
61
|
+
if (params) {
|
|
62
|
+
//if params is string
|
|
63
|
+
if (typeof params === "string") {
|
|
64
|
+
url = `/api/v2/device/list?${params}`;
|
|
65
|
+
}
|
|
66
|
+
// if params is object
|
|
67
|
+
else {
|
|
68
|
+
url = `/api/v2/device/list?${Object.keys(params)
|
|
69
|
+
.map((key) => `${key}=${params[key]}`)
|
|
70
|
+
.join("&")}`;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return axios.post(url, condition).then((res) => {
|
|
62
75
|
return res.data;
|
|
63
76
|
});
|
|
64
77
|
},
|
package/dist/device_gateway.js
CHANGED
|
@@ -30,9 +30,22 @@ class DeviceGateway extends Object {
|
|
|
30
30
|
return res.data;
|
|
31
31
|
});
|
|
32
32
|
},
|
|
33
|
-
list: async (condition) => {
|
|
33
|
+
list: async (condition, params = undefined) => {
|
|
34
34
|
let axios = await this.context.ready;
|
|
35
|
-
|
|
35
|
+
var url = `/api/v2/device/list`;
|
|
36
|
+
if (params) {
|
|
37
|
+
//if params is string
|
|
38
|
+
if (typeof params === "string") {
|
|
39
|
+
url = `/api/v2/device/list?${params}`;
|
|
40
|
+
}
|
|
41
|
+
// if params is object
|
|
42
|
+
else {
|
|
43
|
+
url = `/api/v2/device/list?${Object.keys(params)
|
|
44
|
+
.map((key) => `${key}=${params[key]}`)
|
|
45
|
+
.join("&")}`;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return axios.post(url, condition).then((res) => {
|
|
36
49
|
return res.data;
|
|
37
50
|
});
|
|
38
51
|
},
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ const contract_gateway_1 = require("./contract_gateway");
|
|
|
23
23
|
const customer_gateway_1 = require("./customer_gateway");
|
|
24
24
|
const company_gateway_1 = require("./company_gateway");
|
|
25
25
|
const news_gateway_1 = require("./news_gateway");
|
|
26
|
+
const logs_gateway_1 = require("./logs_gateway");
|
|
26
27
|
class Cpzxrobot {
|
|
27
28
|
constructor(appCode) {
|
|
28
29
|
this.pigfarm = new pigfarm_gateway_1.PigfarmGateway(this);
|
|
@@ -38,6 +39,7 @@ class Cpzxrobot {
|
|
|
38
39
|
this.customer = new customer_gateway_1.CustomerGateway(this);
|
|
39
40
|
this.company = new company_gateway_1.CompanyGateway(this);
|
|
40
41
|
this.news = new news_gateway_1.NewsGateway(this);
|
|
42
|
+
this.logs = new logs_gateway_1.LogsGateway(this);
|
|
41
43
|
//获取当前浏览器的域名
|
|
42
44
|
this.ready = new Promise((resolve, reject) => {
|
|
43
45
|
this.resolveReady = resolve;
|
|
@@ -338,7 +340,7 @@ class Cpzxrobot {
|
|
|
338
340
|
const token = localStorage.getItem("token");
|
|
339
341
|
if (token) {
|
|
340
342
|
this.token = token;
|
|
341
|
-
this.initAxios(
|
|
343
|
+
this.initAxios(baseURL);
|
|
342
344
|
this.axios.get("/api/v1/user/auth").then((res) => {
|
|
343
345
|
if (res.data.Error) {
|
|
344
346
|
window.location.href = "/login.html?error=" + res.data.Error;
|
|
@@ -370,7 +372,7 @@ class Cpzxrobot {
|
|
|
370
372
|
const access_token = url.searchParams.get("access_token");
|
|
371
373
|
const app_code = url.searchParams.get("app_code");
|
|
372
374
|
if (access_token && app_code) {
|
|
373
|
-
this.initAxios(
|
|
375
|
+
this.initAxios(baseURL);
|
|
374
376
|
this.axios
|
|
375
377
|
.post("/api/v1/user/auth", {
|
|
376
378
|
appCode: app_code,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LogsGateway = void 0;
|
|
4
|
+
class LogsGateway extends Object {
|
|
5
|
+
constructor(context) {
|
|
6
|
+
super();
|
|
7
|
+
this.context = context;
|
|
8
|
+
}
|
|
9
|
+
operations(args) {
|
|
10
|
+
return this.context.ready.then(axios => {
|
|
11
|
+
return axios.post("/api/v2/log/operationRecord", args);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.LogsGateway = LogsGateway;
|
package/dist/user_gateway.js
CHANGED
|
@@ -123,9 +123,11 @@ class UserGateway extends Object {
|
|
|
123
123
|
//当前如果打开的是公司,则说明该应用支持在公司级别打开,则要求该应用应该有对应的公司级别的角色配置,所以并不需要查找公司下属工厂或工厂的对应公司,再去查找用户
|
|
124
124
|
return axios.get(`/api/v2/company/${factory.id}/users?roleCode=${role}`);
|
|
125
125
|
}
|
|
126
|
-
async mypermission() {
|
|
126
|
+
async mypermission(params = undefined) {
|
|
127
127
|
var axios = await this.context.ready;
|
|
128
|
-
return axios.get("/api/v2/user/role/mypermission"
|
|
128
|
+
return axios.get("/api/v2/user/role/mypermission", {
|
|
129
|
+
params
|
|
130
|
+
});
|
|
129
131
|
}
|
|
130
132
|
async delete(id) {
|
|
131
133
|
var axios = await this.context.ready;
|
package/index.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { ContractGateway } from "./contract_gateway";
|
|
|
18
18
|
import { CustomerGateway } from "./customer_gateway";
|
|
19
19
|
import { CompanyGateway } from "./company_gateway";
|
|
20
20
|
import { NewsGateway } from "./news_gateway";
|
|
21
|
+
import { LogsGateway } from "./logs_gateway";
|
|
21
22
|
|
|
22
23
|
export class Cpzxrobot {
|
|
23
24
|
device: DeviceGateway;
|
|
@@ -62,6 +63,7 @@ export class Cpzxrobot {
|
|
|
62
63
|
customer: CustomerGateway = new CustomerGateway(this);
|
|
63
64
|
company: CompanyGateway = new CompanyGateway(this);
|
|
64
65
|
news: NewsGateway = new NewsGateway(this);
|
|
66
|
+
logs: LogsGateway = new LogsGateway(this);
|
|
65
67
|
|
|
66
68
|
|
|
67
69
|
constructor(appCode: string) {
|
|
@@ -386,7 +388,7 @@ export class Cpzxrobot {
|
|
|
386
388
|
const token = localStorage.getItem("token");
|
|
387
389
|
if (token) {
|
|
388
390
|
this.token = token;
|
|
389
|
-
this.initAxios(
|
|
391
|
+
this.initAxios(baseURL);
|
|
390
392
|
this.axios.get("/api/v1/user/auth").then((res) => {
|
|
391
393
|
if (res.data.Error) {
|
|
392
394
|
window.location.href = "/login.html?error=" + res.data.Error;
|
|
@@ -417,7 +419,7 @@ export class Cpzxrobot {
|
|
|
417
419
|
const access_token = url.searchParams.get("access_token");
|
|
418
420
|
const app_code = url.searchParams.get("app_code");
|
|
419
421
|
if (access_token && app_code) {
|
|
420
|
-
this.initAxios(
|
|
422
|
+
this.initAxios(baseURL);
|
|
421
423
|
this.axios
|
|
422
424
|
.post("/api/v1/user/auth", {
|
|
423
425
|
appCode: app_code,
|
package/logs_gateway.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Cpzxrobot, Factory, Unit } from "./types";
|
|
2
|
+
|
|
3
|
+
export class LogsGateway extends Object {
|
|
4
|
+
context: Cpzxrobot;
|
|
5
|
+
|
|
6
|
+
constructor(context: Cpzxrobot) {
|
|
7
|
+
super();
|
|
8
|
+
this.context = context;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
operations(args:any){
|
|
12
|
+
return this.context.ready.then(axios => {
|
|
13
|
+
return axios.post("/api/v2/log/operationRecord", args);
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
}
|
package/package.json
CHANGED
package/readme.md
CHANGED
package/types.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { ProductGateway } from "@cpzxrobot/sdk/product_gateway";
|
|
|
13
13
|
import { ContractGateway } from "@cpzxrobot/sdk/contract_gateway";
|
|
14
14
|
import { CustomerGateway } from "@cpzxrobot/sdk/customer_gateway";
|
|
15
15
|
import { CompanyGateway } from "@cpzxrobot/sdk/company_gateway";
|
|
16
|
+
import { LogsGateway } from "@cpzxrobot/sdk/logs_gateway";
|
|
16
17
|
|
|
17
18
|
type Device = {
|
|
18
19
|
id: number;
|
|
@@ -329,6 +330,7 @@ class Cpzxrobot {
|
|
|
329
330
|
contract: ContractGateway;
|
|
330
331
|
customer: CustomerGateway;
|
|
331
332
|
company: CompanyGateway;
|
|
333
|
+
logs: LogsGateway;
|
|
332
334
|
dict: (key: string) => any;
|
|
333
335
|
_getSelectedFarmFromMiniApp: () => Promise<Factory>;
|
|
334
336
|
_getSelectedUnitFromMiniApp: () => Promise<Unit>;
|
package/user_gateway.ts
CHANGED
|
@@ -136,9 +136,11 @@ export class UserGateway extends Object {
|
|
|
136
136
|
return axios.get(`/api/v2/company/${factory.id}/users?roleCode=${role}`);
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
async mypermission() {
|
|
139
|
+
async mypermission(params: any = undefined) {
|
|
140
140
|
var axios = await this.context.ready;
|
|
141
|
-
return axios.get("/api/v2/user/role/mypermission"
|
|
141
|
+
return axios.get("/api/v2/user/role/mypermission",{
|
|
142
|
+
params
|
|
143
|
+
});
|
|
142
144
|
}
|
|
143
145
|
|
|
144
146
|
async delete(id: number) {
|