Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzuaa
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzuaa
提交
1e9cca60
提交
1e9cca60
编写于
6月 12, 2020
作者:
laizhilong
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
http://labcs.ibizee.cn/ibiz4jteam/ibzuaa
上级
8c7bb1c0
1fc75548
变更
42
隐藏空白字符变更
内嵌
并排
正在显示
42 个修改的文件
包含
969 行增加
和
290 行删除
+969
-290
CHANGELOG.md
app_web/CHANGELOG.md
+62
-0
app-form-item.less
app_web/src/components/app-form-item/app-form-item.less
+27
-0
app-form-item.vue
app_web/src/components/app-form-item/app-form-item.vue
+55
-7
app-transfer.vue
app_web/src/components/app-transfer/app-transfer.vue
+92
-70
dropdown-list.vue
app_web/src/components/dropdown-list/dropdown-list.vue
+1
-1
edit-view2-engine.ts
app_web/src/engine/view/edit-view2-engine.ts
+2
-0
edit-view3-engine.ts
app_web/src/engine/view/edit-view3-engine.ts
+2
-0
sys-permissionedit-view2-base.vue
...ys-permissionedit-view2/sys-permissionedit-view2-base.vue
+9
-0
sys-role-permissionedit-view2-base.vue
...rmissionedit-view2/sys-role-permissionedit-view2-base.vue
+9
-0
sys-roleedit-view2-base.vue
.../pages/uaa/sys-roleedit-view2/sys-roleedit-view2-base.vue
+9
-0
sys-user-roleedit-view2-base.vue
.../sys-user-roleedit-view2/sys-user-roleedit-view2-base.vue
+9
-0
sys-useredit-view2-base.vue
.../pages/uaa/sys-useredit-view2/sys-useredit-view2-base.vue
+9
-0
uiaction-tool.ts
app_web/src/utils/uiaction-tool/uiaction-tool.ts
+1
-1
view-tool.ts
app_web/src/utils/view-tool/view-tool.ts
+2
-2
main-grid-base.vue
app_web/src/widgets/sys-app/main-grid/main-grid-base.vue
+3
-0
main-grid-base.vue
...web/src/widgets/sys-auth-log/main-grid/main-grid-base.vue
+1
-0
default-drbar-base.vue
...dgets/sys-permission/default-drbar/default-drbar-base.vue
+56
-3
main-grid-base.vue
...b/src/widgets/sys-permission/main-grid/main-grid-base.vue
+1
-0
default-drbar-base.vue
.../sys-role-permission/default-drbar/default-drbar-base.vue
+56
-3
main-grid-base.vue
.../widgets/sys-role-permission/main-grid/main-grid-base.vue
+1
-0
default-drbar-base.vue
...src/widgets/sys-role/default-drbar/default-drbar-base.vue
+56
-3
main-grid-base.vue
app_web/src/widgets/sys-role/main-grid/main-grid-base.vue
+1
-0
default-drbar-base.vue
...idgets/sys-user-role/default-drbar/default-drbar-base.vue
+56
-3
main-grid-base.vue
...eb/src/widgets/sys-user-role/main-grid/main-grid-base.vue
+1
-0
default-drbar-base.vue
...src/widgets/sys-user/default-drbar/default-drbar-base.vue
+56
-3
main-grid-base.vue
app_web/src/widgets/sys-user/main-grid/main-grid-base.vue
+1
-0
SysApp.java
...core/src/main/java/cn/ibizlab/core/uaa/domain/SysApp.java
+0
-1
SysAuthLog.java
.../src/main/java/cn/ibizlab/core/uaa/domain/SysAuthLog.java
+2
-2
SysPermission.java
...c/main/java/cn/ibizlab/core/uaa/domain/SysPermission.java
+2
-2
SysRole.java
...ore/src/main/java/cn/ibizlab/core/uaa/domain/SysRole.java
+2
-2
SysRolePermission.java
...in/java/cn/ibizlab/core/uaa/domain/SysRolePermission.java
+2
-2
SysUser.java
...ore/src/main/java/cn/ibizlab/core/uaa/domain/SysUser.java
+2
-2
SysUserRole.java
...src/main/java/cn/ibizlab/core/uaa/domain/SysUserRole.java
+2
-2
SysAppService.java
...cn/ibizlab/core/uaa/extensions/service/SysAppService.java
+8
-2
apiSecurityConfig.java
...rc/main/java/cn/ibizlab/api/config/apiSecurityConfig.java
+1
-0
ClientAuthenticationResource.java
...lab/api/rest/extensions/ClientAuthenticationResource.java
+6
-19
UAACoreResource.java
.../java/cn/ibizlab/api/rest/extensions/UAACoreResource.java
+19
-0
IBZUAAFallback.java
.../src/main/java/cn/ibizlab/util/client/IBZUAAFallback.java
+5
-0
IBZUAAFeignClient.java
...c/main/java/cn/ibizlab/util/client/IBZUAAFeignClient.java
+5
-0
AuthTokenUtil.java
...src/main/java/cn/ibizlab/util/security/AuthTokenUtil.java
+4
-160
SimpleTokenUtil.java
...c/main/java/cn/ibizlab/util/security/SimpleTokenUtil.java
+170
-0
UAATokenUtil.java
.../src/main/java/cn/ibizlab/util/security/UAATokenUtil.java
+161
-0
未找到文件。
app_web/CHANGELOG.md
浏览文件 @
1e9cca60
## v7.0.0-alpha.9 [2020-6-11]
### Bug修复
数值代码表多语言
树右键菜单滚动条样式bug
列表面板界面行为bug
多选视图界面逻辑修复
图表刷新bug修复
日历部件选中抛出数据逻辑调整
编辑视图,app-span显示0时不显示
树视图右键界面行为刷新bug
快捷菜单控制台报错bug
门户加载自定义模型错误时,正常显示默认看板
修复雷达图显示异常问题
修复编辑类、分页导航视图带数据标题问题
修复饼图、漏斗图 获取序列参数错误问题
### 功能新增及优化
#### 模板
看板和门户布局模板调整,支持门户部件标题栏界面行为组
支持数据选择、地址框、自动完成、下拉列表、标签、选项框列表、单选列表等编辑器导航参数调整
支持树导航栏、表格导航栏、列表导航栏、卡片导航栏、日历导航栏、表单关系界面、数据选择面板、分页导航面板、数据关系栏、界面行为、新建逻辑、编辑逻辑导航参数调整
支持图表无数据时显示暂无数据
支持表格新建默认值
支持日历部件右键菜单
支持表格列触发界面行为
面板布局调整
#### 基础文件
门户部件视图的样式
数据选择,地址框,自动完成,下拉列表,标签,选项框列表,单选列表等编辑器导航参数调整
表单项label位置
调整登录页面
穿梭框编辑器支持
## v7.0.0-alpha.8 [2020-6-4]
### Bug修复
...
...
app_web/src/components/app-form-item/app-form-item.less
浏览文件 @
1e9cca60
...
...
@@ -16,4 +16,31 @@
display: inline-block;
padding: 0 0 10px;
}
}
.app-form-item-label-left{
.app-form-item-label{
float: left;
text-align: right;
padding-right: 12px;
}
}
.app-form-item-label-right{
.app-form-item-label{
float: right;
text-align: left;
padding-left: 12px;
}
}
.app-form-item-label-top{
.app-form-item-label{
display: block;
padding-bottom: 10px;
}
}
.app-form-item-label-bottom{
.app-form-item-label{
display: block;
padding-top: 10px;
}
}
\ No newline at end of file
app_web/src/components/app-form-item/app-form-item.vue
浏览文件 @
1e9cca60
...
...
@@ -21,12 +21,16 @@
:error=
"error"
:required=
"required"
:rules=
"rules"
:class=
"classes"
:label-width=
"this.isShowCaption ? !Object.is(this.labelPos, 'TOP') ? this.labelWidth : null : 0"
>
<span
slot=
'label'
v-if=
"this.isShowCaption && this.labelWidth > 0"
:class=
"labelclasses"
>
{{
this
.
isEmptyCaption
?
''
:
this
.
caption
}}
</span>
:class=
"classes"
>
<div
v-if=
"Object.is(this.labelPos,'BOTTOM') || Object.is(this.labelPos,'NONE') || !this.labelPos"
class=
"slot-editor"
:style=
"slotstyle"
>
<slot></slot>
</div>
<span
v-if=
"!Object.is(this.labelPos,'NONE') && this.isShowCaption && this.labelWidth > 0"
:style=
"labelstyle"
:class=
"labelclasses"
>
{{
this
.
isEmptyCaption
?
''
:
this
.
caption
}}
</span>
<div
v-if=
"Object.is(this.labelPos,'TOP') || Object.is(this.labelPos,'LEFT') || Object.is(this.labelPos,'RIGHT')"
class=
"slot-editor"
:style=
"slotstyle"
>
<slot></slot>
</div>
</form-item>
</div>
</div>
...
...
@@ -167,9 +171,27 @@ export default class AppFormItem extends Vue {
* @memberof AppFormItem
*/
get
classes
():
string
[]
{
let
posClass
=
''
;
switch
(
this
.
labelPos
)
{
case
'TOP'
:
posClass
=
'app-form-item-label-top'
;
break
;
case
'LEFT'
:
posClass
=
'app-form-item-label-left'
;
break
;
case
'BOTTOM'
:
posClass
=
'app-form-item-label-bottom'
;
break
;
case
'RIGHT'
:
posClass
=
'app-form-item-label-right'
;
break
;
case
'NONE'
:
posClass
=
'app-form-item-label-none'
;
break
;
}
return
[
'app-form-item'
,
Object
.
is
(
this
.
labelPos
,
'TOP'
)
?
'app-form-item-label-top'
:
''
posClass
];
}
...
...
@@ -181,7 +203,33 @@ export default class AppFormItem extends Vue {
* @memberof AppFormItem
*/
get
labelclasses
():
string
{
return
this
.
labelStyle
?
this
.
labelStyle
:
''
;
return
this
.
labelStyle
?
this
.
labelStyle
+
' app-form-item-label'
:
'app-form-item-label'
;
}
/**
* label行内样式
*
* @readonly
* @type {string}
* @memberof AppFormItem
*/
get
labelstyle
():
any
{
return
{
width
:
this
.
labelWidth
+
'px'
};
}
/**
* slot行内样式
*
* @readonly
* @type {string}
* @memberof AppFormItem
*/
get
slotstyle
():
any
{
if
(
Object
.
is
(
this
.
labelPos
,
'LEFT'
)){
return
{
marginLeft
:
this
.
labelWidth
+
'px'
};
}
else
if
(
Object
.
is
(
this
.
labelPos
,
'RIGHT'
)){
return
{
marginRight
:
this
.
labelWidth
+
'px'
};
}
}
/**
...
...
app_web/src/components/app-transfer/app-transfer.vue
浏览文件 @
1e9cca60
...
...
@@ -3,7 +3,7 @@
@
on-open-change=
"transferRefresh"
@
on-change=
"dataChange"
v-model=
"dataRight"
:style=
"
{width:width}"
:style=
"
{width:width
?width:'586px'
}"
multiple
>
<Option
class=
"hidden"
:value=
"item"
v-for=
"(item,i) in dataRight"
:key=
"i"
>
{{
findLabel
(
item
)
}}
</Option>
...
...
@@ -17,44 +17,23 @@ import { ElSelect } from "element-ui/types/select";
@
Component
({})
export
default
class
AppTransfer
extends
Vue
{
/**
* 左侧框数据
*/
public
dataLeft
:
any
[]
=
[];
/**
* 右侧框数据
*/
public
dataRight
:
any
[]
=
[];
/**
* 穿梭框宽度
*/
@
Prop
()
public
width
:
any
;
/**
* 代码表服务对象
*
* @type {CodeListService}
* @memberof AppTransfer
*/
public
codeListService
:
CodeListService
=
new
CodeListService
({
$store
:
this
.
$store
});
/**
* 查询参数
* @type {*}
* @memberof AppTransfer
*/
public
queryParam
:
any
;
@
Prop
()
public
width
:
any
;
/**
* 表单传入字符串值分隔符
*
* @type {string}
* @memberof AppTransfer
*/
@
Prop
()
public
valueSeparator
?:
string
;
@
Prop
()
public
valueSeparator
!
:
string
;
/**
* 当前选中值
* @type {any}
...
...
@@ -79,26 +58,20 @@ export default class AppTransfer extends Vue {
@
Prop
()
public
codelistType
?:
string
;
/**
* 组件change事件,右侧框数据变化时
* 局部上下文导航参数
*
* @type {*}
* @memberof AppTransfer
*/
dataChange
(
e
:
any
)
{
let
newVal
:
any
;
newVal
=
e
.
join
(
`
${
this
.
valueSeparator
}
`
);
if
(
newVal
)
{
this
.
$emit
(
"change"
,
newVal
);
}
else
{
this
.
$emit
(
"change"
,
null
);
}
}
@
Prop
()
public
localContext
!
:
any
;
/**
*
传入额外
参数
*
局部导航
参数
*
* @type {*}
* @memberof AppTransfer
*/
@
Prop
()
public
itemParam
?
:
any
;
@
Prop
()
public
localParam
!
:
any
;
/**
* 视图上下文
...
...
@@ -118,6 +91,7 @@ export default class AppTransfer extends Vue {
/**
* 是否禁用
*
* @type {any}
* @memberof AppTransfer
*
...
...
@@ -125,18 +99,38 @@ export default class AppTransfer extends Vue {
@
Prop
()
public
disabled
?:
any
;
/**
* 是否支持过滤
* @type {boolean}
* placeholder
*
* @type {string}
* @memberof AppTransfer
*
*/
@
Prop
()
public
filterable
?:
boolean
;
@
Prop
()
public
placeholder
?:
string
;
/**
* 下拉选提示内容
* @type {string}
* 左侧框数据
*
* @type {any[]}
* @memberof AppTransfer
*/
@
Prop
()
public
placeholder
?:
string
;
public
dataLeft
:
any
[]
=
[];
/**
* 右侧框数据
*
* @type {any[]}
* @memberof AppTransfer
*/
public
dataRight
:
any
[]
=
[];
/**
* 代码表服务对象
*
* @type {CodeListService}
* @memberof AppTransfer
*/
public
codeListService
:
CodeListService
=
new
CodeListService
({
$store
:
this
.
$store
});
/**
* vue 生命周期
...
...
@@ -147,8 +141,34 @@ export default class AppTransfer extends Vue {
this
.
dataHandle
();
}
/**
* 组件change事件,右侧框数据变化时
*
* @memberof AppTransfer
*/
dataChange
(
e
:
any
)
{
let
_valueSeparator
:
string
=
this
.
initValueSeparator
();
let
newVal
:
string
=
e
.
join
(
`
${
_valueSeparator
}
`
);
if
(
newVal
)
{
this
.
$emit
(
"change"
,
newVal
);
}
else
{
this
.
$emit
(
"change"
,
null
);
}
}
/**
* 初始化valueSeparator
*
* @memberof AppTransfer
*/
public
initValueSeparator
()
{
return
this
.
valueSeparator
?
this
.
valueSeparator
:
","
;
}
/**
* 数据处理
*
* @memberof AppTransfer
*/
public
dataHandle
()
{
if
(
this
.
tag
&&
Object
.
is
(
this
.
codelistType
,
"STATIC"
))
{
...
...
@@ -167,14 +187,11 @@ export default class AppTransfer extends Vue {
// 参数处理
let
_context
=
data
.
context
;
let
_param
=
data
.
param
;
this
.
codeListService
.
getItems
(
this
.
tag
,
_context
,
_param
)
.
then
((
res
:
any
)
=>
{
this
.
codeListService
.
getItems
(
this
.
tag
,
_context
,
_param
).
then
((
res
:
any
)
=>
{
this
.
dataLeft
=
res
;
this
.
initLeft
();
this
.
initRight
();
})
.
catch
((
error
:
any
)
=>
{
}).
catch
((
error
:
any
)
=>
{
console
.
log
(
`----
${
this
.
tag
}
----代码表不存在`
);
});
}
...
...
@@ -189,30 +206,23 @@ export default class AppTransfer extends Vue {
*/
public
handlePublicParams
(
arg
:
any
)
{
// 合并表单参数
arg
.
param
=
this
.
viewparams
?
JSON
.
parse
(
JSON
.
stringify
(
this
.
viewparams
))
:
{};
arg
.
param
=
this
.
viewparams
?
JSON
.
parse
(
JSON
.
stringify
(
this
.
viewparams
)):
{};
arg
.
context
=
this
.
context
?
JSON
.
parse
(
JSON
.
stringify
(
this
.
context
))
:
{};
// 附加参数处理
if
(
this
.
itemParam
&&
this
.
itemParam
.
context
)
{
let
_context
=
this
.
$util
.
formatData
(
this
.
itemValue
,
arg
.
context
,
this
.
itemParam
.
context
);
if
(
this
.
localContext
&&
Object
.
keys
(
this
.
localContext
).
length
>
0
)
{
let
_context
=
this
.
$util
.
computedNavData
(
this
.
itemValue
,
arg
.
context
,
arg
.
param
,
this
.
localContext
);
Object
.
assign
(
arg
.
context
,
_context
);
}
if
(
this
.
itemParam
&&
this
.
itemParam
.
param
)
{
let
_param
=
this
.
$util
.
formatData
(
this
.
itemValue
,
arg
.
param
,
this
.
itemParam
.
param
);
if
(
this
.
localParam
&&
Object
.
keys
(
this
.
localParam
).
length
>
0
)
{
let
_param
=
this
.
$util
.
computedNavData
(
this
.
itemValue
,
arg
.
context
,
arg
.
param
,
this
.
localParam
);
Object
.
assign
(
arg
.
param
,
_param
);
}
}
/**
* 初始化左侧框数据
*
* @memberof AppTransfer
*/
public
initLeft
()
{
let
left
:
any
[]
=
[];
...
...
@@ -222,46 +232,58 @@ export default class AppTransfer extends Vue {
this
.
dataLeft
.
push
({
key
:
elem
.
id
,
value
:
elem
.
value
,
label
:
elem
.
label
,
label
:
elem
.
text
,
disabled
:
elem
.
disabled
});
});
}
/**
* 初始化右侧框数据
*
* @memberof AppTransfer
*/
public
initRight
()
{
let
_valueSeparator
:
any
;
_valueSeparator
=
this
.
initValueSeparator
();
let
_data
:
any
=
this
.
itemValue
;
if
(
_data
)
{
let
newData
:
any
[]
=
_data
.
split
(
`
${
this
.
valueSeparator
}
`
);
let
_dataRight
:
any
=
[];
let
newData
:
any
[]
=
_data
.
split
(
`
${
_valueSeparator
}
`
);
this
.
dataLeft
.
forEach
((
elem
:
any
)
=>
{
newData
.
forEach
((
item
:
any
)
=>
{
if
(
item
===
elem
.
value
)
{
this
.
dataRight
.
push
(
elem
.
key
);
_
dataRight
.
push
(
elem
.
key
);
}
});
});
this
.
dataRight
=
_dataRight
;
}
}
/**
* 穿梭框打开时刷新数据
*
* @memberof AppTransfer
*/
public
transferRefresh
(
e
:
any
)
{
if
(
e
&&
this
.
codelistType
===
"DYNAMIC"
)
{
this
.
dataLeft
=
[];
this
.
dataRight
=
[];
this
.
dataHandle
();
}
}
/**
* 找到dataLeft中key与dataRight中item相等的元素,返回label
*
* @memberof AppTransfer
*/
public
findLabel
(
item
:
any
)
{
for
(
const
elem
of
this
.
dataLeft
)
{
if
(
elem
.
key
===
item
)
return
elem
.
label
;
}
}
}
</
script
>
...
...
app_web/src/components/dropdown-list/dropdown-list.vue
浏览文件 @
1e9cca60
...
...
@@ -116,7 +116,7 @@ export default class DropDownList extends Vue {
* @memberof AppFormDRUIPart
*/
@
Prop
()
public
viewparams
!
:
any
;
/**
* 是否禁用
* @type {any}
...
...
app_web/src/engine/view/edit-view2-engine.ts
浏览文件 @
1e9cca60
...
...
@@ -89,6 +89,7 @@ export default class EditView2Engine extends EditViewEngine {
*/
public
onFormLoad
(
arg
:
any
=
{}):
void
{
super
.
onFormLoad
(
arg
);
this
.
view
.
formData
=
arg
;
if
(
this
.
getDRBar
())
{
const
tag
=
this
.
getDRBar
().
name
;
this
.
setViewState2
({
tag
:
tag
,
action
:
'state'
,
viewdata
:
this
.
view
.
vieparams
});
...
...
@@ -103,6 +104,7 @@ export default class EditView2Engine extends EditViewEngine {
*/
public
onFormSave
(
arg
:
any
=
{}):
void
{
super
.
onFormSave
(
arg
);
this
.
view
.
formData
=
arg
;
if
(
this
.
getDRBar
())
{
const
tag
=
this
.
getDRBar
().
name
;
this
.
setViewState2
({
tag
:
tag
,
action
:
'state'
,
viewdata
:
this
.
view
.
viewparams
});
...
...
app_web/src/engine/view/edit-view3-engine.ts
浏览文件 @
1e9cca60
...
...
@@ -89,6 +89,7 @@ export default class EditView3Engine extends EditViewEngine {
*/
public
onFormLoad
(
arg
:
any
=
{}):
void
{
super
.
onFormLoad
(
arg
);
this
.
view
.
formData
=
arg
;
if
(
this
.
getDrTab
())
{
const
tag
=
this
.
getDrTab
().
name
;
this
.
setViewState2
({
tag
:
tag
,
action
:
'state'
,
viewdata
:
this
.
view
.
viewparams
});
...
...
@@ -103,6 +104,7 @@ export default class EditView3Engine extends EditViewEngine {
*/
public
onFormSave
(
arg
:
any
=
{}):
void
{
super
.
onFormSave
(
arg
);
this
.
view
.
formData
=
arg
;
if
(
this
.
getDrTab
())
{
const
tag
=
this
.
getDrTab
().
name
;
this
.
setViewState2
({
tag
:
tag
,
action
:
'state'
,
viewdata
:
this
.
view
.
viewparams
});
...
...
app_web/src/pages/uaa/sys-permissionedit-view2/sys-permissionedit-view2-base.vue
浏览文件 @
1e9cca60
...
...
@@ -48,6 +48,7 @@
ref=
'drbar'
:viewparams=
"viewparams"
:context=
"context"
:formData=
"formData"
@
selectionchange=
"drbar_selectionchange($event)"
@
load=
"drbar_load($event)"
@
closeview=
"closeView($event)"
>
...
...
@@ -1031,6 +1032,14 @@ export default class SYS_PERMISSIONEditView2Base extends Vue {
* @memberof SYS_PERMISSIONEditView2
*/
public
selection
:
any
=
{};
/**
* 表单数据
*
* @type {*}
* @memberof SYS_PERMISSIONEditView2Base
*/
public
formData
:
any
=
{};
}
</
script
>
...
...
app_web/src/pages/uaa/sys-role-permissionedit-view2/sys-role-permissionedit-view2-base.vue
浏览文件 @
1e9cca60
...
...
@@ -48,6 +48,7 @@
ref=
'drbar'
:viewparams=
"viewparams"
:context=
"context"
:formData=
"formData"
@
selectionchange=
"drbar_selectionchange($event)"
@
load=
"drbar_load($event)"
@
closeview=
"closeView($event)"
>
...
...
@@ -1031,6 +1032,14 @@ export default class SYS_ROLE_PERMISSIONEditView2Base extends Vue {
* @memberof SYS_ROLE_PERMISSIONEditView2
*/
public
selection
:
any
=
{};
/**
* 表单数据
*
* @type {*}
* @memberof SYS_ROLE_PERMISSIONEditView2Base
*/
public
formData
:
any
=
{};
}
</
script
>
...
...
app_web/src/pages/uaa/sys-roleedit-view2/sys-roleedit-view2-base.vue
浏览文件 @
1e9cca60
...
...
@@ -48,6 +48,7 @@
ref=
'drbar'
:viewparams=
"viewparams"
:context=
"context"
:formData=
"formData"
@
selectionchange=
"drbar_selectionchange($event)"
@
load=
"drbar_load($event)"
@
closeview=
"closeView($event)"
>
...
...
@@ -1031,6 +1032,14 @@ export default class SYS_ROLEEditView2Base extends Vue {
* @memberof SYS_ROLEEditView2
*/
public
selection
:
any
=
{};
/**
* 表单数据
*
* @type {*}
* @memberof SYS_ROLEEditView2Base
*/
public
formData
:
any
=
{};
}
</
script
>
...
...
app_web/src/pages/uaa/sys-user-roleedit-view2/sys-user-roleedit-view2-base.vue
浏览文件 @
1e9cca60
...
...
@@ -48,6 +48,7 @@
ref=
'drbar'
:viewparams=
"viewparams"
:context=
"context"
:formData=
"formData"
@
selectionchange=
"drbar_selectionchange($event)"
@
load=
"drbar_load($event)"
@
closeview=
"closeView($event)"
>
...
...
@@ -1031,6 +1032,14 @@ export default class SYS_USER_ROLEEditView2Base extends Vue {
* @memberof SYS_USER_ROLEEditView2
*/
public
selection
:
any
=
{};
/**
* 表单数据
*
* @type {*}
* @memberof SYS_USER_ROLEEditView2Base
*/
public
formData
:
any
=
{};
}
</
script
>
...
...
app_web/src/pages/uaa/sys-useredit-view2/sys-useredit-view2-base.vue
浏览文件 @
1e9cca60
...
...
@@ -48,6 +48,7 @@
ref=
'drbar'
:viewparams=
"viewparams"
:context=
"context"
:formData=
"formData"
@
selectionchange=
"drbar_selectionchange($event)"
@
load=
"drbar_load($event)"
@
closeview=
"closeView($event)"
>
...
...
@@ -1031,6 +1032,14 @@ export default class SYS_USEREditView2Base extends Vue {
* @memberof SYS_USEREditView2
*/
public
selection
:
any
=
{};
/**
* 表单数据
*
* @type {*}
* @memberof SYS_USEREditView2Base
*/
public
formData
:
any
=
{};
}
</
script
>
...
...
app_web/src/utils/uiaction-tool/uiaction-tool.ts
浏览文件 @
1e9cca60
...
...
@@ -44,7 +44,7 @@ export class UIActionTool {
*/
private
static
formatData
(
actionTarget
:
any
,
args
:
any
,
parentContext
:
any
,
parentParams
:
any
,
_params
:
any
):
any
{
let
_data
:
any
=
{};
if
(
Object
.
is
(
actionTarget
,
'SINGLEKEY'
))
{
if
(
Object
.
is
(
actionTarget
,
'SINGLEKEY'
)
||
Object
.
is
(
actionTarget
,
'NONE'
)
)
{
let
[
arg
]
=
args
;
Object
.
keys
(
_params
).
forEach
((
name
:
string
)
=>
{
let
hasProperty
=
true
;
...
...
app_web/src/utils/view-tool/view-tool.ts
浏览文件 @
1e9cca60
...
...
@@ -128,7 +128,7 @@ export class ViewTool {
const
[{
pathName
,
parameterName
}]
=
parameters
;
routePath
=
`/
${
pathName
}
`
;
if
(
Object
.
keys
(
data
).
length
>
0
)
{
routePath
=
`
${
routePath
}
/
${
qs
.
stringify
(
data
,
{
delimiter
:
';'
})}
`
;
routePath
=
`
${
routePath
}
?
${
qs
.
stringify
(
data
,
{
delimiter
:
';'
})}
`
;
}
}
else
if
(
parameters
.
length
===
2
)
{
let
[
arg
]
=
args
;
...
...
@@ -138,7 +138,7 @@ export class ViewTool {
arg
[
_parameterName
]
:
null
;
routePath
=
`/
${
_pathName
}
/
${
_value
}
/
${
_pathName2
}
`
;
if
(
Object
.
keys
(
data
).
length
>
0
)
{
routePath
=
`
${
routePath
}
/
${
qs
.
stringify
(
data
,
{
delimiter
:
';'
})}
`
;
routePath
=
`
${
routePath
}
?
${
qs
.
stringify
(
data
,
{
delimiter
:
';'
})}
`
;
}
}
return
routePath
;
...
...
app_web/src/widgets/sys-app/main-grid/main-grid-base.vue
浏览文件 @
1e9cca60
...
...
@@ -45,6 +45,7 @@
style=""
@change="($event)=>{gridEditItemChange(row, column.property, $event, $index)}">
</dropdown-list>
</app-form-item>
</
template
>
<
template
v-if=
"!actualIsOpenEdit"
>
...
...
@@ -159,6 +160,7 @@
style=""
@change="($event)=>{gridEditItemChange(row, column.property, $event, $index)}">
</dropdown-list>
</app-form-item>
</
template
>
<
template
v-if=
"!actualIsOpenEdit"
>
...
...
@@ -1573,6 +1575,7 @@ export default class MainBase extends Vue implements ControlInterface {
*/
public
uiAction
(
row
:
any
,
tag
:
any
,
$event
:
any
)
{
// this.rowClick(row, true);
$event
.
stopPropagation
();
}
/**
...
...
app_web/src/widgets/sys-auth-log/main-grid/main-grid-base.vue
浏览文件 @
1e9cca60
...
...
@@ -1389,6 +1389,7 @@ export default class MainBase extends Vue implements ControlInterface {
*/
public
uiAction
(
row
:
any
,
tag
:
any
,
$event
:
any
)
{
// this.rowClick(row, true);
$event
.
stopPropagation
();
}
/**
...
...
app_web/src/widgets/sys-permission/default-drbar/default-drbar-base.vue
浏览文件 @
1e9cca60
...
...
@@ -151,6 +151,7 @@ export default class DefaultBase extends Vue implements ControlInterface {
}
/**
* 获取多项数据
*
...
...
@@ -179,6 +180,14 @@ export default class DefaultBase extends Vue implements ControlInterface {
*/
@
Prop
()
public
loadAction
?:
string
;
/**
* 表单数据
*
* @type {*}
* @memberof DefaultBase
*/
@
Prop
({
default
:{}})
public
formData
?:
any
;
/**
* 数据选中项
*
...
...
@@ -201,6 +210,15 @@ export default class DefaultBase extends Vue implements ControlInterface {
},
];
/**
* 关系栏数据项导航参数集合
*
* @type {any[]}
* @memberof DefaultBase
*/
public
navParamsArray
:
Array
<
any
>
=
[
];
/**
* 默认打开项
*
...
...
@@ -323,6 +341,36 @@ export default class DefaultBase extends Vue implements ControlInterface {
return
item
;
}
/**
* 初始化导航参数
*
* @param {*} drItem
* @memberof DefaultBase
*/
public
initNavParam
(
drItem
:
any
){
let
returnNavParam
:
any
=
{};
if
(
drItem
&&
drItem
.
id
){
let
curDRItem
:
any
=
this
.
navParamsArray
.
find
((
item
:
any
)
=>
{
return
Object
.
is
(
item
.
id
,
drItem
.
id
);
})
if
(
curDRItem
){
let
localContext
:
any
=
curDRItem
.
localContext
;
let
localViewParam
:
any
=
curDRItem
.
localViewParam
;
if
(
localContext
&&
Object
.
keys
(
localContext
).
length
>
0
){
let
_context
:
any
=
this
.
$util
.
computedNavData
(
this
.
formData
,
this
.
context
,
this
.
viewparams
,
localContext
);
returnNavParam
.
localContext
=
_context
;
}
if
(
localViewParam
&&
Object
.
keys
(
localViewParam
).
length
>
0
){
let
_params
:
any
=
this
.
$util
.
computedNavData
(
this
.
formData
,
this
.
context
,
this
.
viewparams
,
localViewParam
);
returnNavParam
.
localViewParam
=
_params
;
}
return
returnNavParam
;
}
else
{
return
null
;
}
}
}
/**
* 节点选中
*
...
...
@@ -334,13 +382,18 @@ export default class DefaultBase extends Vue implements ControlInterface {
if
(
Object
.
is
(
item
.
id
,
this
.
selection
.
id
))
{
return
;
}
this
.
$emit
(
'selectionchange'
,
[
item
]);
let
localNavParam
:
any
=
this
.
initNavParam
(
item
);
const
refview
=
this
.
getDRBarItem
({
nodetype
:
item
.
id
});
this
.
selection
=
{};
const
_context
:
any
=
{
...
JSON
.
parse
(
JSON
.
stringify
(
this
.
context
))
};
const
_params
:
any
=
{
...
JSON
.
parse
(
JSON
.
stringify
(
this
.
viewparams
))
};
if
(
localNavParam
&&
localNavParam
.
localContext
){
Object
.
assign
(
_context
,
localNavParam
.
localContext
);
}
const
_params
:
any
=
{};
if
(
localNavParam
&&
localNavParam
.
localViewParam
){
Object
.
assign
(
_params
,
localNavParam
.
localViewParam
);
}
if
(
refview
&&
refview
.
parentdatajo
)
{
Object
.
assign
(
_context
,
refview
.
parentdatajo
);
Object
.
assign
(
this
.
selection
,
{
view
:
{
viewname
:
refview
.
viewname
},
data
:
_context
,
param
:
_params
});
...
...
app_web/src/widgets/sys-permission/main-grid/main-grid-base.vue
浏览文件 @
1e9cca60
...
...
@@ -1251,6 +1251,7 @@ export default class MainBase extends Vue implements ControlInterface {
*/
public
uiAction
(
row
:
any
,
tag
:
any
,
$event
:
any
)
{
// this.rowClick(row, true);
$event
.
stopPropagation
();
}
/**
...
...
app_web/src/widgets/sys-role-permission/default-drbar/default-drbar-base.vue
浏览文件 @
1e9cca60
...
...
@@ -151,6 +151,7 @@ export default class DefaultBase extends Vue implements ControlInterface {
}
/**
* 获取多项数据
*
...
...
@@ -179,6 +180,14 @@ export default class DefaultBase extends Vue implements ControlInterface {
*/
@
Prop
()
public
loadAction
?:
string
;
/**
* 表单数据
*
* @type {*}
* @memberof DefaultBase
*/
@
Prop
({
default
:{}})
public
formData
?:
any
;
/**
* 数据选中项
*
...
...
@@ -201,6 +210,15 @@ export default class DefaultBase extends Vue implements ControlInterface {
},
];
/**
* 关系栏数据项导航参数集合
*
* @type {any[]}
* @memberof DefaultBase
*/
public
navParamsArray
:
Array
<
any
>
=
[
];
/**
* 默认打开项
*
...
...
@@ -323,6 +341,36 @@ export default class DefaultBase extends Vue implements ControlInterface {
return
item
;
}
/**
* 初始化导航参数
*
* @param {*} drItem
* @memberof DefaultBase
*/
public
initNavParam
(
drItem
:
any
){
let
returnNavParam
:
any
=
{};
if
(
drItem
&&
drItem
.
id
){
let
curDRItem
:
any
=
this
.
navParamsArray
.
find
((
item
:
any
)
=>
{
return
Object
.
is
(
item
.
id
,
drItem
.
id
);
})
if
(
curDRItem
){
let
localContext
:
any
=
curDRItem
.
localContext
;
let
localViewParam
:
any
=
curDRItem
.
localViewParam
;
if
(
localContext
&&
Object
.
keys
(
localContext
).
length
>
0
){
let
_context
:
any
=
this
.
$util
.
computedNavData
(
this
.
formData
,
this
.
context
,
this
.
viewparams
,
localContext
);
returnNavParam
.
localContext
=
_context
;
}
if
(
localViewParam
&&
Object
.
keys
(
localViewParam
).
length
>
0
){
let
_params
:
any
=
this
.
$util
.
computedNavData
(
this
.
formData
,
this
.
context
,
this
.
viewparams
,
localViewParam
);
returnNavParam
.
localViewParam
=
_params
;
}
return
returnNavParam
;
}
else
{
return
null
;
}
}
}
/**
* 节点选中
*
...
...
@@ -334,13 +382,18 @@ export default class DefaultBase extends Vue implements ControlInterface {
if
(
Object
.
is
(
item
.
id
,
this
.
selection
.
id
))
{
return
;
}
this
.
$emit
(
'selectionchange'
,
[
item
]);
let
localNavParam
:
any
=
this
.
initNavParam
(
item
);
const
refview
=
this
.
getDRBarItem
({
nodetype
:
item
.
id
});
this
.
selection
=
{};
const
_context
:
any
=
{
...
JSON
.
parse
(
JSON
.
stringify
(
this
.
context
))
};
const
_params
:
any
=
{
...
JSON
.
parse
(
JSON
.
stringify
(
this
.
viewparams
))
};
if
(
localNavParam
&&
localNavParam
.
localContext
){
Object
.
assign
(
_context
,
localNavParam
.
localContext
);
}
const
_params
:
any
=
{};
if
(
localNavParam
&&
localNavParam
.
localViewParam
){
Object
.
assign
(
_params
,
localNavParam
.
localViewParam
);
}
if
(
refview
&&
refview
.
parentdatajo
)
{
Object
.
assign
(
_context
,
refview
.
parentdatajo
);
Object
.
assign
(
this
.
selection
,
{
view
:
{
viewname
:
refview
.
viewname
},
data
:
_context
,
param
:
_params
});
...
...
app_web/src/widgets/sys-role-permission/main-grid/main-grid-base.vue
浏览文件 @
1e9cca60
...
...
@@ -1284,6 +1284,7 @@ export default class MainBase extends Vue implements ControlInterface {
*/
public
uiAction
(
row
:
any
,
tag
:
any
,
$event
:
any
)
{
// this.rowClick(row, true);
$event
.
stopPropagation
();
}
/**
...
...
app_web/src/widgets/sys-role/default-drbar/default-drbar-base.vue
浏览文件 @
1e9cca60
...
...
@@ -151,6 +151,7 @@ export default class DefaultBase extends Vue implements ControlInterface {
}
/**
* 获取多项数据
*
...
...
@@ -179,6 +180,14 @@ export default class DefaultBase extends Vue implements ControlInterface {
*/
@
Prop
()
public
loadAction
?:
string
;
/**
* 表单数据
*
* @type {*}
* @memberof DefaultBase
*/
@
Prop
({
default
:{}})
public
formData
?:
any
;
/**
* 数据选中项
*
...
...
@@ -201,6 +210,15 @@ export default class DefaultBase extends Vue implements ControlInterface {
},
];
/**
* 关系栏数据项导航参数集合
*
* @type {any[]}
* @memberof DefaultBase
*/
public
navParamsArray
:
Array
<
any
>
=
[
];
/**
* 默认打开项
*
...
...
@@ -323,6 +341,36 @@ export default class DefaultBase extends Vue implements ControlInterface {
return
item
;
}
/**
* 初始化导航参数
*
* @param {*} drItem
* @memberof DefaultBase
*/
public
initNavParam
(
drItem
:
any
){
let
returnNavParam
:
any
=
{};
if
(
drItem
&&
drItem
.
id
){
let
curDRItem
:
any
=
this
.
navParamsArray
.
find
((
item
:
any
)
=>
{
return
Object
.
is
(
item
.
id
,
drItem
.
id
);
})
if
(
curDRItem
){
let
localContext
:
any
=
curDRItem
.
localContext
;
let
localViewParam
:
any
=
curDRItem
.
localViewParam
;
if
(
localContext
&&
Object
.
keys
(
localContext
).
length
>
0
){
let
_context
:
any
=
this
.
$util
.
computedNavData
(
this
.
formData
,
this
.
context
,
this
.
viewparams
,
localContext
);
returnNavParam
.
localContext
=
_context
;
}
if
(
localViewParam
&&
Object
.
keys
(
localViewParam
).
length
>
0
){
let
_params
:
any
=
this
.
$util
.
computedNavData
(
this
.
formData
,
this
.
context
,
this
.
viewparams
,
localViewParam
);
returnNavParam
.
localViewParam
=
_params
;
}
return
returnNavParam
;
}
else
{
return
null
;
}
}
}
/**
* 节点选中
*
...
...
@@ -334,13 +382,18 @@ export default class DefaultBase extends Vue implements ControlInterface {
if
(
Object
.
is
(
item
.
id
,
this
.
selection
.
id
))
{
return
;
}
this
.
$emit
(
'selectionchange'
,
[
item
]);
let
localNavParam
:
any
=
this
.
initNavParam
(
item
);
const
refview
=
this
.
getDRBarItem
({
nodetype
:
item
.
id
});
this
.
selection
=
{};
const
_context
:
any
=
{
...
JSON
.
parse
(
JSON
.
stringify
(
this
.
context
))
};
const
_params
:
any
=
{
...
JSON
.
parse
(
JSON
.
stringify
(
this
.
viewparams
))
};
if
(
localNavParam
&&
localNavParam
.
localContext
){
Object
.
assign
(
_context
,
localNavParam
.
localContext
);
}
const
_params
:
any
=
{};
if
(
localNavParam
&&
localNavParam
.
localViewParam
){
Object
.
assign
(
_params
,
localNavParam
.
localViewParam
);
}
if
(
refview
&&
refview
.
parentdatajo
)
{
Object
.
assign
(
_context
,
refview
.
parentdatajo
);
Object
.
assign
(
this
.
selection
,
{
view
:
{
viewname
:
refview
.
viewname
},
data
:
_context
,
param
:
_params
});
...
...
app_web/src/widgets/sys-role/main-grid/main-grid-base.vue
浏览文件 @
1e9cca60
...
...
@@ -1303,6 +1303,7 @@ export default class MainBase extends Vue implements ControlInterface {
*/
public
uiAction
(
row
:
any
,
tag
:
any
,
$event
:
any
)
{
// this.rowClick(row, true);
$event
.
stopPropagation
();
}
/**
...
...
app_web/src/widgets/sys-user-role/default-drbar/default-drbar-base.vue
浏览文件 @
1e9cca60
...
...
@@ -151,6 +151,7 @@ export default class DefaultBase extends Vue implements ControlInterface {
}
/**
* 获取多项数据
*
...
...
@@ -179,6 +180,14 @@ export default class DefaultBase extends Vue implements ControlInterface {
*/
@
Prop
()
public
loadAction
?:
string
;
/**
* 表单数据
*
* @type {*}
* @memberof DefaultBase
*/
@
Prop
({
default
:{}})
public
formData
?:
any
;
/**
* 数据选中项
*
...
...
@@ -201,6 +210,15 @@ export default class DefaultBase extends Vue implements ControlInterface {
},
];
/**
* 关系栏数据项导航参数集合
*
* @type {any[]}
* @memberof DefaultBase
*/
public
navParamsArray
:
Array
<
any
>
=
[
];
/**
* 默认打开项
*
...
...
@@ -323,6 +341,36 @@ export default class DefaultBase extends Vue implements ControlInterface {
return
item
;
}
/**
* 初始化导航参数
*
* @param {*} drItem
* @memberof DefaultBase
*/
public
initNavParam
(
drItem
:
any
){
let
returnNavParam
:
any
=
{};
if
(
drItem
&&
drItem
.
id
){
let
curDRItem
:
any
=
this
.
navParamsArray
.
find
((
item
:
any
)
=>
{
return
Object
.
is
(
item
.
id
,
drItem
.
id
);
})
if
(
curDRItem
){
let
localContext
:
any
=
curDRItem
.
localContext
;
let
localViewParam
:
any
=
curDRItem
.
localViewParam
;
if
(
localContext
&&
Object
.
keys
(
localContext
).
length
>
0
){
let
_context
:
any
=
this
.
$util
.
computedNavData
(
this
.
formData
,
this
.
context
,
this
.
viewparams
,
localContext
);
returnNavParam
.
localContext
=
_context
;
}
if
(
localViewParam
&&
Object
.
keys
(
localViewParam
).
length
>
0
){
let
_params
:
any
=
this
.
$util
.
computedNavData
(
this
.
formData
,
this
.
context
,
this
.
viewparams
,
localViewParam
);
returnNavParam
.
localViewParam
=
_params
;
}
return
returnNavParam
;
}
else
{
return
null
;
}
}
}
/**
* 节点选中
*
...
...
@@ -334,13 +382,18 @@ export default class DefaultBase extends Vue implements ControlInterface {
if
(
Object
.
is
(
item
.
id
,
this
.
selection
.
id
))
{
return
;
}
this
.
$emit
(
'selectionchange'
,
[
item
]);
let
localNavParam
:
any
=
this
.
initNavParam
(
item
);
const
refview
=
this
.
getDRBarItem
({
nodetype
:
item
.
id
});
this
.
selection
=
{};
const
_context
:
any
=
{
...
JSON
.
parse
(
JSON
.
stringify
(
this
.
context
))
};
const
_params
:
any
=
{
...
JSON
.
parse
(
JSON
.
stringify
(
this
.
viewparams
))
};
if
(
localNavParam
&&
localNavParam
.
localContext
){
Object
.
assign
(
_context
,
localNavParam
.
localContext
);
}
const
_params
:
any
=
{};
if
(
localNavParam
&&
localNavParam
.
localViewParam
){
Object
.
assign
(
_params
,
localNavParam
.
localViewParam
);
}
if
(
refview
&&
refview
.
parentdatajo
)
{
Object
.
assign
(
_context
,
refview
.
parentdatajo
);
Object
.
assign
(
this
.
selection
,
{
view
:
{
viewname
:
refview
.
viewname
},
data
:
_context
,
param
:
_params
});
...
...
app_web/src/widgets/sys-user-role/main-grid/main-grid-base.vue
浏览文件 @
1e9cca60
...
...
@@ -1279,6 +1279,7 @@ export default class MainBase extends Vue implements ControlInterface {
*/
public
uiAction
(
row
:
any
,
tag
:
any
,
$event
:
any
)
{
// this.rowClick(row, true);
$event
.
stopPropagation
();
}
/**
...
...
app_web/src/widgets/sys-user/default-drbar/default-drbar-base.vue
浏览文件 @
1e9cca60
...
...
@@ -151,6 +151,7 @@ export default class DefaultBase extends Vue implements ControlInterface {
}
/**
* 获取多项数据
*
...
...
@@ -179,6 +180,14 @@ export default class DefaultBase extends Vue implements ControlInterface {
*/
@
Prop
()
public
loadAction
?:
string
;
/**
* 表单数据
*
* @type {*}
* @memberof DefaultBase
*/
@
Prop
({
default
:{}})
public
formData
?:
any
;
/**
* 数据选中项
*
...
...
@@ -201,6 +210,15 @@ export default class DefaultBase extends Vue implements ControlInterface {
},
];
/**
* 关系栏数据项导航参数集合
*
* @type {any[]}
* @memberof DefaultBase
*/
public
navParamsArray
:
Array
<
any
>
=
[
];
/**
* 默认打开项
*
...
...
@@ -323,6 +341,36 @@ export default class DefaultBase extends Vue implements ControlInterface {
return
item
;
}
/**
* 初始化导航参数
*
* @param {*} drItem
* @memberof DefaultBase
*/
public
initNavParam
(
drItem
:
any
){
let
returnNavParam
:
any
=
{};
if
(
drItem
&&
drItem
.
id
){
let
curDRItem
:
any
=
this
.
navParamsArray
.
find
((
item
:
any
)
=>
{
return
Object
.
is
(
item
.
id
,
drItem
.
id
);
})
if
(
curDRItem
){
let
localContext
:
any
=
curDRItem
.
localContext
;
let
localViewParam
:
any
=
curDRItem
.
localViewParam
;
if
(
localContext
&&
Object
.
keys
(
localContext
).
length
>
0
){
let
_context
:
any
=
this
.
$util
.
computedNavData
(
this
.
formData
,
this
.
context
,
this
.
viewparams
,
localContext
);
returnNavParam
.
localContext
=
_context
;
}
if
(
localViewParam
&&
Object
.
keys
(
localViewParam
).
length
>
0
){
let
_params
:
any
=
this
.
$util
.
computedNavData
(
this
.
formData
,
this
.
context
,
this
.
viewparams
,
localViewParam
);
returnNavParam
.
localViewParam
=
_params
;
}
return
returnNavParam
;
}
else
{
return
null
;
}
}
}
/**
* 节点选中
*
...
...
@@ -334,13 +382,18 @@ export default class DefaultBase extends Vue implements ControlInterface {
if
(
Object
.
is
(
item
.
id
,
this
.
selection
.
id
))
{
return
;
}
this
.
$emit
(
'selectionchange'
,
[
item
]);
let
localNavParam
:
any
=
this
.
initNavParam
(
item
);
const
refview
=
this
.
getDRBarItem
({
nodetype
:
item
.
id
});
this
.
selection
=
{};
const
_context
:
any
=
{
...
JSON
.
parse
(
JSON
.
stringify
(
this
.
context
))
};
const
_params
:
any
=
{
...
JSON
.
parse
(
JSON
.
stringify
(
this
.
viewparams
))
};
if
(
localNavParam
&&
localNavParam
.
localContext
){
Object
.
assign
(
_context
,
localNavParam
.
localContext
);
}
const
_params
:
any
=
{};
if
(
localNavParam
&&
localNavParam
.
localViewParam
){
Object
.
assign
(
_params
,
localNavParam
.
localViewParam
);
}
if
(
refview
&&
refview
.
parentdatajo
)
{
Object
.
assign
(
_context
,
refview
.
parentdatajo
);
Object
.
assign
(
this
.
selection
,
{
view
:
{
viewname
:
refview
.
viewname
},
data
:
_context
,
param
:
_params
});
...
...
app_web/src/widgets/sys-user/main-grid/main-grid-base.vue
浏览文件 @
1e9cca60
...
...
@@ -1284,6 +1284,7 @@ export default class MainBase extends Vue implements ControlInterface {
*/
public
uiAction
(
row
:
any
,
tag
:
any
,
$event
:
any
)
{
// this.rowClick(row, true);
$event
.
stopPropagation
();
}
/**
...
...
ibzuaa-core/src/main/java/cn/ibizlab/core/uaa/domain/SysApp.java
浏览文件 @
1e9cca60
...
...
@@ -29,7 +29,6 @@ import org.springframework.data.annotation.Transient;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public
class
SysApp
extends
EntityBase
implements
Serializable
{
/**
...
...
ibzuaa-core/src/main/java/cn/ibizlab/core/uaa/domain/SysAuthLog.java
浏览文件 @
1e9cca60
...
...
@@ -22,17 +22,17 @@ import lombok.*;
import
org.springframework.data.annotation.Transient
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.baomidou.mybatisplus.annotation.*
;
import
cn.ibizlab.util.domain.EntityMP
;
/**
* 实体[认证日志]
*/
@Getter
@Setter
@NoArgsConstructor
@
AllArgsConstructor
@
JsonIgnoreProperties
(
value
=
"handler"
)
@TableName
(
value
=
"IBZAUTHLOG"
,
resultMap
=
"SysAuthLogResultMap"
)
public
class
SysAuthLog
extends
EntityMP
implements
Serializable
{
...
...
ibzuaa-core/src/main/java/cn/ibizlab/core/uaa/domain/SysPermission.java
浏览文件 @
1e9cca60
...
...
@@ -22,17 +22,17 @@ import lombok.*;
import
org.springframework.data.annotation.Transient
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.baomidou.mybatisplus.annotation.*
;
import
cn.ibizlab.util.domain.EntityMP
;
/**
* 实体[权限/资源]
*/
@Getter
@Setter
@NoArgsConstructor
@
AllArgsConstructor
@
JsonIgnoreProperties
(
value
=
"handler"
)
@TableName
(
value
=
"IBZPERMISSION"
,
resultMap
=
"SysPermissionResultMap"
)
public
class
SysPermission
extends
EntityMP
implements
Serializable
{
...
...
ibzuaa-core/src/main/java/cn/ibizlab/core/uaa/domain/SysRole.java
浏览文件 @
1e9cca60
...
...
@@ -22,17 +22,17 @@ import lombok.*;
import
org.springframework.data.annotation.Transient
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.baomidou.mybatisplus.annotation.*
;
import
cn.ibizlab.util.domain.EntityMP
;
/**
* 实体[系统角色]
*/
@Getter
@Setter
@NoArgsConstructor
@
AllArgsConstructor
@
JsonIgnoreProperties
(
value
=
"handler"
)
@TableName
(
value
=
"IBZROLE"
,
resultMap
=
"SysRoleResultMap"
)
public
class
SysRole
extends
EntityMP
implements
Serializable
{
...
...
ibzuaa-core/src/main/java/cn/ibizlab/core/uaa/domain/SysRolePermission.java
浏览文件 @
1e9cca60
...
...
@@ -22,17 +22,17 @@ import lombok.*;
import
org.springframework.data.annotation.Transient
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.baomidou.mybatisplus.annotation.*
;
import
cn.ibizlab.util.domain.EntityMP
;
/**
* 实体[角色权限关系]
*/
@Getter
@Setter
@NoArgsConstructor
@
AllArgsConstructor
@
JsonIgnoreProperties
(
value
=
"handler"
)
@TableName
(
value
=
"IBZROLE_PERMISSION"
,
resultMap
=
"SysRolePermissionResultMap"
)
public
class
SysRolePermission
extends
EntityMP
implements
Serializable
{
...
...
ibzuaa-core/src/main/java/cn/ibizlab/core/uaa/domain/SysUser.java
浏览文件 @
1e9cca60
...
...
@@ -22,17 +22,17 @@ import lombok.*;
import
org.springframework.data.annotation.Transient
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.baomidou.mybatisplus.annotation.*
;
import
cn.ibizlab.util.domain.EntityMP
;
/**
* 实体[系统用户]
*/
@Getter
@Setter
@NoArgsConstructor
@
AllArgsConstructor
@
JsonIgnoreProperties
(
value
=
"handler"
)
@TableName
(
value
=
"IBZUSER"
,
resultMap
=
"SysUserResultMap"
)
public
class
SysUser
extends
EntityMP
implements
Serializable
{
...
...
ibzuaa-core/src/main/java/cn/ibizlab/core/uaa/domain/SysUserRole.java
浏览文件 @
1e9cca60
...
...
@@ -22,17 +22,17 @@ import lombok.*;
import
org.springframework.data.annotation.Transient
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.baomidou.mybatisplus.annotation.*
;
import
cn.ibizlab.util.domain.EntityMP
;
/**
* 实体[用户角色关系]
*/
@Getter
@Setter
@NoArgsConstructor
@
AllArgsConstructor
@
JsonIgnoreProperties
(
value
=
"handler"
)
@TableName
(
value
=
"IBZUSER_ROLE"
,
resultMap
=
"SysUserRoleResultMap"
)
public
class
SysUserRole
extends
EntityMP
implements
Serializable
{
...
...
ibzuaa-core/src/main/java/cn/ibizlab/core/uaa/extensions/service/SysAppService.java
浏览文件 @
1e9cca60
...
...
@@ -42,7 +42,7 @@ public class SysAppService extends SysAppServiceImpl
private
UAACoreService
uaaCoreService
;
@Cacheable
(
value
=
"ibzuaa_switcher"
,
key
=
"'id:'+#p0+'||'+#p1"
)
//
@Cacheable( value="ibzuaa_switcher",key = "'id:'+#p0+'||'+#p1")
public
JSONObject
getAppSwitcher
(
String
id
,
String
userId
)
{
JSONObject
jo
=
ibzConfigService
.
getConfig
(
"AppSwitcher"
,
id
,
userId
);
...
...
@@ -68,7 +68,7 @@ public class SysAppService extends SysAppServiceImpl
});
final
boolean
flag
=
nullSwitcher
;
defApps
.
values
().
forEach
(
sysApp
->
{
if
(
1
!=
sysApp
.
getVisabled
()
)
return
;
if
(
sysApp
.
getVisabled
()==
null
||
sysApp
.
getVisabled
()==
0
)
return
;
if
(
flag
&&
id
.
equalsIgnoreCase
(
"default"
))
sysApp
.
setVisabled
(
1
);
else
...
...
@@ -80,6 +80,12 @@ public class SysAppService extends SysAppServiceImpl
return
jo
;
}
@CacheEvict
(
value
=
"ibzuaa_switcher"
,
key
=
"'id:'+#p0+'||'+#p1"
)
public
boolean
saveAppSwitcher
(
String
id
,
String
userId
,
JSONObject
config
)
{
return
ibzConfigService
.
saveConfig
(
"AppSwitcher"
,
id
,
userId
,
config
);
}
@CacheEvict
(
value
=
"ibzuaa_switcher"
,
allEntries
=
true
)
public
void
resetAppNavigationBars
()
{
...
...
ibzuaa-provider/ibzuaa-provider-api/src/main/java/cn/ibizlab/api/config/apiSecurityConfig.java
浏览文件 @
1e9cca60
...
...
@@ -121,6 +121,7 @@ public class apiSecurityConfig extends WebSecurityConfigurerAdapter {
.
antMatchers
(
"/syspssystems/save"
).
permitAll
()
.
antMatchers
(
"/uaa/login"
).
permitAll
()
.
antMatchers
(
"/uaa/loginbyusername"
).
permitAll
()
.
antMatchers
(
"/uaa/publickey"
).
permitAll
()
// 所有请求都需要认证
.
anyRequest
().
authenticated
()
// 防止iframe 造成跨域
...
...
ibzuaa-provider/ibzuaa-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/ClientAuthenticationResource.java
浏览文件 @
1e9cca60
...
...
@@ -3,12 +3,8 @@ package cn.ibizlab.api.rest.extensions;
import
cn.ibizlab.core.uaa.extensions.service.SysAppService
;
import
cn.ibizlab.core.uaa.extensions.service.UAACoreService
;
import
cn.ibizlab.util.client.IBZOUFeignClient
;
import
cn.ibizlab.util.helper.CachedBeanCopier
;
import
cn.ibizlab.util.security.AuthTokenUtil
;
import
cn.ibizlab.util.security.AuthenticationInfo
;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
cn.ibizlab.util.security.AuthorizationLogin
;
import
cn.ibizlab.util.security.*
;
import
cn.ibizlab.util.service.AuthenticationUserService
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -16,16 +12,9 @@ import org.springframework.beans.factory.annotation.Qualifier;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.authority.AuthorityUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.Cookie
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.*
;
/**
* 客户端登录认证
*/
...
...
@@ -51,7 +40,8 @@ public class ClientAuthenticationResource
@Qualifier
(
"UAAUserService"
)
private
AuthenticationUserService
userDetailsService
;
@Autowired
UAACoreService
uaaCoreService
;
@PostMapping
(
value
=
"v7/login"
)
public
ResponseEntity
<
AuthenticationInfo
>
login
(
@Validated
@RequestBody
AuthorizationLogin
authorizationLogin
){
...
...
@@ -82,13 +72,10 @@ public class ClientAuthenticationResource
return
ResponseEntity
.
ok
().
body
(
user
);
}
@Autowired
private
SysAppService
sysAppService
;
@GetMapping
(
value
=
"uaa/access-center/app-switcher/{id}"
)
public
ResponseEntity
<
JSONObject
>
appswitcher
(
@PathVariable
(
"id"
)
String
id
)
{
return
ResponseEntity
.
ok
(
sysAppService
.
getAppSwitcher
(
id
,
AuthenticationUser
.
getAuthenticationUser
().
getUserid
()));
@GetMapping
(
value
=
"uaa/publickey"
)
public
ResponseEntity
<
String
>
getPublicKey
(){
return
ResponseEntity
.
ok
().
body
(
uaaCoreService
.
getPublicKey
());
}
}
ibzuaa-provider/ibzuaa-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/UAACoreResource.java
浏览文件 @
1e9cca60
...
...
@@ -8,9 +8,12 @@ import cn.ibizlab.core.uaa.domain.SysPSSystem;
import
cn.ibizlab.core.uaa.domain.SysRolePermission
;
import
cn.ibizlab.core.uaa.extensions.domain.PermissionNode
;
import
cn.ibizlab.core.uaa.extensions.domain.SysStructure
;
import
cn.ibizlab.core.uaa.extensions.service.SysAppService
;
import
cn.ibizlab.core.uaa.extensions.service.UAACoreService
;
import
cn.ibizlab.core.uaa.service.ISysPSSystemService
;
import
cn.ibizlab.core.uaa.service.ISysRolePermissionService
;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
com.alibaba.fastjson.JSONObject
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
...
...
@@ -74,4 +77,20 @@ public class UAACoreResource {
uaaCoreService
.
saveByRoleid
(
sysrole_id
,
domainlist
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
true
);
}
@Autowired
private
SysAppService
sysAppService
;
@GetMapping
(
value
=
"uaa/access-center/app-switcher/{id}"
)
public
ResponseEntity
<
JSONObject
>
appswitcher
(
@PathVariable
(
"id"
)
String
id
)
{
return
ResponseEntity
.
ok
(
sysAppService
.
getAppSwitcher
(
id
,
AuthenticationUser
.
getAuthenticationUser
().
getUserid
()));
}
@PutMapping
(
value
=
"uaa/access-center/app-switcher/{id}"
)
public
ResponseEntity
<
Boolean
>
appswitcher
(
@PathVariable
(
"id"
)
String
id
,
@RequestBody
JSONObject
config
)
{
return
ResponseEntity
.
ok
(
sysAppService
.
saveAppSwitcher
(
id
,
AuthenticationUser
.
getAuthenticationUser
().
getUserid
(),
config
));
}
}
ibzuaa-util/src/main/java/cn/ibizlab/util/client/IBZUAAFallback.java
浏览文件 @
1e9cca60
...
...
@@ -22,4 +22,9 @@ public class IBZUAAFallback implements IBZUAAFeignClient {
public
AuthenticationUser
loginByUsername
(
String
username
)
{
return
null
;
}
@Override
public
String
getPublicKey
()
{
return
null
;
}
}
ibzuaa-util/src/main/java/cn/ibizlab/util/client/IBZUAAFeignClient.java
浏览文件 @
1e9cca60
...
...
@@ -2,6 +2,7 @@ package cn.ibizlab.util.client;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
cn.ibizlab.util.security.AuthorizationLogin
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.*
;
import
com.alibaba.fastjson.JSONObject
;
...
...
@@ -28,4 +29,8 @@ public interface IBZUAAFeignClient
@PostMapping
(
value
=
"/uaa/loginbyusername"
)
AuthenticationUser
loginByUsername
(
@RequestBody
String
username
);
@Cacheable
(
value
=
"ibzuaa_publickey"
)
@GetMapping
(
value
=
"/uaa/publickey"
)
String
getPublicKey
();
}
ibzuaa-util/src/main/java/cn/ibizlab/util/security/AuthTokenUtil.java
浏览文件 @
1e9cca60
package
cn
.
ibizlab
.
util
.
security
;
import
io.jsonwebtoken.Claims
;
import
io.jsonwebtoken.Clock
;
import
io.jsonwebtoken.Jwts
;
import
io.jsonwebtoken.SignatureAlgorithm
;
import
io.jsonwebtoken.impl.DefaultClock
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.security.core.context.SecurityContext
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.stereotype.Component
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.function.Function
;
public
interface
AuthTokenUtil
{
@Component
public
class
AuthTokenUtil
implements
Serializable
{
String
generateToken
(
UserDetails
userDetails
);
private
static
final
long
serialVersionUID
=
-
3301605591108950415L
;
private
Clock
clock
=
DefaultClock
.
INSTANCE
;
Boolean
validateToken
(
String
token
,
UserDetails
userDetails
);
@Value
(
"${ibiz.jwt.secret:ibzsecret}"
)
private
String
secret
;
String
getUsernameFromToken
(
String
token
);
@Value
(
"${ibiz.jwt.expiration:7200000}"
)
private
Long
expiration
;
@Value
(
"${ibiz.jwt.header:Authorization}"
)
private
String
tokenHeader
;
public
String
getUsernameFromToken
(
String
token
)
{
return
getClaimFromToken
(
token
,
Claims:
:
getSubject
);
}
public
Date
getIssuedAtDateFromToken
(
String
token
)
{
return
getClaimFromToken
(
token
,
Claims:
:
getIssuedAt
);
}
public
Date
getExpirationDateFromToken
(
String
token
)
{
return
getClaimFromToken
(
token
,
Claims:
:
getExpiration
);
}
public
<
T
>
T
getClaimFromToken
(
String
token
,
Function
<
Claims
,
T
>
claimsResolver
)
{
final
Claims
claims
=
getAllClaimsFromToken
(
token
);
return
claimsResolver
.
apply
(
claims
);
}
private
Claims
getAllClaimsFromToken
(
String
token
)
{
return
Jwts
.
parser
()
.
setSigningKey
(
secret
)
.
parseClaimsJws
(
token
)
.
getBody
();
}
private
Boolean
isTokenExpired
(
String
token
)
{
final
Date
expiration
=
getExpirationDateFromToken
(
token
);
return
expiration
.
before
(
clock
.
now
());
}
private
Boolean
isCreatedBeforeLastPasswordReset
(
Date
created
,
Date
lastPasswordReset
)
{
return
(
lastPasswordReset
!=
null
&&
created
.
before
(
lastPasswordReset
));
}
private
Boolean
ignoreTokenExpiration
(
String
token
)
{
// here you specify tokens, for that the expiration is ignored
return
false
;
}
public
String
generateToken
(
UserDetails
userDetails
)
{
Map
<
String
,
Object
>
claims
=
new
HashMap
<>();
return
doGenerateToken
(
claims
,
userDetails
.
getUsername
());
}
private
String
doGenerateToken
(
Map
<
String
,
Object
>
claims
,
String
subject
)
{
final
Date
createdDate
=
clock
.
now
();
final
Date
expirationDate
=
calculateExpirationDate
(
createdDate
);
return
Jwts
.
builder
()
.
setClaims
(
claims
)
.
setSubject
(
subject
)
.
setIssuedAt
(
createdDate
)
.
setExpiration
(
expirationDate
)
.
signWith
(
SignatureAlgorithm
.
HS512
,
secret
)
.
compact
();
}
public
Boolean
canTokenBeRefreshed
(
String
token
,
Date
lastPasswordReset
)
{
final
Date
created
=
getIssuedAtDateFromToken
(
token
);
return
!
isCreatedBeforeLastPasswordReset
(
created
,
lastPasswordReset
)
&&
(!
isTokenExpired
(
token
)
||
ignoreTokenExpiration
(
token
));
}
public
String
refreshToken
(
String
token
)
{
final
Date
createdDate
=
clock
.
now
();
final
Date
expirationDate
=
calculateExpirationDate
(
createdDate
);
final
Claims
claims
=
getAllClaimsFromToken
(
token
);
claims
.
setIssuedAt
(
createdDate
);
claims
.
setExpiration
(
expirationDate
);
return
Jwts
.
builder
()
.
setClaims
(
claims
)
.
signWith
(
SignatureAlgorithm
.
HS512
,
secret
)
.
compact
();
}
public
Boolean
validateToken
(
String
token
,
UserDetails
userDetails
)
{
AuthenticationUser
user
=
(
AuthenticationUser
)
userDetails
;
final
Date
created
=
getIssuedAtDateFromToken
(
token
);
return
(!
isTokenExpired
(
token
)
);
}
private
Date
calculateExpirationDate
(
Date
createdDate
)
{
return
new
Date
(
createdDate
.
getTime
()
+
expiration
);
}
/**
* Get the login of the current user.
*
* @return the login of the current user
*/
public
static
Optional
<
String
>
getCurrentUserLogin
()
{
SecurityContext
securityContext
=
SecurityContextHolder
.
getContext
();
return
Optional
.
ofNullable
(
securityContext
.
getAuthentication
())
.
map
(
authentication
->
{
if
(
authentication
.
getPrincipal
()
instanceof
UserDetails
)
{
UserDetails
springSecurityUser
=
(
UserDetails
)
authentication
.
getPrincipal
();
return
springSecurityUser
.
getUsername
();
}
else
if
(
authentication
.
getPrincipal
()
instanceof
String
)
{
return
(
String
)
authentication
.
getPrincipal
();
}
return
null
;
});
}
/**
* Check if a user is authenticated.
*
* @return true if the user is authenticated, false otherwise
*/
public
static
boolean
isAuthenticated
()
{
SecurityContext
securityContext
=
SecurityContextHolder
.
getContext
();
return
Optional
.
ofNullable
(
securityContext
.
getAuthentication
())
.
map
(
authentication
->
authentication
.
getAuthorities
().
stream
()
.
noneMatch
(
grantedAuthority
->
grantedAuthority
.
getAuthority
().
equals
(
"ANONYMOUS"
)))
.
orElse
(
false
);
}
/**
* If the current user has a specific authority (security role).
* <p>
* The name of this method comes from the isUserInRole() method in the Servlet API
*
* @param authority the authority to check
* @return true if the current user has the authority, false otherwise
*/
public
static
boolean
isCurrentUserInRole
(
String
authority
)
{
SecurityContext
securityContext
=
SecurityContextHolder
.
getContext
();
return
Optional
.
ofNullable
(
securityContext
.
getAuthentication
())
.
map
(
authentication
->
authentication
.
getAuthorities
().
stream
()
.
anyMatch
(
grantedAuthority
->
grantedAuthority
.
getAuthority
().
equals
(
authority
)))
.
orElse
(
false
);
}
}
ibzuaa-util/src/main/java/cn/ibizlab/util/security/SimpleTokenUtil.java
0 → 100644
浏览文件 @
1e9cca60
package
cn
.
ibizlab
.
util
.
security
;
import
io.jsonwebtoken.Claims
;
import
io.jsonwebtoken.Clock
;
import
io.jsonwebtoken.Jwts
;
import
io.jsonwebtoken.SignatureAlgorithm
;
import
io.jsonwebtoken.impl.DefaultClock
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.security.core.context.SecurityContext
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.function.Function
;
//@Component
//@ConditionalOnExpression("(!${ibiz.enablePermissionValid:false})&&'${ibiz.auth.service:SimpleTokenUtil}'.equals('SimpleTokenUtil')")
public
class
SimpleTokenUtil
implements
AuthTokenUtil
,
Serializable
{
private
static
final
long
serialVersionUID
=
-
3301605591108950415L
;
private
Clock
clock
=
DefaultClock
.
INSTANCE
;
@Value
(
"${ibiz.jwt.secret:ibzsecret}"
)
private
String
secret
;
@Value
(
"${ibiz.jwt.expiration:7200000}"
)
private
Long
expiration
;
@Value
(
"${ibiz.jwt.header:Authorization}"
)
private
String
tokenHeader
;
public
String
getUsernameFromToken
(
String
token
)
{
return
getClaimFromToken
(
token
,
Claims:
:
getSubject
);
}
public
Date
getIssuedAtDateFromToken
(
String
token
)
{
return
getClaimFromToken
(
token
,
Claims:
:
getIssuedAt
);
}
public
Date
getExpirationDateFromToken
(
String
token
)
{
return
getClaimFromToken
(
token
,
Claims:
:
getExpiration
);
}
public
<
T
>
T
getClaimFromToken
(
String
token
,
Function
<
Claims
,
T
>
claimsResolver
)
{
final
Claims
claims
=
getAllClaimsFromToken
(
token
);
return
claimsResolver
.
apply
(
claims
);
}
private
Claims
getAllClaimsFromToken
(
String
token
)
{
return
Jwts
.
parser
()
.
setSigningKey
(
secret
)
.
parseClaimsJws
(
token
)
.
getBody
();
}
private
Boolean
isTokenExpired
(
String
token
)
{
final
Date
expiration
=
getExpirationDateFromToken
(
token
);
return
expiration
.
before
(
clock
.
now
());
}
private
Boolean
isCreatedBeforeLastPasswordReset
(
Date
created
,
Date
lastPasswordReset
)
{
return
(
lastPasswordReset
!=
null
&&
created
.
before
(
lastPasswordReset
));
}
private
Boolean
ignoreTokenExpiration
(
String
token
)
{
// here you specify tokens, for that the expiration is ignored
return
false
;
}
public
String
generateToken
(
UserDetails
userDetails
)
{
Map
<
String
,
Object
>
claims
=
new
HashMap
<>();
return
doGenerateToken
(
claims
,
userDetails
.
getUsername
());
}
private
String
doGenerateToken
(
Map
<
String
,
Object
>
claims
,
String
subject
)
{
final
Date
createdDate
=
clock
.
now
();
final
Date
expirationDate
=
calculateExpirationDate
(
createdDate
);
return
Jwts
.
builder
()
.
setClaims
(
claims
)
.
setSubject
(
subject
)
.
setIssuedAt
(
createdDate
)
.
setExpiration
(
expirationDate
)
.
signWith
(
SignatureAlgorithm
.
HS512
,
secret
)
.
compact
();
}
public
Boolean
canTokenBeRefreshed
(
String
token
,
Date
lastPasswordReset
)
{
final
Date
created
=
getIssuedAtDateFromToken
(
token
);
return
!
isCreatedBeforeLastPasswordReset
(
created
,
lastPasswordReset
)
&&
(!
isTokenExpired
(
token
)
||
ignoreTokenExpiration
(
token
));
}
public
String
refreshToken
(
String
token
)
{
final
Date
createdDate
=
clock
.
now
();
final
Date
expirationDate
=
calculateExpirationDate
(
createdDate
);
final
Claims
claims
=
getAllClaimsFromToken
(
token
);
claims
.
setIssuedAt
(
createdDate
);
claims
.
setExpiration
(
expirationDate
);
return
Jwts
.
builder
()
.
setClaims
(
claims
)
.
signWith
(
SignatureAlgorithm
.
HS512
,
secret
)
.
compact
();
}
public
Boolean
validateToken
(
String
token
,
UserDetails
userDetails
)
{
AuthenticationUser
user
=
(
AuthenticationUser
)
userDetails
;
final
Date
created
=
getIssuedAtDateFromToken
(
token
);
return
(!
isTokenExpired
(
token
)
);
}
private
Date
calculateExpirationDate
(
Date
createdDate
)
{
return
new
Date
(
createdDate
.
getTime
()
+
expiration
);
}
/**
* Get the login of the current user.
*
* @return the login of the current user
*/
public
static
Optional
<
String
>
getCurrentUserLogin
()
{
SecurityContext
securityContext
=
SecurityContextHolder
.
getContext
();
return
Optional
.
ofNullable
(
securityContext
.
getAuthentication
())
.
map
(
authentication
->
{
if
(
authentication
.
getPrincipal
()
instanceof
UserDetails
)
{
UserDetails
springSecurityUser
=
(
UserDetails
)
authentication
.
getPrincipal
();
return
springSecurityUser
.
getUsername
();
}
else
if
(
authentication
.
getPrincipal
()
instanceof
String
)
{
return
(
String
)
authentication
.
getPrincipal
();
}
return
null
;
});
}
/**
* Check if a user is authenticated.
*
* @return true if the user is authenticated, false otherwise
*/
public
static
boolean
isAuthenticated
()
{
SecurityContext
securityContext
=
SecurityContextHolder
.
getContext
();
return
Optional
.
ofNullable
(
securityContext
.
getAuthentication
())
.
map
(
authentication
->
authentication
.
getAuthorities
().
stream
()
.
noneMatch
(
grantedAuthority
->
grantedAuthority
.
getAuthority
().
equals
(
"ANONYMOUS"
)))
.
orElse
(
false
);
}
/**
* If the current user has a specific authority (security role).
* <p>
* The name of this method comes from the isUserInRole() method in the Servlet API
*
* @param authority the authority to check
* @return true if the current user has the authority, false otherwise
*/
public
static
boolean
isCurrentUserInRole
(
String
authority
)
{
SecurityContext
securityContext
=
SecurityContextHolder
.
getContext
();
return
Optional
.
ofNullable
(
securityContext
.
getAuthentication
())
.
map
(
authentication
->
authentication
.
getAuthorities
().
stream
()
.
anyMatch
(
grantedAuthority
->
grantedAuthority
.
getAuthority
().
equals
(
authority
)))
.
orElse
(
false
);
}
}
ibzuaa-util/src/main/java/cn/ibizlab/util/security/UAATokenUtil.java
0 → 100644
浏览文件 @
1e9cca60
package
cn
.
ibizlab
.
util
.
security
;
import
io.jsonwebtoken.Claims
;
import
io.jsonwebtoken.Clock
;
import
io.jsonwebtoken.Jwts
;
import
io.jsonwebtoken.SignatureAlgorithm
;
import
io.jsonwebtoken.impl.DefaultClock
;
import
lombok.SneakyThrows
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.io.IOUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.stereotype.Component
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.Serializable
;
import
java.security.KeyFactory
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.PrivateKey
;
import
java.security.PublicKey
;
import
java.security.spec.InvalidKeySpecException
;
import
java.security.spec.PKCS8EncodedKeySpec
;
import
java.security.spec.X509EncodedKeySpec
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.function.Function
;
@Component
//@ConditionalOnExpression("${ibiz.enablePermissionValid:false}||'${ibiz.auth.service:SimpleTokenUtil}'.equals('UAATokenUtil')")
public
class
UAATokenUtil
implements
AuthTokenUtil
,
Serializable
{
private
static
final
long
serialVersionUID
=
-
3301605591108950415L
;
private
Clock
clock
=
DefaultClock
.
INSTANCE
;
@Value
(
"${ibiz.jwt.secret:ibzsecret}"
)
private
String
secret
;
@Value
(
"${ibiz.jwt.expiration:7200000}"
)
private
Long
expiration
;
@Value
(
"${ibiz.jwt.header:Authorization}"
)
private
String
tokenHeader
;
public
String
getUsernameFromToken
(
String
token
)
{
return
getClaimFromToken
(
token
,
Claims:
:
getSubject
);
}
public
Date
getIssuedAtDateFromToken
(
String
token
)
{
return
getClaimFromToken
(
token
,
Claims:
:
getIssuedAt
);
}
public
Date
getExpirationDateFromToken
(
String
token
)
{
return
getClaimFromToken
(
token
,
Claims:
:
getExpiration
);
}
public
<
T
>
T
getClaimFromToken
(
String
token
,
Function
<
Claims
,
T
>
claimsResolver
)
{
final
Claims
claims
=
getAllClaimsFromToken
(
token
);
return
claimsResolver
.
apply
(
claims
);
}
public
Claims
getAllClaimsFromToken
(
String
token
)
{
PublicKey
publicKey
=
getPublicKey
(
getPublicKeyString
());
return
Jwts
.
parser
()
.
setSigningKey
(
publicKey
)
.
parseClaimsJws
(
token
)
.
getBody
();
}
private
Boolean
isTokenExpired
(
String
token
)
{
final
Date
expiration
=
getExpirationDateFromToken
(
token
);
return
expiration
.
before
(
clock
.
now
());
}
public
String
generateToken
(
UserDetails
userDetails
)
{
Map
<
String
,
Object
>
claims
=
new
HashMap
<>();
return
doGenerateToken
(
claims
,
userDetails
.
getUsername
());
}
private
String
doGenerateToken
(
Map
<
String
,
Object
>
claims
,
String
subject
)
{
final
Date
createdDate
=
clock
.
now
();
final
Date
expirationDate
=
calculateExpirationDate
(
createdDate
);
return
Jwts
.
builder
()
.
setClaims
(
claims
)
.
setSubject
(
subject
)
.
setIssuedAt
(
createdDate
)
.
setExpiration
(
expirationDate
)
.
signWith
(
SignatureAlgorithm
.
RS256
,
getPrivateKey
(
getPrivateKeyString
()))
.
compact
();
}
public
Boolean
validateToken
(
String
token
,
UserDetails
userDetails
)
{
AuthenticationUser
user
=
(
AuthenticationUser
)
userDetails
;
final
Date
created
=
getIssuedAtDateFromToken
(
token
);
return
(!
isTokenExpired
(
token
)
);
}
private
Date
calculateExpirationDate
(
Date
createdDate
)
{
return
new
Date
(
createdDate
.
getTime
()
+
expiration
);
}
@SneakyThrows
private
String
getPrivateKeyString
(){
String
key
=
""
;
String
usrHome
=
System
.
getProperty
(
"user.home"
)+
"/.ibzrt"
;
File
priKeyFile
=
new
File
(
usrHome
,
"ibzrt_rsa"
);
if
(!
priKeyFile
.
exists
())
{
key
=
IOUtils
.
toString
(
this
.
getClass
().
getResourceAsStream
(
"/keypair/ibzrt_rsa"
));
}
else
{
key
=
IOUtils
.
toString
(
new
FileInputStream
(
priKeyFile
));
}
return
key
;
}
@SneakyThrows
private
String
getPublicKeyString
(){
String
key
=
""
;
String
usrHome
=
System
.
getProperty
(
"user.home"
)+
"/.ibzrt"
;
File
pubKeyFile
=
new
File
(
usrHome
,
"ibzrt_rsa.pub"
);
if
(!
pubKeyFile
.
exists
())
{
key
=
IOUtils
.
toString
(
this
.
getClass
().
getResourceAsStream
(
"/keypair/ibzrt_rsa.pub"
));
}
else
{
key
=
IOUtils
.
toString
(
new
FileInputStream
(
pubKeyFile
));
}
return
key
;
}
/**
* 获取PublicKey对象
* @param publicKeyBase64
* @return
* @throws NoSuchAlgorithmException
* @throws InvalidKeySpecException
*/
@SneakyThrows
public
PublicKey
getPublicKey
(
String
publicKeyBase64
)
{
byte
[]
byteKey
=
Base64
.
decodeBase64
(
publicKeyBase64
);
X509EncodedKeySpec
x509EncodedKeySpec
=
new
X509EncodedKeySpec
(
byteKey
);
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
"RSA"
);
return
keyFactory
.
generatePublic
(
x509EncodedKeySpec
);
}
/**
* 获取PrivateKey对象
* @param privateKeyBase64
* @return
*/
@SneakyThrows
private
PrivateKey
getPrivateKey
(
String
privateKeyBase64
)
{
byte
[]
byteKey
=
Base64
.
decodeBase64
(
privateKeyBase64
);
PKCS8EncodedKeySpec
x509EncodedKeySpec
=
new
PKCS8EncodedKeySpec
(
byteKey
);
KeyFactory
keyFactory
=
KeyFactory
.
getInstance
(
"RSA"
);
return
keyFactory
.
generatePrivate
(
x509EncodedKeySpec
);
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录