Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdisk
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdisk
提交
1921adde
提交
1921adde
编写于
11月 13, 2020
作者:
ibizdev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ibiz4j 发布系统代码 [ibz-disk,存储]
上级
5fb2b1c7
变更
49
隐藏空白字符变更
内嵌
并排
正在显示
49 个修改的文件
包含
965 行增加
和
608 行删除
+965
-608
package.json
app_web/package.json
+9
-1
app-register.ts
app_web/src/app-register.ts
+3
-1
app-picker.vue
app_web/src/components/app-picker/app-picker.vue
+1
-0
menu-icon.less
app_web/src/components/menu-icon/menu-icon.less
+0
-0
menu-icon.tsx
app_web/src/components/menu-icon/menu-icon.tsx
+41
-0
search-view-engine.ts
app_web/src/engine/view/search-view-engine.ts
+9
-0
sdfile-edit-view-base.vue
...src/pages/disk/sdfile-edit-view/sdfile-edit-view-base.vue
+4
-4
sdfile-grid-view-base.vue
...src/pages/disk/sdfile-grid-view/sdfile-grid-view-base.vue
+4
-4
sdindex-view-base.vue
app_web/src/pages/disk/sdindex-view/sdindex-view-base.vue
+4
-4
default.less
app_web/src/styles/default.less
+1
-1
interceptor.ts
app_web/src/utils/interceptor/interceptor.ts
+7
-1
sdindex-view-appmenu-base.vue
...ts/app/sdindex-view-appmenu/sdindex-view-appmenu-base.vue
+10
-2
control-service.ts
app_web/src/widgets/control-service.ts
+19
-0
main-form-base.vue
app_web/src/widgets/sdfile/main-form/main-form-base.vue
+135
-37
main-grid-base.vue
app_web/src/widgets/sdfile/main-grid/main-grid-base.vue
+1
-1
SDFile.java
...ore/src/main/java/cn/ibizlab/core/disk/domain/SDFile.java
+37
-37
SDFileSearchContext.java
...java/cn/ibizlab/core/disk/filter/SDFileSearchContext.java
+1
-0
SDFileMapper.java
...c/main/java/cn/ibizlab/core/disk/mapper/SDFileMapper.java
+9
-9
ISDFileService.java
...ain/java/cn/ibizlab/core/disk/service/ISDFileService.java
+16
-16
SDFileServiceImpl.java
.../cn/ibizlab/core/disk/service/impl/SDFileServiceImpl.java
+21
-16
pom.xml
ibzdisk-dependencies/pom.xml
+0
-1
SDFileMapping.java
...i/src/main/java/cn/ibizlab/api/mapping/SDFileMapping.java
+3
-4
AuditAspect.java
...til/src/main/java/cn/ibizlab/util/aspect/AuditAspect.java
+56
-57
DEFieldDefaultValueAspect.java
...ava/cn/ibizlab/util/aspect/DEFieldDefaultValueAspect.java
+62
-56
VersionCheckAspect.java
.../main/java/cn/ibizlab/util/aspect/VersionCheckAspect.java
+50
-43
DTOBase.java
...sk-util/src/main/java/cn/ibizlab/util/domain/DTOBase.java
+12
-6
EntityBase.java
...util/src/main/java/cn/ibizlab/util/domain/EntityBase.java
+15
-11
EntityMP.java
...k-util/src/main/java/cn/ibizlab/util/domain/EntityMP.java
+6
-6
EntityMongo.java
...til/src/main/java/cn/ibizlab/util/domain/EntityMongo.java
+0
-2
QueryBuildContext.java
...c/main/java/cn/ibizlab/util/filter/QueryBuildContext.java
+4
-3
QueryFilter.java
...til/src/main/java/cn/ibizlab/util/filter/QueryFilter.java
+8
-5
QueryWrapperContext.java
...main/java/cn/ibizlab/util/filter/QueryWrapperContext.java
+14
-12
SearchContextBase.java
...c/main/java/cn/ibizlab/util/filter/SearchContextBase.java
+6
-4
CachedBeanCopier.java
...rc/main/java/cn/ibizlab/util/helper/CachedBeanCopier.java
+2
-3
DEFieldCacheMap.java
...src/main/java/cn/ibizlab/util/helper/DEFieldCacheMap.java
+52
-31
DataObject.java
...util/src/main/java/cn/ibizlab/util/helper/DataObject.java
+62
-38
RuleUtils.java
...-util/src/main/java/cn/ibizlab/util/helper/RuleUtils.java
+102
-54
PermissionSyncJob.java
.../src/main/java/cn/ibizlab/util/job/PermissionSyncJob.java
+4
-4
AppController.java
...til/src/main/java/cn/ibizlab/util/rest/AppController.java
+12
-6
AuthenticationController.java
...n/java/cn/ibizlab/util/rest/AuthenticationController.java
+1
-1
AuthPermissionEvaluator.java
...ava/cn/ibizlab/util/security/AuthPermissionEvaluator.java
+33
-17
AuthenticationUser.java
...ain/java/cn/ibizlab/util/security/AuthenticationUser.java
+4
-2
IBZConfigService.java
...c/main/java/cn/ibizlab/util/service/IBZConfigService.java
+8
-4
IBZUAAUserService.java
.../main/java/cn/ibizlab/util/service/IBZUAAUserService.java
+4
-3
SimpleAuditService.java
...main/java/cn/ibizlab/util/service/SimpleAuditService.java
+99
-85
SimpleUserService.java
.../main/java/cn/ibizlab/util/service/SimpleUserService.java
+7
-7
FeignRequestInterceptor.java
...ain/java/cn/ibizlab/util/web/FeignRequestInterceptor.java
+2
-1
IBZOperationParameterReader.java
...java/cn/ibizlab/util/web/IBZOperationParameterReader.java
+5
-5
SearchContextHandlerMethodArgumentResolver.java
.../util/web/SearchContextHandlerMethodArgumentResolver.java
+0
-3
未找到文件。
app_web/package.json
浏览文件 @
1921adde
...
...
@@ -9,7 +9,8 @@
"dev-build"
:
"node --max_old_space_size=8102 ./node_modules/@vue/cli-service/bin/vue-cli-service build --mode development"
,
"test:unit"
:
"vue-cli-service test:unit"
,
"test:e2e"
:
"vue-cli-service test:e2e"
,
"lint"
:
"vue-cli-service lint"
"lint"
:
"vue-cli-service lint"
,
"format-code"
:
"prettier-eslint --write
\"
src/**/*.js
\"
\"
src/**/*.vue
\"
\"
src/**/*.tsx
\"
\"
src/**/*.ts
\"
\"
src/**/*.less
\"
"
},
"dependencies"
:
{
"@fullcalendar/core"
:
"^4.4.0"
,
...
...
@@ -66,5 +67,12 @@
"script-loader"
:
"^0.7.2"
,
"typescript"
:
"~3.5.3"
,
"vue-template-compiler"
:
"^2.6.10"
},
"eslintConfig"
:
{
"root"
:
true
,
"extends"
:
[
"gitee"
,
"stylelint-config-prettier"
]
}
}
app_web/src/app-register.ts
浏览文件 @
1921adde
...
...
@@ -98,6 +98,7 @@ import AppAlert from './components/app-alert/app-alert.vue'
import
AppAlertGroup
from
'./components/app-alert-group/app-alert-group.vue'
import
AppRawItem
from
'./components/app-rawitem/app-rawitem.vue'
import
AppImageRomate
from
'./components/app-image-romate/app-image-romate.vue'
import
{
MenuIcon
}
from
'./components/menu-icon/menu-icon'
// 全局挂载UI实体服务注册中心
window
[
'uiServiceRegister'
]
=
uiServiceRegister
;
...
...
@@ -210,6 +211,7 @@ export const AppComponents = {
v
.
component
(
'app-alert'
,
AppAlert
);
v
.
component
(
'app-alert-group'
,
AppAlertGroup
);
v
.
component
(
'app-rawitem'
,
AppRawItem
);
v
.
component
(
'app-image-romate'
,
AppImageRomate
)
v
.
component
(
'app-image-romate'
,
AppImageRomate
);
v
.
component
(
'menu-icon'
,
MenuIcon
);
},
};
\ No newline at end of file
app_web/src/components/app-picker/app-picker.vue
浏览文件 @
1921adde
...
...
@@ -341,6 +341,7 @@ export default class AppPicker extends Vue {
public
onSelectOpen
(
flag
:
boolean
):
void
{
this
.
open
=
flag
;
if
(
this
.
open
)
{
this
.
items
=
[];
//设置下拉列表的最大宽度
this
.
setDropdownWidth
();
this
.
onSearch
(
this
.
curvalue
,
null
,
true
);
...
...
app_web/src/components/menu-icon/menu-icon.less
0 → 100644
浏览文件 @
1921adde
app_web/src/components/menu-icon/menu-icon.tsx
0 → 100644
浏览文件 @
1921adde
import
{
Vue
,
Component
,
Prop
}
from
'vue-property-decorator'
;
import
'./menu-icon.less'
;
/**
* 平台菜单按钮适配
*
* @export
* @class MenuIcon
* @extends {Vue}
*/
@
Component
({})
export
class
MenuIcon
extends
Vue
{
/**
* 项数据
*
* @type {*}
* @memberof MenuIcon
*/
@
Prop
()
public
item
:
any
;
/**
* 绘制图标
*
* @returns {*}
* @memberof MenuIcon
*/
public
render
():
any
{
if
(
this
.
item
)
{
if
(
this
.
item
.
iconcls
)
{
return
<
i
class=
{
this
.
item
.
iconcls
}
/>
}
if
(
this
.
item
.
icon
)
{
return
<
img
src=
{
this
.
item
.
icon
}
/>
}
}
return
<
span
/>
}
}
\ No newline at end of file
app_web/src/engine/view/search-view-engine.ts
浏览文件 @
1921adde
...
...
@@ -97,6 +97,15 @@ export class SearchViewEngine extends ViewEngine {
if
(
this
.
view
&&
!
this
.
view
.
isExpandSearchForm
)
{
Object
.
assign
(
arg
,
{
query
:
this
.
view
.
query
});
}
// 快速分组和快速搜索栏
let
otherQueryParam
:
any
=
{};
if
(
this
.
view
&&
this
.
view
.
quickGroupData
){
Object
.
assign
(
otherQueryParam
,
this
.
view
.
quickGroupData
);
}
if
(
this
.
view
&&
this
.
view
.
quickFormData
){
Object
.
assign
(
otherQueryParam
,
this
.
view
.
quickFormData
);
}
Object
.
assign
(
arg
,{
viewparams
:
otherQueryParam
});
}
...
...
app_web/src/pages/disk/sdfile-edit-view/sdfile-edit-view-base.vue
浏览文件 @
1921adde
...
...
@@ -254,11 +254,11 @@ export default class SDFileEditViewBase extends Vue {
@
Watch
(
'viewparam'
,{
immediate
:
true
,
deep
:
true
})
onParamData
(
newVal
:
any
,
oldVal
:
any
)
{
if
(
newVal
){
for
(
let
key
in
this
.
viewparams
){
delete
this
.
viewparams
[
key
];
}
if
(
typeof
this
.
viewparams
==
'string'
)
{
this
.
viewparams
=
{};
if
(
typeof
newVal
==
'string'
)
{
Object
.
assign
(
this
.
viewparams
,
JSON
.
parse
(
this
.
viewparam
));
}
else
{
this
.
viewparams
=
Util
.
deepCopy
(
this
.
viewparam
);
}
}
...
...
app_web/src/pages/disk/sdfile-grid-view/sdfile-grid-view-base.vue
浏览文件 @
1921adde
...
...
@@ -283,11 +283,11 @@ export default class SDFileGridViewBase extends Vue {
@
Watch
(
'viewparam'
,{
immediate
:
true
,
deep
:
true
})
onParamData
(
newVal
:
any
,
oldVal
:
any
)
{
if
(
newVal
){
for
(
let
key
in
this
.
viewparams
){
delete
this
.
viewparams
[
key
];
}
if
(
typeof
this
.
viewparams
==
'string'
)
{
this
.
viewparams
=
{};
if
(
typeof
newVal
==
'string'
)
{
Object
.
assign
(
this
.
viewparams
,
JSON
.
parse
(
this
.
viewparam
));
}
else
{
this
.
viewparams
=
Util
.
deepCopy
(
this
.
viewparam
);
}
}
...
...
app_web/src/pages/disk/sdindex-view/sdindex-view-base.vue
浏览文件 @
1921adde
...
...
@@ -167,11 +167,11 @@ export default class SDIndexViewBase extends Vue {
@
Watch
(
'viewparam'
,{
immediate
:
true
,
deep
:
true
})
onParamData
(
newVal
:
any
,
oldVal
:
any
)
{
if
(
newVal
){
for
(
let
key
in
this
.
viewparams
){
delete
this
.
viewparams
[
key
];
}
if
(
typeof
this
.
viewparams
==
'string'
)
{
this
.
viewparams
=
{};
if
(
typeof
newVal
==
'string'
)
{
Object
.
assign
(
this
.
viewparams
,
JSON
.
parse
(
this
.
viewparam
));
}
else
{
this
.
viewparams
=
Util
.
deepCopy
(
this
.
viewparam
);
}
}
...
...
app_web/src/styles/default.less
浏览文件 @
1921adde
...
...
@@ -246,7 +246,7 @@
}
}
.view-container.degridview, .view-container.degridview9, .view-container.dewfgridview, .view-container.delistview, .view-container.delistview9, .view-container.dedataview, .view-container.dedataview9{
.view-container.degridview, .view-container.degridview9, .view-container.dewfgridview, .view-container.delistview, .view-container.delistview9, .view-container.dedataview, .view-container.dedataview9
,.view-container.dechartview,.view-container.dechartview9
{
>.view-card.view-no-caption{
>.ivu-card-body{
height: 100%;
...
...
app_web/src/utils/interceptor/interceptor.ts
浏览文件 @
1921adde
...
...
@@ -109,7 +109,13 @@ export class Interceptors {
error
=
error
?
error
:
{
response
:
{}
};
let
{
response
:
res
}
=
error
;
let
{
data
:
_data
}
=
res
;
// 处理异常
if
(
res
.
headers
&&
res
.
headers
[
'x-ibz-error'
]){
res
.
data
.
errorKey
=
res
.
headers
[
'x-ibz-error'
];
}
if
(
res
.
headers
&&
res
.
headers
[
'x-ibz-params'
]){
res
.
data
.
entityName
=
res
.
headers
[
'x-ibz-params'
];
}
if
(
res
.
status
===
401
)
{
this
.
doNoLogin
(
_data
.
data
);
}
...
...
app_web/src/widgets/app/sdindex-view-appmenu/sdindex-view-appmenu-base.vue
浏览文件 @
1921adde
...
...
@@ -682,9 +682,17 @@ export default class SDIndexViewBase extends Vue implements ControlInterface {
item
.
items
.
map
((
singleItem
:
any
)
=>
{
if
(
!
singleItem
.
hidden
){
item
.
hidden
=
false
;
}
else
{
if
(
singleItem
.
items
&&
singleItem
.
items
.
length
>
0
){
singleItem
.
items
.
map
((
grandsonItem
:
any
)
=>
{
if
(
!
grandsonItem
.
hidden
){
item
.
hidden
=
false
;
}
})
}
}
if
(
singleItem
.
items
&&
singleI
tem
.
items
.
length
>
0
){
this
.
computeParentMenus
(
singleI
tem
.
items
);
if
(
item
.
items
&&
i
tem
.
items
.
length
>
0
){
this
.
computeParentMenus
(
i
tem
.
items
);
}
})
}
...
...
app_web/src/widgets/control-service.ts
浏览文件 @
1921adde
...
...
@@ -310,4 +310,23 @@ export default class ControlService {
}
})
}
/**
* 根据后台标识获取数据标识名称
*
* @param prop 后台标识
* @memberof ControlService
*/
public
getNameByProp
(
prop
:
any
)
{
let
model
:
any
=
this
.
getMode
();
if
(
!
model
||
!
prop
)
{
return
false
;
}
let
dataItems
:
any
[]
=
model
.
getDataItems
();
prop
=
prop
.
replace
(
/
([
A-Z
])
/g
,
"_$1"
).
toLowerCase
();
let
data
:
any
=
dataItems
.
find
((
item
:
any
)
=>
{
return
Object
.
is
(
prop
,
item
.
prop
);
});
return
data
.
name
;
}
}
\ No newline at end of file
app_web/src/widgets/sdfile/main-form/main-form-base.vue
浏览文件 @
1921adde
<
template
>
<i-form
:model=
"this.data"
class=
'app-form'
ref=
'form'
id=
'sdfile_main'
style=
""
>
<i-form
:model=
"this.data"
class=
'app-form'
ref=
'form'
id=
'sdfile_main'
style=
""
@
on-validate=
"formItemValidate"
>
<input
style=
"display:none;"
/>
<row
>
<i-col
v-show=
"detailsModel.group1.visible"
:style=
"
{}" :lg="{ span: 24, offset: 0 }">
...
...
@@ -332,6 +332,15 @@ export default class MainBase extends Vue implements ControlInterface {
@
Inject
({
from
:
'navModel'
,
default
:
'tab'
})
public
navModel
!
:
string
;
/**
* 主键表单项名称
*
* @protected
* @type {string}
* @memberof MainBase
*/
public
formKeyItemName
:
string
=
''
;
/**
* 界面UI服务对象
*
...
...
@@ -506,6 +515,35 @@ export default class MainBase extends Vue implements ControlInterface {
*/
public
mixinData
:
any
=
{};
/**
* 表单项校验错误提示信息
*
* @memberof MainBase
*/
public
errorMessages
:
Array
<
any
>
=
[];
/**
* 设置表单项错误提示信息
*
* @param {*} prop 表单项字段名
* @param {*} status 校验状态
* @param {*} error 错误信息
* @memberof MainBase
*/
public
formItemValidate
(
prop
:
string
,
status
:
boolean
,
error
:
string
){
error
=
error
?
error
:
''
;
if
(
this
.
errorMessages
&&
this
.
errorMessages
.
length
>
0
){
const
index
=
this
.
errorMessages
.
findIndex
((
errorMessage
:
any
)
=>
Object
.
is
(
errorMessage
.
prop
,
prop
));
if
(
index
!=
-
1
){
this
.
errorMessages
[
index
].
error
=
error
;
}
else
{
this
.
errorMessages
.
push
({
prop
:
prop
,
error
:
error
});
}
}
else
{
this
.
errorMessages
.
push
({
prop
:
prop
,
error
:
error
});
}
}
/**
* 表单数据对象
*
...
...
@@ -570,6 +608,14 @@ export default class MainBase extends Vue implements ControlInterface {
*/
public
saveState
:
any
;
/**
* 主信息属性映射表单项名称
*
* @type {string}
* @memberof MainBase
*/
public
majorMessageField
:
string
=
""
;
/**
* 值规则
*
...
...
@@ -658,9 +704,9 @@ export default class MainBase extends Vue implements ControlInterface {
let
startOp
=
(
val
:
boolean
)
=>
{
if
(
falg
.
isPast
){
if
(
opValue
){
falg
.
isPast
=
falg
&&
val
;
falg
.
isPast
=
falg
.
isPast
&&
val
;
}
else
{
falg
.
isPast
=
falg
||
val
;
falg
.
isPast
=
falg
.
isPast
||
val
;
}
}
else
{
falg
.
isPast
=
val
;
...
...
@@ -669,6 +715,11 @@ export default class MainBase extends Vue implements ControlInterface {
for
(
let
i
=
0
;
i
<
rule
[
name
].
length
;
i
++
){
let
item
:
any
=
rule
[
name
][
i
];
let
dataValue
=
item
.
deName
?
this
.
data
[
this
.
service
.
getItemNameByDeName
(
item
.
deName
)]:
""
;
item
.
ruleInfo
=
item
.
ruleInfo
?
item
.
ruleInfo
:
this
.
$t
(
'app.formpage.valuecheckex'
);
if
((
dataValue
===
null
||
dataValue
===
undefined
||
dataValue
===
""
)
&&
(
item
.
type
!=
'GROUP'
)){
startOp
(
true
);
return
falg
;
}
// 常规规则
if
(
item
.
type
==
'SIMPLE'
){
startOp
(
!
this
.
$verify
.
checkFieldSimpleRule
(
dataValue
,
item
.
condOP
,
item
.
paramValue
,
item
.
ruleInfo
,
item
.
paramType
,
this
.
data
,
item
.
isKeyCond
));
...
...
@@ -701,7 +752,7 @@ export default class MainBase extends Vue implements ControlInterface {
}
// 分组
if
(
item
.
type
==
'GROUP'
){
falg
=
this
.
verifyDeRules
(
'group'
,
item
)
falg
=
this
.
verifyDeRules
(
'group'
,
item
,
item
.
condOP
?
item
.
condOP
:
"AND"
);
if
(
item
.
isNotMode
){
falg
.
isPast
=
!
falg
.
isPast
;
}
...
...
@@ -1614,6 +1665,7 @@ export default class MainBase extends Vue implements ControlInterface {
const
arg
:
any
=
{
...
opt
};
const
data
=
this
.
getValues
();
Object
.
assign
(
arg
,
data
);
Object
.
assign
(
arg
,{
srfmajortext
:
data
[
this
.
majorMessageField
]});
const
action
:
any
=
Object
.
is
(
data
.
srfuf
,
'1'
)
?
this
.
updateAction
:
this
.
createAction
;
if
(
!
action
){
let
actionName
:
any
=
Object
.
is
(
data
.
srfuf
,
'1'
)?
"updateAction"
:
"createAction"
;
...
...
@@ -1639,24 +1691,45 @@ export default class MainBase extends Vue implements ControlInterface {
});
}).
catch
((
response
:
any
)
=>
{
if
(
response
&&
response
.
status
&&
response
.
data
)
{
if
(
response
.
data
.
errorKey
&&
Object
.
is
(
response
.
data
.
errorKey
,
"versionCheck"
)){
this
.
$Modal
.
confirm
({
title
:
(
this
.
$t
(
'app.formpage.saveerror'
)
as
string
),
content
:
(
this
.
$t
(
'app.formpage.savecontent'
)
as
string
),
onOk
:
()
=>
{
this
.
refresh
([]);
},
onCancel
:
()
=>
{
}
});
}
else
{
this
.
$Notice
.
error
({
title
:
(
this
.
$t
(
'app.commonWords.wrong'
)
as
string
),
desc
:
response
.
data
.
message
});
if
(
response
.
data
.
errorKey
)
{
if
(
Object
.
is
(
response
.
data
.
errorKey
,
"versionCheck"
))
{
this
.
$Modal
.
confirm
({
title
:
(
this
.
$t
(
'app.formpage.saveerror'
)
as
string
),
content
:
(
this
.
$t
(
'app.formpage.savecontent'
)
as
string
),
onOk
:
()
=>
{
this
.
refresh
([]);
},
onCancel
:
()
=>
{
}
});
}
else
if
(
Object
.
is
(
response
.
data
.
errorKey
,
'DupCheck'
))
{
let
errorProp
:
string
=
response
.
data
.
message
.
match
(
/
\[[
a-zA-Z
]
*
\]
/
)[
0
];
let
name
:
string
=
this
.
service
.
getNameByProp
(
errorProp
.
substr
(
1
,
errorProp
.
length
-
2
));
if
(
name
)
{
this
.
$Notice
.
error
({
title
:
(
this
.
$t
(
'app.commonWords.createFailed'
)
as
string
),
desc
:
this
.
detailsModel
[
name
].
caption
+
" : "
+
arg
[
name
]
+
(
this
.
$t
(
'app.commonWords.isExist'
)
as
string
)
+
'!'
,
});
}
else
{
this
.
$Notice
.
error
({
title
:
(
this
.
$t
(
'app.commonWords.createFailed'
)
as
string
),
desc
:
response
.
data
.
message
?
response
.
data
.
message
:(
this
.
$t
(
'app.commonWords.sysException'
)
as
string
),
})
}
}
else
if
(
Object
.
is
(
response
.
data
.
errorKey
,
'DuplicateKeyException'
)){
this
.
$Notice
.
error
({
title
:
(
this
.
$t
(
'app.commonWords.createFailed'
)
as
string
),
desc
:
this
.
detailsModel
[
this
.
formKeyItemName
].
caption
+
" : "
+
arg
[
this
.
formKeyItemName
]
+
(
this
.
$t
(
'app.commonWords.isExist'
)
as
string
)
+
'!'
,
});
}
else
{
this
.
$Notice
.
error
({
title
:
(
this
.
$t
(
'app.commonWords.wrong'
)
as
string
),
desc
:
response
.
data
.
message
?
response
.
data
.
message
:(
this
.
$t
(
'app.commonWords.sysException'
)
as
string
)
});
}
}
else
{
this
.
$Notice
.
error
({
title
:
(
this
.
$t
(
'app.commonWords.wrong'
)
as
string
),
desc
:
response
.
data
.
message
?
response
.
data
.
message
:(
this
.
$t
(
'app.commonWords.sysException'
)
as
string
)
});
}
return
;
}
else
{
this
.
$Notice
.
error
({
title
:
(
this
.
$t
(
'app.commonWords.wrong'
)
as
string
),
desc
:
(
this
.
$t
(
'app.commonWords.sysException'
)
as
string
)
});
}
return
;
}
if
(
!
response
||
!
response
.
status
||
!
response
.
data
)
{
this
.
$Notice
.
error
({
title
:
(
this
.
$t
(
'app.commonWords.wrong'
)
as
string
),
desc
:
(
this
.
$t
(
'app.commonWords.sysException'
)
as
string
)
});
return
;
}
});
}
...
...
@@ -1673,13 +1746,22 @@ export default class MainBase extends Vue implements ControlInterface {
return
new
Promise
((
resolve
:
any
,
reject
:
any
)
=>
{
showResultInfo
=
showResultInfo
===
undefined
?
true
:
false
;
if
(
!
this
.
formValidateStatus
())
{
this
.
$Notice
.
error
({
title
:
(
this
.
$t
(
'app.commonWords.wrong'
)
as
string
),
desc
:
(
this
.
$t
(
'app.formpage.valuecheckex'
)
as
string
)
});
if
(
this
.
errorMessages
&&
this
.
errorMessages
.
length
>
0
)
{
let
descMessage
:
string
=
''
;
this
.
errorMessages
.
forEach
((
message
:
any
)
=>
{
descMessage
=
descMessage
+
'<p>'
+
message
.
error
+
'<p>'
;
})
this
.
$Notice
.
error
({
title
:
(
this
.
$t
(
'app.commonWords.wrong'
)
as
string
),
desc
:
descMessage
});
}
else
{
this
.
$Notice
.
error
({
title
:
(
this
.
$t
(
'app.commonWords.wrong'
)
as
string
),
desc
:
(
this
.
$t
(
'app.formpage.valuecheckex'
)
as
string
)
});
}
return
;
}
const
arg
:
any
=
{
...
opt
};
const
data
=
this
.
getValues
();
Object
.
assign
(
arg
,
this
.
context
);
Object
.
assign
(
arg
,
data
);
Object
.
assign
(
arg
,{
srfmajortext
:
data
[
this
.
majorMessageField
]});
if
(
ifStateNext
)
{
this
.
drcounter
=
0
;
if
(
this
.
drcounter
!==
0
){
...
...
@@ -1720,27 +1802,43 @@ export default class MainBase extends Vue implements ControlInterface {
}
resolve
(
response
);
}).
catch
((
response
:
any
)
=>
{
if
(
response
&&
response
.
status
&&
response
.
data
)
{
if
(
response
.
data
.
errorKey
&&
Object
.
is
(
response
.
data
.
errorKey
,
"versionCheck"
)){
this
.
$Modal
.
confirm
({
title
:
(
this
.
$t
(
'app.formpage.saveerror'
)
as
string
),
content
:
(
this
.
$t
(
'app.formpage.savecontent'
)
as
string
),
onOk
:
()
=>
{
this
.
refresh
([]);
},
onCancel
:
()
=>
{
}
});
}
else
{
if
(
response
&&
response
.
status
&&
response
.
data
)
{
if
(
response
.
data
.
errorKey
)
{
if
(
Object
.
is
(
response
.
data
.
errorKey
,
"versionCheck"
))
{
this
.
$Modal
.
confirm
({
title
:
(
this
.
$t
(
'app.formpage.saveerror'
)
as
string
),
content
:
(
this
.
$t
(
'app.formpage.savecontent'
)
as
string
),
onOk
:
()
=>
{
this
.
refresh
([]);
},
onCancel
:
()
=>
{
}
});
}
else
if
(
Object
.
is
(
response
.
data
.
errorKey
,
'DupCheck'
))
{
let
errorProp
:
string
=
response
.
data
.
message
.
match
(
/
\[[
a-zA-Z
]
*
\]
/
)[
0
];
let
name
:
string
=
this
.
service
.
getNameByProp
(
errorProp
.
substr
(
1
,
errorProp
.
length
-
2
));
if
(
name
)
{
this
.
$Notice
.
error
({
title
:
(
this
.
$t
(
'app.commonWords.createFailed'
)
as
string
),
desc
:
this
.
detailsModel
[
name
].
caption
+
" : "
+
arg
[
name
]
+
(
this
.
$t
(
'app.commonWords.isExist'
)
as
string
)
+
'!'
,
});
}
else
{
this
.
$Notice
.
error
({
title
:
(
this
.
$t
(
'app.commonWords.createFailed'
)
as
string
),
desc
:
response
.
data
.
message
,
})
}
}
else
{
this
.
$Notice
.
error
({
title
:
(
this
.
$t
(
'app.commonWords.wrong'
)
as
string
),
desc
:
response
.
data
.
message
});
}
}
else
{
this
.
$Notice
.
error
({
title
:
(
this
.
$t
(
'app.commonWords.wrong'
)
as
string
),
desc
:
response
.
data
.
message
});
reject
(
response
);
}
return
;
}
if
(
!
response
||
!
response
.
status
||
!
response
.
data
)
{
}
else
{
this
.
$Notice
.
error
({
title
:
(
this
.
$t
(
'app.commonWords.wrong'
)
as
string
),
desc
:
(
this
.
$t
(
'app.commonWords.sysException'
)
as
string
)
});
reject
(
response
);
return
;
}
}
reject
(
response
);
});
})
...
...
app_web/src/widgets/sdfile/main-grid/main-grid-base.vue
浏览文件 @
1921adde
...
...
@@ -4,5 +4,5 @@ Tip: If the failing expression is known to be legally refer to something that's
----
FTL stack trace ("~" means nesting-related):
- Failed at: ${ctrl.getPSAppDataEntity().getMajorP... [in template "TEMPLCODE_en_US" at line 11
74
, column 39]
- Failed at: ${ctrl.getPSAppDataEntity().getMajorP... [in template "TEMPLCODE_en_US" at line 11
97
, column 39]
----
\ No newline at end of file
ibzdisk-core/src/main/java/cn/ibizlab/core/disk/domain/SDFile.java
浏览文件 @
1921adde
...
...
@@ -38,7 +38,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
@Setter
@NoArgsConstructor
@JsonIgnoreProperties
(
value
=
"handler"
)
@TableName
(
value
=
"IBZFILE"
,
resultMap
=
"SDFileResultMap"
)
@TableName
(
value
=
"IBZFILE"
,
resultMap
=
"SDFileResultMap"
)
public
class
SDFile
extends
EntityMP
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
@@ -46,8 +46,8 @@ public class SDFile extends EntityMP implements Serializable {
/**
* 标识
*/
@DEField
(
name
=
"fileid"
,
isKeyField
=
true
)
@TableId
(
value
=
"fileid"
,
type
=
IdType
.
ASSIGN_UUID
)
@DEField
(
name
=
"fileid"
,
isKeyField
=
true
)
@TableId
(
value
=
"fileid"
,
type
=
IdType
.
ASSIGN_UUID
)
@JSONField
(
name
=
"id"
)
@JsonProperty
(
"id"
)
private
String
id
;
...
...
@@ -120,7 +120,7 @@ public class SDFile extends EntityMP implements Serializable {
* 创建人
*/
@DEField
(
preType
=
DEPredefinedFieldType
.
CREATEMAN
)
@TableField
(
value
=
"createman"
,
fill
=
FieldFill
.
INSERT
)
@TableField
(
value
=
"createman"
,
fill
=
FieldFill
.
INSERT
)
@JSONField
(
name
=
"createman"
)
@JsonProperty
(
"createman"
)
private
String
createman
;
...
...
@@ -128,9 +128,9 @@ public class SDFile extends EntityMP implements Serializable {
* 创建日期
*/
@DEField
(
preType
=
DEPredefinedFieldType
.
CREATEDATE
)
@TableField
(
value
=
"createdate"
,
fill
=
FieldFill
.
INSERT
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
locale
=
"zh"
,
timezone
=
"GMT+8"
)
@JSONField
(
name
=
"createdate"
,
format
=
"yyyy-MM-dd HH:mm:ss"
)
@TableField
(
value
=
"createdate"
,
fill
=
FieldFill
.
INSERT
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
locale
=
"zh"
,
timezone
=
"GMT+8"
)
@JSONField
(
name
=
"createdate"
,
format
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonProperty
(
"createdate"
)
private
Timestamp
createdate
;
/**
...
...
@@ -146,8 +146,8 @@ public class SDFile extends EntityMP implements Serializable {
*/
@DEField
(
preType
=
DEPredefinedFieldType
.
UPDATEDATE
)
@TableField
(
value
=
"updatedate"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
locale
=
"zh"
,
timezone
=
"GMT+8"
)
@JSONField
(
name
=
"updatedate"
,
format
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
locale
=
"zh"
,
timezone
=
"GMT+8"
)
@JSONField
(
name
=
"updatedate"
,
format
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonProperty
(
"updatedate"
)
private
Timestamp
updatedate
;
...
...
@@ -156,73 +156,73 @@ public class SDFile extends EntityMP implements Serializable {
/**
* 设置 [名称]
*/
public
void
setName
(
String
name
){
this
.
name
=
name
;
this
.
modify
(
"filename"
,
name
);
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
this
.
modify
(
"filename"
,
name
);
}
/**
* 设置 [路径]
*/
public
void
setFilePath
(
String
filePath
){
this
.
filePath
=
filePath
;
this
.
modify
(
"filepath"
,
filePath
);
public
void
setFilePath
(
String
filePath
)
{
this
.
filePath
=
filePath
;
this
.
modify
(
"filepath"
,
filePath
);
}
/**
* 设置 [特定目录]
*/
public
void
setFolder
(
String
folder
){
this
.
folder
=
folder
;
this
.
modify
(
"folder"
,
folder
);
public
void
setFolder
(
String
folder
)
{
this
.
folder
=
folder
;
this
.
modify
(
"folder"
,
folder
);
}
/**
* 设置 [文件大小]
*/
public
void
setFileSize
(
Integer
fileSize
){
this
.
fileSize
=
fileSize
;
this
.
modify
(
"filesize"
,
fileSize
);
public
void
setFileSize
(
Integer
fileSize
)
{
this
.
fileSize
=
fileSize
;
this
.
modify
(
"filesize"
,
fileSize
);
}
/**
* 设置 [扩展名]
*/
public
void
setExtension
(
String
extension
){
this
.
extension
=
extension
;
this
.
modify
(
"fileext"
,
extension
);
public
void
setExtension
(
String
extension
)
{
this
.
extension
=
extension
;
this
.
modify
(
"fileext"
,
extension
);
}
/**
* 设置 [所属类型]
*/
public
void
setOwnerType
(
String
ownerType
){
this
.
ownerType
=
ownerType
;
this
.
modify
(
"ownertype"
,
ownerType
);
public
void
setOwnerType
(
String
ownerType
)
{
this
.
ownerType
=
ownerType
;
this
.
modify
(
"ownertype"
,
ownerType
);
}
/**
* 设置 [所属主体]
*/
public
void
setOwnerId
(
String
ownerId
){
this
.
ownerId
=
ownerId
;
this
.
modify
(
"ownerid"
,
ownerId
);
public
void
setOwnerId
(
String
ownerId
)
{
this
.
ownerId
=
ownerId
;
this
.
modify
(
"ownerid"
,
ownerId
);
}
/**
* 设置 [备注]
*/
public
void
setMemo
(
String
memo
){
this
.
memo
=
memo
;
this
.
modify
(
"memo"
,
memo
);
public
void
setMemo
(
String
memo
)
{
this
.
memo
=
memo
;
this
.
modify
(
"memo"
,
memo
);
}
/**
* 设置 [签名]
*/
public
void
setDigestCode
(
String
digestCode
){
this
.
digestCode
=
digestCode
;
this
.
modify
(
"digestcode"
,
digestCode
);
public
void
setDigestCode
(
String
digestCode
)
{
this
.
digestCode
=
digestCode
;
this
.
modify
(
"digestcode"
,
digestCode
);
}
...
...
@@ -236,7 +236,7 @@ public class SDFile extends EntityMP implements Serializable {
@Override
public
<
T
>
T
copyTo
(
T
targetEntity
,
boolean
bIncEmpty
)
{
this
.
reset
(
"fileid"
);
return
super
.
copyTo
(
targetEntity
,
bIncEmpty
);
return
super
.
copyTo
(
targetEntity
,
bIncEmpty
);
}
}
...
...
ibzdisk-core/src/main/java/cn/ibizlab/core/disk/filter/SDFileSearchContext.java
浏览文件 @
1921adde
...
...
@@ -38,6 +38,7 @@ public class SDFileSearchContext extends QueryWrapperContext<SDFile> {
/**
* 启用快速搜索
*/
@Override
public
void
setQuery
(
String
query
)
{
this
.
query
=
query
;
...
...
ibzdisk-core/src/main/java/cn/ibizlab/core/disk/mapper/SDFileMapper.java
浏览文件 @
1921adde
...
...
@@ -17,9 +17,9 @@ import java.io.Serializable;
import
com.baomidou.mybatisplus.core.toolkit.Constants
;
import
com.alibaba.fastjson.JSONObject
;
public
interface
SDFileMapper
extends
BaseMapper
<
SDFile
>{
public
interface
SDFileMapper
extends
BaseMapper
<
SDFile
>
{
Page
<
SDFile
>
searchDefault
(
IPage
page
,
@Param
(
"srf"
)
SDFileSearchContext
context
,
@Param
(
"ew"
)
Wrapper
<
SDFile
>
wrapper
)
;
Page
<
SDFile
>
searchDefault
(
IPage
page
,
@Param
(
"srf"
)
SDFileSearchContext
context
,
@Param
(
"ew"
)
Wrapper
<
SDFile
>
wrapper
);
@Override
SDFile
selectById
(
Serializable
id
);
@Override
...
...
@@ -30,13 +30,13 @@ public interface SDFileMapper extends BaseMapper<SDFile>{
int
update
(
@Param
(
Constants
.
ENTITY
)
SDFile
entity
,
@Param
(
"ew"
)
Wrapper
<
SDFile
>
updateWrapper
);
@Override
int
deleteById
(
Serializable
id
);
/**
* 自定义查询SQL
* @param sql
* @return
*/
@Select
(
"${sql}"
)
List
<
JSONObject
>
selectBySQL
(
@Param
(
"sql"
)
String
sql
,
@Param
(
"et"
)
Map
param
);
/**
* 自定义查询SQL
* @param sql
* @return
*/
@Select
(
"${sql}"
)
List
<
JSONObject
>
selectBySQL
(
@Param
(
"sql"
)
String
sql
,
@Param
(
"et"
)
Map
param
);
/**
* 自定义更新SQL
...
...
ibzdisk-core/src/main/java/cn/ibizlab/core/disk/service/ISDFileService.java
浏览文件 @
1921adde
...
...
@@ -23,20 +23,20 @@ import com.baomidou.mybatisplus.extension.service.IService;
/**
* 实体[SDFile] 服务对象接口
*/
public
interface
ISDFileService
extends
IService
<
SDFile
>{
boolean
create
(
SDFile
et
)
;
void
createBatch
(
List
<
SDFile
>
list
)
;
boolean
update
(
SDFile
et
)
;
void
updateBatch
(
List
<
SDFile
>
list
)
;
boolean
remove
(
String
key
)
;
void
removeBatch
(
Collection
<
String
>
idList
)
;
SDFile
get
(
String
key
)
;
SDFile
getDraft
(
SDFile
et
)
;
boolean
checkKey
(
SDFile
et
)
;
boolean
save
(
SDFile
et
)
;
void
saveBatch
(
List
<
SDFile
>
list
)
;
Page
<
SDFile
>
searchDefault
(
SDFileSearchContext
context
)
;
public
interface
ISDFileService
extends
IService
<
SDFile
>
{
boolean
create
(
SDFile
et
);
void
createBatch
(
List
<
SDFile
>
list
);
boolean
update
(
SDFile
et
);
void
updateBatch
(
List
<
SDFile
>
list
);
boolean
remove
(
String
key
);
void
removeBatch
(
Collection
<
String
>
idList
);
SDFile
get
(
String
key
);
SDFile
getDraft
(
SDFile
et
);
boolean
checkKey
(
SDFile
et
);
boolean
save
(
SDFile
et
);
void
saveBatch
(
List
<
SDFile
>
list
);
Page
<
SDFile
>
searchDefault
(
SDFileSearchContext
context
);
/**
*自定义查询SQL
* @param sql select * from table where id =#{et.param}
...
...
@@ -52,8 +52,8 @@ public interface ISDFileService extends IService<SDFile>{
*/
boolean
execute
(
String
sql
,
Map
param
);
List
<
SDFile
>
getSdfileByIds
(
List
<
String
>
ids
)
;
List
<
SDFile
>
getSdfileByEntities
(
List
<
SDFile
>
entities
)
;
List
<
SDFile
>
getSdfileByIds
(
List
<
String
>
ids
);
List
<
SDFile
>
getSdfileByEntities
(
List
<
SDFile
>
entities
);
}
ibzdisk-core/src/main/java/cn/ibizlab/core/disk/service/impl/SDFileServiceImpl.java
浏览文件 @
1921adde
...
...
@@ -54,37 +54,39 @@ public class SDFileServiceImpl extends ServiceImpl<SDFileMapper, SDFile> impleme
@Override
@Transactional
public
boolean
create
(
SDFile
et
)
{
if
(!
this
.
retBool
(
this
.
baseMapper
.
insert
(
et
)))
if
(!
this
.
retBool
(
this
.
baseMapper
.
insert
(
et
)))
{
return
false
;
CachedBeanCopier
.
copy
(
get
(
et
.
getId
()),
et
);
}
CachedBeanCopier
.
copy
(
get
(
et
.
getId
()),
et
);
return
true
;
}
@Override
@Transactional
public
void
createBatch
(
List
<
SDFile
>
list
)
{
this
.
saveBatch
(
list
,
batchSize
);
this
.
saveBatch
(
list
,
batchSize
);
}
@Override
@Transactional
public
boolean
update
(
SDFile
et
)
{
if
(!
update
(
et
,(
Wrapper
)
et
.
getUpdateWrapper
(
true
).
eq
(
"fileid"
,
et
.
getId
())))
if
(!
update
(
et
,
(
Wrapper
)
et
.
getUpdateWrapper
(
true
).
eq
(
"fileid"
,
et
.
getId
())))
{
return
false
;
CachedBeanCopier
.
copy
(
get
(
et
.
getId
()),
et
);
}
CachedBeanCopier
.
copy
(
get
(
et
.
getId
()),
et
);
return
true
;
}
@Override
@Transactional
public
void
updateBatch
(
List
<
SDFile
>
list
)
{
updateBatchById
(
list
,
batchSize
);
updateBatchById
(
list
,
batchSize
);
}
@Override
@Transactional
public
boolean
remove
(
String
key
)
{
boolean
result
=
removeById
(
key
);
boolean
result
=
removeById
(
key
);
return
result
;
}
...
...
@@ -98,11 +100,11 @@ public class SDFileServiceImpl extends ServiceImpl<SDFileMapper, SDFile> impleme
@Transactional
public
SDFile
get
(
String
key
)
{
SDFile
et
=
getById
(
key
);
if
(
et
==
null
){
et
=
new
SDFile
();
if
(
et
==
null
){
et
=
new
SDFile
();
et
.
setId
(
key
);
}
else
{
else
{
}
return
et
;
}
...
...
@@ -114,13 +116,14 @@ public class SDFileServiceImpl extends ServiceImpl<SDFileMapper, SDFile> impleme
@Override
public
boolean
checkKey
(
SDFile
et
)
{
return
(!
ObjectUtils
.
isEmpty
(
et
.
getId
()))
&&
(!
Objects
.
isNull
(
this
.
getById
(
et
.
getId
())));
return
(!
ObjectUtils
.
isEmpty
(
et
.
getId
()))
&&
(!
Objects
.
isNull
(
this
.
getById
(
et
.
getId
())));
}
@Override
@Transactional
public
boolean
save
(
SDFile
et
)
{
if
(!
saveOrUpdate
(
et
))
if
(!
saveOrUpdate
(
et
))
{
return
false
;
}
return
true
;
}
...
...
@@ -202,10 +205,12 @@ public class SDFileServiceImpl extends ServiceImpl<SDFileMapper, SDFile> impleme
ids
.
add
(
id
);
}
}
if
(
ids
.
size
()>
0
)
return
this
.
listByIds
(
ids
);
else
return
entities
;
if
(
ids
.
size
()>
0
)
{
return
this
.
listByIds
(
ids
);
}
else
{
return
entities
;
}
}
...
...
ibzdisk-dependencies/pom.xml
浏览文件 @
1921adde
...
...
@@ -264,7 +264,6 @@
<version>
${baomidou-jobs.version}
</version>
</dependency>
</dependencies>
</dependencyManagement>
...
...
ibzdisk-provider/ibzdisk-provider-api/src/main/java/cn/ibizlab/api/mapping/SDFileMapping.java
浏览文件 @
1921adde
...
...
@@ -4,11 +4,10 @@ import org.mapstruct.*;
import
cn.ibizlab.core.disk.domain.SDFile
;
import
cn.ibizlab.api.dto.SDFileDTO
;
import
cn.ibizlab.util.domain.MappingBase
;
import
org.mapstruct.factory.Mappers
;
@Mapper
(
componentModel
=
"spring"
,
uses
=
{},
implementationName
=
"apiSDFileMapping"
,
nullValuePropertyMappingStrategy
=
NullValuePropertyMappingStrategy
.
IGNORE
,
nullValueCheckStrategy
=
NullValueCheckStrategy
.
ALWAYS
)
@Mapper
(
componentModel
=
"spring"
,
uses
=
{},
implementationName
=
"apiSDFileMapping"
,
nullValuePropertyMappingStrategy
=
NullValuePropertyMappingStrategy
.
IGNORE
,
nullValueCheckStrategy
=
NullValueCheckStrategy
.
ALWAYS
)
public
interface
SDFileMapping
extends
MappingBase
<
SDFileDTO
,
SDFile
>
{
...
...
ibzdisk-util/src/main/java/cn/ibizlab/util/aspect/AuditAspect.java
浏览文件 @
1921adde
...
...
@@ -43,30 +43,31 @@ public class AuditAspect
*/
@AfterReturning
(
value
=
"execution(* cn.ibizlab.core.*.service.*.create(..))"
)
@SneakyThrows
public
void
create
(
JoinPoint
point
){
HttpServletRequest
request
=
null
;
RequestAttributes
requestAttributes
=
RequestContextHolder
.
getRequestAttributes
();
if
(
requestAttributes
!=
null
){
request
=
((
ServletRequestAttributes
)
requestAttributes
).
getRequest
();
public
void
create
(
JoinPoint
point
)
{
HttpServletRequest
request
=
null
;
RequestAttributes
requestAttributes
=
RequestContextHolder
.
getRequestAttributes
();
if
(
requestAttributes
!=
null
)
{
request
=
((
ServletRequestAttributes
)
requestAttributes
).
getRequest
();
}
Object
[]
args
=
point
.
getArgs
();
if
(
ObjectUtils
.
isEmpty
(
args
)
||
args
.
length
==
0
)
if
(
ObjectUtils
.
isEmpty
(
args
)
||
args
.
length
==
0
)
{
return
;
Object
serviceParam
=
args
[
0
];
if
(
serviceParam
instanceof
EntityBase
){
EntityBase
entity
=(
EntityBase
)
serviceParam
;
//创建数据
Map
<
String
,
Audit
>
auditFields
=
DEFieldCacheMap
.
getAuditFields
(
entity
.
getClass
());
if
(
auditFields
.
size
()==
0
)
//是否有审计属性
}
Object
serviceParam
=
args
[
0
];
if
(
serviceParam
instanceof
EntityBase
)
{
EntityBase
entity
=
(
EntityBase
)
serviceParam
;
Map
<
String
,
Audit
>
auditFields
=
DEFieldCacheMap
.
getAuditFields
(
entity
.
getClass
());
//是否有审计属性
if
(
auditFields
.
size
()==
0
)
{
return
;
String
idField
=
DEFieldCacheMap
.
getDEKeyField
(
entity
.
getClass
());
Object
idValue
=
""
;
if
(!
StringUtils
.
isEmpty
(
idField
)){
}
String
idField
=
DEFieldCacheMap
.
getDEKeyField
(
entity
.
getClass
());
Object
idValue
=
""
;
if
(!
StringUtils
.
isEmpty
(
idField
))
{
idValue
=
entity
.
get
(
idField
);
}
//记录审计日志
dataAuditService
.
createAudit
(
request
,
entity
,
idValue
,
auditFields
);
dataAuditService
.
createAudit
(
request
,
entity
,
idValue
,
auditFields
);
}
}
...
...
@@ -77,39 +78,38 @@ public class AuditAspect
*/
@Around
(
"execution(* cn.ibizlab.core.*.service.*.update(..))"
)
public
Object
update
(
ProceedingJoinPoint
point
)
throws
Throwable
{
HttpServletRequest
request
=
null
;
RequestAttributes
requestAttributes
=
RequestContextHolder
.
getRequestAttributes
();
if
(
requestAttributes
!=
null
){
HttpServletRequest
request
=
null
;
RequestAttributes
requestAttributes
=
RequestContextHolder
.
getRequestAttributes
();
if
(
requestAttributes
!=
null
)
{
request
=((
ServletRequestAttributes
)
requestAttributes
).
getRequest
();
}
Object
serviceObj
=
point
.
getTarget
();
Object
args
[]=
point
.
getArgs
();
if
(
ObjectUtils
.
isEmpty
(
args
)
||
args
.
length
==
0
)
Object
serviceObj
=
point
.
getTarget
();
Object
args
[]
=
point
.
getArgs
();
if
(
ObjectUtils
.
isEmpty
(
args
)
||
args
.
length
==
0
)
{
return
point
.
proceed
();
Object
arg
=
args
[
0
];
if
(
arg
instanceof
EntityBase
){
EntityBase
entity
=
(
EntityBase
)
arg
;
Map
<
String
,
Audit
>
auditFields
=
DEFieldCacheMap
.
getAuditFields
(
entity
.
getClass
());
}
Object
arg
=
args
[
0
];
if
(
arg
instanceof
EntityBase
)
{
EntityBase
entity
=
(
EntityBase
)
arg
;
Map
<
String
,
Audit
>
auditFields
=
DEFieldCacheMap
.
getAuditFields
(
entity
.
getClass
());
//是否有审计属性
if
(
auditFields
.
size
()==
0
)
if
(
auditFields
.
size
()==
0
)
{
return
point
.
proceed
();
String
idField
=
DEFieldCacheMap
.
getDEKeyField
(
entity
.
getClass
());
Object
idValue
=
""
;
}
String
idField
=
DEFieldCacheMap
.
getDEKeyField
(
entity
.
getClass
());
Object
idValue
=
""
;
if
(!
StringUtils
.
isEmpty
(
idField
)){
idValue
=
entity
.
get
(
idField
);
idValue
=
entity
.
get
(
idField
);
}
if
(
ObjectUtils
.
isEmpty
(
idValue
))
if
(
ObjectUtils
.
isEmpty
(
idValue
))
{
return
point
.
proceed
();
}
//获取更新前实体
EntityBase
beforeEntity
=
getEntity
(
serviceObj
,
idValue
);
EntityBase
beforeEntity
=
getEntity
(
serviceObj
,
idValue
);
//执行更新操作
point
.
proceed
();
//记录审计日志
dataAuditService
.
updateAudit
(
request
,
beforeEntity
,
serviceObj
,
idValue
,
auditFields
);
dataAuditService
.
updateAudit
(
request
,
beforeEntity
,
serviceObj
,
idValue
,
auditFields
);
return
true
;
}
return
point
.
proceed
();
...
...
@@ -124,28 +124,27 @@ public class AuditAspect
*/
@Around
(
"execution(* cn.ibizlab.core.*.service.*.remove(..))"
)
public
Object
remove
(
ProceedingJoinPoint
point
)
throws
Throwable
{
HttpServletRequest
request
=
null
;
RequestAttributes
requestAttributes
=
RequestContextHolder
.
getRequestAttributes
();
if
(
requestAttributes
!=
null
)
{
request
=
((
ServletRequestAttributes
)
requestAttributes
).
getRequest
();
HttpServletRequest
request
=
null
;
RequestAttributes
requestAttributes
=
RequestContextHolder
.
getRequestAttributes
();
if
(
requestAttributes
!=
null
)
{
request
=
((
ServletRequestAttributes
)
requestAttributes
).
getRequest
();
}
Object
serviceObj
=
point
.
getTarget
();
Object
args
[]=
point
.
getArgs
();
if
(
ObjectUtils
.
isEmpty
(
args
)
||
args
.
length
==
0
)
Object
serviceObj
=
point
.
getTarget
();
Object
args
[]
=
point
.
getArgs
();
if
(
ObjectUtils
.
isEmpty
(
args
)
||
args
.
length
==
0
)
{
return
point
.
proceed
();
Object
idValue
=
args
[
0
];
EntityBase
entity
=
getEntity
(
serviceObj
,
idValue
);
Map
<
String
,
Audit
>
auditFields
=
DEFieldCacheMap
.
getAuditFields
(
entity
.
getClass
());
if
(
auditFields
.
size
()==
0
){
}
Object
idValue
=
args
[
0
];
EntityBase
entity
=
getEntity
(
serviceObj
,
idValue
);
Map
<
String
,
Audit
>
auditFields
=
DEFieldCacheMap
.
getAuditFields
(
entity
.
getClass
());
if
(
auditFields
.
size
()==
0
)
{
return
point
.
proceed
();
}
else
{
//执行删除操作
point
.
proceed
();
//记录审计日志
dataAuditService
.
removeAudit
(
request
,
entity
,
idValue
,
auditFields
);
dataAuditService
.
removeAudit
(
request
,
entity
,
idValue
,
auditFields
);
return
true
;
}
}
...
...
@@ -157,12 +156,12 @@ public class AuditAspect
* @return
*/
@SneakyThrows
private
EntityBase
getEntity
(
Object
service
,
Object
id
){
EntityBase
entity
=
null
;
if
(!
ObjectUtils
.
isEmpty
(
service
)){
private
EntityBase
getEntity
(
Object
service
,
Object
id
)
{
EntityBase
entity
=
null
;
if
(!
ObjectUtils
.
isEmpty
(
service
))
{
EvaluationContext
oldContext
=
new
StandardEvaluationContext
();
oldContext
.
setVariable
(
"service"
,
service
);
oldContext
.
setVariable
(
"id"
,
id
);
oldContext
.
setVariable
(
"service"
,
service
);
oldContext
.
setVariable
(
"id"
,
id
);
Expression
oldExp
=
parser
.
parseExpression
(
"#service.get(#id)"
);
return
oldExp
.
getValue
(
oldContext
,
EntityBase
.
class
);
}
...
...
ibzdisk-util/src/main/java/cn/ibizlab/util/aspect/DEFieldDefaultValueAspect.java
浏览文件 @
1921adde
...
...
@@ -79,29 +79,31 @@ public class DEFieldDefaultValueAspect
Object
[]
args
=
joinPoint
.
getArgs
();
if
(
args
.
length
>
0
)
{
Object
obj
=
args
[
0
];
String
actionName
=
joinPoint
.
getSignature
().
getName
();
String
actionName
=
joinPoint
.
getSignature
().
getName
();
if
(
obj
instanceof
EntityBase
)
{
Map
<
String
,
DEField
>
deFields
=
DEFieldCacheMap
.
getDEFields
(
obj
.
getClass
());
AuthenticationUser
curUser
=
AuthenticationUser
.
getAuthenticationUser
();
String
keyField
=
DEFieldCacheMap
.
getDEKeyField
(
obj
.
getClass
());
if
(
StringUtils
.
isEmpty
(
keyField
))
String
keyField
=
DEFieldCacheMap
.
getDEKeyField
(
obj
.
getClass
());
if
(
StringUtils
.
isEmpty
(
keyField
))
{
return
true
;
fillDEField
((
EntityBase
)
obj
,
deFields
,
actionName
,
curUser
,
keyField
);
}
fillDEField
((
EntityBase
)
obj
,
deFields
,
actionName
,
curUser
,
keyField
);
}
else
if
(
obj
instanceof
List
)
{
Map
<
String
,
DEField
>
deFields
=
null
;
AuthenticationUser
curUser
=
null
;
String
keyField
=
""
;
for
(
Object
item
:
(
List
)
obj
)
{
for
(
Object
item
:
(
List
)
obj
)
{
if
(
item
instanceof
EntityBase
)
{
if
(
deFields
==
null
)
{
if
(
deFields
==
null
)
{
deFields
=
DEFieldCacheMap
.
getDEFields
(
item
.
getClass
());
curUser
=
AuthenticationUser
.
getAuthenticationUser
();
keyField
=
DEFieldCacheMap
.
getDEKeyField
(
item
.
getClass
());
if
(
StringUtils
.
isEmpty
(
keyField
))
keyField
=
DEFieldCacheMap
.
getDEKeyField
(
item
.
getClass
());
if
(
StringUtils
.
isEmpty
(
keyField
))
{
return
true
;
}
}
fillDEField
((
EntityBase
)
item
,
deFields
,
actionName
,
curUser
,
keyField
);
fillDEField
((
EntityBase
)
item
,
deFields
,
actionName
,
curUser
,
keyField
);
}
}
}
...
...
@@ -115,15 +117,15 @@ public class DEFieldDefaultValueAspect
* 填充系统预置属性
* @param et 当前实体对象
*/
private
void
fillDEField
(
EntityBase
et
,
Map
<
String
,
DEField
>
deFields
,
String
actionName
,
AuthenticationUser
curUser
,
String
keyField
)
throws
Exception
{
if
(
deFields
.
size
()==
0
)
return
;
private
void
fillDEField
(
EntityBase
et
,
Map
<
String
,
DEField
>
deFields
,
String
actionName
,
AuthenticationUser
curUser
,
String
keyField
)
throws
Exception
{
if
(
deFields
.
size
()==
0
)
{
return
;
}
if
(
actionName
.
toLowerCase
().
startsWith
(
"save"
))
{
if
(
ObjectUtils
.
isEmpty
(
et
.
get
(
keyField
)))
if
(
ObjectUtils
.
isEmpty
(
et
.
get
(
keyField
)))
{
actionName
=
"create"
;
}
}
for
(
Map
.
Entry
<
String
,
DEField
>
entry
:
deFields
.
entrySet
())
{
String
fieldname
=
entry
.
getKey
();
//获取注解
...
...
@@ -136,12 +138,12 @@ public class DEFieldDefaultValueAspect
DEPredefinedFieldType
predefinedFieldType
=
fieldAnnotation
.
preType
();
//填充系统默认值
if
(
actionName
.
toLowerCase
().
startsWith
(
"create"
)
&&
(
deFieldType
!=
DEFieldDefaultValueType
.
NONE
||
(!
StringUtils
.
isEmpty
(
deFieldDefaultValue
))
))
{
if
(
actionName
.
toLowerCase
().
startsWith
(
"create"
)
&&
(
deFieldType
!=
DEFieldDefaultValueType
.
NONE
||
(!
StringUtils
.
isEmpty
(
deFieldDefaultValue
))))
{
fillFieldDefaultValue
(
fieldname
,
deFieldType
,
deFieldDefaultValue
,
et
,
curUser
)
;
}
//填充系统预置属性
if
(
predefinedFieldType
!=
DEPredefinedFieldType
.
NONE
){
fillPreFieldValue
(
fieldname
,
predefinedFieldType
,
et
,
actionName
,
fieldAnnotation
.
logicval
(),
curUser
);
if
(
predefinedFieldType
!=
DEPredefinedFieldType
.
NONE
)
{
fillPreFieldValue
(
fieldname
,
predefinedFieldType
,
et
,
actionName
,
fieldAnnotation
.
logicval
(),
curUser
);
}
}
}
...
...
@@ -154,17 +156,17 @@ public class DEFieldDefaultValueAspect
* @param et 当前实体对象
* @throws Exception
*/
private
void
fillFieldDefaultValue
(
String
fieldname
,
DEFieldDefaultValueType
deFieldType
,
String
deFieldDefaultValue
,
EntityBase
et
,
AuthenticationUser
curUser
)
throws
Exception
{
private
void
fillFieldDefaultValue
(
String
fieldname
,
DEFieldDefaultValueType
deFieldType
,
String
deFieldDefaultValue
,
EntityBase
et
,
AuthenticationUser
curUser
)
throws
Exception
{
Object
fieldValue
=
et
.
get
(
fieldname
);
if
(
org
.
springframework
.
util
.
ObjectUtils
.
isEmpty
(
fieldValue
)){
if
(
org
.
springframework
.
util
.
ObjectUtils
.
isEmpty
(
fieldValue
))
{
//填充直接值及其余默认值类型
if
(
(
deFieldType
==
DEFieldDefaultValueType
.
NONE
&&
!
StringUtils
.
isEmpty
(
deFieldDefaultValue
))
||
(
deFieldType
!=
DEFieldDefaultValueType
.
NONE
)
)
{
switch
(
deFieldType
){
if
(
(
deFieldType
==
DEFieldDefaultValueType
.
NONE
&&
!
StringUtils
.
isEmpty
(
deFieldDefaultValue
))
||
(
deFieldType
!=
DEFieldDefaultValueType
.
NONE
))
{
switch
(
deFieldType
)
{
case
SESSION:
if
(!
StringUtils
.
isEmpty
(
deFieldDefaultValue
)){
if
(!
StringUtils
.
isEmpty
(
deFieldDefaultValue
))
{
Object
sessionFieldValue
=
curUser
.
getSessionParams
().
get
(
deFieldDefaultValue
.
toLowerCase
());
if
(!
ObjectUtils
.
isEmpty
(
sessionFieldValue
)){
et
.
set
(
fieldname
,
sessionFieldValue
);
if
(!
ObjectUtils
.
isEmpty
(
sessionFieldValue
))
{
et
.
set
(
fieldname
,
sessionFieldValue
);
}
}
break
;
...
...
@@ -172,91 +174,95 @@ public class DEFieldDefaultValueAspect
//暂未实现
break
;
case
UNIQUEID:
et
.
set
(
fieldname
,(
new
AlternativeJdkIdGenerator
()).
generateId
().
toString
().
replace
(
"-"
,
""
));
et
.
set
(
fieldname
,
(
new
AlternativeJdkIdGenerator
()).
generateId
().
toString
().
replace
(
"-"
,
""
));
break
;
case
CONTEXT:
if
(!
StringUtils
.
isEmpty
(
deFieldDefaultValue
)){
if
(!
StringUtils
.
isEmpty
(
deFieldDefaultValue
))
{
Object
paramFieldValue
=
et
.
get
(
deFieldDefaultValue
);
if
(!
ObjectUtils
.
isEmpty
(
paramFieldValue
)){
et
.
set
(
fieldname
,
paramFieldValue
);
if
(!
ObjectUtils
.
isEmpty
(
paramFieldValue
))
{
et
.
set
(
fieldname
,
paramFieldValue
);
}
}
break
;
case
PARAM:
if
(!
StringUtils
.
isEmpty
(
deFieldDefaultValue
)){
if
(!
StringUtils
.
isEmpty
(
deFieldDefaultValue
))
{
Object
paramFieldValue
=
et
.
get
(
deFieldDefaultValue
);
if
(!
ObjectUtils
.
isEmpty
(
paramFieldValue
)){
et
.
set
(
fieldname
,
paramFieldValue
);
if
(!
ObjectUtils
.
isEmpty
(
paramFieldValue
))
{
et
.
set
(
fieldname
,
paramFieldValue
);
}
}
break
;
case
OPERATOR:
et
.
set
(
fieldname
,
curUser
.
getUserid
());
et
.
set
(
fieldname
,
curUser
.
getUserid
());
break
;
case
OPERATORNAME:
et
.
set
(
fieldname
,
curUser
.
getPersonname
());
et
.
set
(
fieldname
,
curUser
.
getPersonname
());
break
;
case
CURTIME:
et
.
set
(
fieldname
,
new
Timestamp
(
new
Date
().
getTime
()));
et
.
set
(
fieldname
,
new
Timestamp
(
new
Date
().
getTime
()));
break
;
case
APPDATA:
//暂未实现
break
;
case
NONE:
et
.
set
(
fieldname
,
deFieldDefaultValue
);
et
.
set
(
fieldname
,
deFieldDefaultValue
);
break
;
}
}
}
}
private
void
fillPreFieldValue
(
String
fieldname
,
DEPredefinedFieldType
preFieldType
,
EntityBase
et
,
String
actionName
,
String
logicValue
,
AuthenticationUser
curUser
)
throws
Exception
{
private
void
fillPreFieldValue
(
String
fieldname
,
DEPredefinedFieldType
preFieldType
,
EntityBase
et
,
String
actionName
,
String
logicValue
,
AuthenticationUser
curUser
)
throws
Exception
{
Object
fieldValue
=
et
.
get
(
fieldname
);
//为预置属性进行赋值
if
(
actionName
.
toLowerCase
().
startsWith
(
"create"
)
||
if
(
actionName
.
toLowerCase
().
startsWith
(
"create"
)
||
preFieldType
==
DEPredefinedFieldType
.
UPDATEDATE
||
preFieldType
==
DEPredefinedFieldType
.
UPDATEMAN
||
preFieldType
==
DEPredefinedFieldType
.
UPDATEMANNAME
){
preFieldType
==
DEPredefinedFieldType
.
UPDATEMANNAME
)
{
switch
(
preFieldType
)
{
//根据注解给预置属性填充值
switch
(
preFieldType
)
{
case
CREATEMAN:
et
.
set
(
fieldname
,
curUser
.
getUserid
());
et
.
set
(
fieldname
,
curUser
.
getUserid
());
break
;
case
CREATEMANNAME:
et
.
set
(
fieldname
,
curUser
.
getPersonname
());
et
.
set
(
fieldname
,
curUser
.
getPersonname
());
break
;
case
UPDATEMAN:
et
.
set
(
fieldname
,
curUser
.
getUserid
());
et
.
set
(
fieldname
,
curUser
.
getUserid
());
break
;
case
UPDATEMANNAME:
et
.
set
(
fieldname
,
curUser
.
getPersonname
());
et
.
set
(
fieldname
,
curUser
.
getPersonname
());
break
;
case
CREATEDATE:
et
.
set
(
fieldname
,
new
Timestamp
(
new
Date
().
getTime
()));
et
.
set
(
fieldname
,
new
Timestamp
(
new
Date
().
getTime
()));
break
;
case
UPDATEDATE:
et
.
set
(
fieldname
,
new
Timestamp
(
new
Date
().
getTime
()));
et
.
set
(
fieldname
,
new
Timestamp
(
new
Date
().
getTime
()));
break
;
case
ORGID:
if
(
org
.
springframework
.
util
.
StringUtils
.
isEmpty
(
fieldValue
))
et
.
set
(
fieldname
,
curUser
.
getOrgid
());
if
(
org
.
springframework
.
util
.
StringUtils
.
isEmpty
(
fieldValue
))
{
et
.
set
(
fieldname
,
curUser
.
getOrgid
());
}
break
;
case
ORGNAME:
if
(
org
.
springframework
.
util
.
StringUtils
.
isEmpty
(
fieldValue
))
et
.
set
(
fieldname
,
curUser
.
getOrgname
());
if
(
org
.
springframework
.
util
.
StringUtils
.
isEmpty
(
fieldValue
))
{
et
.
set
(
fieldname
,
curUser
.
getOrgname
());
}
break
;
case
ORGSECTORID:
if
(
org
.
springframework
.
util
.
StringUtils
.
isEmpty
(
fieldValue
))
et
.
set
(
fieldname
,
curUser
.
getMdeptid
());
if
(
org
.
springframework
.
util
.
StringUtils
.
isEmpty
(
fieldValue
))
{
et
.
set
(
fieldname
,
curUser
.
getMdeptid
());
}
break
;
case
ORGSECTORNAME:
if
(
org
.
springframework
.
util
.
StringUtils
.
isEmpty
(
fieldValue
))
et
.
set
(
fieldname
,
curUser
.
getMdeptname
());
if
(
org
.
springframework
.
util
.
StringUtils
.
isEmpty
(
fieldValue
))
{
et
.
set
(
fieldname
,
curUser
.
getMdeptname
());
}
break
;
case
LOGICVALID:
if
(
StringUtils
.
isEmpty
(
logicValue
)){
if
(
StringUtils
.
isEmpty
(
logicValue
))
{
logicValue
=
"1"
;
}
et
.
set
(
fieldname
,
logicValue
);
et
.
set
(
fieldname
,
logicValue
);
break
;
}
}
...
...
ibzdisk-util/src/main/java/cn/ibizlab/util/aspect/VersionCheckAspect.java
浏览文件 @
1921adde
...
...
@@ -32,55 +32,62 @@ import java.util.Map;
public
class
VersionCheckAspect
{
private
final
ExpressionParser
parser
=
new
SpelExpressionParser
();
private
final
String
IgnoreField
=
"ignoreversioncheck"
;
private
final
String
IgnoreField
=
"ignoreversioncheck"
;
@SneakyThrows
@Before
(
"execution(* cn.ibizlab.*.rest.*.update(..)) && @annotation(versionCheck)"
)
public
void
BeforeUpdate
(
JoinPoint
point
,
VersionCheck
versionCheck
){
public
void
BeforeUpdate
(
JoinPoint
point
,
VersionCheck
versionCheck
)
{
Object
[]
args
=
point
.
getArgs
();
Object
id
=
args
[
0
];
Object
dto
=
args
[
1
];
if
(
ObjectUtils
.
isEmpty
(
id
)
||
ObjectUtils
.
isEmpty
(
dto
))
Object
id
=
args
[
0
];
Object
dto
=
args
[
1
];
if
(
ObjectUtils
.
isEmpty
(
id
)
||
ObjectUtils
.
isEmpty
(
dto
))
{
return
;
String
versionField
=
versionCheck
.
versionfield
();
if
(
StringUtils
.
isEmpty
(
versionField
))
}
String
versionField
=
versionCheck
.
versionfield
();
if
(
StringUtils
.
isEmpty
(
versionField
))
{
return
;
versionCheck
(
versionCheck
,
point
.
getTarget
(),
dto
,
id
);
}
versionCheck
(
versionCheck
,
point
.
getTarget
(),
dto
,
id
);
}
@SneakyThrows
@Before
(
"execution(* cn.ibizlab.*.rest.*.updateBy*(..)) && @annotation(versionCheck)"
)
public
void
BeforeUpdateBy
(
JoinPoint
point
,
VersionCheck
versionCheck
){
public
void
BeforeUpdateBy
(
JoinPoint
point
,
VersionCheck
versionCheck
)
{
Object
[]
args
=
point
.
getArgs
();
if
(
args
.
length
>=
2
){
Object
id
=
args
[
args
.
length
-
2
];
Object
dto
=
args
[
args
.
length
-
1
];
if
(
ObjectUtils
.
isEmpty
(
id
)
||
ObjectUtils
.
isEmpty
(
dto
))
if
(
args
.
length
>=
2
)
{
Object
id
=
args
[
args
.
length
-
2
];
Object
dto
=
args
[
args
.
length
-
1
];
if
(
ObjectUtils
.
isEmpty
(
id
)
||
ObjectUtils
.
isEmpty
(
dto
))
{
return
;
String
versionField
=
versionCheck
.
versionfield
();
if
(
StringUtils
.
isEmpty
(
versionField
))
}
String
versionField
=
versionCheck
.
versionfield
();
if
(
StringUtils
.
isEmpty
(
versionField
))
{
return
;
versionCheck
(
versionCheck
,
point
.
getTarget
(),
dto
,
id
);
}
versionCheck
(
versionCheck
,
point
.
getTarget
(),
dto
,
id
);
}
}
private
void
versionCheck
(
VersionCheck
versionCheck
,
Object
resource
,
Object
dto
,
Object
id
)
{
private
void
versionCheck
(
VersionCheck
versionCheck
,
Object
resource
,
Object
dto
,
Object
id
)
{
EvaluationContext
context
=
new
StandardEvaluationContext
();
context
.
setVariable
(
"dto"
,
dto
);
context
.
setVariable
(
"dto"
,
dto
);
//忽略版本检查
Expression
dtoParamsExp
=
parser
.
parseExpression
(
"#dto.extensionparams"
);
Map
dtoParam
=
dtoParamsExp
.
getValue
(
context
,
Map
.
class
);
if
(!
ObjectUtils
.
isEmpty
(
dtoParam
)
&&
!
ObjectUtils
.
isEmpty
(
dtoParam
.
get
(
IgnoreField
))
&&
dtoParam
.
get
(
IgnoreField
).
equals
(
1
))
Map
dtoParam
=
dtoParamsExp
.
getValue
(
context
,
Map
.
class
);
if
(!
ObjectUtils
.
isEmpty
(
dtoParam
)
&&
!
ObjectUtils
.
isEmpty
(
dtoParam
.
get
(
IgnoreField
))
&&
dtoParam
.
get
(
IgnoreField
).
equals
(
1
))
{
return
;
Expression
newExp
=
parser
.
parseExpression
(
String
.
format
(
"#dto.%s"
,
versionCheck
.
versionfield
()));
Object
newVersion
=
newExp
.
getValue
(
context
);
if
(
ObjectUtils
.
isEmpty
(
newVersion
))
}
Expression
newExp
=
parser
.
parseExpression
(
String
.
format
(
"#dto.%s"
,
versionCheck
.
versionfield
()));
Object
newVersion
=
newExp
.
getValue
(
context
);
if
(
ObjectUtils
.
isEmpty
(
newVersion
))
{
return
;
}
//进行版本检查
Object
oldVersion
=
getDBVersion
(
versionCheck
,
getService
(
resource
,
versionCheck
.
entity
()),
id
);
if
(!
ObjectUtils
.
isEmpty
(
oldVersion
)){
if
(
RuleUtils
.
gt
(
newVersion
,
oldVersion
))
throw
new
BadRequestAlertException
(
"数据已变更,可能后台数据已被修改,请重新加载数据"
,
"VersionCheckAspect"
,
"versionCheck"
);
Object
oldVersion
=
getDBVersion
(
versionCheck
,
getService
(
resource
,
versionCheck
.
entity
()),
id
);
if
(!
ObjectUtils
.
isEmpty
(
oldVersion
))
{
if
(
RuleUtils
.
gt
(
newVersion
,
oldVersion
))
{
throw
new
BadRequestAlertException
(
"数据已变更,可能后台数据已被修改,请重新加载数据"
,
"VersionCheckAspect"
,
"versionCheck"
);
}
}
}
...
...
@@ -91,12 +98,12 @@ public class VersionCheckAspect
* @return
*/
@SneakyThrows
private
Object
getService
(
Object
resource
,
String
entity
)
{
private
Object
getService
(
Object
resource
,
String
entity
)
{
Object
service
=
null
;
Field
[]
fields
=
resource
.
getClass
().
getDeclaredFields
();
for
(
Field
field
:
fields
){
if
(
field
.
getModifiers
()==
1
&&
field
.
getName
().
equalsIgnoreCase
(
String
.
format
(
"%sService"
,
entity
))){
service
=
field
.
get
(
resource
);
Field
[]
fields
=
resource
.
getClass
().
getDeclaredFields
();
for
(
Field
field
:
fields
)
{
if
(
field
.
getModifiers
()==
1
&&
field
.
getName
().
equalsIgnoreCase
(
String
.
format
(
"%sService"
,
entity
)))
{
service
=
field
.
get
(
resource
);
break
;
}
}
...
...
@@ -111,21 +118,21 @@ public class VersionCheckAspect
* @return
*/
@SneakyThrows
private
Object
getDBVersion
(
VersionCheck
versionCheck
,
Object
service
,
Object
id
)
{
private
Object
getDBVersion
(
VersionCheck
versionCheck
,
Object
service
,
Object
id
)
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
Timestamp
dbVersion
=
null
;
String
versionField
=
versionCheck
.
versionfield
();
if
(!
ObjectUtils
.
isEmpty
(
service
)){
Timestamp
dbVersion
=
null
;
String
versionField
=
versionCheck
.
versionfield
();
if
(!
ObjectUtils
.
isEmpty
(
service
))
{
EvaluationContext
oldContext
=
new
StandardEvaluationContext
();
oldContext
.
setVariable
(
"service"
,
service
);
oldContext
.
setVariable
(
"id"
,
id
);
oldContext
.
setVariable
(
"service"
,
service
);
oldContext
.
setVariable
(
"id"
,
id
);
Expression
oldExp
=
parser
.
parseExpression
(
"#service.get(#id)"
);
EntityBase
oldEntity
=
oldExp
.
getValue
(
oldContext
,
EntityBase
.
class
);
Object
oldDate
=
oldEntity
.
get
(
versionField
);
if
(
oldDate
!=
null
&&
oldDate
instanceof
Timestamp
){
Timestamp
db_time
=
(
Timestamp
)
oldDate
;
EntityBase
oldEntity
=
oldExp
.
getValue
(
oldContext
,
EntityBase
.
class
);
Object
oldDate
=
oldEntity
.
get
(
versionField
);
if
(
oldDate
!=
null
&&
oldDate
instanceof
Timestamp
)
{
Timestamp
db_time
=
(
Timestamp
)
oldDate
;
Date
db_date
=
sdf
.
parse
(
sdf
.
format
(
db_time
));
dbVersion
=
new
Timestamp
(
db_date
.
getTime
());
dbVersion
=
new
Timestamp
(
db_date
.
getTime
());
}
}
return
dbVersion
;
...
...
ibzdisk-util/src/main/java/cn/ibizlab/util/domain/DTOBase.java
浏览文件 @
1921adde
...
...
@@ -21,33 +21,39 @@ public class DTOBase implements Serializable {
public
void
modify
(
String
field
,
Object
val
)
{
if
(
val
==
null
)
if
(
val
==
null
)
{
this
.
getFocusNull
(
true
).
add
(
field
.
toLowerCase
());
else
}
else
{
this
.
getFocusNull
(
true
).
remove
(
field
.
toLowerCase
());
}
}
public
Set
<
String
>
getFocusNull
()
{
if
(
focusNull
==
null
)
if
(
focusNull
==
null
)
{
focusNull
=
new
HashSet
<>();
}
if
(
focusNull
.
size
()>
0
&&
extensionparams
.
containsKey
(
"dirtyflagenable"
))
{
Set
<
String
>
nocheck
=
new
HashSet
<>();
for
(
String
key:
focusNull
)
{
if
(!
extensionparams
.
containsKey
(
key
+
"dirtyflag"
))
if
(!
extensionparams
.
containsKey
(
key
+
"dirtyflag"
))
{
nocheck
.
add
(
key
);
}
}
for
(
String
key:
nocheck
)
for
(
String
key:
nocheck
)
{
focusNull
.
remove
(
key
);
}
}
return
focusNull
;
}
private
Set
<
String
>
getFocusNull
(
boolean
newflag
)
{
if
(
focusNull
==
null
)
if
(
focusNull
==
null
)
{
focusNull
=
new
HashSet
<>();
}
return
focusNull
;
}
...
...
ibzdisk-util/src/main/java/cn/ibizlab/util/domain/EntityBase.java
浏览文件 @
1921adde
...
...
@@ -24,8 +24,9 @@ public class EntityBase implements Serializable {
private
Set
<
String
>
focusNull
;
public
Set
<
String
>
getFocusNull
()
{
if
(
focusNull
==
null
)
if
(
focusNull
==
null
)
{
focusNull
=
new
HashSet
<>();
}
return
focusNull
;
}
...
...
@@ -50,8 +51,9 @@ public class EntityBase implements Serializable {
private
BeanMap
getMap
()
{
if
(
map
==
null
)
map
=
BeanMap
.
create
(
this
);
if
(
map
==
null
)
{
map
=
BeanMap
.
create
(
this
);
}
return
map
;
}
...
...
@@ -68,17 +70,16 @@ public class EntityBase implements Serializable {
this
.
extensionparams
=
extensionparams
;
}
public
Object
get
(
String
field
)
{
String
fieldRealName
=
DEFieldCacheMap
.
getFieldRealName
(
this
.
getClass
(),
field
);
if
(!
StringUtils
.
isEmpty
(
fieldRealName
))
if
(!
StringUtils
.
isEmpty
(
fieldRealName
))
{
return
getMap
().
get
(
fieldRealName
);
else
}
else
{
return
this
.
extensionparams
.
get
(
field
.
toLowerCase
());
}
}
@JsonAnyGetter
public
Map
<
String
,
Object
>
any
()
{
return
extensionparams
;
...
...
@@ -89,13 +90,16 @@ public class EntityBase implements Serializable {
field
=
field
.
toLowerCase
();
String
fieldRealName
=
DEFieldCacheMap
.
getFieldRealName
(
this
.
getClass
(),
field
);
if
(!
StringUtils
.
isEmpty
(
fieldRealName
))
{
if
(
value
==
null
)
if
(
value
==
null
)
{
getMap
().
put
(
fieldRealName
,
null
);
else
}
else
{
getMap
().
put
(
fieldRealName
,
DEFieldCacheMap
.
fieldValueOf
(
this
.
getClass
(),
fieldRealName
,
value
));
}
}
else
else
{
this
.
extensionparams
.
put
(
field
.
toLowerCase
(),
value
);
}
}
/**
...
...
ibzdisk-util/src/main/java/cn/ibizlab/util/domain/EntityMP.java
浏览文件 @
1921adde
...
...
@@ -5,24 +5,25 @@ import org.springframework.util.StringUtils;
public
class
EntityMP
extends
EntityBase
{
public
UpdateWrapper
getUpdateWrapper
(
boolean
clean
)
{
UpdateWrapper
wrapper
=
new
UpdateWrapper
();
for
(
String
nullField:
getFocusNull
())
{
wrapper
.
set
(
nullField
,
null
);
}
if
(
clean
)
if
(
clean
)
{
getFocusNull
().
clear
();
}
return
wrapper
;
}
@Override
public
void
modify
(
String
field
,
Object
val
)
{
if
(
val
==
null
)
if
(
val
==
null
)
{
this
.
getFocusNull
().
add
(
field
.
toLowerCase
());
else
}
else
{
this
.
getFocusNull
().
remove
(
field
.
toLowerCase
());
}
}
@Override
...
...
@@ -33,6 +34,5 @@ public class EntityMP extends EntityBase {
getFocusNull
().
remove
(
resetField
);
}
}
}
ibzdisk-util/src/main/java/cn/ibizlab/util/domain/EntityMongo.java
浏览文件 @
1921adde
...
...
@@ -2,7 +2,5 @@ package cn.ibizlab.util.domain;
public
class
EntityMongo
extends
EntityBase
{
}
ibzdisk-util/src/main/java/cn/ibizlab/util/filter/QueryBuildContext.java
浏览文件 @
1921adde
...
...
@@ -44,9 +44,9 @@ public class QueryBuildContext extends SearchContextBase implements ISearchConte
*/
private
QueryBuilder
parseQueryFilter
(
QueryFilter
queryFilter
){
if
(
ObjectUtils
.
isEmpty
(
queryFilter
.
get
$and
())
&&
ObjectUtils
.
isEmpty
(
queryFilter
.
get
$or
())
&&
ObjectUtils
.
isEmpty
(
queryFilter
.
any
()))
if
(
ObjectUtils
.
isEmpty
(
queryFilter
.
get
$and
())
&&
ObjectUtils
.
isEmpty
(
queryFilter
.
get
$or
())
&&
ObjectUtils
.
isEmpty
(
queryFilter
.
any
()))
{
return
null
;
}
QueryBuilder
rsBuilder
=
QueryBuilder
.
start
();
QueryBuilder
fieldBuilder
=
parseFieldMap
(
queryFilter
.
any
());
QueryBuilder
orBuilder
=
parseOrQueryFilter
(
queryFilter
.
get
$or
());
...
...
@@ -107,8 +107,9 @@ public class QueryBuildContext extends SearchContextBase implements ISearchConte
* @return
*/
private
QueryBuilder
parseFieldMap
(
Map
<
String
,
QueryFilter
.
SegmentCond
>
fieldMap
)
{
if
(
fieldMap
.
size
()==
0
)
if
(
fieldMap
.
size
()==
0
)
{
return
null
;
}
QueryBuilder
fieldBuilders
=
QueryBuilder
.
start
();
for
(
Map
.
Entry
<
String
,
QueryFilter
.
SegmentCond
>
entry:
fieldMap
.
entrySet
()){
getSegmentCondSql
(
entry
.
getKey
(),
entry
.
getValue
(),
fieldBuilders
);
...
...
ibzdisk-util/src/main/java/cn/ibizlab/util/filter/QueryFilter.java
浏览文件 @
1921adde
...
...
@@ -63,8 +63,9 @@ public class QueryFilter {
private
Map
<
String
,
SegmentCond
>
getMap
()
{
if
(
map
==
null
)
if
(
map
==
null
)
{
map
=
new
LinkedHashMap
<>();
}
return
map
;
}
...
...
@@ -132,11 +133,12 @@ public class QueryFilter {
}
private
QueryFilter
op
(
String
column
,
SegmentCond
segmentCond
)
{
if
(
this
.
getMap
().
containsKey
(
column
))
if
(
this
.
getMap
().
containsKey
(
column
))
{
((
SegmentCond
)
this
.
getMap
().
get
(
column
)).
getMap
().
putAll
(
segmentCond
.
getMap
());
else
}
else
{
this
.
getMap
().
put
(
column
,
segmentCond
);
}
return
this
;
}
...
...
@@ -155,8 +157,9 @@ public class QueryFilter {
private
Map
<
String
,
Object
>
getMap
()
{
if
(
map
==
null
)
if
(
map
==
null
)
{
map
=
new
LinkedHashMap
<>();
}
return
map
;
}
...
...
ibzdisk-util/src/main/java/cn/ibizlab/util/filter/QueryWrapperContext.java
浏览文件 @
1921adde
...
...
@@ -37,17 +37,20 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch
int
pageSize
=
getPageable
().
getPageSize
();
//构造mybatis-plus分页
if
(
StringUtils
.
isEmpty
(
currentPage
)
||
StringUtils
.
isEmpty
(
pageSize
))
if
(
StringUtils
.
isEmpty
(
currentPage
)
||
StringUtils
.
isEmpty
(
pageSize
))
{
page
=
new
Page
(
1
,
Short
.
MAX_VALUE
);
else
}
else
{
page
=
new
Page
(
currentPage
+
1
,
pageSize
);
}
//构造mybatis-plus排序
Sort
sort
=
getPageable
().
getSort
();
Iterator
<
Sort
.
Order
>
it_sort
=
sort
.
iterator
();
if
(
ObjectUtils
.
isEmpty
(
it_sort
))
if
(
ObjectUtils
.
isEmpty
(
it_sort
))
{
return
page
;
}
ParameterizedType
parameterizedType
=
(
ParameterizedType
)
getClass
().
getGenericSuperclass
();
Class
<
T
>
type
=
(
Class
<
T
>)
parameterizedType
.
getActualTypeArguments
()[
0
];
...
...
@@ -95,9 +98,9 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch
* @return
*/
private
Consumer
<
QueryWrapper
<
T
>>
parseQueryFilter
(
QueryFilter
queryFilter
){
if
(
queryFilter
.
any
().
size
()==
0
&&
queryFilter
.
get
$or
()==
null
&&
queryFilter
.
get
$and
()==
null
)
return
null
;
if
(
queryFilter
.
any
().
size
()==
0
&&
queryFilter
.
get
$or
()==
null
&&
queryFilter
.
get
$and
()==
null
)
{
return
null
;
}
Consumer
<
QueryWrapper
<
T
>>
consumer
=
queryWrapper
->
{
Consumer
fieldConsumer
=
parseFieldMap
(
queryFilter
.
any
());
Consumer
orConsumer
=
parseOrQueryFilter
(
queryFilter
.
get
$or
());
...
...
@@ -121,7 +124,6 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch
* @return
*/
private
Consumer
<
QueryWrapper
<
T
>>
parseOrQueryFilter
(
List
<
QueryFilter
>
queryFilters
)
{
if
(
queryFilters
==
null
||
queryFilters
.
size
()==
0
)
return
null
;
Consumer
<
QueryWrapper
<
T
>>
consumer
=
queryWrapper
->
{
...
...
@@ -139,10 +141,10 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch
* @return
*/
private
Consumer
<
QueryWrapper
<
T
>>
parseAndQueryFilter
(
List
<
QueryFilter
>
queryFilters
)
{
if
(
queryFilters
==
null
||
queryFilters
.
size
()==
0
)
if
(
queryFilters
==
null
||
queryFilters
.
size
()==
0
)
{
return
null
;
Consumer
<
QueryWrapper
<
T
>>
consumer
=
queryWrapper
->
{
}
Consumer
<
QueryWrapper
<
T
>>
consumer
=
queryWrapper
->
{
for
(
QueryFilter
queryFilter:
queryFilters
){
Consumer
tempQueryWrapper
=
parseQueryFilter
(
queryFilter
);
queryWrapper
.
and
(
tempQueryWrapper
);
...
...
@@ -157,9 +159,9 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch
* @return
*/
private
Consumer
<
QueryWrapper
<
T
>>
parseFieldMap
(
Map
<
String
,
QueryFilter
.
SegmentCond
>
fieldMap
)
{
if
(
fieldMap
.
size
()==
0
)
if
(
fieldMap
.
size
()==
0
)
{
return
null
;
}
Consumer
<
QueryWrapper
<
T
>>
consumer
=
queryWrapper
->
{
for
(
Map
.
Entry
<
String
,
QueryFilter
.
SegmentCond
>
field:
fieldMap
.
entrySet
()){
String
fieldName
=
field
.
getKey
();
...
...
ibzdisk-util/src/main/java/cn/ibizlab/util/filter/SearchContextBase.java
浏览文件 @
1921adde
...
...
@@ -98,10 +98,12 @@ public class SearchContextBase implements ISearchContext{
* @return
*/
public
Pageable
getPageable
()
{
if
(
ObjectUtils
.
isEmpty
(
pageSort
))
return
PageRequest
.
of
(
page
,
size
);
else
return
PageRequest
.
of
(
page
,
size
,
pageSort
);
if
(
ObjectUtils
.
isEmpty
(
pageSort
))
{
return
PageRequest
.
of
(
page
,
size
);
}
else
{
return
PageRequest
.
of
(
page
,
size
,
pageSort
);
}
}
/**
...
...
ibzdisk-util/src/main/java/cn/ibizlab/util/helper/CachedBeanCopier.java
浏览文件 @
1921adde
...
...
@@ -13,8 +13,9 @@ public class CachedBeanCopier {
}
public
static
void
copy
(
Object
srcObj
,
Object
destObj
,
boolean
useConverter
)
{
if
(
srcObj
==
null
||
destObj
==
null
)
if
(
srcObj
==
null
||
destObj
==
null
)
{
return
;
}
getCopier
(
srcObj
,
destObj
,
useConverter
).
copy
(
srcObj
,
destObj
,
null
);
}
...
...
@@ -29,6 +30,4 @@ public class CachedBeanCopier {
}
return
copier
;
}
}
ibzdisk-util/src/main/java/cn/ibizlab/util/helper/DEFieldCacheMap.java
浏览文件 @
1921adde
...
...
@@ -36,13 +36,16 @@ public class DEFieldCacheMap {
*/
public
static
<
T
>
Hashtable
<
String
,
Field
>
getFieldMap
(
Class
<
T
>
clazz
)
{
String
className
=
clazz
.
getName
();
if
(
className
.
indexOf
(
"_$"
)>
0
)
className
=
className
.
substring
(
0
,
className
.
lastIndexOf
(
"_$"
));
if
(
cacheMap
.
containsKey
(
className
))
return
cacheMap
.
get
(
className
);
if
(
className
.
indexOf
(
"_$"
)>
0
)
{
className
=
className
.
substring
(
0
,
className
.
lastIndexOf
(
"_$"
));
}
if
(
cacheMap
.
containsKey
(
className
))
{
return
cacheMap
.
get
(
className
);
}
synchronized
(
objLock1
)
{
if
(
cacheMap
.
containsKey
(
className
))
return
cacheMap
.
get
(
className
);
if
(
cacheMap
.
containsKey
(
className
))
{
return
cacheMap
.
get
(
className
);
}
Hashtable
<
String
,
Field
>
result
=
new
Hashtable
<
String
,
Field
>();
List
<
Field
>
list
=
new
ArrayList
<
Field
>();
Hashtable
<
String
,
String
>
keys
=
new
Hashtable
<
String
,
String
>();
...
...
@@ -58,8 +61,9 @@ public class DEFieldCacheMap {
Audit
auditField
=
field
.
getAnnotation
(
Audit
.
class
);
if
(!
ObjectUtils
.
isEmpty
(
deField
))
{
defields
.
put
(
field
.
getName
(),
deField
);
if
(
deField
.
isKeyField
())
cacheDEKeyField
.
put
(
className
,
field
.
getName
());
if
(
deField
.
isKeyField
())
{
cacheDEKeyField
.
put
(
className
,
field
.
getName
());
}
}
if
(!
ObjectUtils
.
isEmpty
(
auditField
))
{
auditfields
.
put
(
field
.
getName
(),
auditField
);
...
...
@@ -74,10 +78,12 @@ public class DEFieldCacheMap {
}
}
public
static
Hashtable
<
String
,
Field
>
getFieldMap
(
String
className
)
{
if
(
className
.
indexOf
(
"_$"
)>
0
)
className
=
className
.
substring
(
0
,
className
.
lastIndexOf
(
"_$"
));
if
(
cacheMap
.
containsKey
(
className
))
return
cacheMap
.
get
(
className
);
if
(
className
.
indexOf
(
"_$"
)>
0
)
{
className
=
className
.
substring
(
0
,
className
.
lastIndexOf
(
"_$"
));
}
if
(
cacheMap
.
containsKey
(
className
))
{
return
cacheMap
.
get
(
className
);
}
Class
clazz
=
null
;
try
{
clazz
=
Class
.
forName
(
className
);
...
...
@@ -96,10 +102,12 @@ public class DEFieldCacheMap {
*/
public
static
<
T
>
Hashtable
<
String
,
DEField
>
getDEFields
(
Class
<
T
>
clazz
)
{
String
className
=
clazz
.
getName
();
if
(
className
.
indexOf
(
"_$"
)>
0
)
if
(
className
.
indexOf
(
"_$"
)>
0
)
{
className
=
className
.
substring
(
0
,
className
.
lastIndexOf
(
"_$"
));
if
(
cacheDEField
.
containsKey
(
className
))
}
if
(
cacheDEField
.
containsKey
(
className
))
{
return
cacheDEField
.
get
(
className
);
}
else
{
DEFieldCacheMap
.
getFieldMap
(
className
);
return
cacheDEField
.
get
(
className
);
...
...
@@ -113,10 +121,12 @@ public class DEFieldCacheMap {
*/
public
static
<
T
>
Hashtable
<
String
,
Audit
>
getAuditFields
(
Class
<
T
>
clazz
)
{
String
className
=
clazz
.
getName
();
if
(
className
.
indexOf
(
"_$"
)>
0
)
if
(
className
.
indexOf
(
"_$"
)>
0
)
{
className
=
className
.
substring
(
0
,
className
.
lastIndexOf
(
"_$"
));
if
(
cacheAuditField
.
containsKey
(
className
))
}
if
(
cacheAuditField
.
containsKey
(
className
))
{
return
cacheAuditField
.
get
(
className
);
}
else
{
DEFieldCacheMap
.
getFieldMap
(
className
);
return
cacheAuditField
.
get
(
className
);
...
...
@@ -130,10 +140,12 @@ public class DEFieldCacheMap {
*/
public
static
<
T
>
String
getDEKeyField
(
Class
<
T
>
clazz
)
{
String
className
=
clazz
.
getName
();
if
(
className
.
indexOf
(
"_$"
)>
0
)
if
(
className
.
indexOf
(
"_$"
)>
0
)
{
className
=
className
.
substring
(
0
,
className
.
lastIndexOf
(
"_$"
));
if
(
cacheDEKeyField
.
containsKey
(
className
))
}
if
(
cacheDEKeyField
.
containsKey
(
className
))
{
return
cacheDEKeyField
.
get
(
className
);
}
else
{
DEFieldCacheMap
.
getFieldMap
(
className
);
return
cacheDEKeyField
.
get
(
className
);
...
...
@@ -148,10 +160,12 @@ public class DEFieldCacheMap {
*/
public
static
<
T
>
List
<
Field
>
getFields
(
Class
<
T
>
clazz
)
{
String
className
=
clazz
.
getName
();
if
(
className
.
indexOf
(
"_$"
)>
0
)
if
(
className
.
indexOf
(
"_$"
)>
0
)
{
className
=
className
.
substring
(
0
,
className
.
lastIndexOf
(
"_$"
));
if
(
cacheList
.
containsKey
(
className
))
}
if
(
cacheList
.
containsKey
(
className
))
{
return
cacheList
.
get
(
className
);
}
else
{
DEFieldCacheMap
.
getFieldMap
(
className
);
return
cacheList
.
get
(
className
);
...
...
@@ -159,10 +173,12 @@ public class DEFieldCacheMap {
}
public
static
List
<
Field
>
getFields
(
String
className
)
{
if
(
className
.
indexOf
(
"_$"
)>
0
)
if
(
className
.
indexOf
(
"_$"
)>
0
)
{
className
=
className
.
substring
(
0
,
className
.
lastIndexOf
(
"_$"
));
if
(
cacheList
.
containsKey
(
className
))
}
if
(
cacheList
.
containsKey
(
className
))
{
return
cacheList
.
get
(
className
);
}
else
{
DEFieldCacheMap
.
getFieldMap
(
className
);
return
cacheList
.
get
(
className
);
...
...
@@ -176,10 +192,12 @@ public class DEFieldCacheMap {
*/
public
static
<
T
>
Hashtable
<
String
,
String
>
getFieldKeys
(
Class
<
T
>
clazz
)
{
String
className
=
clazz
.
getName
();
if
(
className
.
indexOf
(
"_$"
)>
0
)
if
(
className
.
indexOf
(
"_$"
)>
0
)
{
className
=
className
.
substring
(
0
,
className
.
lastIndexOf
(
"_$"
));
if
(
cacheKey
.
containsKey
(
className
))
}
if
(
cacheKey
.
containsKey
(
className
))
{
return
cacheKey
.
get
(
className
);
}
else
{
DEFieldCacheMap
.
getFieldMap
(
className
);
return
cacheKey
.
get
(
className
);
...
...
@@ -189,20 +207,25 @@ public class DEFieldCacheMap {
public
static
<
T
>
String
getFieldRealName
(
Class
<
T
>
clazz
,
String
fieldname
)
{
fieldname
=
fieldname
.
toLowerCase
();
Hashtable
<
String
,
String
>
keys
=
DEFieldCacheMap
.
getFieldKeys
(
clazz
);
if
(
keys
.
containsKey
(
fieldname
))
if
(
keys
.
containsKey
(
fieldname
))
{
return
keys
.
get
(
fieldname
);
else
if
(
keys
.
containsKey
(
fieldname
.
replace
(
"_"
,
""
)))
}
else
if
(
keys
.
containsKey
(
fieldname
.
replace
(
"_"
,
""
)))
{
return
keys
.
get
(
fieldname
.
replace
(
"_"
,
""
));
else
}
else
{
return
""
;
}
}
public
static
<
T
>
Field
getField
(
Class
<
T
>
clazz
,
String
fieldname
)
{
String
fieldRealName
=
DEFieldCacheMap
.
getFieldRealName
(
clazz
,
fieldname
);
if
(!
StringUtils
.
isEmpty
(
fieldRealName
))
if
(!
StringUtils
.
isEmpty
(
fieldRealName
))
{
return
DEFieldCacheMap
.
getFieldMap
(
clazz
).
get
(
fieldRealName
);
else
}
else
{
return
null
;
}
}
public
static
<
T
>
String
getFieldColumnName
(
Class
<
T
>
clazz
,
String
fieldname
)
{
...
...
@@ -226,6 +249,4 @@ public class DEFieldCacheMap {
}
return
resultValue
;
}
}
\ No newline at end of file
ibzdisk-util/src/main/java/cn/ibizlab/util/helper/DataObject.java
浏览文件 @
1921adde
...
...
@@ -19,30 +19,34 @@ public class DataObject {
final
static
public
DateFormat
dayFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
final
static
public
String
getStringValue
(
Object
objValue
,
String
strDefault
)
{
if
(
objValue
==
null
)
return
strDefault
;
if
(
objValue
instanceof
String
)
return
(
String
)
objValue
;
if
(
objValue
==
null
)
{
return
strDefault
;
}
if
(
objValue
instanceof
String
)
{
return
(
String
)
objValue
;
}
if
(
objValue
instanceof
java
.
sql
.
Timestamp
||
objValue
instanceof
java
.
sql
.
Date
||
objValue
instanceof
java
.
util
.
Date
)
{
String
rt
=
datetimeFormat
.
format
(
objValue
);
if
(
rt
.
endsWith
(
" 00:00:00"
))
if
(
rt
.
endsWith
(
" 00:00:00"
))
{
rt
=
dayFormat
.
format
(
objValue
);
else
if
(
rt
.
endsWith
(
":00"
))
}
else
if
(
rt
.
endsWith
(
":00"
))
{
rt
=
datetimeFormat2
.
format
(
objValue
);
}
return
rt
;
}
return
objValue
.
toString
();
}
public
static
<
T
>
Object
objectValueOf
(
Class
<
T
>
type
,
Object
fieldValue
)
{
if
(
fieldValue
==
null
)
if
(
fieldValue
==
null
)
{
return
null
;
}
Object
resultValue
=
fieldValue
;
String
targetType
=
type
.
getSimpleName
();
if
(
targetType
.
equalsIgnoreCase
(
fieldValue
.
getClass
().
getSimpleName
()))
if
(
targetType
.
equalsIgnoreCase
(
fieldValue
.
getClass
().
getSimpleName
()))
{
return
resultValue
;
}
if
(
targetType
.
equals
(
"Boolean"
)){
resultValue
=
getBooleanValue
(
fieldValue
,
false
);
}
...
...
@@ -79,10 +83,9 @@ public class DataObject {
else
if
(
targetType
.
equals
(
"String"
))
{
resultValue
=
getStringValue
(
fieldValue
,
null
);
}
if
(
resultValue
==
null
)
if
(
resultValue
==
null
)
{
return
null
;
}
return
resultValue
;
}
...
...
@@ -95,8 +98,9 @@ public class DataObject {
if
(
objValue
==
null
)
{
return
jDefault
;
}
if
(
objValue
instanceof
JSONObject
)
if
(
objValue
instanceof
JSONObject
)
{
return
(
JSONObject
)
objValue
;
}
String
strValue
=
objValue
.
toString
();
try
{
return
JSONObject
.
parseObject
(
strValue
);
...
...
@@ -111,8 +115,9 @@ public class DataObject {
if
(
objValue
==
null
)
{
return
jDefault
;
}
if
(
objValue
instanceof
JSONArray
)
if
(
objValue
instanceof
JSONArray
)
{
return
(
JSONArray
)
objValue
;
}
String
strValue
=
objValue
.
toString
();
try
{
return
JSONArray
.
parseArray
(
strValue
);
...
...
@@ -133,8 +138,9 @@ public class DataObject {
List
<
String
>
chk1
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
arr
.
size
();
i
++)
{
if
(
arr
.
get
(
i
)
instanceof
String
)
if
(
arr
.
get
(
i
)
instanceof
String
)
{
chk1
.
add
(
arr
.
getString
(
i
));
}
}
return
chk1
;
}
...
...
@@ -146,8 +152,9 @@ public class DataObject {
}
final
static
public
Boolean
getBooleanValue
(
Object
objValue
,
Boolean
bDefault
)
{
if
(
objValue
==
null
)
return
bDefault
;
if
(
objValue
==
null
)
{
return
bDefault
;
}
if
(
objValue
instanceof
Boolean
)
{
return
(
Boolean
)
objValue
;
}
...
...
@@ -155,20 +162,24 @@ public class DataObject {
}
final
static
public
char
[]
getCharacterValue
(
Object
objValue
,
char
[]
cDefault
)
{
if
(
objValue
==
null
)
return
cDefault
;
if
(
objValue
==
null
)
{
return
cDefault
;
}
return
objValue
.
toString
().
toCharArray
();
}
final
static
public
Double
getDoubleValue
(
Object
objValue
,
Double
dDefault
)
{
if
(
objValue
==
null
)
return
dDefault
;
if
(
objValue
==
null
)
{
return
dDefault
;
}
if
(
objValue
instanceof
Double
)
{
return
(
Double
)
objValue
;
}
String
strValue
=
objValue
.
toString
();
if
(
StringUtils
.
isEmpty
(
strValue
))
return
null
;
if
(
StringUtils
.
isEmpty
(
strValue
))
{
return
null
;
}
strValue
=
strValue
.
replace
(
","
,
""
);
return
Double
.
parseDouble
(
strValue
);
}
...
...
@@ -179,8 +190,9 @@ public class DataObject {
return
nDefault
;
}
if
(
objValue
instanceof
Integer
)
if
(
objValue
instanceof
Integer
)
{
return
(
Integer
)
objValue
;
}
if
(
objValue
instanceof
Double
)
{
return
((
Double
)
objValue
).
intValue
();
...
...
@@ -191,8 +203,9 @@ public class DataObject {
}
String
strValue
=
objValue
.
toString
();
if
(
StringUtils
.
isEmpty
(
strValue
))
if
(
StringUtils
.
isEmpty
(
strValue
))
{
return
nDefault
;
}
strValue
=
strValue
.
replace
(
","
,
""
);
return
Integer
.
parseInt
(
strValue
);
}
...
...
@@ -204,12 +217,13 @@ public class DataObject {
}
try
{
if
(
objValue
instanceof
Float
)
if
(
objValue
instanceof
Float
)
{
return
(
Float
)
objValue
;
}
String
strValue
=
objValue
.
toString
();
if
(
StringUtils
.
isEmpty
(
strValue
))
if
(
StringUtils
.
isEmpty
(
strValue
))
{
return
fDefault
;
}
strValue
=
strValue
.
replace
(
","
,
""
);
return
Float
.
parseFloat
(
strValue
);
}
catch
(
Exception
ex
)
{
...
...
@@ -233,8 +247,9 @@ public class DataObject {
return
BigDecimal
.
valueOf
((
Long
)
objValue
);
}
String
strValue
=
objValue
.
toString
();
if
(
StringUtils
.
isEmpty
(
strValue
))
if
(
StringUtils
.
isEmpty
(
strValue
))
{
return
fDefault
;
}
strValue
=
strValue
.
replace
(
","
,
""
);
return
BigDecimal
.
valueOf
(
Double
.
parseDouble
(
strValue
));
}
catch
(
Exception
ex
)
{
...
...
@@ -253,8 +268,9 @@ public class DataObject {
}
else
{
Long
l
=
getLongValue
(
objValue
,
null
);
if
(
l
!=
null
)
if
(
l
!=
null
)
{
return
BigInteger
.
valueOf
(
l
);
}
}
}
catch
(
Exception
ex
)
{
...
...
@@ -283,8 +299,9 @@ public class DataObject {
}
String
strValue
=
objValue
.
toString
();
if
(
StringUtils
.
isEmpty
(
strValue
))
if
(
StringUtils
.
isEmpty
(
strValue
))
{
return
nDefault
;
}
strValue
=
strValue
.
replace
(
","
,
""
);
return
Long
.
parseLong
(
strValue
);
}
catch
(
Exception
ex
)
{
...
...
@@ -294,7 +311,9 @@ public class DataObject {
final
static
public
byte
[]
getBinaryValue
(
Object
objValue
,
byte
[]
def
)
{
if
(
objValue
==
null
)
return
def
;
if
(
objValue
==
null
)
{
return
def
;
}
if
(
objValue
instanceof
byte
[]){
return
(
byte
[])
objValue
;
}
...
...
@@ -312,7 +331,9 @@ public class DataObject {
* @
*/
final
static
public
java
.
sql
.
Timestamp
getTimestampValue
(
Object
objValue
,
java
.
sql
.
Timestamp
tDefault
)
{
if
(
objValue
==
null
)
return
tDefault
;
if
(
objValue
==
null
)
{
return
tDefault
;
}
if
(
objValue
instanceof
java
.
sql
.
Timestamp
)
{
java
.
sql
.
Timestamp
ti
=
(
java
.
sql
.
Timestamp
)
objValue
;
...
...
@@ -332,7 +353,9 @@ public class DataObject {
if
(
objValue
instanceof
String
)
{
String
strValue
=
(
String
)
objValue
;
strValue
=
strValue
.
trim
();
if
(
StringUtils
.
isEmpty
(
strValue
))
return
null
;
if
(
StringUtils
.
isEmpty
(
strValue
))
{
return
null
;
}
try
{
java
.
util
.
Date
date
=
parse
((
String
)
objValue
);
...
...
@@ -373,7 +396,9 @@ public class DataObject {
* @
*/
public
static
Object
testDateTime
(
String
strInput
,
TimeZone
timeZone
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
strInput
))
return
null
;
if
(
StringUtils
.
isEmpty
(
strInput
))
{
return
null
;
}
Date
dtDate
=
parse
(
strInput
,
timeZone
);
java
.
sql
.
Timestamp
retDate
=
new
java
.
sql
.
Timestamp
(
dtDate
.
getTime
());
return
retDate
;
...
...
@@ -425,8 +450,9 @@ public class DataObject {
if
(
strTimeString
.
indexOf
(
"T"
)!=-
1
){
strPart
=
strTimeString
.
split
(
"[T]"
);
}
else
else
{
strPart
=
strTimeString
.
split
(
" "
);
}
if
(
strPart
.
length
==
2
)
{
// 两个部分
String
strDate
=
""
;
...
...
@@ -589,6 +615,4 @@ public class DataObject {
return
new
Timestamp
(
cl
.
getTime
().
getTime
());
}
}
ibzdisk-util/src/main/java/cn/ibizlab/util/helper/RuleUtils.java
浏览文件 @
1921adde
...
...
@@ -18,8 +18,9 @@ public class RuleUtils
public
static
Object
getObj
(
Object
object
,
String
members
)
{
if
(
object
==
null
)
if
(
object
==
null
)
{
return
null
;
}
Object
currentObj
=
object
;
String
[]
arrayOfString
=
members
.
split
(
"\\."
);
int
i
=
arrayOfString
.
length
;
...
...
@@ -31,20 +32,23 @@ public class RuleUtils
if
(
currentObj
instanceof
EntityBase
)
{
currentObj
=((
EntityBase
)
currentObj
).
get
(
methodName
);
if
(
currentObj
==
null
)
if
(
currentObj
==
null
)
{
return
null
;
}
}
else
if
(
currentObj
instanceof
JSONObject
)
{
currentObj
=((
JSONObject
)
currentObj
).
get
(
methodName
);
if
(
currentObj
==
null
)
if
(
currentObj
==
null
)
{
return
null
;
}
}
else
if
(
currentObj
instanceof
Map
)
{
currentObj
=((
Map
)
currentObj
).
get
(
methodName
);
if
(
currentObj
==
null
)
if
(
currentObj
==
null
)
{
return
null
;
}
}
else
{
...
...
@@ -60,10 +64,10 @@ public class RuleUtils
}
currentObj
=
method
.
invoke
(
currentObj
,
methodName
);
if
(
currentObj
==
null
)
if
(
currentObj
==
null
)
{
return
null
;
}
}
}
catch
(
Exception
e
)
{
...
...
@@ -77,44 +81,63 @@ public class RuleUtils
public
static
boolean
test
(
Object
finalObject
,
String
option
,
Object
exp
)
{
if
(
option
.
equalsIgnoreCase
(
"eq"
)||
option
.
equalsIgnoreCase
(
"equal"
)||
option
.
equalsIgnoreCase
(
"="
))
if
(
option
.
equalsIgnoreCase
(
"eq"
)||
option
.
equalsIgnoreCase
(
"equal"
)||
option
.
equalsIgnoreCase
(
"="
))
{
return
equal
(
exp
,
finalObject
);
else
if
(
option
.
equalsIgnoreCase
(
"noteq"
)||
option
.
equalsIgnoreCase
(
"notequal"
)||
option
.
equalsIgnoreCase
(
"<>"
)||
option
.
equalsIgnoreCase
(
"!="
))
}
else
if
(
option
.
equalsIgnoreCase
(
"noteq"
)||
option
.
equalsIgnoreCase
(
"notequal"
)||
option
.
equalsIgnoreCase
(
"<>"
)||
option
.
equalsIgnoreCase
(
"!="
)){
return
!
equal
(
exp
,
finalObject
);
else
if
(
option
.
equalsIgnoreCase
(
"gt"
)||
option
.
equalsIgnoreCase
(
">"
))
}
else
if
(
option
.
equalsIgnoreCase
(
"gt"
)||
option
.
equalsIgnoreCase
(
">"
)){
return
gt
(
exp
,
finalObject
);
else
if
(
option
.
equalsIgnoreCase
(
"lt"
)||
option
.
equalsIgnoreCase
(
"<"
))
}
else
if
(
option
.
equalsIgnoreCase
(
"lt"
)||
option
.
equalsIgnoreCase
(
"<"
)){
return
lt
(
exp
,
finalObject
);
else
if
(
option
.
equalsIgnoreCase
(
"gtandeq"
)||
option
.
equalsIgnoreCase
(
"ge"
)||
option
.
equalsIgnoreCase
(
">="
))
}
else
if
(
option
.
equalsIgnoreCase
(
"gtandeq"
)||
option
.
equalsIgnoreCase
(
"ge"
)||
option
.
equalsIgnoreCase
(
">="
)){
return
ge
(
exp
,
finalObject
);
else
if
(
option
.
equalsIgnoreCase
(
"ltandeq"
)||
option
.
equalsIgnoreCase
(
"le"
)||
option
.
equalsIgnoreCase
(
"<="
))
}
else
if
(
option
.
equalsIgnoreCase
(
"ltandeq"
)||
option
.
equalsIgnoreCase
(
"le"
)||
option
.
equalsIgnoreCase
(
"<="
)){
return
le
(
exp
,
finalObject
);
else
if
(
option
.
equalsIgnoreCase
(
"null"
)||
option
.
equalsIgnoreCase
(
"isnull"
))
}
else
if
(
option
.
equalsIgnoreCase
(
"null"
)||
option
.
equalsIgnoreCase
(
"isnull"
)){
return
isNull
(
finalObject
);
else
if
(
option
.
equalsIgnoreCase
(
"notnull"
)||
option
.
equalsIgnoreCase
(
"isnotnull"
))
}
else
if
(
option
.
equalsIgnoreCase
(
"notnull"
)||
option
.
equalsIgnoreCase
(
"isnotnull"
)){
return
isNotNull
(
finalObject
);
else
if
(
option
.
equalsIgnoreCase
(
"like"
)||
option
.
equalsIgnoreCase
(
"matchor"
))
}
else
if
(
option
.
equalsIgnoreCase
(
"like"
)||
option
.
equalsIgnoreCase
(
"matchor"
)){
return
matchor
(
exp
,
finalObject
);
else
if
(
option
.
equalsIgnoreCase
(
"leftlike"
)||
option
.
equalsIgnoreCase
(
"startswith"
)||
option
.
equalsIgnoreCase
(
"begin"
))
}
else
if
(
option
.
equalsIgnoreCase
(
"leftlike"
)||
option
.
equalsIgnoreCase
(
"startswith"
)||
option
.
equalsIgnoreCase
(
"begin"
)){
return
leftmatchor
(
exp
,
finalObject
);
else
if
(
option
.
equalsIgnoreCase
(
"rightlike"
)||
option
.
equalsIgnoreCase
(
"endswith"
)||
option
.
equalsIgnoreCase
(
"end"
))
}
else
if
(
option
.
equalsIgnoreCase
(
"rightlike"
)||
option
.
equalsIgnoreCase
(
"endswith"
)||
option
.
equalsIgnoreCase
(
"end"
)){
return
rightmatchor
(
exp
,
finalObject
);
else
if
(
option
.
equalsIgnoreCase
(
"match"
)||
option
.
equalsIgnoreCase
(
"matchand"
)||
option
.
equalsIgnoreCase
(
"matches"
))
}
else
if
(
option
.
equalsIgnoreCase
(
"match"
)||
option
.
equalsIgnoreCase
(
"matchand"
)||
option
.
equalsIgnoreCase
(
"matches"
)){
return
matchand
(
exp
,
finalObject
);
else
if
(
option
.
equalsIgnoreCase
(
"in"
))
}
else
if
(
option
.
equalsIgnoreCase
(
"in"
)){
return
in
(
exp
,
finalObject
);
else
if
(
option
.
equalsIgnoreCase
(
"notin"
))
}
else
if
(
option
.
equalsIgnoreCase
(
"notin"
)){
return
notin
(
exp
,
finalObject
);
else
if
(
option
.
equalsIgnoreCase
(
"NOTLIKE"
))
}
else
if
(
option
.
equalsIgnoreCase
(
"NOTLIKE"
)){
return
notmatchor
(
exp
,
finalObject
);
else
if
(
option
.
equalsIgnoreCase
(
"LEFTNOTLIKE"
))
}
else
if
(
option
.
equalsIgnoreCase
(
"LEFTNOTLIKE"
)){
return
!
leftmatchor
(
exp
,
finalObject
);
else
if
(
option
.
equalsIgnoreCase
(
"RIGHTNOTLIKE"
))
}
else
if
(
option
.
equalsIgnoreCase
(
"RIGHTNOTLIKE"
)){
return
!
rightmatchor
(
exp
,
finalObject
);
else
if
(
option
.
equalsIgnoreCase
(
"NOTMATCHES"
))
}
else
if
(
option
.
equalsIgnoreCase
(
"NOTMATCHES"
)){
return
notmatchand
(
exp
,
finalObject
);
else
}
else
{
return
false
;
}
}
...
...
@@ -125,10 +148,12 @@ public class RuleUtils
public
static
boolean
equal
(
Object
exp
,
Object
finalObject
)
{
if
(
exp
==
null
)
if
(
exp
==
null
)
{
return
false
;
if
(
finalObject
==
null
)
}
if
(
finalObject
==
null
){
return
false
;
}
if
(
exp
instanceof
String
&&
((
String
)
exp
).
length
()==
10
&&
finalObject
instanceof
Timestamp
)
{
...
...
@@ -145,10 +170,12 @@ public class RuleUtils
return
ObjectUtils
.
nullSafeEquals
(
tm
,
finalObject
);
}
if
(
ObjectUtils
.
nullSafeEquals
(
exp
,
finalObject
))
if
(
ObjectUtils
.
nullSafeEquals
(
exp
,
finalObject
))
{
return
true
;
if
(
exp
.
toString
().
equalsIgnoreCase
(
finalObject
.
toString
()))
}
if
(
exp
.
toString
().
equalsIgnoreCase
(
finalObject
.
toString
())){
return
true
;
}
return
false
;
}
...
...
@@ -158,10 +185,12 @@ public class RuleUtils
}
public
static
boolean
gt
(
Object
exp
,
Object
finalObject
)
{
if
(
ObjectUtils
.
isEmpty
(
exp
))
if
(
ObjectUtils
.
isEmpty
(
exp
))
{
return
false
;
if
(
ObjectUtils
.
isEmpty
(
finalObject
))
}
if
(
ObjectUtils
.
isEmpty
(
finalObject
)){
return
false
;
}
try
{
if
(
finalObject
instanceof
java
.
sql
.
Timestamp
)
...
...
@@ -176,8 +205,9 @@ public class RuleUtils
else
{
tm
=
DataObject
.
getTimestampValue
(
exp
,
null
);
if
(
tm
==
null
)
if
(
tm
==
null
)
{
return
false
;
}
}
return
finalTime
.
getTime
()>
tm
.
getTime
();
}
...
...
@@ -209,15 +239,14 @@ public class RuleUtils
{
return
finalObject
.
toString
().
compareToIgnoreCase
(
exp
.
toString
())>
0
;
}
else
else
{
return
false
;
}
}
catch
(
Exception
ex
)
{
return
false
;
}
}
public
static
boolean
lt
(
Object
exp
,
Object
object
,
String
members
)
...
...
@@ -226,10 +255,12 @@ public class RuleUtils
}
public
static
boolean
lt
(
Object
exp
,
Object
finalObject
)
{
if
(
ObjectUtils
.
isEmpty
(
exp
))
if
(
ObjectUtils
.
isEmpty
(
exp
))
{
return
false
;
if
(
ObjectUtils
.
isEmpty
(
finalObject
))
}
if
(
ObjectUtils
.
isEmpty
(
finalObject
)){
return
false
;
}
try
{
if
(
finalObject
instanceof
java
.
sql
.
Timestamp
)
...
...
@@ -311,8 +342,9 @@ public class RuleUtils
return
false
;
String
tvs
=
expObj
.
toString
().
trim
();
if
(
StringUtils
.
isEmpty
(
tvs
))
if
(
StringUtils
.
isEmpty
(
tvs
))
{
return
false
;
}
if
(
finalObject
instanceof
Integer
)
{
...
...
@@ -352,8 +384,9 @@ public class RuleUtils
}
public
static
boolean
isNull
(
Object
finalObject
)
{
if
(
finalObject
instanceof
String
)
if
(
finalObject
instanceof
String
)
{
return
StringUtils
.
isEmpty
(
finalObject
.
toString
().
trim
());
}
return
(
ObjectUtils
.
isEmpty
(
finalObject
));
}
...
...
@@ -382,11 +415,13 @@ public class RuleUtils
}
public
static
boolean
matchor
(
Object
expObj
,
Object
obj
)
{
if
(
obj
==
null
)
if
(
obj
==
null
)
{
return
false
;
}
String
exp
=
expObj
.
toString
().
trim
();
if
(
StringUtils
.
isEmpty
(
exp
))
if
(
StringUtils
.
isEmpty
(
exp
))
{
return
false
;
}
exp
=
exp
.
replace
(
";"
,
","
);
exp
=
exp
.
replace
(
";"
,
","
);
exp
=
exp
.
replace
(
","
,
","
);
...
...
@@ -403,11 +438,13 @@ public class RuleUtils
public
static
boolean
leftmatchor
(
Object
expObj
,
Object
obj
)
{
if
(
obj
==
null
)
if
(
obj
==
null
)
{
return
false
;
}
String
exp
=
expObj
.
toString
().
trim
();
if
(
StringUtils
.
isEmpty
(
exp
))
if
(
StringUtils
.
isEmpty
(
exp
))
{
return
false
;
}
exp
=
exp
.
replace
(
";"
,
","
);
exp
=
exp
.
replace
(
";"
,
","
);
exp
=
exp
.
replace
(
","
,
","
);
...
...
@@ -416,19 +453,22 @@ public class RuleUtils
for
(
String
strExp:
arr
)
{
bRt
=
obj
.
toString
().
matches
(
strExp
+
"(.*)"
);
if
(
bRt
)
if
(
bRt
)
{
return
true
;
}
}
return
bRt
;
}
public
static
boolean
rightmatchor
(
Object
expObj
,
Object
obj
)
{
if
(
obj
==
null
)
if
(
obj
==
null
)
{
return
false
;
}
String
exp
=
expObj
.
toString
().
trim
();
if
(
StringUtils
.
isEmpty
(
exp
))
if
(
StringUtils
.
isEmpty
(
exp
))
{
return
false
;
}
exp
=
exp
.
replace
(
";"
,
","
);
exp
=
exp
.
replace
(
";"
,
","
);
exp
=
exp
.
replace
(
","
,
","
);
...
...
@@ -437,8 +477,9 @@ public class RuleUtils
for
(
String
strExp:
arr
)
{
bRt
=
obj
.
toString
().
matches
(
"(.*)"
+
strExp
);
if
(
bRt
)
if
(
bRt
)
{
return
true
;
}
}
return
bRt
;
}
...
...
@@ -449,13 +490,16 @@ public class RuleUtils
}
public
static
boolean
matchand
(
Object
expObj
,
Object
obj
)
{
if
(
obj
==
null
)
if
(
obj
==
null
)
{
return
false
;
if
(
expObj
==
null
)
}
if
(
expObj
==
null
){
return
false
;
}
String
exp
=
expObj
.
toString
().
trim
();
if
(
StringUtils
.
isEmpty
(
exp
))
if
(
StringUtils
.
isEmpty
(
exp
))
{
return
false
;
}
exp
=
exp
.
replace
(
";"
,
","
);
exp
=
exp
.
replace
(
";"
,
","
);
exp
=
exp
.
replace
(
","
,
","
);
...
...
@@ -464,11 +508,13 @@ public class RuleUtils
boolean
bRt
=
true
;
for
(
String
strExp:
arr
)
{
if
(
strExp
.
trim
().
length
()==
0
)
if
(
strExp
.
trim
().
length
()==
0
)
{
continue
;
}
bRt
=(
obj
.
toString
()).
matches
(
"(.*)"
+(
strExp
)+
"(.*)"
);
if
(!
bRt
)
if
(!
bRt
)
{
return
false
;
}
}
return
bRt
;
}
...
...
@@ -503,12 +549,14 @@ public class RuleUtils
switch
(
str1
.
hashCode
())
{
case
105
:
if
(
str1
.
equals
(
"i"
))
if
(
str1
.
equals
(
"i"
))
{
i
=
0
;
}
break
;
case
115
:
if
(
str1
.
equals
(
"s"
))
if
(
str1
.
equals
(
"s"
))
{
i
=
1
;
}
}
switch
(
i
)
{
...
...
ibzdisk-util/src/main/java/cn/ibizlab/util/job/PermissionSyncJob.java
浏览文件 @
1921adde
...
...
@@ -46,14 +46,14 @@ public class PermissionSyncJob implements ApplicationRunner {
public
void
run
(
ApplicationArguments
args
)
{
try
{
Thread
.
sleep
(
10000
);
InputStream
permission
=
this
.
getClass
().
getResourceAsStream
(
"/permission/systemResource.json"
);
//获取当前系统所有实体资源能力
InputStream
permission
=
this
.
getClass
().
getResourceAsStream
(
"/permission/systemResource.json"
);
//获取当前系统所有实体资源能力
String
permissionResult
=
IOUtils
.
toString
(
permission
,
"UTF-8"
);
JSONObject
system
=
new
JSONObject
();
system
.
put
(
"pssystemid"
,
systemId
);
system
.
put
(
"pssystemname"
,
systemName
);
system
.
put
(
"sysstructure"
,
JSONObject
.
parseObject
(
permissionResult
));
system
.
put
(
"md5check"
,
DigestUtils
.
md5DigestAsHex
(
permissionResult
.
getBytes
()));
if
(
client
.
syncSysAuthority
(
system
)){
if
(
client
.
syncSysAuthority
(
system
))
{
log
.
info
(
"向[UAA]同步系统资源成功"
);
}
else
{
log
.
error
(
"向[UAA]同步系统资源失败"
);
...
...
@@ -64,9 +64,9 @@ public class PermissionSyncJob implements ApplicationRunner {
}
try
{
InputStream
sysModel
=
this
.
getClass
().
getResourceAsStream
(
"/sysmodel/ibzdisk.json"
);
//获取当前系统所有实体资源能力
InputStream
sysModel
=
this
.
getClass
().
getResourceAsStream
(
"/sysmodel/ibzdisk.json"
);
//获取当前系统所有实体资源能力
String
strSysModel
=
IOUtils
.
toString
(
sysModel
,
"UTF-8"
);
if
(
liteFeignClient
.
syncSysModel
(
JSONObject
.
parseObject
(
strSysModel
))){
if
(
liteFeignClient
.
syncSysModel
(
JSONObject
.
parseObject
(
strSysModel
)))
{
log
.
info
(
"向[lite]同步系统模型成功"
);
}
else
{
log
.
error
(
"向[lite]同步系统模型失败"
);
...
...
ibzdisk-util/src/main/java/cn/ibizlab/util/rest/AppController.java
浏览文件 @
1921adde
...
...
@@ -42,10 +42,12 @@ public class AppController {
while
(
it
.
hasNext
())
{
GrantedAuthority
authority
=
(
GrantedAuthority
)
it
.
next
();
String
strAuthority
=
authority
.
getAuthority
();
if
(
strAuthority
.
startsWith
(
"UNIRES_"
+
systemId
))
if
(
strAuthority
.
startsWith
(
"UNIRES_"
+
systemId
))
{
uniRes
.
add
(
strAuthority
.
substring
(
systemId
.
length
()+
8
));
else
if
(
strAuthority
.
startsWith
(
"APPMENU_"
+
systemId
))
}
else
if
(
strAuthority
.
startsWith
(
"APPMENU_"
+
systemId
)){
appMenu
.
add
(
strAuthority
.
substring
(
systemId
.
length
()+
9
));
}
}
}
Map
<
String
,
Object
>
context
=
new
HashMap
<>();
...
...
@@ -55,10 +57,12 @@ public class AppController {
appData
.
put
(
"unires"
,
uniRes
);
appData
.
put
(
"appmenu"
,
appMenu
);
appData
.
put
(
"enablepermissionvalid"
,
enablePermissionValid
);
if
(
curUser
.
getSuperuser
()==
1
)
if
(
curUser
.
getSuperuser
()==
1
)
{
appData
.
put
(
"enablepermissionvalid"
,
false
);
else
}
else
{
appData
.
put
(
"enablepermissionvalid"
,
enablePermissionValid
);
}
fillAppData
(
appData
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
appData
);
}
...
...
@@ -76,16 +80,18 @@ public class AppController {
@RequestMapping
(
method
=
RequestMethod
.
PUT
,
value
=
"/configs/{configType}/{targetType}"
)
public
ResponseEntity
<
Boolean
>
saveConfig
(
@PathVariable
(
"configType"
)
String
configType
,
@PathVariable
(
"targetType"
)
String
targetType
,
@RequestBody
JSONObject
config
)
{
String
userId
=
AuthenticationUser
.
getAuthenticationUser
().
getUserid
();
if
(
StringUtils
.
isEmpty
(
userId
))
if
(
StringUtils
.
isEmpty
(
userId
))
{
throw
new
BadRequestAlertException
(
"保存配置失败,参数缺失"
,
"IBZConfig"
,
configType
);
}
return
ResponseEntity
.
ok
(
ibzConfigService
.
saveConfig
(
configType
,
targetType
,
userId
,
config
));
}
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/configs/{configType}/{targetType}"
)
public
ResponseEntity
<
JSONObject
>
getConfig
(
@PathVariable
(
"configType"
)
String
configType
,
@PathVariable
(
"targetType"
)
String
targetType
)
{
String
userId
=
AuthenticationUser
.
getAuthenticationUser
().
getUserid
();
if
(
StringUtils
.
isEmpty
(
userId
))
if
(
StringUtils
.
isEmpty
(
userId
))
{
throw
new
BadRequestAlertException
(
"获取配置失败,参数缺失"
,
"IBZConfig"
,
configType
);
}
return
ResponseEntity
.
ok
(
ibzConfigService
.
getConfig
(
configType
,
targetType
,
userId
));
}
...
...
ibzdisk-util/src/main/java/cn/ibizlab/util/rest/AuthenticationController.java
浏览文件 @
1921adde
...
...
@@ -56,5 +56,5 @@ public class AuthenticationController
authuserdetail
=
userDetailsService
.
loadUserByUsername
(
userDetails
.
getUsername
());
}
return
ResponseEntity
.
ok
().
body
(
authuserdetail
);
}
}
}
ibzdisk-util/src/main/java/cn/ibizlab/util/security/AuthPermissionEvaluator.java
浏览文件 @
1921adde
...
...
@@ -38,18 +38,22 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
@Override
@SneakyThrows
public
boolean
hasPermission
(
Authentication
authentication
,
Object
entity
,
Object
action
)
{
if
(!
enablePermissionValid
)
if
(!
enablePermissionValid
)
{
return
true
;
}
Object
principal
=
authentication
.
getPrincipal
();
if
(
ObjectUtils
.
isEmpty
(
principal
))
if
(
ObjectUtils
.
isEmpty
(
principal
))
{
return
false
;
}
AuthenticationUser
authenticationUser
=
(
AuthenticationUser
)
authentication
.
getPrincipal
();
if
(
authenticationUser
.
getSuperuser
()==
1
)
if
(
authenticationUser
.
getSuperuser
()==
1
)
{
return
true
;
}
String
strAction
=
String
.
valueOf
(
action
);
Set
<
String
>
userAuthorities
=
getAuthorities
(
authentication
,
strAction
);
if
(
userAuthorities
.
size
()==
0
)
if
(
userAuthorities
.
size
()==
0
)
{
return
false
;
}
if
(
isAllData
(
strAction
,
userAuthorities
)){
return
true
;
}
...
...
@@ -102,8 +106,9 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
*/
@SneakyThrows
private
void
setPermissionCondToSearchContext
(
EntityBase
entity
,
QueryWrapperContext
qc
,
Set
<
String
>
userAuthorities
,
AuthenticationUser
authenticationUser
){
if
(
entity
==
null
)
if
(
entity
==
null
)
{
return
;
}
Map
<
String
,
String
>
permissionField
=
getPermissionField
(
entity
);
//获取组织、部门预置属性
String
orgField
=
permissionField
.
get
(
"orgfield"
);
String
orgDeptField
=
permissionField
.
get
(
"orgsecfield"
);
...
...
@@ -185,8 +190,9 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
Iterator
it
=
authorities
.
iterator
();
while
(
it
.
hasNext
())
{
GrantedAuthority
authority
=
(
GrantedAuthority
)
it
.
next
();
if
(
authority
.
getAuthority
().
contains
(
action
))
if
(
authority
.
getAuthority
().
contains
(
action
))
{
userAuthorities
.
add
(
authority
.
getAuthority
());
}
}
return
userAuthorities
;
}
...
...
@@ -253,23 +259,27 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
}
if
(
action
.
endsWith
(
"Create"
)
||
action
.
endsWith
(
"Save"
)){
if
(!
ObjectUtils
.
isEmpty
(
orgFieldValue
)
&&
!
userOrg
.
contains
(
orgFieldValue
))
if
(!
ObjectUtils
.
isEmpty
(
orgFieldValue
)
&&
!
userOrg
.
contains
(
orgFieldValue
))
{
return
false
;
if
(!
ObjectUtils
.
isEmpty
(
orgDeptFieldValue
)
&&
!
userOrgDept
.
contains
(
orgDeptFieldValue
))
}
if
(!
ObjectUtils
.
isEmpty
(
orgDeptFieldValue
)
&&
!
userOrgDept
.
contains
(
orgDeptFieldValue
)){
return
false
;
if
(!
ObjectUtils
.
isEmpty
(
crateManFieldValue
)
&&
!
authenticationUser
.
getUserid
().
equals
(
crateManFieldValue
))
}
if
(!
ObjectUtils
.
isEmpty
(
crateManFieldValue
)
&&
!
authenticationUser
.
getUserid
().
equals
(
crateManFieldValue
)){
return
false
;
}
return
true
;
}
else
{
if
(!
ObjectUtils
.
isEmpty
(
orgFieldValue
)
&&
userOrg
.
contains
(
orgFieldValue
))
if
(!
ObjectUtils
.
isEmpty
(
orgFieldValue
)
&&
userOrg
.
contains
(
orgFieldValue
))
{
return
true
;
if
(!
ObjectUtils
.
isEmpty
(
orgDeptFieldValue
)
&&
userOrgDept
.
contains
(
orgDeptFieldValue
))
}
if
(!
ObjectUtils
.
isEmpty
(
orgDeptFieldValue
)
&&
userOrgDept
.
contains
(
orgDeptFieldValue
)){
return
true
;
if
(!
ObjectUtils
.
isEmpty
(
crateManFieldValue
)
&&
authenticationUser
.
getUserid
().
equals
(
crateManFieldValue
))
}
if
(!
ObjectUtils
.
isEmpty
(
crateManFieldValue
)
&&
authenticationUser
.
getUserid
().
equals
(
crateManFieldValue
)){
return
true
;
}
return
false
;
}
}
...
...
@@ -293,12 +303,18 @@ public class AuthPermissionEvaluator implements PermissionEvaluator {
String
fieldName
=
entry
.
getKey
();
//获取注解字段
DEField
fieldAnnotation
=
entry
.
getValue
();
//获取注解值
DEPredefinedFieldType
prefieldType
=
fieldAnnotation
.
preType
();
if
(
prefieldType
==
prefieldType
.
ORGID
)
//用户配置系统预置属性-组织机构标识
//用户配置系统预置属性-组织机构标识
if
(
prefieldType
==
prefieldType
.
ORGID
){
orgField
=
fieldName
;
if
(
prefieldType
==
prefieldType
.
ORGSECTORID
)
//用户配置系统预置属性-部门标识
}
//用户配置系统预置属性-部门标识
if
(
prefieldType
==
prefieldType
.
ORGSECTORID
){
orgDeptField
=
fieldName
;
if
(
prefieldType
==
prefieldType
.
CREATEMAN
)
//用户配置系统预置属性-部门标识
}
//用户配置系统预置属性-部门标识
if
(
prefieldType
==
prefieldType
.
CREATEMAN
){
createManField
=
fieldName
;
}
}
permissionFiled
.
put
(
"orgfield"
,
orgField
);
permissionFiled
.
put
(
"orgsecfield"
,
orgDeptField
);
...
...
ibzdisk-util/src/main/java/cn/ibizlab/util/security/AuthenticationUser.java
浏览文件 @
1921adde
...
...
@@ -260,10 +260,12 @@ public class AuthenticationUser implements UserDetails
return
this
.
sessionParams
;
}
private
Map
<
String
,
Object
>
getUserSessionParam
()
{
if
(
userSessionParam
!=
null
)
if
(
userSessionParam
!=
null
)
{
return
userSessionParam
;
else
}
else
{
return
new
HashMap
<>();
}
}
public
void
setOrgInfo
(
Map
<
String
,
Set
<
String
>>
orgInfo
)
{
...
...
ibzdisk-util/src/main/java/cn/ibizlab/util/service/IBZConfigService.java
浏览文件 @
1921adde
...
...
@@ -29,8 +29,9 @@ public class IBZConfigService extends ServiceImpl<IBZConfigMapper, IBZConfig> im
@Cacheable
(
value
=
"ibzrt_configs"
,
key
=
"'cfgid:'+#p0+'||'+#p1+'||'+#p2"
)
public
JSONObject
getConfig
(
String
cfgType
,
String
targetType
,
String
userId
)
{
if
(
StringUtils
.
isEmpty
(
userId
)||
StringUtils
.
isEmpty
(
cfgType
)||
StringUtils
.
isEmpty
(
targetType
))
if
(
StringUtils
.
isEmpty
(
userId
)||
StringUtils
.
isEmpty
(
cfgType
)||
StringUtils
.
isEmpty
(
targetType
))
{
throw
new
BadRequestAlertException
(
"获取配置失败,参数缺失"
,
"IBZConfig"
,
cfgType
);
}
IBZConfig
config
=
this
.
getOne
(
Wrappers
.
query
(
IBZConfig
.
builder
().
systemId
(
systemId
).
cfgType
(
cfgType
).
targetType
(
targetType
).
userId
(
userId
).
build
()),
false
);
if
(
config
==
null
)
{
config
=
this
.
getOne
(
Wrappers
.
query
(
IBZConfig
.
builder
().
systemId
(
systemId
).
cfgType
(
cfgType
).
targetType
(
targetType
).
userId
(
adminuserid
).
build
()),
false
);
...
...
@@ -44,19 +45,22 @@ public class IBZConfigService extends ServiceImpl<IBZConfigMapper, IBZConfig> im
@CacheEvict
(
value
=
"ibzrt_configs"
,
key
=
"'cfgid:'+#p0+'||'+#p1+'||'+#p2"
)
public
boolean
saveConfig
(
String
cfgType
,
String
targetType
,
String
userId
,
JSONObject
config
)
{
if
(
StringUtils
.
isEmpty
(
userId
)||
StringUtils
.
isEmpty
(
cfgType
)||
StringUtils
.
isEmpty
(
targetType
))
if
(
StringUtils
.
isEmpty
(
userId
)||
StringUtils
.
isEmpty
(
cfgType
)||
StringUtils
.
isEmpty
(
targetType
))
{
throw
new
BadRequestAlertException
(
"保存配置失败,参数缺失"
,
"IBZConfig"
,
cfgType
);
}
String
cfg
=
"{}"
;
if
(
config
!=
null
)
if
(
config
!=
null
)
{
cfg
=
JSONObject
.
toJSONString
(
config
);
}
return
this
.
saveOrUpdate
(
IBZConfig
.
builder
().
systemId
(
systemId
).
cfgType
(
cfgType
).
targetType
(
targetType
).
userId
(
userId
).
cfg
(
cfg
).
updateDate
(
DataObject
.
getNow
()).
build
());
}
@CacheEvict
(
value
=
"ibzrt_configs"
,
key
=
"'cfgid:'+#p0+'||'+#p1+'||'+#p2"
)
public
void
resetConfig
(
String
cfgType
,
String
targetType
,
String
userId
)
{
if
(
StringUtils
.
isEmpty
(
userId
)||
StringUtils
.
isEmpty
(
cfgType
)||
StringUtils
.
isEmpty
(
targetType
))
if
(
StringUtils
.
isEmpty
(
userId
)||
StringUtils
.
isEmpty
(
cfgType
)||
StringUtils
.
isEmpty
(
targetType
))
{
throw
new
BadRequestAlertException
(
"重置配置失败,参数缺失"
,
"IBZConfig"
,
cfgType
);
}
this
.
remove
(
Wrappers
.
query
(
IBZConfig
.
builder
().
systemId
(
systemId
).
cfgType
(
cfgType
).
targetType
(
targetType
).
userId
(
userId
).
build
()));
}
...
...
ibzdisk-util/src/main/java/cn/ibizlab/util/service/IBZUAAUserService.java
浏览文件 @
1921adde
...
...
@@ -26,10 +26,10 @@ public class IBZUAAUserService implements AuthenticationUserService{
@Override
public
AuthenticationUser
loadUserByUsername
(
String
username
)
{
AuthenticationUser
user
=
uaaFeignClient
.
loginByUsername
(
username
);
if
(
user
==
null
)
if
(
user
==
null
)
{
throw
new
BadRequestAlertException
(
"登录失败"
,
"IBZUAAUser"
,
username
);
}
return
user
;
}
...
...
@@ -48,8 +48,9 @@ public class IBZUAAUserService implements AuthenticationUserService{
logininfo
.
setLoginname
(
loginname
);
logininfo
.
setPassword
(
password
);
AuthenticationUser
user
=
uaaFeignClient
.
login
(
logininfo
);
if
(
user
==
null
)
if
(
user
==
null
)
{
throw
new
BadRequestAlertException
(
"登录失败"
,
"IBZUAAUser"
,
username
);
}
return
user
;
}
...
...
ibzdisk-util/src/main/java/cn/ibizlab/util/service/SimpleAuditService.java
浏览文件 @
1921adde
...
...
@@ -42,13 +42,15 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
*/
@Scheduled
(
fixedRate
=
10000
)
public
void
saveAudit
()
{
if
(
cacheMap
.
size
()>
0
){
if
(
cacheMap
.
size
()>
0
)
{
log
.
info
(
String
.
format
(
"正在保存审计数据,当前审计集合数量为[%s]"
,
cacheMap
.
size
()));
List
temp
=
new
ArrayList
();
if
(
cacheMap
.
size
()<
500
)
if
(
cacheMap
.
size
()<
500
)
{
temp
.
addAll
(
cacheMap
);
else
}
else
{
temp
.
addAll
(
cacheMap
.
subList
(
0
,
500
));
}
this
.
saveBatch
(
temp
);
cacheMap
.
removeAll
(
temp
);
log
.
info
(
String
.
format
(
"保存完成,当前审计集合数量为[%s]"
,
cacheMap
.
size
()));
...
...
@@ -64,16 +66,17 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
*/
@Override
public
void
createAudit
(
HttpServletRequest
request
,
EntityBase
entity
,
Object
idValue
,
Map
<
String
,
Audit
>
auditFields
)
{
IBZDataAudit
dataAudit
=
new
IBZDataAudit
();
IBZDataAudit
dataAudit
=
new
IBZDataAudit
();
dataAudit
.
setOppersonid
(
AuthenticationUser
.
getAuthenticationUser
().
getUserid
());
dataAudit
.
setOppersonname
(
String
.
format
(
"%s[%s]"
,
AuthenticationUser
.
getAuthenticationUser
().
getPersonname
(),
AuthenticationUser
.
getAuthenticationUser
().
getOrgname
()));
dataAudit
.
setAudittype
(
"CREATE"
);
dataAudit
.
setAuditobject
(
entity
.
getClass
().
getSimpleName
());
dataAudit
.
setAuditobjectdata
(
idValue
);
dataAudit
.
setOptime
(
new
Timestamp
(
new
Date
().
getTime
()));
if
(
request
!=
null
)
if
(
request
!=
null
)
{
dataAudit
.
setIpaddress
(
getIpAddress
(
request
,
AuthenticationUser
.
getAuthenticationUser
()));
dataAudit
.
setAuditinfo
(
getAuditInfo
(
entity
,
auditFields
));
}
dataAudit
.
setAuditinfo
(
getAuditInfo
(
entity
,
auditFields
));
dataAudit
.
setIsdatachanged
(
1
);
cacheMap
.
add
(
dataAudit
);
}
...
...
@@ -87,24 +90,26 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
* @param auditFields
*/
@SneakyThrows
public
void
updateAudit
(
HttpServletRequest
request
,
EntityBase
beforeEntity
,
Object
serviceObj
,
Object
idValue
,
Map
<
String
,
Audit
>
auditFields
){
public
void
updateAudit
(
HttpServletRequest
request
,
EntityBase
beforeEntity
,
Object
serviceObj
,
Object
idValue
,
Map
<
String
,
Audit
>
auditFields
)
{
//获取更新后的实体
EntityBase
afterEntity
=
getEntity
(
serviceObj
,
idValue
);
EntityBase
afterEntity
=
getEntity
(
serviceObj
,
idValue
);
//获取更新后的审计内容
String
auditInfo
=
getUpdateAuditInfo
(
beforeEntity
,
afterEntity
,
auditFields
);
//比较更新前后差异内容
int
isDataChanged
=
1
;
if
(
StringUtils
.
isEmpty
(
auditInfo
))
//审计内容是否发生变化
isDataChanged
=
0
;
IBZDataAudit
dataAudit
=
new
IBZDataAudit
();
String
auditInfo
=
getUpdateAuditInfo
(
beforeEntity
,
afterEntity
,
auditFields
);
//比较更新前后差异内容
int
isDataChanged
=
1
;
//审计内容是否发生变化
if
(
StringUtils
.
isEmpty
(
auditInfo
))
{
isDataChanged
=
0
;
}
IBZDataAudit
dataAudit
=
new
IBZDataAudit
();
dataAudit
.
setOppersonid
(
AuthenticationUser
.
getAuthenticationUser
().
getUserid
());
dataAudit
.
setOppersonname
(
String
.
format
(
"%s[%s]"
,
AuthenticationUser
.
getAuthenticationUser
().
getPersonname
(),
AuthenticationUser
.
getAuthenticationUser
().
getOrgname
()));
dataAudit
.
setOppersonname
(
String
.
format
(
"%s[%s]"
,
AuthenticationUser
.
getAuthenticationUser
().
getPersonname
(),
AuthenticationUser
.
getAuthenticationUser
().
getOrgname
()));
dataAudit
.
setAudittype
(
"UPDATE"
);
dataAudit
.
setAuditobject
(
afterEntity
.
getClass
().
getSimpleName
());
dataAudit
.
setAuditobjectdata
(
idValue
);
dataAudit
.
setOptime
(
new
Timestamp
(
new
Date
().
getTime
()));
if
(
request
!=
null
)
if
(
request
!=
null
)
{
dataAudit
.
setIpaddress
(
getIpAddress
(
request
,
AuthenticationUser
.
getAuthenticationUser
()));
}
dataAudit
.
setAuditinfo
(
auditInfo
);
dataAudit
.
setIsdatachanged
(
isDataChanged
);
cacheMap
.
add
(
dataAudit
);
...
...
@@ -117,53 +122,55 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
* @param idValue
* @param auditFields
*/
public
void
removeAudit
(
HttpServletRequest
request
,
EntityBase
entity
,
Object
idValue
,
Map
<
String
,
Audit
>
auditFields
)
{
IBZDataAudit
dataAudit
=
new
IBZDataAudit
();
public
void
removeAudit
(
HttpServletRequest
request
,
EntityBase
entity
,
Object
idValue
,
Map
<
String
,
Audit
>
auditFields
)
{
IBZDataAudit
dataAudit
=
new
IBZDataAudit
();
dataAudit
.
setOppersonid
(
AuthenticationUser
.
getAuthenticationUser
().
getUserid
());
dataAudit
.
setOppersonname
(
String
.
format
(
"%s[%s]"
,
AuthenticationUser
.
getAuthenticationUser
().
getPersonname
(),
AuthenticationUser
.
getAuthenticationUser
().
getOrgname
()));
dataAudit
.
setOppersonname
(
String
.
format
(
"%s[%s]"
,
AuthenticationUser
.
getAuthenticationUser
().
getPersonname
(),
AuthenticationUser
.
getAuthenticationUser
().
getOrgname
()));
dataAudit
.
setAudittype
(
"REMOVE"
);
dataAudit
.
setAuditobject
(
entity
.
getClass
().
getSimpleName
());
dataAudit
.
setAuditobjectdata
(
idValue
);
dataAudit
.
setOptime
(
new
Timestamp
(
new
Date
().
getTime
()));
if
(
request
!=
null
)
if
(
request
!=
null
)
{
dataAudit
.
setIpaddress
(
getIpAddress
(
request
,
AuthenticationUser
.
getAuthenticationUser
()));
dataAudit
.
setAuditinfo
(
getAuditInfo
(
entity
,
auditFields
));
}
dataAudit
.
setAuditinfo
(
getAuditInfo
(
entity
,
auditFields
));
dataAudit
.
setIsdatachanged
(
1
);
cacheMap
.
add
(
dataAudit
);
}
private
String
getAuditInfo
(
EntityBase
entity
,
Map
<
String
,
Audit
>
auditFields
){
String
auditResult
=
""
;
if
(
auditFields
.
size
()
==
0
)
private
String
getAuditInfo
(
EntityBase
entity
,
Map
<
String
,
Audit
>
auditFields
)
{
String
auditResult
=
""
;
if
(
auditFields
.
size
()
==
0
)
{
return
auditResult
;
Map
<
String
,
DEField
>
deFields
=
DEFieldCacheMap
.
getDEFields
(
entity
.
getClass
());
if
(
deFields
.
size
()
==
0
)
}
Map
<
String
,
DEField
>
deFields
=
DEFieldCacheMap
.
getDEFields
(
entity
.
getClass
());
if
(
deFields
.
size
()
==
0
)
{
return
auditResult
;
JSONArray
auditFieldArray
=
new
JSONArray
();
}
JSONArray
auditFieldArray
=
new
JSONArray
();
for
(
Map
.
Entry
<
String
,
Audit
>
auditField
:
auditFields
.
entrySet
())
{
Object
objFieldName
=
auditField
.
getKey
();
String
fieldName
=
String
.
valueOf
(
objFieldName
);
DEField
deField
=
null
;
if
(
deFields
.
containsKey
(
fieldName
)){
deField
=
deFields
.
get
(
fieldName
);
Object
objFieldName
=
auditField
.
getKey
();
String
fieldName
=
String
.
valueOf
(
objFieldName
);
DEField
deField
=
null
;
if
(
deFields
.
containsKey
(
fieldName
))
{
deField
=
deFields
.
get
(
fieldName
);
}
if
(
ObjectUtils
.
isEmpty
(
deField
))
if
(
ObjectUtils
.
isEmpty
(
deField
))
{
continue
;
Object
value
=
dataTransfer
(
entity
.
get
(
fieldName
),
deField
.
fieldType
(),
deField
.
format
());
if
(!
StringUtils
.
isEmpty
(
value
)){
JSONObject
auditFieldObj
=
new
JSONObject
();
auditFieldObj
.
put
(
"field"
,
deField
.
value
());
auditFieldObj
.
put
(
"value"
,
value
);
if
(!
StringUtils
.
isEmpty
(
deField
.
dict
())){
auditFieldObj
.
put
(
"dict"
,
deField
.
dict
());
}
Object
value
=
dataTransfer
(
entity
.
get
(
fieldName
),
deField
.
fieldType
(),
deField
.
format
());
if
(!
StringUtils
.
isEmpty
(
value
))
{
JSONObject
auditFieldObj
=
new
JSONObject
();
auditFieldObj
.
put
(
"field"
,
deField
.
value
());
auditFieldObj
.
put
(
"value"
,
value
);
if
(!
StringUtils
.
isEmpty
(
deField
.
dict
()))
{
auditFieldObj
.
put
(
"dict"
,
deField
.
dict
());
}
auditFieldArray
.
add
(
auditFieldObj
);
}
}
if
(
auditFieldArray
.
size
()>
0
){
auditResult
=
auditFieldArray
.
toString
();
if
(
auditFieldArray
.
size
()>
0
)
{
auditResult
=
auditFieldArray
.
toString
();
}
return
auditResult
;
}
...
...
@@ -176,41 +183,44 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
* @return
*/
private
String
getUpdateAuditInfo
(
EntityBase
oldData
,
EntityBase
newData
,
Map
<
String
,
Audit
>
auditFields
){
String
auditResult
=
""
;
JSONArray
auditFieldArray
=
new
JSONArray
();
if
(
auditFields
.
size
()
==
0
)
String
auditResult
=
""
;
JSONArray
auditFieldArray
=
new
JSONArray
();
if
(
auditFields
.
size
()
==
0
)
{
return
auditResult
;
}
Map
<
String
,
DEField
>
deFields
=
DEFieldCacheMap
.
getDEFields
(
oldData
.
getClass
());
if
(
deFields
.
size
()
==
0
)
Map
<
String
,
DEField
>
deFields
=
DEFieldCacheMap
.
getDEFields
(
oldData
.
getClass
());
if
(
deFields
.
size
()
==
0
){
return
auditResult
;
}
for
(
Map
.
Entry
<
String
,
Audit
>
auditField
:
auditFields
.
entrySet
())
{
Object
objFieldName
=
auditField
.
getKey
();
//获取注解字段
String
fieldName
=
String
.
valueOf
(
objFieldName
);
//属性名称
DEField
deField
=
null
;
if
(
deFields
.
containsKey
(
fieldName
)){
deField
=
deFields
.
get
(
fieldName
);
Object
objFieldName
=
auditField
.
getKey
();
//获取注解字段
String
fieldName
=
String
.
valueOf
(
objFieldName
);
//属性名称
DEField
deField
=
null
;
if
(
deFields
.
containsKey
(
fieldName
))
{
deField
=
deFields
.
get
(
fieldName
);
}
if
(
ObjectUtils
.
isEmpty
(
deField
))
if
(
ObjectUtils
.
isEmpty
(
deField
))
{
continue
;
Object
oldValue
=
oldData
.
get
(
fieldName
);
//老属性值
Object
newValue
=
newData
.
get
(
fieldName
);
//新属性值
if
(!
compare
(
oldValue
,
newValue
)){
oldValue
=
dataTransfer
(
oldValue
,
deField
.
fieldType
(),
deField
.
format
());
//属性值转换
newValue
=
dataTransfer
(
newValue
,
deField
.
fieldType
(),
deField
.
format
());
//属性值转换
JSONObject
auditFieldObj
=
new
JSONObject
();
auditFieldObj
.
put
(
"field"
,
deField
.
value
());
auditFieldObj
.
put
(
"beforevalue"
,
oldValue
);
auditFieldObj
.
put
(
"value"
,
newValue
);
if
(!
StringUtils
.
isEmpty
(
deField
.
dict
())){
auditFieldObj
.
put
(
"dict"
,
deField
.
dict
());
}
Object
oldValue
=
oldData
.
get
(
fieldName
);
//老属性值
Object
newValue
=
newData
.
get
(
fieldName
);
//新属性值
if
(!
compare
(
oldValue
,
newValue
))
{
oldValue
=
dataTransfer
(
oldValue
,
deField
.
fieldType
(),
deField
.
format
());
//属性值转换
newValue
=
dataTransfer
(
newValue
,
deField
.
fieldType
(),
deField
.
format
());
//属性值转换
JSONObject
auditFieldObj
=
new
JSONObject
();
auditFieldObj
.
put
(
"field"
,
deField
.
value
());
auditFieldObj
.
put
(
"beforevalue"
,
oldValue
);
auditFieldObj
.
put
(
"value"
,
newValue
);
if
(!
StringUtils
.
isEmpty
(
deField
.
dict
()))
{
auditFieldObj
.
put
(
"dict"
,
deField
.
dict
());
}
auditFieldArray
.
add
(
auditFieldObj
);
}
}
if
(
auditFieldArray
.
size
()>
0
){
auditResult
=
auditFieldArray
.
toString
();
if
(
auditFieldArray
.
size
()>
0
)
{
auditResult
=
auditFieldArray
.
toString
();
}
return
auditResult
;
}
...
...
@@ -222,15 +232,16 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
* @param strFormat 转换字段格式化文本
* @return
*/
private
String
dataTransfer
(
Object
value
,
String
dataType
,
String
strFormat
)
{
if
(
value
==
null
)
private
String
dataTransfer
(
Object
value
,
String
dataType
,
String
strFormat
)
{
if
(
value
==
null
)
{
return
""
;
}
String
transResult
=
value
.
toString
();
if
((
dataType
.
equals
(
"DATE"
)
||
dataType
.
equals
(
"DATETIME"
)
||
dataType
.
equals
(
"TIME"
))
&&
(!
StringUtils
.
isEmpty
(
strFormat
))){
//时间类型转换
Timestamp
timestamp
=(
Timestamp
)
value
;
Date
date
=
timestamp
;
SimpleDateFormat
format
=
new
SimpleDateFormat
(
strFormat
);
transResult
=
format
.
format
(
date
);
if
((
dataType
.
equals
(
"DATE"
)
||
dataType
.
equals
(
"DATETIME"
)
||
dataType
.
equals
(
"TIME"
))
&&
(!
StringUtils
.
isEmpty
(
strFormat
)))
{
//时间类型转换
Timestamp
timestamp
=
(
Timestamp
)
value
;
Date
date
=
timestamp
;
SimpleDateFormat
format
=
new
SimpleDateFormat
(
strFormat
);
transResult
=
format
.
format
(
date
);
}
return
transResult
;
}
...
...
@@ -241,11 +252,13 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
* @param targetObj 比较目标对象
* @return
*/
private
boolean
compare
(
Object
sourceObj
,
Object
targetObj
)
{
if
(
sourceObj
==
null
&&
targetObj
==
null
)
private
boolean
compare
(
Object
sourceObj
,
Object
targetObj
)
{
if
(
sourceObj
==
null
&&
targetObj
==
null
)
{
return
true
;
if
(
sourceObj
==
null
&&
targetObj
!=
null
)
}
if
(
sourceObj
==
null
&&
targetObj
!=
null
)
{
return
false
;
}
return
sourceObj
.
equals
(
targetObj
);
}
...
...
@@ -256,9 +269,9 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
* @return
*/
@SneakyThrows
private
EntityBase
getEntity
(
Object
service
,
Object
id
){
EntityBase
entity
=
null
;
if
(!
ObjectUtils
.
isEmpty
(
service
)){
private
EntityBase
getEntity
(
Object
service
,
Object
id
)
{
EntityBase
entity
=
null
;
if
(!
ObjectUtils
.
isEmpty
(
service
))
{
EvaluationContext
oldContext
=
new
StandardEvaluationContext
();
oldContext
.
setVariable
(
"service"
,
service
);
oldContext
.
setVariable
(
"id"
,
id
);
...
...
@@ -275,14 +288,15 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
*/
public
String
getIpAddress
(
HttpServletRequest
request
,
AuthenticationUser
authenticationUser
)
{
//客户端有提交ip,以提交的ip为准
if
(
authenticationUser
!=
null
&&
!
StringUtils
.
isEmpty
(
authenticationUser
.
getAddr
())){
if
(
authenticationUser
!=
null
&&
!
StringUtils
.
isEmpty
(
authenticationUser
.
getAddr
()))
{
return
authenticationUser
.
getAddr
();
}
if
(
request
==
null
)
if
(
request
==
null
)
{
return
""
;
}
String
Xip
=
request
.
getHeader
(
"X-Real-IP"
);
String
XFor
=
request
.
getHeader
(
"X-Forwarded-For"
);
if
(!
StringUtils
.
isEmpty
(
XFor
)
&&
!
"unKnown"
.
equalsIgnoreCase
(
XFor
)){
if
(!
StringUtils
.
isEmpty
(
XFor
)
&&
!
"unKnown"
.
equalsIgnoreCase
(
XFor
))
{
//多次反向代理后会有多个ip值,第一个ip才是真实ip
int
index
=
XFor
.
indexOf
(
","
);
if
(
index
!=
-
1
){
...
...
@@ -292,7 +306,7 @@ public class SimpleAuditService extends ServiceImpl<IBZDataAuditMapper, IBZDataA
}
}
XFor
=
Xip
;
if
(!
StringUtils
.
isEmpty
(
XFor
)
&&
!
"unKnown"
.
equalsIgnoreCase
(
XFor
)){
if
(!
StringUtils
.
isEmpty
(
XFor
)
&&
!
"unKnown"
.
equalsIgnoreCase
(
XFor
))
{
return
XFor
;
}
if
(
StringUtils
.
isEmpty
(
XFor
)
||
"unknown"
.
equalsIgnoreCase
(
XFor
))
{
...
...
ibzdisk-util/src/main/java/cn/ibizlab/util/service/SimpleUserService.java
浏览文件 @
1921adde
...
...
@@ -19,19 +19,19 @@ import org.springframework.security.core.authority.AuthorityUtils;
@Primary
@Service
(
"SimpleUserService"
)
@ConditionalOnExpression
(
"(!${ibiz.enablePermissionValid:false})&&'${ibiz.auth.service:IBZUAAUserService}'.equals('SimpleUserService')"
)
public
class
SimpleUserService
implements
AuthenticationUserService
{
public
class
SimpleUserService
implements
AuthenticationUserService
{
@Override
public
AuthenticationUser
loadUserByUsername
(
String
username
)
{
AuthenticationUser
user
=
new
AuthenticationUser
();
String
[]
data
=
username
.
split
(
"[|]"
);
String
loginname
=
username
;
String
domains
=
""
;
String
password
=
""
;
String
[]
data
=
username
.
split
(
"[|]"
);
String
loginname
=
username
;
String
domains
=
""
;
String
password
=
""
;
if
(
data
.
length
==
2
)
{
loginname
=
data
[
0
].
trim
();
domains
=
data
[
1
].
trim
();
loginname
=
data
[
0
].
trim
();
domains
=
data
[
1
].
trim
();
}
user
.
setUserid
(
username
);
...
...
ibzdisk-util/src/main/java/cn/ibizlab/util/web/FeignRequestInterceptor.java
浏览文件 @
1921adde
...
...
@@ -29,8 +29,9 @@ public class FeignRequestInterceptor implements RequestInterceptor {
if
(
headerNames
!=
null
)
{
while
(
headerNames
.
hasMoreElements
())
{
String
name
=
headerNames
.
nextElement
();
if
(
name
.
equalsIgnoreCase
(
"transfer-encoding"
))
if
(
name
.
equalsIgnoreCase
(
"transfer-encoding"
))
{
continue
;
}
String
values
=
request
.
getHeader
(
name
);
requestTemplate
.
header
(
name
,
values
);
}
...
...
ibzdisk-util/src/main/java/cn/ibizlab/util/web/IBZOperationParameterReader.java
浏览文件 @
1921adde
...
...
@@ -49,19 +49,19 @@ public class IBZOperationParameterReader implements OperationBuilderPlugin {
public
IBZOperationParameterReader
(
ModelAttributeParameterExpander
expander
,
EnumTypeDeterminer
enumTypeDeterminer
)
{
this
.
expander
=
expander
;
this
.
enumTypeDeterminer
=
enumTypeDeterminer
;
this
.
expander
=
expander
;
this
.
enumTypeDeterminer
=
enumTypeDeterminer
;
}
@Override
public
void
apply
(
OperationContext
context
)
{
context
.
operationBuilder
().
parameters
(
context
.
getGlobalOperationParameters
());
context
.
operationBuilder
().
parameters
(
readParameters
(
context
));
context
.
operationBuilder
().
parameters
(
context
.
getGlobalOperationParameters
());
context
.
operationBuilder
().
parameters
(
readParameters
(
context
));
}
@Override
public
boolean
supports
(
DocumentationType
delimiter
)
{
return
true
;
return
true
;
}
private
List
<
Parameter
>
readParameters
(
final
OperationContext
context
)
{
...
...
ibzdisk-util/src/main/java/cn/ibizlab/util/web/SearchContextHandlerMethodArgumentResolver.java
浏览文件 @
1921adde
...
...
@@ -41,7 +41,4 @@ public class SearchContextHandlerMethodArgumentResolver implements HandlerMethod
String
json
=
objectMapper
.
writeValueAsString
(
set
);
return
objectMapper
.
readValue
(
json
,
parameter
.
getParameterType
());
}
}
\ No newline at end of file
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录