Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdict
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdict
提交
8efcea16
提交
8efcea16
编写于
4月 20, 2020
作者:
ibizdev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ibizdev提交
上级
df88a3fd
变更
7
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
202 行增加
和
69 行删除
+202
-69
app-data-upload.vue
app_web/src/components/app-data-upload/app-data-upload.vue
+2
-1
IBZDict.java
...re/src/main/java/cn/ibizlab/core/dict/domain/IBZDict.java
+3
-4
IBZDictItem.java
...rc/main/java/cn/ibizlab/core/dict/domain/IBZDictItem.java
+2
-1
DEField.java
...til/src/main/java/cn/ibizlab/util/annotation/DEField.java
+12
-0
DEFieldDefaultValueAspect.java
...ava/cn/ibizlab/util/aspect/DEFieldDefaultValueAspect.java
+128
-41
EntityBase.java
...util/src/main/java/cn/ibizlab/util/domain/EntityBase.java
+9
-22
EntityMP.java
...t-util/src/main/java/cn/ibizlab/util/domain/EntityMP.java
+46
-0
未找到文件。
app_web/src/components/app-data-upload/app-data-upload.vue
浏览文件 @
8efcea16
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
</ul>
</ul>
</
template
>
</
template
>
<
template
v-if=
"hasImported === true && importDataArray.length === 0"
>
<
template
v-if=
"hasImported === true && importDataArray.length === 0"
>
<span
class=
"font-class"
>
{{
isUploading
===
true
?
$t
(
'info.importing'
)
+
"......"
:
$t
(
'info.completed'
)
}}
</span>
<span
class=
"font-class"
>
{{
isUploading
===
true
?
$t
(
'info.importing'
)
+
"......"
:
promptInfo
}}
</span>
</
template
>
</
template
>
</div>
</div>
</el-row>
</el-row>
...
@@ -327,6 +327,7 @@ export default class AppDataUploadView extends Vue {
...
@@ -327,6 +327,7 @@ export default class AppDataUploadView extends Vue {
return
;
return
;
}
}
this
.
importSuccessData
=
result
.
data
;
this
.
importSuccessData
=
result
.
data
;
this
.
promptInfo
=
(
this
.
$t
(
'info.completed'
)
as
string
);
this
.
isUploading
=
false
;
this
.
isUploading
=
false
;
})
})
}).
catch
((
error
:
any
)
=>
{
}).
catch
((
error
:
any
)
=>
{
...
...
ibzdict-core/src/main/java/cn/ibizlab/core/dict/domain/IBZDict.java
浏览文件 @
8efcea16
...
@@ -17,6 +17,7 @@ import cn.ibizlab.util.enums.DEPredefinedFieldType;
...
@@ -17,6 +17,7 @@ import cn.ibizlab.util.enums.DEPredefinedFieldType;
import
cn.ibizlab.util.enums.DEFieldDefaultValueType
;
import
cn.ibizlab.util.enums.DEFieldDefaultValueType
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
lombok.Data
;
import
lombok.Data
;
import
org.springframework.data.annotation.Transient
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
org.springframework.data.mongodb.core.mapping.Document
;
...
@@ -24,13 +25,12 @@ import org.springframework.data.annotation.Id;
...
@@ -24,13 +25,12 @@ import org.springframework.data.annotation.Id;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
org.springframework.data.mongodb.core.mapping.Field
;
import
org.springframework.data.mongodb.core.mapping.Field
;
import
org.springframework.data.mongodb.core.mapping.FieldType
;
import
org.springframework.data.mongodb.core.mapping.FieldType
;
import
org.springframework.data.annotation.Transient
;
/**
/**
* 大数据 [数据字典] 对象
* 大数据 [数据字典] 对象
*/
*/
@Data
@Data
@Document
(
collection
=
"ibzdict"
)
@Document
(
collection
=
"ibzdict"
)
public
class
IBZDict
implements
Serializable
{
public
class
IBZDict
extends
EntityBase
implements
Serializable
{
/**
/**
* 字典标识
* 字典标识
...
@@ -39,7 +39,6 @@ public class IBZDict implements Serializable {
...
@@ -39,7 +39,6 @@ public class IBZDict implements Serializable {
@DEField
(
isKeyField
=
true
)
@DEField
(
isKeyField
=
true
)
@JSONField
(
name
=
"dictid"
)
@JSONField
(
name
=
"dictid"
)
@JsonProperty
(
"dictid"
)
@JsonProperty
(
"dictid"
)
@Field
(
name
=
"ibzdictid"
)
private
String
dictid
;
private
String
dictid
;
/**
/**
...
@@ -53,7 +52,7 @@ public class IBZDict implements Serializable {
...
@@ -53,7 +52,7 @@ public class IBZDict implements Serializable {
/**
/**
* 逻辑有效标志
* 逻辑有效标志
*/
*/
@DEField
(
preType
=
DEPredefinedFieldType
.
LOGICVALID
)
@DEField
(
preType
=
DEPredefinedFieldType
.
LOGICVALID
,
logicval
=
"1"
,
logicdelval
=
"0"
)
@JSONField
(
name
=
"enable"
)
@JSONField
(
name
=
"enable"
)
@JsonProperty
(
"enable"
)
@JsonProperty
(
"enable"
)
@Field
(
name
=
"enable"
)
@Field
(
name
=
"enable"
)
...
...
ibzdict-core/src/main/java/cn/ibizlab/core/dict/domain/IBZDictItem.java
浏览文件 @
8efcea16
...
@@ -17,13 +17,14 @@ import cn.ibizlab.util.enums.DEPredefinedFieldType;
...
@@ -17,13 +17,14 @@ import cn.ibizlab.util.enums.DEPredefinedFieldType;
import
cn.ibizlab.util.enums.DEFieldDefaultValueType
;
import
cn.ibizlab.util.enums.DEFieldDefaultValueType
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
lombok.Data
;
import
lombok.Data
;
import
org.springframework.data.annotation.Transient
;
/**
/**
* ServiceApi [字典项目] 对象
* ServiceApi [字典项目] 对象
*/
*/
@Data
@Data
public
class
IBZDictItem
implements
Serializable
{
public
class
IBZDictItem
extends
EntityBase
implements
Serializable
{
/**
/**
* 字典项目标识
* 字典项目标识
...
...
ibzdict-util/src/main/java/cn/ibizlab/util/annotation/DEField.java
浏览文件 @
8efcea16
...
@@ -33,5 +33,17 @@ public @interface DEField
...
@@ -33,5 +33,17 @@ public @interface DEField
* @return
* @return
*/
*/
DEPredefinedFieldType
preType
()
default
DEPredefinedFieldType
.
DEFAULT
;
DEPredefinedFieldType
preType
()
default
DEPredefinedFieldType
.
DEFAULT
;
/**
* 逻辑删除有效值
* @return
*/
String
logicval
()
default
""
;
/**
* 逻辑删除无效值
* @return
*/
String
logicdelval
()
default
""
;
}
}
ibzdict-util/src/main/java/cn/ibizlab/util/aspect/DEFieldDefaultValueAspect.java
浏览文件 @
8efcea16
...
@@ -2,6 +2,7 @@ package cn.ibizlab.util.aspect;
...
@@ -2,6 +2,7 @@ package cn.ibizlab.util.aspect;
import
cn.ibizlab.util.annotation.DEField
;
import
cn.ibizlab.util.annotation.DEField
;
import
cn.ibizlab.util.enums.DEFieldDefaultValueType
;
import
cn.ibizlab.util.enums.DEFieldDefaultValueType
;
import
cn.ibizlab.util.enums.DEPredefinedFieldType
;
import
cn.ibizlab.util.helper.DEFieldCacheMap
;
import
cn.ibizlab.util.helper.DEFieldCacheMap
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Aspect
;
...
@@ -13,6 +14,8 @@ import org.springframework.util.StringUtils;
...
@@ -13,6 +14,8 @@ import org.springframework.util.StringUtils;
import
java.beans.PropertyDescriptor
;
import
java.beans.PropertyDescriptor
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
java.sql.Timestamp
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -35,6 +38,16 @@ public class DEFieldDefaultValueAspect
...
@@ -35,6 +38,16 @@ public class DEFieldDefaultValueAspect
fillDEFieldDefaultValue
(
point
);
fillDEFieldDefaultValue
(
point
);
}
}
/**
* 更新数据切入点
* @param point
* @throws Exception
*/
@Before
(
value
=
"execution(* cn.ibizlab.core.*.service.*.update(..))"
)
public
void
BeforeUpdate
(
JoinPoint
point
)
throws
Exception
{
fillDEFieldDefaultValue
(
point
);
}
/**
/**
* 保存数据切入点
* 保存数据切入点
* @param point
* @param point
...
@@ -113,7 +126,7 @@ public class DEFieldDefaultValueAspect
...
@@ -113,7 +126,7 @@ public class DEFieldDefaultValueAspect
//从属性列表中过滤出预置属性
//从属性列表中过滤出预置属性
Map
<
Field
,
DEField
>
deFields
=
this
.
SearchDEField
(
className
);
Map
<
Field
,
DEField
>
deFields
=
this
.
SearchDEField
(
className
);
//填充预置属性
//填充预置属性
fillDEField
(
obj
,
deFields
);
fillDEField
(
obj
,
deFields
,
joinPoint
);
return
true
;
return
true
;
}
}
return
true
;
return
true
;
...
@@ -141,61 +154,135 @@ public class DEFieldDefaultValueAspect
...
@@ -141,61 +154,135 @@ public class DEFieldDefaultValueAspect
* 填充系统预置属性
* 填充系统预置属性
* @param et 当前实体对象
* @param et 当前实体对象
*/
*/
private
void
fillDEField
(
Object
et
,
Map
<
Field
,
DEField
>
deFields
)
throws
Exception
{
private
void
fillDEField
(
Object
et
,
Map
<
Field
,
DEField
>
deFields
,
JoinPoint
joinPoint
)
throws
Exception
{
if
(
deFields
.
size
()==
0
)
if
(
deFields
.
size
()==
0
)
return
;
return
;
for
(
Map
.
Entry
<
Field
,
DEField
>
entry
:
deFields
.
entrySet
())
{
for
(
Map
.
Entry
<
Field
,
DEField
>
entry
:
deFields
.
entrySet
())
{
//获取预置属性
Field
deField
=
entry
.
getKey
();
Field
deField
=
entry
.
getKey
();
String
file
n
ame
=
deField
.
getName
();
String
file
N
ame
=
deField
.
getName
();
//获取
预置属性
注解
//获取注解
DEField
fieldAnnotation
=
entry
.
getValue
();
DEField
fieldAnnotation
=
entry
.
getValue
();
//获取
预置属性
类型
//获取
默认值
类型
DEFieldDefaultValueType
deFieldType
=
fieldAnnotation
.
defaultValueType
();
DEFieldDefaultValueType
deFieldType
=
fieldAnnotation
.
defaultValueType
();
//获取属性默认值
String
deFieldDefaultValue
=
fieldAnnotation
.
defaultValue
();
String
deFieldDefaultValue
=
fieldAnnotation
.
defaultValue
();
//获取预置属性类型
DEPredefinedFieldType
predefinedFieldType
=
fieldAnnotation
.
preType
();
//获取预置属性的get、set方法及字段值
//填充系统默认值
PropertyDescriptor
field
=
new
PropertyDescriptor
(
filename
,
et
.
getClass
());
if
(
deFieldType
!=
DEFieldDefaultValueType
.
NONE
||
(!
StringUtils
.
isEmpty
(
deFieldDefaultValue
))
){
Method
fieldSetMethod
=
field
.
getWriteMethod
();
fillFieldDefaultValue
(
fileName
,
deFieldType
,
deFieldDefaultValue
,
et
)
;
Method
fieldGetMethod
=
field
.
getReadMethod
();
}
Object
fieldValue
=
fieldGetMethod
.
invoke
(
et
);
//填充系统预置属性
if
(
predefinedFieldType
!=
DEPredefinedFieldType
.
NONE
){
//为默认值属性进行赋值
fillPreFieldValue
(
fileName
,
predefinedFieldType
,
et
,
joinPoint
);
if
(
org
.
springframework
.
util
.
StringUtils
.
isEmpty
(
fieldValue
)){
}
//填充直接值及其余默认值类型
}
if
(
(
deFieldType
==
DEFieldDefaultValueType
.
NONE
&&
!
StringUtils
.
isEmpty
(
deFieldDefaultValue
))
||
(
deFieldType
!=
DEFieldDefaultValueType
.
NONE
)
){
}
switch
(
deFieldType
){
//根据注解给预置属性填充值
case
SESSION:
/**
break
;
* 填充属性默认值
case
APPLICATION:
* @param fileName 实体属性名
break
;
* @param deFieldType 默认值类型
case
UNIQUEID:
* @param deFieldDefaultValue 默认值
break
;
* @param et 当前实体对象
case
CONTEXT:
* @throws Exception
break
;
*/
case
PARAM:
private
void
fillFieldDefaultValue
(
String
fileName
,
DEFieldDefaultValueType
deFieldType
,
String
deFieldDefaultValue
,
Object
et
)
throws
Exception
{
break
;
case
OPERATOR:
//获取当前所需填充属性的get、set方法及字段值
break
;
PropertyDescriptor
field
=
new
PropertyDescriptor
(
fileName
,
et
.
getClass
());
case
OPERATORNAME:
Method
fieldSetMethod
=
field
.
getWriteMethod
();
break
;
Method
fieldGetMethod
=
field
.
getReadMethod
();
case
CURTIME:
Object
fieldValue
=
fieldGetMethod
.
invoke
(
et
);
break
;
case
APPDATA:
break
;
if
(
org
.
springframework
.
util
.
StringUtils
.
isEmpty
(
fieldValue
)){
case
NONE:
//填充直接值及其余默认值类型
//对字段值进行类型转换
if
(
(
deFieldType
==
DEFieldDefaultValueType
.
NONE
&&
!
StringUtils
.
isEmpty
(
deFieldDefaultValue
))
||
(
deFieldType
!=
DEFieldDefaultValueType
.
NONE
)
){
Object
deFieldDefaultValueObj
=
fieldValueConvert
(
deFieldDefaultValue
,
field
);
switch
(
deFieldType
){
//根据注解给预置属性填充值
fieldSetMethod
.
invoke
(
et
,
deFieldDefaultValueObj
);
case
SESSION:
break
;
break
;
}
case
APPLICATION:
break
;
case
UNIQUEID:
break
;
case
CONTEXT:
break
;
case
PARAM:
break
;
case
OPERATOR:
break
;
case
OPERATORNAME:
break
;
case
CURTIME:
break
;
case
APPDATA:
break
;
case
NONE:
//对字段值进行类型转换
Object
deFieldDefaultValueObj
=
fieldValueConvert
(
deFieldDefaultValue
,
field
);
fieldSetMethod
.
invoke
(
et
,
deFieldDefaultValueObj
);
break
;
}
}
}
}
}
}
}
}
/**
* 填充系统预置属性
* @param fileName 实体属性名
* @param preFieldType 预置类型
* @param et 当前实体对象
* @throws Exception
*/
private
void
fillPreFieldValue
(
String
fileName
,
DEPredefinedFieldType
preFieldType
,
Object
et
,
JoinPoint
joinPoint
)
throws
Exception
{
//当前操作行为
String
actionName
=
joinPoint
.
getSignature
().
getName
();
//获取当前所需填充属性的get、set方法及字段值
PropertyDescriptor
field
=
new
PropertyDescriptor
(
fileName
,
et
.
getClass
());
Method
fieldSetMethod
=
field
.
getWriteMethod
();
Method
fieldGetMethod
=
field
.
getReadMethod
();
Object
fieldValue
=
fieldGetMethod
.
invoke
(
et
);
//为预置属性进行赋值
if
(
(
actionName
.
equalsIgnoreCase
(
"create"
)
&&
org
.
springframework
.
util
.
StringUtils
.
isEmpty
(
fieldValue
)
)||
preFieldType
==
DEPredefinedFieldType
.
UPDATEDATE
||
preFieldType
==
DEPredefinedFieldType
.
UPDATEMAN
||
preFieldType
==
DEPredefinedFieldType
.
UPDATEMANNAME
){
switch
(
preFieldType
){
//根据注解给预置属性填充值
case
CREATEMAN:
break
;
case
CREATEMANNAME:
break
;
case
UPDATEMAN:
break
;
case
UPDATEMANNAME:
break
;
case
CREATEDATE:
fieldSetMethod
.
invoke
(
et
,
new
Timestamp
(
new
Date
().
getTime
()));
break
;
case
UPDATEDATE:
fieldSetMethod
.
invoke
(
et
,
new
Timestamp
(
new
Date
().
getTime
()));
case
ORGID:
break
;
case
ORGNAME:
break
;
case
ORGSECTORID:
break
;
case
ORGSECTORNAME:
break
;
case
LOGICVALID:
break
;
}
}
}
/**
/**
* 值类型转换
* 值类型转换
* @param fieldValue
* @param fieldValue
...
...
ibzdict-util/src/main/java/cn/ibizlab/util/domain/EntityBase.java
浏览文件 @
8efcea16
package
cn
.
ibizlab
.
util
.
domain
;
package
cn
.
ibizlab
.
util
.
domain
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.IdWorker
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
lombok.Data
;
import
org.springframework.util.AlternativeJdkIdGenerator
;
import
org.springframework.data.annotation.Transient
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Set
;
import
java.util.Set
;
@Data
public
class
EntityBase
implements
Serializable
{
public
class
EntityBase
implements
Serializable
{
@JsonIgnore
@JsonIgnore
@JSONField
(
serialize
=
false
)
@JSONField
(
serialize
=
false
)
@T
ableField
(
exist
=
false
)
@T
ransient
private
Set
<
String
>
focusNull
;
private
Set
<
String
>
focusNull
;
public
void
modify
(
String
field
,
Object
val
)
{
public
void
modify
(
String
field
,
Object
val
)
{
if
(
val
==
null
)
if
(
val
==
null
)
this
.
getFocusNull
().
add
(
field
.
toLowerCase
());
this
.
getFocusNull
().
add
(
field
.
toLowerCase
());
...
@@ -26,30 +22,21 @@ public class EntityBase implements Serializable {
...
@@ -26,30 +22,21 @@ public class EntityBase implements Serializable {
this
.
getFocusNull
().
remove
(
field
.
toLowerCase
());
this
.
getFocusNull
().
remove
(
field
.
toLowerCase
());
}
}
public
Set
<
String
>
getFocusNull
()
{
public
Set
<
String
>
getFocusNull
()
{
if
(
focusNull
==
null
)
if
(
focusNull
==
null
)
focusNull
=
new
HashSet
<>();
focusNull
=
new
HashSet
<>();
return
focusNull
;
return
focusNull
;
}
}
public
void
setFocusNull
(
Set
<
String
>
focusNull
)
{
public
UpdateWrapper
getUpdateWrapper
(
boolean
clean
)
{
this
.
focusNull
=
focusNull
;
UpdateWrapper
wrapper
=
new
UpdateWrapper
();
for
(
String
nullField:
getFocusNull
())
{
wrapper
.
set
(
nullField
,
null
);
}
if
(
clean
)
focusNull
.
clear
();
return
wrapper
;
}
public
Serializable
getDefaultKey
(
boolean
gen
)
{
return
IdWorker
.
get32UUID
();
}
}
public
Serializable
getDefaultKey
(
boolean
gen
)
{
String
Id
=(
new
AlternativeJdkIdGenerator
()).
generateId
().
toString
();
return
gen
?
Id
.
replace
(
"-"
,
""
):
Id
;
}
}
}
ibzdict-util/src/main/java/cn/ibizlab/util/domain/EntityMP.java
0 → 100644
浏览文件 @
8efcea16
package
cn
.
ibizlab
.
util
.
domain
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.IdWorker
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
java.io.Serializable
;
import
java.util.HashSet
;
import
java.util.Set
;
public
class
EntityMP
extends
EntityBase
{
@JsonIgnore
@JSONField
(
serialize
=
false
)
@TableField
(
exist
=
false
)
private
Set
<
String
>
focusNull
;
@Override
public
Set
<
String
>
getFocusNull
()
{
if
(
focusNull
==
null
)
focusNull
=
new
HashSet
<>();
return
focusNull
;
}
@Override
public
void
setFocusNull
(
Set
<
String
>
focusNull
)
{
this
.
focusNull
=
focusNull
;
}
public
UpdateWrapper
getUpdateWrapper
(
boolean
clean
)
{
UpdateWrapper
wrapper
=
new
UpdateWrapper
();
for
(
String
nullField:
getFocusNull
())
{
wrapper
.
set
(
nullField
,
null
);
}
if
(
clean
)
focusNull
.
clear
();
return
wrapper
;
}
@Override
public
Serializable
getDefaultKey
(
boolean
gen
)
{
return
IdWorker
.
get32UUID
();
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录