Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibizlab-generator
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibizlab-generator
提交
dedcd2e4
提交
dedcd2e4
编写于
2月 08, 2022
作者:
tony001
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update:更新应用权限服务
上级
9cba1e72
变更
5
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
262 行增加
和
16 行删除
+262
-16
i-app-auth-service.ts
...{{apps}}/src/core/interface/service/i-app-auth-service.ts
+36
-0
app-auth-service-base.ts
...s}}/src/core/service/app-service/app-auth-service-base.ts
+141
-0
entity-ui-service-base.ts
.../core/service/entity-ui-service/entity-ui-service-base.ts
+25
-16
app-auth-service.ts.hbs
...templ/r7/app_{{apps}}/src/service/app-auth-service.ts.hbs
+58
-0
{{appEntities}}-ui-service-base.ts.hbs
...ce/{{appEntities}}/{{appEntities}}-ui-service-base.ts.hbs
+2
-0
未找到文件。
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/core/interface/service/i-app-auth-service.ts
浏览文件 @
dedcd2e4
...
@@ -32,6 +32,42 @@ export interface IAppAuthService {
...
@@ -32,6 +32,42 @@ export interface IAppAuthService {
*/
*/
setAppData
(
opt
:
IParam
):
void
;
setAppData
(
opt
:
IParam
):
void
;
/**
* 获取指定数据操作标识是否鉴权
*
* @param {IParam} context 应用上下文
* @param {string} dataAccAction 操作标识
* @param {string} [key] 数据主键
* @param {IParam} [mainSateOPPrivs] 指定数据主状态操作标识
* @param {IParam} [param] 额外参数
* @return {*} {IParam}
* @memberof IAppAuthService
*/
getOPEnableAuth
(
context
:
IParam
,
dataAccAction
:
string
,
key
?:
string
,
mainSateOPPrivs
?:
IParam
,
param
?:
IParam
):
IParam
;
/**
* 获取应用权限
*
* @param {string | undefined} dataAccAction 操作标识
* @param {('RESOURCE'|'RT'|'MINIX')} [mode='RESOURCE'] RT(RT模式),RESOURCE(资源模式),MINIX(混合模式),默认值RESOURCE
* @return {*} {boolean}
* @memberof IAppAuthService
*/
getAppAuth
(
dataAccAction
:
string
|
undefined
,
mode
:
'RESOURCE'
|
'RT'
|
'MINIX'
):
boolean
;
/**
* 获取实体级权限
*
* @param {IParam} context 应用上下文
* @param {string} key 数据主键标识
* @param {string} dataAccAction 操作标识
* @param {IParam} [param] 额外参数
* @return {*} {boolean}
* @memberof IAppAuthService
*/
getDEAuth
(
context
:
IParam
,
key
:
string
,
dataAccAction
:
string
,
param
?:
IParam
):
boolean
;
/**
/**
* 登录
* 登录
*
*
...
...
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/core/service/app-service/app-auth-service-base.ts
浏览文件 @
dedcd2e4
...
@@ -22,6 +22,22 @@ export abstract class AppAuthServiceBase implements IAppAuthService {
...
@@ -22,6 +22,22 @@ export abstract class AppAuthServiceBase implements IAppAuthService {
*/
*/
private
appData
:
IParam
=
{};
private
appData
:
IParam
=
{};
/**
* 系统默认操作标识
*
* @protected
* @type {IParam}
* @memberof AppAuthServiceBase
*/
protected
sysOPPrivs
:
IParam
=
{};
/**
* @description 系统操作标识映射统一资源映射表
* @type {Map<string, string>}
* @memberof AppAuthServiceBase
*/
protected
sysOPPrivsMap
:
Map
<
string
,
string
>
=
new
Map
();
/**
/**
* 获取应用数据
* 获取应用数据
*
*
...
@@ -39,9 +55,20 @@ export abstract class AppAuthServiceBase implements IAppAuthService {
...
@@ -39,9 +55,20 @@ export abstract class AppAuthServiceBase implements IAppAuthService {
* @memberof AppAuthServiceBase
* @memberof AppAuthServiceBase
*/
*/
public
setAppData
(
opt
:
IParam
=
{}):
void
{
public
setAppData
(
opt
:
IParam
=
{}):
void
{
console
.
log
(
opt
);
this
.
appData
=
opt
;
this
.
appData
=
opt
;
}
}
/**
* 应用是否启用权限
*
* @return {boolean}
* @memberof AppAuthServiceBase
*/
public
getEnablePermission
():
boolean
{
return
this
.
appData
.
enablepermissionvalid
&&
Environment
.
enablePermissionValid
;
}
/**
/**
* 初始化应用权限
* 初始化应用权限
*
*
...
@@ -108,6 +135,103 @@ export abstract class AppAuthServiceBase implements IAppAuthService {
...
@@ -108,6 +135,103 @@ export abstract class AppAuthServiceBase implements IAppAuthService {
}
}
}
}
/**
* 获取指定数据操作标识是否鉴权
*
* @param {IParam} context 应用上下文
* @param {{ key: string, dataAccAction: string, mainSateOPPrivs: IParam }} { key, dataAccAction, mainSateOPPrivs } {数据主键,操作标识,指定数据主状态操作标识 }
* @param {IParam} [param] 额外参数
* @return {*} {IParam}
* @memberof AppAuthServiceBase
*/
/**
* 获取指定数据操作标识是否鉴权
*
* @param {IParam} context 应用上下文
* @param {string} dataAccAction 操作标识
* @param {string} [key] 数据主键
* @param {IParam} [mainSateOPPrivs] 指定数据主状态操作标识
* @param {IParam} [param] 额外参数
* @return {*} {IParam}
* @memberof IAppAuthService
*/
public
getOPEnableAuth
(
context
:
IParam
,
dataAccAction
:
string
,
key
?:
string
,
mainSateOPPrivs
?:
IParam
,
param
?:
IParam
):
IParam
{
let
result
:
IParam
=
{
[
dataAccAction
]:
1
};
// 统一资源权限
const
curDefaultOPPrivs
:
any
=
this
.
handleSysOPPrivs
();
if
(
curDefaultOPPrivs
&&
(
Object
.
keys
(
curDefaultOPPrivs
).
length
>
0
)
&&
(
curDefaultOPPrivs
[
dataAccAction
]
===
0
))
{
result
[
dataAccAction
]
=
0
;
}
// 主状态权限
if
(
mainSateOPPrivs
&&
(
Object
.
keys
(
mainSateOPPrivs
).
length
>
0
)
&&
mainSateOPPrivs
.
hasOwnProperty
(
dataAccAction
))
{
result
[
dataAccAction
]
=
result
[
dataAccAction
]
&&
mainSateOPPrivs
[
dataAccAction
];
}
// 实体级权限
if
(
key
&&
!
this
.
getDEAuth
(
context
,
key
,
dataAccAction
,
param
))
{
result
[
dataAccAction
]
=
0
;
}
return
result
;
}
/**
* 获取应用权限
*
* @param {string | undefined} dataAccAction 操作标识
* @param {('RESOURCE'|'RT'|'MINIX')} [mode='RESOURCE'] RT(RT模式),RESOURCE(资源模式),MINIX(混合模式),默认值RESOURCE
* @return {*} {boolean}
* @memberof AppAuthServiceBase
*/
public
getAppAuth
(
dataAccAction
:
string
|
undefined
,
mode
:
'RESOURCE'
|
'RT'
|
'MINIX'
=
'RESOURCE'
):
boolean
{
if
(
!
this
.
getEnablePermission
()
||
!
dataAccAction
)
{
return
true
;
}
const
computeAuth
=
(
authData
:
string
[])
=>
{
if
(
!
authData
||
(
authData
.
length
==
0
))
{
return
false
;
}
const
index
=
authData
.
findIndex
((
item
:
string
)
=>
{
return
item
===
dataAccAction
;
})
if
(
index
===
-
1
)
{
return
false
;
}
else
{
return
true
;
}
}
// 统一资源数据
const
resourceData
:
string
[]
=
this
.
getAppData
().
unires
;
// 菜单数据
const
menuData
:
string
[]
=
this
.
getAppData
().
appmenu
;
// 资源模式
if
(
Object
.
is
(
mode
,
'RESOURCE'
))
{
return
computeAuth
(
resourceData
);
}
// RT模式(菜单)
if
(
Object
.
is
(
mode
,
'RT'
))
{
return
computeAuth
(
menuData
);
}
// 混合模式
if
(
Object
.
is
(
mode
,
'MINIX'
))
{
return
computeAuth
(
resourceData
)
&&
computeAuth
(
menuData
);
}
return
false
;
}
/**
* 获取实体级权限
*
* @param {IParam} context 应用上下文
* @param {string} key 数据主键标识
* @param {string} dataAccAction 操作标识
* @param {IParam} [param] 额外参数
* @return {*} {boolean}
* @memberof AppAuthServiceBase
*/
public
getDEAuth
(
context
:
IParam
,
key
:
string
,
dataAccAction
:
string
,
param
?:
IParam
):
boolean
{
// TODO 暂未实现
return
true
;
}
/**
/**
* 通过租户获取组织数据
* 通过租户获取组织数据
*
*
...
@@ -241,4 +365,21 @@ export abstract class AppAuthServiceBase implements IAppAuthService {
...
@@ -241,4 +365,21 @@ export abstract class AppAuthServiceBase implements IAppAuthService {
return
tempViewParam
;
return
tempViewParam
;
}
}
/**
* 处理统一资源与系统操作标识映射
*
* @return {IParam}
* @memberof AppAuthServiceBase
*/
public
handleSysOPPrivs
()
{
let
copySysOPPrivs
:
IParam
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
sysOPPrivs
));
if
(
Object
.
keys
(
copySysOPPrivs
).
length
===
0
)
return
{};
Object
.
keys
(
copySysOPPrivs
).
forEach
((
name
:
any
)
=>
{
if
(
this
.
sysOPPrivsMap
.
get
(
name
))
{
copySysOPPrivs
[
name
]
=
this
.
getAppAuth
(
this
.
sysOPPrivsMap
.
get
(
name
))
?
1
:
0
;
}
})
return
copySysOPPrivs
;
}
}
}
\ No newline at end of file
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/core/service/entity-ui-service/entity-ui-service-base.ts
浏览文件 @
dedcd2e4
...
@@ -27,6 +27,15 @@ export class UIServiceBase {
...
@@ -27,6 +27,15 @@ export class UIServiceBase {
*/
*/
protected
appDeKeyFieldName
:
string
=
''
;
protected
appDeKeyFieldName
:
string
=
''
;
/**
* 是否启用主状态
*
* @protected
* @type {boolean}
* @memberof UIServiceBase
*/
protected
isEnableDEMainState
:
boolean
=
false
;
/**
/**
* 主状态属性集合
* 主状态属性集合
*
*
...
@@ -39,14 +48,14 @@ export class UIServiceBase {
...
@@ -39,14 +48,14 @@ export class UIServiceBase {
*
*
* @memberof UIServiceBase
* @memberof UIServiceBase
*/
*/
protected
allDeMainStateMap
:
Map
<
string
,
string
>
=
new
Map
();
protected
allDeMainStateMap
:
Map
<
string
,
string
>
=
new
Map
();
/**
/**
* 主状态操作标识Map
* 主状态操作标识Map
*
*
* @memberof UIServiceBase
* @memberof UIServiceBase
*/
*/
protected
allDeMainStateOPPrivsMap
:
Map
<
string
,
any
>
=
new
Map
();
protected
allDeMainStateOPPrivsMap
:
Map
<
string
,
any
>
=
new
Map
();
/**
/**
*
*
...
@@ -61,20 +70,20 @@ export class UIServiceBase {
...
@@ -61,20 +70,20 @@ export class UIServiceBase {
* 获取数据对象所有的操作标识
* 获取数据对象所有的操作标识
*
*
* @param data 当前数据
* @param data 当前数据
* @param data
acca
ction 数据操作标识
* @param data
AccA
ction 数据操作标识
* @memberof UIServiceBase
* @memberof UIServiceBase
*/
*/
protected
getAllOPPrivs
(
data
:
any
,
data
acca
ction
:
string
)
{
protected
getAllOPPrivs
(
data
:
any
,
data
AccA
ction
:
string
)
{
if
(
!
Environment
.
enablePermissionValid
)
{
if
(
!
Environment
.
enablePermissionValid
)
{
return
1
;
return
1
;
}
}
if
(
data
&&
(
Object
.
keys
(
data
).
length
>
0
))
{
if
(
data
&&
(
Object
.
keys
(
data
).
length
>
0
))
{
const
curActiveK
ey
:
string
=
`
${
data
[
this
.
appDeKeyFieldName
?.
toLowerCase
()]}
`;
const
k
ey
:
string
=
`
${
data
[
this
.
appDeKeyFieldName
?.
toLowerCase
()]}
`;
//const result = this.authService.getOPPrivs(curActiveKey, dataaccaction
, this.getDEMainStateOPPrivs(data));
const result = App.getAppAuthService().getOPEnableAuth(this.context, dataAccAction, key
, this.getDEMainStateOPPrivs(data));
return
1
;
return
result[dataAccAction]
;
} else {
} else {
// const result = this.authService.getOPPrivs(undefined, dataaccaction, undefined
);
const result = App.getAppAuthService().getOPEnableAuth(this.context, dataAccAction
);
return
1
;
return
result[dataAccAction]
;
}
}
}
}
...
@@ -92,7 +101,7 @@ export class UIServiceBase {
...
@@ -92,7 +101,7 @@ export class UIServiceBase {
return null;
return null;
}
}
}
}
/**
/**
* 获取数据对象的主状态标识
* 获取数据对象的主状态标识
*
*
...
@@ -100,7 +109,7 @@ export class UIServiceBase {
...
@@ -100,7 +109,7 @@ export class UIServiceBase {
* @memberof UIServiceBase
* @memberof UIServiceBase
*/
*/
protected getDEMainStateTag(data: IParam) {
protected getDEMainStateTag(data: IParam) {
const mainStateFields: string[] =
[]
;
const mainStateFields: string[] =
this.mainStateFields
;
if (mainStateFields.length === 0) return null;
if (mainStateFields.length === 0) return null;
mainStateFields.forEach((singleMainField: any) => {
mainStateFields.forEach((singleMainField: any) => {
if (!(singleMainField in data)) {
if (!(singleMainField in data)) {
...
...
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/service/app-auth-service.ts
→
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/service/app-auth-service.ts
.hbs
浏览文件 @
dedcd2e4
import
{
AppAuthServiceBase
,
IAppAuthService
,
IParam
}
from
"@core"
;
import { AppAuthServiceBase, IAppAuthService } from "@core";
/**
/**
* 应用权限服务
* 应用权限服务
...
@@ -17,6 +17,33 @@ export class AppAuthService extends AppAuthServiceBase implements IAppAuthServic
...
@@ -17,6 +17,33 @@ export class AppAuthService extends AppAuthServiceBase implements IAppAuthServic
*/
*/
private static readonly instance = new AppAuthService();
private static readonly instance = new AppAuthService();
/**
* Creates an instance of AppAuthService.
* @memberof AppAuthService
*/
public constructor() {
super();
this.initBaseData();
}
/**
* 初始化基础数据
*
* @memberof AppAuthService
*/
public initBaseData() {
// 系统默认操作标识
this.sysOPPrivs = {
{{
~#
each
app
.
psSystem
.
allPSDEOPPrivs
as
|
psDEOPPriv
|~
}}
{{
psDEOPPriv
.
name
}}
:1
{{#
unless
@last
}}
,
{{/
unless
}}
{{
~
/
each
~
}}
};
{{#
each
app
.
psSystem
.
allPSDEOPPrivs
as
|
psDEOPPriv
|
}}
// 系统操作标识映射统一资源映射表
this.sysOPPrivsMap.set('
{{
psDEOPPriv
.
name
}}
', '
{{
psDEOPPriv
.
mapPSSysUniRes
.
resCode
}}
');
{{/
each
}}
}
/**
/**
* 获取唯一实例
* 获取唯一实例
*
*
...
...
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/ui-service/{{appEntities}}/{{appEntities}}-ui-service-base.ts.hbs
浏览文件 @
dedcd2e4
...
@@ -28,6 +28,8 @@ export class {{pascalCase appEntity.codeName}}UIServiceBase extends UIServiceBas
...
@@ -28,6 +28,8 @@ export class {{pascalCase appEntity.codeName}}UIServiceBase extends UIServiceBas
public initBasicData() {
public initBasicData() {
// 应用实体主键属性
// 应用实体主键属性
this.appDeKeyFieldName = '
{{
lowerCase
appEntity
.
pSDataEntity
.
keyPSDEField
.
codeName
}}
';
this.appDeKeyFieldName = '
{{
lowerCase
appEntity
.
pSDataEntity
.
keyPSDEField
.
codeName
}}
';
// 是否启用主状态
this.isEnableDEMainState =
{{#if
appEntity
.
allPSDEMainStates
}}
true
{{else}}
false
{{/if}}
;
{{#if
appEntity
.
pSDataEntity
.
dEMainStateDEFields
}}
{{#if
appEntity
.
pSDataEntity
.
dEMainStateDEFields
}}
// 主状态属性集合
// 主状态属性集合
this.mainStateFields = [
this.mainStateFields = [
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录