@steedos/standard-process-approval 2.3.3-beta.2 → 2.3.3-beta.3

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,128 @@
1
+ /*
2
+ * @Author: sunhaolin@hotoa.com
3
+ * @Date: 2022-12-14 10:26:50
4
+ * @LastEditors: sunhaolin@hotoa.com
5
+ * @LastEditTime: 2022-12-14 17:15:10
6
+ * @Description:
7
+ */
8
+ const { getObjectProcessDefinition, recordSubmit } = require('@steedos/process')
9
+ "use strict";
10
+ /**
11
+ * @typedef {import('moleculer').Context} Context Moleculer's Context
12
+ */
13
+ module.exports = {
14
+ name: 'approval_process',
15
+ namespace: "steedos",
16
+ mixins: [],
17
+ /**
18
+ * Settings
19
+ */
20
+ settings: {
21
+
22
+ },
23
+
24
+ /**
25
+ * Dependencies
26
+ */
27
+ dependencies: [],
28
+
29
+ /**
30
+ * Actions
31
+ */
32
+ actions: {
33
+ /**
34
+ * @api {call} submit 提请批准
35
+ * @apiVersion 0.0.0
36
+ * @apiName submit
37
+ * @apiGroup approval_process.service.js
38
+ * @apiBody {String} objectName 对象API Name
39
+ * @apiBody {String} recordId 记录ID
40
+ * @apiBody {String} comment 意见
41
+ * @apiBody {String} approver 批准人ID
42
+ * @apiSuccess {String} state 返回提请批准结果
43
+ * @apiExample {js} 示例:
44
+ * await broker.call('approval_process.submit', {
45
+ * objectName: '',
46
+ * recordId: '',
47
+ * comment: '',
48
+ * approver: ''
49
+ * }, { meta: { user: userSession } })
50
+ * @apiSuccessExample {json} Success-Response:
51
+ * HTTP/1.1 200 OK
52
+ * {
53
+ * "state": "SUCCESS"
54
+ * }
55
+ * @apiErrorExample {json} Error-Response:
56
+ * HTTP/1.1 200 OK
57
+ * {
58
+ * "state": "FAILURE",
59
+ * "error": ""
60
+ * }
61
+ */
62
+ submit: {
63
+ params: {
64
+ objectName: { type: 'string' },
65
+ recordId: { type: 'string' },
66
+ comment: { type: 'string', optional: true },
67
+ approver: { type: 'string', optional: true },
68
+ },
69
+ async handler(ctx) {
70
+ try {
71
+ this.broker.logger.info('[service][approval_process]===>', 'submit', ctx.params.name)
72
+ const userSession = ctx.meta.user;
73
+ const params = ctx.params;
74
+ const objectName = params.objectName;
75
+ const recordId = params.recordId;
76
+ const comment = params.comment;
77
+ const approver = params.approver;
78
+
79
+ const processDefinition = await getObjectProcessDefinition(objectName, recordId, userSession);
80
+ if (!processDefinition) {
81
+ throw new Error('process_approval_error_notFindProcessDefinition');
82
+ }
83
+ await recordSubmit(processDefinition._id, objectName, recordId, userSession, comment, approver);
84
+ return { state: 'SUCCESS' };
85
+ } catch (error) {
86
+ return { state: 'FAILURE', error: error.message };
87
+ }
88
+
89
+ }
90
+ },
91
+
92
+ },
93
+
94
+ /**
95
+ * Events
96
+ */
97
+ events: {
98
+
99
+ },
100
+
101
+ /**
102
+ * Methods
103
+ */
104
+ methods: {
105
+
106
+ },
107
+
108
+ /**
109
+ * Service created lifecycle event handler
110
+ */
111
+ async created() {
112
+
113
+ },
114
+
115
+ /**
116
+ * Service started lifecycle event handler
117
+ */
118
+ async started() {
119
+ this.broker.logger.info('[service][approval_process]===>', 'started')
120
+ },
121
+
122
+ /**
123
+ * Service stopped lifecycle event handler
124
+ */
125
+ async stopped() {
126
+
127
+ }
128
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/standard-process-approval",
3
- "version": "2.3.3-beta.2",
3
+ "version": "2.3.3-beta.3",
4
4
  "main": "package.service.js",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -9,8 +9,11 @@
9
9
  "keywords": [
10
10
  "steedos"
11
11
  ],
12
+ "dependencies": {
13
+ "@steedos/process": "2.3.3-beta.3"
14
+ },
12
15
  "description": "steedos package",
13
16
  "repository": {},
14
17
  "license": "MIT",
15
- "gitHead": "31f7216ca782b7793e47e5238d72b46a5b9eca3d"
18
+ "gitHead": "2e0d4c875056b95d9655d14e99ab6cd7bae891b5"
16
19
  }