@lcap/nasl 0.3.9 → 0.3.10-beta
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/out/service/create/errHandles.js +7 -2
- package/out/service/create/errHandles.js.map +1 -1
- package/out/service/debugger/debugger.d.ts +3 -0
- package/out/service/debugger/debugger.js +95 -0
- package/out/service/debugger/debugger.js.map +1 -0
- package/out/service/logic/logic.d.ts +27 -0
- package/out/service/logic/logic.js +20 -0
- package/out/service/logic/logic.js.map +1 -1
- package/out/service/page/element.d.ts +9 -0
- package/out/service/page/element.js +6 -0
- package/out/service/page/element.js.map +1 -1
- package/out/service/permission/api.d.ts +57 -0
- package/out/service/permission/api.js +41 -0
- package/out/service/permission/api.js.map +1 -0
- package/out/service/permission/index.d.ts +2 -0
- package/out/service/permission/index.js +17 -0
- package/out/service/permission/index.js.map +1 -0
- package/out/service/webFile/index.js +5 -0
- package/out/service/webFile/index.js.map +1 -1
- package/out/types/app/App.d.ts +4 -1
- package/out/types/app/App.js +24 -0
- package/out/types/app/App.js.map +1 -1
- package/out/types/app/Service.d.ts +2 -2
- package/out/types/app/Service.js +28 -3
- package/out/types/app/Service.js.map +1 -1
- package/out/types/cache.d.ts +6 -0
- package/out/types/cache.js +54 -0
- package/out/types/cache.js.map +1 -0
- package/out/types/common/Vertex.d.ts +25 -0
- package/out/types/common/Vertex.js +40 -0
- package/out/types/common/Vertex.js.map +1 -1
- package/out/types/data/Entity.js +1 -0
- package/out/types/data/Entity.js.map +1 -1
- package/out/types/data/Enum.d.ts +5 -0
- package/out/types/data/Enum.js +5 -0
- package/out/types/data/Enum.js.map +1 -1
- package/out/types/data/Interface.js +5 -3
- package/out/types/data/Interface.js.map +1 -1
- package/out/types/data/genBlock/genCreateBlock.js +5 -5
- package/out/types/data/genBlock/genCreateBlock.js.map +1 -1
- package/out/types/data/genBlock/genCurdBlock.js +3 -3
- package/out/types/data/genBlock/genCurdBlock.js.map +1 -1
- package/out/types/data/genBlock/genEnumSelectBlock.d.ts +1 -1
- package/out/types/data/genBlock/genEnumSelectBlock.js +2 -2
- package/out/types/data/genBlock/genEnumSelectBlock.js.map +1 -1
- package/out/types/data/genBlock/genGridViewBlock.js +12 -1
- package/out/types/data/genBlock/genGridViewBlock.js.map +1 -1
- package/out/types/data/genBlock/genListViewBlock.js +2 -2
- package/out/types/data/genBlock/genSelectBlock.js +2 -2
- package/out/types/data/genBlock/genTableBlock.js +14 -3
- package/out/types/data/genBlock/genTableBlock.js.map +1 -1
- package/out/types/data/genBlock/genUpdateBlock.js +5 -5
- package/out/types/data/genBlock/genUpdateBlock.js.map +1 -1
- package/out/types/data/systemTypes.js +47 -0
- package/out/types/data/systemTypes.js.map +1 -1
- package/out/types/enum.d.ts +6 -0
- package/out/types/enum.js +11 -0
- package/out/types/enum.js.map +1 -0
- package/out/types/generator/hotReload.d.ts +2 -0
- package/out/types/generator/hotReload.js +12 -1
- package/out/types/generator/hotReload.js.map +1 -1
- package/out/types/index.d.ts +7 -1
- package/out/types/index.js +11 -2
- package/out/types/index.js.map +1 -1
- package/out/types/logic/BreakPoint.d.ts +42 -0
- package/out/types/logic/BreakPoint.js +155 -0
- package/out/types/logic/BreakPoint.js.map +1 -0
- package/out/types/logic/Debugger.d.ts +156 -0
- package/out/types/logic/Debugger.js +912 -0
- package/out/types/logic/Debugger.js.map +1 -0
- package/out/types/logic/Logic.d.ts +40 -0
- package/out/types/logic/Logic.js +130 -31
- package/out/types/logic/Logic.js.map +1 -1
- package/out/types/logic/LogicItem.d.ts +21 -1
- package/out/types/logic/LogicItem.js +227 -24
- package/out/types/logic/LogicItem.js.map +1 -1
- package/out/types/logic/Param.d.ts +1 -0
- package/out/types/logic/Param.js +38 -20
- package/out/types/logic/Param.js.map +1 -1
- package/out/types/logic/Return.js +14 -19
- package/out/types/logic/Return.js.map +1 -1
- package/out/types/logic/Variable.js +14 -19
- package/out/types/logic/Variable.js.map +1 -1
- package/out/types/logic/translator.js +0 -2
- package/out/types/logic/translator.js.map +1 -1
- package/out/types/nuims/Nuims.d.ts +1 -1
- package/out/types/nuims/Nuims.js +11 -4
- package/out/types/nuims/Nuims.js.map +1 -1
- package/out/types/page/Element.d.ts +5 -0
- package/out/types/page/Element.js +114 -130
- package/out/types/page/Element.js.map +1 -1
- package/out/types/page/Event.js.map +1 -1
- package/out/types/page/Page.d.ts +1 -0
- package/out/types/page/Page.js +59 -27
- package/out/types/page/Page.js.map +1 -1
- package/out/types/page/View.d.ts +17 -3
- package/out/types/page/View.js +53 -37
- package/out/types/page/View.js.map +1 -1
- package/out/types/page/ViewParam.d.ts +1 -0
- package/out/types/page/ViewParam.js +23 -4
- package/out/types/page/ViewParam.js.map +1 -1
- package/out/types/page/ViewVariable.js +13 -18
- package/out/types/page/ViewVariable.js.map +1 -1
- package/out/types/permission/Permission.d.ts +41 -0
- package/out/types/permission/Permission.js +122 -0
- package/out/types/permission/Permission.js.map +1 -0
- package/package.json +2 -2
- package/src/service/create/errHandles.js +6 -2
- package/src/service/debugger/debugger.js +90 -0
- package/src/service/developPermission/api.js +37 -0
- package/src/service/developPermission/index.js +13 -0
- package/src/service/logic/logic.js +20 -0
- package/src/service/page/element.js +6 -0
- package/src/service/permission/api.js +38 -0
- package/src/service/permission/index.js +13 -0
- package/src/service/webFile/index.js +6 -1
- package/src/types/app/App.ts +27 -1
- package/src/types/app/Service.ts +32 -3
- package/src/types/cache.ts +50 -0
- package/src/types/common/Vertex.ts +30 -0
- package/src/types/data/Entity.ts +1 -0
- package/src/types/data/Enum.ts +5 -0
- package/src/types/data/Interface.ts +4 -3
- package/src/types/data/genBlock/genCreateBlock.ts +5 -5
- package/src/types/data/genBlock/genCurdBlock.ts +3 -3
- package/src/types/data/genBlock/genEnumSelectBlock.ts +2 -2
- package/src/types/data/genBlock/genGridViewBlock.ts +12 -1
- package/src/types/data/genBlock/genListViewBlock.ts +2 -2
- package/src/types/data/genBlock/genSelectBlock.ts +2 -2
- package/src/types/data/genBlock/genTableBlock.ts +14 -3
- package/src/types/data/genBlock/genUpdateBlock.ts +5 -5
- package/src/types/data/systemTypes.ts +47 -0
- package/src/types/enum.ts +6 -0
- package/src/types/generator/hotReload.ts +10 -0
- package/src/types/index.ts +7 -1
- package/src/types/logic/BreakPoint.ts +200 -0
- package/src/types/logic/Debugger.ts +1140 -0
- package/src/types/logic/Logic.ts +133 -28
- package/src/types/logic/LogicItem.ts +250 -28
- package/src/types/logic/Param.ts +26 -8
- package/src/types/logic/Return.ts +4 -9
- package/src/types/logic/Variable.ts +4 -8
- package/src/types/logic/translator.d.ts +16 -0
- package/src/types/logic/translator.js +144 -88
- package/src/types/logic/translator_backup.js +5 -16
- package/src/types/nuims/Nuims.ts +11 -5
- package/src/types/page/Element.ts +63 -75
- package/src/types/page/Event.ts +0 -3
- package/src/types/page/Page.ts +73 -40
- package/src/types/page/View.ts +45 -18
- package/src/types/page/ViewParam.ts +22 -3
- package/src/types/page/ViewVariable.ts +4 -8
- package/src/types/permission/Permission.ts +112 -0
- package/tsconfig.json +1 -1
package/src/types/page/View.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
|
|
1
2
|
import { immutable, circular, action, excludedInJSON } from '../decorators';
|
|
2
|
-
import { config, history, LEVEL_ENUM, Vertex, PackageJSON, App, Enum, Service, WebService, Structure, Page, Element, utils, ViewParam, ViewVariable, Lifecycle, genFinalCode, generator, Nuims, ActionOptions, ACTION_MODE, vertexsMap, updateDataTypeList, Interface } from '..';
|
|
3
|
+
import { config, history, LEVEL_ENUM, Vertex, PackageJSON, App, Enum, Service, WebService, Structure, Page, Element, utils, ViewParam, ViewVariable, Lifecycle, genFinalCode, generator, Nuims, ActionOptions, ACTION_MODE, vertexsMap, updateDataTypeList, Interface, LogicItem } from '..';
|
|
3
4
|
import Block from './Block';
|
|
4
5
|
import { viewService } from '../../service/page';
|
|
5
6
|
import { Param } from '../logic/Param';
|
|
@@ -16,6 +17,15 @@ import * as babel from '@babel/core';
|
|
|
16
17
|
import view from '@/service/page/view';
|
|
17
18
|
import Entity from '../data/Entity';
|
|
18
19
|
import { postServiceType } from '../../service/common/preprocess';
|
|
20
|
+
export interface FrontEndsourceMap {
|
|
21
|
+
[id: string]: {
|
|
22
|
+
isLogic: boolean,
|
|
23
|
+
node: LogicItem,
|
|
24
|
+
from: number,
|
|
25
|
+
to: number,
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
import { catchFn } from './Page';
|
|
19
29
|
|
|
20
30
|
/**
|
|
21
31
|
* 子页面类,前端路由控制
|
|
@@ -111,6 +121,9 @@ export class View extends Block {
|
|
|
111
121
|
*/
|
|
112
122
|
@excludedInJSON()
|
|
113
123
|
public contentPromise: Promise<any> = undefined;
|
|
124
|
+
|
|
125
|
+
@excludedInJSON()
|
|
126
|
+
public sourceMap: FrontEndsourceMap = {};
|
|
114
127
|
/**
|
|
115
128
|
* 输入参数
|
|
116
129
|
*/
|
|
@@ -195,30 +208,41 @@ export class View extends Block {
|
|
|
195
208
|
// def 情况比较特殊,需要单独处理,防止逻辑重新加载
|
|
196
209
|
this._syncDef($def);
|
|
197
210
|
this.attachNodePath(true);
|
|
211
|
+
this.toVueOptions();
|
|
198
212
|
return this;
|
|
199
213
|
} catch (err) { }
|
|
200
214
|
})().finally(() => this.contentPromise = undefined);
|
|
201
215
|
}
|
|
202
|
-
loadAll() {
|
|
216
|
+
loadAll(enableCache = true) {
|
|
203
217
|
// 如果有正在进行的 Promise,则直接返回它
|
|
204
218
|
if (this.contentPromise)
|
|
205
219
|
return this.contentPromise;
|
|
206
220
|
|
|
207
221
|
return this.contentPromise = (async () => {
|
|
208
|
-
try {
|
|
209
222
|
const result: View = await viewService.load({
|
|
210
223
|
path: {
|
|
211
224
|
id: this.id,
|
|
212
225
|
},
|
|
226
|
+
query: {
|
|
227
|
+
enableCache,
|
|
228
|
+
},
|
|
229
|
+
config: { noErrorTip: true },
|
|
213
230
|
});
|
|
214
|
-
|
|
231
|
+
const oldLogics = this.$def.logics;
|
|
232
|
+
Object.assign(result, {
|
|
233
|
+
children: this.children,
|
|
234
|
+
})
|
|
215
235
|
const temp = View.from(result, this.parent, this.page, this);
|
|
236
|
+
const newLogics = temp.$def.logics;
|
|
237
|
+
oldLogics.forEach((logic) => {
|
|
238
|
+
if(!newLogics.find((item) => item.id === logic.id))
|
|
239
|
+
logic.destroy();
|
|
240
|
+
});
|
|
216
241
|
this.assign(temp);
|
|
217
242
|
utils.traverse((current) => {
|
|
218
243
|
current.node.attachNodePath(true);
|
|
219
244
|
}, { node: this });
|
|
220
245
|
return this;
|
|
221
|
-
} catch (err) { }
|
|
222
246
|
})().finally(() => this.contentPromise = undefined);
|
|
223
247
|
}
|
|
224
248
|
isContentLoaded() {
|
|
@@ -325,7 +349,7 @@ export class View extends Block {
|
|
|
325
349
|
operationDesc: actionOptions?.actionDesc || `添加子页面"${this.name}${this.title ? `(${this.title})` : ''}"`,
|
|
326
350
|
},
|
|
327
351
|
body,
|
|
328
|
-
});
|
|
352
|
+
}).catch(catchFn());
|
|
329
353
|
this.deepPick(result.view, ['id']);
|
|
330
354
|
// 添加数据
|
|
331
355
|
this.addData(result);
|
|
@@ -406,7 +430,6 @@ export class View extends Block {
|
|
|
406
430
|
if (!this.parent)
|
|
407
431
|
throw Error('该子页面为根节点!');
|
|
408
432
|
|
|
409
|
-
try {
|
|
410
433
|
await viewService.delete({
|
|
411
434
|
headers: {
|
|
412
435
|
appId: config.defaultApp?.id,
|
|
@@ -416,11 +439,7 @@ export class View extends Block {
|
|
|
416
439
|
path: {
|
|
417
440
|
id: this.id,
|
|
418
441
|
},
|
|
419
|
-
});
|
|
420
|
-
} catch (err) {
|
|
421
|
-
await config.defaultApp?.history.load();
|
|
422
|
-
throw err;
|
|
423
|
-
}
|
|
442
|
+
}).catch(catchFn());
|
|
424
443
|
|
|
425
444
|
const index = this.parent.children.indexOf(this);
|
|
426
445
|
~index && this.parent.children.splice(index, 1);
|
|
@@ -452,7 +471,7 @@ export class View extends Block {
|
|
|
452
471
|
operationDesc: actionOptions?.actionDesc || `修改子页面"${this.name}${this.title ? `(${this.title})` : ''}"`,
|
|
453
472
|
},
|
|
454
473
|
body,
|
|
455
|
-
});
|
|
474
|
+
}).catch(catchFn());
|
|
456
475
|
|
|
457
476
|
await then?.();
|
|
458
477
|
await config.defaultApp?.history.load();
|
|
@@ -662,7 +681,6 @@ export class View extends Block {
|
|
|
662
681
|
let componentOptions = 'const componentOptions = {};';
|
|
663
682
|
if (this.script)
|
|
664
683
|
componentOptions = this.script.trim().replace(/export default |module\.exports +=/, 'const componentOptions = ');
|
|
665
|
-
|
|
666
684
|
const $def = JSON.parse(JSON.stringify(this.$def));
|
|
667
685
|
$def.title = this.title;
|
|
668
686
|
$def.crumb = this.crumb;
|
|
@@ -688,10 +706,16 @@ export class View extends Block {
|
|
|
688
706
|
// );
|
|
689
707
|
// }
|
|
690
708
|
// }, { node: $def }, { mode: 'anyObject' });
|
|
691
|
-
|
|
692
|
-
|
|
709
|
+
const {
|
|
710
|
+
output,
|
|
711
|
+
sourceMap,
|
|
712
|
+
} = translator($def, this.script);
|
|
713
|
+
return {
|
|
714
|
+
script: `${componentOptions}${genFinalCode(output, options && options.finalCode)}
|
|
693
715
|
export default componentOptions;
|
|
694
|
-
|
|
716
|
+
`,
|
|
717
|
+
sourceMap,
|
|
718
|
+
};
|
|
695
719
|
}
|
|
696
720
|
/**
|
|
697
721
|
* 转换成 Vue 文件
|
|
@@ -725,9 +749,12 @@ export class View extends Block {
|
|
|
725
749
|
* @TODO 后面 template 可以优化成 render 函数
|
|
726
750
|
*/
|
|
727
751
|
toVueOptions(options?: ElementToVueOptions) {
|
|
752
|
+
const { script, sourceMap } = this.toScript(options);
|
|
753
|
+
this.sourceMap = sourceMap;
|
|
728
754
|
return {
|
|
729
755
|
template: this.$html.toVue(options),
|
|
730
|
-
script
|
|
756
|
+
script,
|
|
757
|
+
sourceMap,
|
|
731
758
|
// definition: JSON.stringify(this.$def),
|
|
732
759
|
};
|
|
733
760
|
}
|
|
@@ -5,6 +5,25 @@ import { getBasicTypeDefaultValue } from '../data/basicTypes';
|
|
|
5
5
|
import { viewService } from '../../service/page';
|
|
6
6
|
import { View } from './View';
|
|
7
7
|
import { schemaService } from '../../service/common';
|
|
8
|
+
import { refreshPages, refreshView } from '../cache';
|
|
9
|
+
import { BusinessCode } from '../enum';
|
|
10
|
+
|
|
11
|
+
export function catchFn(view: View) {
|
|
12
|
+
return async (err: any) => {
|
|
13
|
+
const code = err?.code;
|
|
14
|
+
// 节点已存在; 节点不存在
|
|
15
|
+
if([BusinessCode.ElementExist, BusinessCode.ElementNotExist].includes(code)) {
|
|
16
|
+
await refreshView(view);
|
|
17
|
+
} else if(code === BusinessCode.ParentElementNotExist) { // 父节点不存在。视图添加变量,发现视图不存在
|
|
18
|
+
await refreshPages();
|
|
19
|
+
} else
|
|
20
|
+
config.defaultApp?.emit('saved', err);
|
|
21
|
+
|
|
22
|
+
config.defaultApp?.history.load();
|
|
23
|
+
|
|
24
|
+
throw err;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
8
27
|
|
|
9
28
|
/**
|
|
10
29
|
* 页面输入参数
|
|
@@ -56,7 +75,7 @@ export class ViewParam extends Param {
|
|
|
56
75
|
operationDesc: actionOptions?.actionDesc || `添加页面"${this.view.name}"输入参数"${this.name}"`,
|
|
57
76
|
},
|
|
58
77
|
body,
|
|
59
|
-
});
|
|
78
|
+
}).catch(catchFn(this.view));
|
|
60
79
|
// convert2RefType(result.schema);
|
|
61
80
|
this.deepPick(result, ['id']);
|
|
62
81
|
this.assign({ code: this.genCode() });
|
|
@@ -88,7 +107,7 @@ export class ViewParam extends Param {
|
|
|
88
107
|
query: {
|
|
89
108
|
id: this.id,
|
|
90
109
|
},
|
|
91
|
-
});
|
|
110
|
+
}).catch(catchFn(this.view));
|
|
92
111
|
} catch(err) {
|
|
93
112
|
await config.defaultApp?.history.load();
|
|
94
113
|
throw err;
|
|
@@ -129,7 +148,7 @@ export class ViewParam extends Param {
|
|
|
129
148
|
operationDesc: actionOptions?.actionDesc || `修改页面"${this.view.name}"输入参数"${this.name}"`,
|
|
130
149
|
},
|
|
131
150
|
body,
|
|
132
|
-
});
|
|
151
|
+
}).catch(catchFn(this.view));
|
|
133
152
|
// convert2RefType(result.schema);
|
|
134
153
|
// this.plainAssign(result);
|
|
135
154
|
|
|
@@ -5,6 +5,7 @@ import { viewService } from '../../service/page';
|
|
|
5
5
|
import { convert2RefType, convert2SchemaType } from '../data/dataTypeUtils';
|
|
6
6
|
import { getBasicTypeDefaultValue } from '../data/basicTypes';
|
|
7
7
|
import { schemaService } from '../../service/common';
|
|
8
|
+
import { catchFn } from './ViewParam';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* 页面局部变量
|
|
@@ -51,7 +52,7 @@ export class ViewVariable extends Variable {
|
|
|
51
52
|
operationDesc: actionOptions?.actionDesc || `添加页面"${this.view.name}"局部变量"${this.name}"`,
|
|
52
53
|
},
|
|
53
54
|
body,
|
|
54
|
-
});
|
|
55
|
+
}).catch(catchFn(this.view));
|
|
55
56
|
// convert2RefType(result.schema);
|
|
56
57
|
this.deepPick(result, ['id']);
|
|
57
58
|
this.assign({ code: this.genCode() });
|
|
@@ -73,7 +74,6 @@ export class ViewVariable extends Variable {
|
|
|
73
74
|
config.defaultApp?.emit('saving');
|
|
74
75
|
|
|
75
76
|
if (this.id) {
|
|
76
|
-
try {
|
|
77
77
|
await viewService.deleteViewVariable({
|
|
78
78
|
headers: {
|
|
79
79
|
appId: config.defaultApp?.id,
|
|
@@ -83,11 +83,7 @@ export class ViewVariable extends Variable {
|
|
|
83
83
|
query: {
|
|
84
84
|
id: this.id,
|
|
85
85
|
},
|
|
86
|
-
});
|
|
87
|
-
} catch (err) {
|
|
88
|
-
await config.defaultApp?.history.load();
|
|
89
|
-
throw err;
|
|
90
|
-
}
|
|
86
|
+
}).catch(catchFn(this.view));
|
|
91
87
|
}
|
|
92
88
|
|
|
93
89
|
const { variables } = this.view.$def;
|
|
@@ -122,7 +118,7 @@ export class ViewVariable extends Variable {
|
|
|
122
118
|
operationDesc: actionOptions?.actionDesc || `修改页面"${this.view.name}"局部变量"${this.name}"`,
|
|
123
119
|
},
|
|
124
120
|
body,
|
|
125
|
-
});
|
|
121
|
+
}).catch(catchFn(this.view));
|
|
126
122
|
// convert2RefType(result.schema);
|
|
127
123
|
// this.plainAssign(result);
|
|
128
124
|
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { immutable } from '../decorators';
|
|
2
|
+
import { View, Element } from '..';
|
|
3
|
+
import permissionService from '../../service/permission';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export class Permission {
|
|
7
|
+
/**
|
|
8
|
+
* App Name
|
|
9
|
+
*/
|
|
10
|
+
@immutable()
|
|
11
|
+
public readonly domainName: string = undefined;
|
|
12
|
+
/**
|
|
13
|
+
* 上报权限后的资源id
|
|
14
|
+
*/
|
|
15
|
+
@immutable()
|
|
16
|
+
public readonly resourceId: string = undefined;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 应用 id
|
|
20
|
+
*/
|
|
21
|
+
@immutable()
|
|
22
|
+
public readonly serviceId: string = undefined;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* view
|
|
26
|
+
*/
|
|
27
|
+
@immutable()
|
|
28
|
+
public readonly view: View = undefined;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* element
|
|
32
|
+
*/
|
|
33
|
+
@immutable()
|
|
34
|
+
public readonly element: Element = undefined;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @param source 需要合并的部分参数
|
|
38
|
+
*/
|
|
39
|
+
constructor(source?: Partial<Permission>) {
|
|
40
|
+
const { domainName } = source;
|
|
41
|
+
Object.assign(this, source);
|
|
42
|
+
if (!domainName) {
|
|
43
|
+
throw new Error('Permission need domainName!');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async createDefaultRoleFromRoleName(roleName: string) {
|
|
48
|
+
if (!roleName)
|
|
49
|
+
return;
|
|
50
|
+
return await permissionService.createRole({
|
|
51
|
+
body: {
|
|
52
|
+
name: roleName,
|
|
53
|
+
serviceId: this.serviceId,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async updateRoleName(roleId: string, roleName: string) {
|
|
59
|
+
return await permissionService.updateRole({
|
|
60
|
+
body: {
|
|
61
|
+
id: roleId,
|
|
62
|
+
name: roleName,
|
|
63
|
+
serviceId: this.serviceId,
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
* @param query {
|
|
71
|
+
* resourceId
|
|
72
|
+
* roleId
|
|
73
|
+
* }
|
|
74
|
+
*/
|
|
75
|
+
async attachPermissionResource(query: Object) {
|
|
76
|
+
return await permissionService.attachPermissionResourceAction({ query });
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async detachPermissionResource(query: Object) {
|
|
80
|
+
return await permissionService.detachPermissionResourceAction({ query });
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async getInitRoles(resourceId: string) {
|
|
84
|
+
return await permissionService.getRoles({
|
|
85
|
+
query: {
|
|
86
|
+
serviceId: this.serviceId,
|
|
87
|
+
resourceId,
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async attachDevRole(resourceId: string) {
|
|
93
|
+
const data: any = await this.getInitRoles(resourceId)|| [];
|
|
94
|
+
let roleId;
|
|
95
|
+
data.forEach((item: any) => {
|
|
96
|
+
if (item.name === 'DEV-AdminRole') {
|
|
97
|
+
roleId = item.id;
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
// 获取权限树资源Id
|
|
101
|
+
if (roleId) {
|
|
102
|
+
// 默认角色开启
|
|
103
|
+
await this.attachPermissionResource({
|
|
104
|
+
resourceId,
|
|
105
|
+
roleId,
|
|
106
|
+
});
|
|
107
|
+
await this.getInitRoles(resourceId);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export default Permission;
|
package/tsconfig.json
CHANGED