Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdict
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdict
提交
5832f911
提交
5832f911
编写于
4月 24, 2020
作者:
ibizdev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ibizdev提交
上级
7c6c6ccd
变更
11
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
369 行增加
和
58 行删除
+369
-58
IBZDictItemServiceImpl.java
...bizlab/core/dict/service/impl/IBZDictItemServiceImpl.java
+0
-2
IBZDictServiceImpl.java
...cn/ibizlab/core/dict/service/impl/IBZDictServiceImpl.java
+0
-2
MongoDBConfig.java
.../main/java/cn/ibizlab/core/util/config/MongoDBConfig.java
+25
-0
DTOBase.java
...ct-util/src/main/java/cn/ibizlab/util/domain/DTOBase.java
+23
-0
EntityBase.java
...util/src/main/java/cn/ibizlab/util/domain/EntityBase.java
+81
-1
EntityMP.java
...t-util/src/main/java/cn/ibizlab/util/domain/EntityMP.java
+2
-28
DEFieldCacheMap.java
...src/main/java/cn/ibizlab/util/helper/DEFieldCacheMap.java
+70
-18
JSR310DateConverters.java
...ain/java/cn/ibizlab/util/helper/JSR310DateConverters.java
+149
-0
AuthenticationController.java
...n/java/cn/ibizlab/util/rest/AuthenticationController.java
+0
-6
AuthenticationUserService.java
...va/cn/ibizlab/util/service/AuthenticationUserService.java
+1
-1
SimpleUserService.java
.../main/java/cn/ibizlab/util/service/SimpleUserService.java
+18
-0
未找到文件。
ibzdict-core/src/main/java/cn/ibizlab/core/dict/service/impl/IBZDictItemServiceImpl.java
浏览文件 @
5832f911
...
...
@@ -67,7 +67,6 @@ public class IBZDictItemServiceImpl implements IIBZDictItemService {
@Override
@Transactional
public
boolean
save
(
IBZDictItem
et
)
{
if
(
et
.
getItemid
()==
null
)
et
.
setItemid
((
String
)
et
.
getDefaultKey
(
true
));
repository
.
save
(
et
);
CachedBeanCopier
.
copy
(
get
(
et
.
getItemid
()),
et
);
return
true
;
...
...
@@ -99,7 +98,6 @@ public class IBZDictItemServiceImpl implements IIBZDictItemService {
@Override
@Transactional
public
boolean
create
(
IBZDictItem
et
)
{
if
(
et
.
getItemid
()==
null
)
et
.
setItemid
((
String
)
et
.
getDefaultKey
(
true
));
repository
.
insert
(
et
);
CachedBeanCopier
.
copy
(
get
(
et
.
getItemid
()),
et
);
return
true
;
...
...
ibzdict-core/src/main/java/cn/ibizlab/core/dict/service/impl/IBZDictServiceImpl.java
浏览文件 @
5832f911
...
...
@@ -66,7 +66,6 @@ public class IBZDictServiceImpl implements IIBZDictService {
@Override
@Transactional
public
boolean
create
(
IBZDict
et
)
{
if
(
et
.
getDictid
()==
null
)
et
.
setDictid
((
String
)
et
.
getDefaultKey
(
true
));
repository
.
insert
(
et
);
ibzdictitemService
.
saveByDictid
(
et
.
getDictid
(),
et
.
getItems
());
CachedBeanCopier
.
copy
(
get
(
et
.
getDictid
()),
et
);
...
...
@@ -118,7 +117,6 @@ public class IBZDictServiceImpl implements IIBZDictService {
@Override
@Transactional
public
boolean
save
(
IBZDict
et
)
{
if
(
et
.
getDictid
()==
null
)
et
.
setDictid
((
String
)
et
.
getDefaultKey
(
true
));
repository
.
save
(
et
);
ibzdictitemService
.
saveByDictid
(
et
.
getDictid
(),
et
.
getItems
());
CachedBeanCopier
.
copy
(
get
(
et
.
getDictid
()),
et
);
...
...
ibzdict-core/src/main/java/cn/ibizlab/core/util/config/MongoDBConfig.java
0 → 100644
浏览文件 @
5832f911
package
cn
.
ibizlab
.
core
.
util
.
config
;
import
cn.ibizlab.util.helper.JSR310DateConverters
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.convert.converter.Converter
;
import
org.springframework.data.mongodb.core.convert.*
;
import
java.util.ArrayList
;
import
java.util.List
;
@Configuration
public
class
MongoDBConfig
{
@Bean
public
MongoCustomConversions
customConversions
()
{
List
<
Converter
<?,
?>>
converterList
=
new
ArrayList
<>();
converterList
.
add
(
JSR310DateConverters
.
DateToZonedDateTimeConverter
.
INSTANCE
);
converterList
.
add
(
JSR310DateConverters
.
ZonedDateTimeToDateConverter
.
INSTANCE
);
converterList
.
add
(
JSR310DateConverters
.
DurationToLongConverter
.
INSTANCE
);
converterList
.
add
(
JSR310DateConverters
.
TimestampToDateConverter
.
INSTANCE
);
converterList
.
add
(
JSR310DateConverters
.
DateToTimestampConverter
.
INSTANCE
);
return
new
MongoCustomConversions
(
converterList
);
}
}
\ No newline at end of file
ibzdict-util/src/main/java/cn/ibizlab/util/domain/DTOBase.java
浏览文件 @
5832f911
package
cn
.
ibizlab
.
util
.
domain
;
import
com.fasterxml.jackson.annotation.JsonAnyGetter
;
import
com.fasterxml.jackson.annotation.JsonAnySetter
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
java.io.Serializable
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Set
;
import
lombok.Data
;
...
...
@@ -29,5 +33,24 @@ public class DTOBase implements Serializable {
return
focusNull
;
}
@JsonIgnore
private
Map
<
String
,
Object
>
extensions
=
new
HashMap
<
String
,
Object
>();
public
Map
<
String
,
Object
>
getExtensions
()
{
return
extensions
;
}
public
void
setExtensions
(
Map
<
String
,
Object
>
extensions
)
{
this
.
extensions
=
extensions
;
}
@JsonAnyGetter
public
Map
<
String
,
Object
>
any
()
{
return
extensions
;
}
@JsonAnySetter
public
void
set
(
String
name
,
Object
value
)
{
extensions
.
put
(
name
.
toLowerCase
(),
value
);
}
}
ibzdict-util/src/main/java/cn/ibizlab/util/domain/EntityBase.java
浏览文件 @
5832f911
package
cn
.
ibizlab
.
util
.
domain
;
import
cn.ibizlab.util.helper.DEFieldCacheMap
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.fasterxml.jackson.annotation.JsonAnyGetter
;
import
com.fasterxml.jackson.annotation.JsonAnySetter
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
org.springframework.cglib.beans.BeanMap
;
import
org.springframework.data.annotation.Transient
;
import
org.springframework.util.AlternativeJdkIdGenerator
;
import
java.io.Serializable
;
import
java.util.*
;
public
class
EntityBase
implements
Serializable
{
@JsonIgnore
@JSONField
(
serialize
=
false
)
@TableField
(
exist
=
false
)
@Transient
private
Set
<
String
>
focusNull
;
public
Set
<
String
>
getFocusNull
()
{
if
(
focusNull
==
null
)
focusNull
=
new
HashSet
<>();
return
focusNull
;
}
public
void
setFocusNull
(
Set
<
String
>
focusNull
)
{
this
.
focusNull
=
focusNull
;
}
public
void
modify
(
String
field
,
Object
val
)
{
if
(
val
==
null
)
this
.
getFocusNull
().
add
(
field
.
toLowerCase
());
else
this
.
getFocusNull
().
remove
(
field
.
toLowerCase
());
}
public
Serializable
getDefaultKey
(
boolean
gen
)
{
...
...
@@ -13,6 +42,57 @@ public class EntityBase implements Serializable {
return
gen
?
Id
.
replace
(
"-"
,
""
):
Id
;
}
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
@TableField
(
exist
=
false
)
@Transient
private
BeanMap
map
;
private
BeanMap
getMap
()
{
if
(
map
==
null
)
map
=
BeanMap
.
create
(
this
);
return
map
;
}
@JsonIgnore
@TableField
(
exist
=
false
)
@Transient
private
Map
<
String
,
Object
>
extensionparams
=
new
HashMap
<
String
,
Object
>();
public
Map
<
String
,
Object
>
getExtensions
()
{
return
extensionparams
;
}
public
void
setExtensions
(
Map
<
String
,
Object
>
extensions
)
{
this
.
extensionparams
=
extensions
;
}
public
Object
get
(
String
field
)
{
field
=
field
.
toLowerCase
();
Hashtable
<
String
,
String
>
keys
=
DEFieldCacheMap
.
getFieldKeys
(
this
.
getClass
().
getName
());
if
(
keys
.
containsKey
(
field
))
return
getMap
().
get
(
keys
.
get
(
field
));
else
return
this
.
extensionparams
.
get
(
field
);
}
@JsonAnyGetter
public
Map
<
String
,
Object
>
any
()
{
return
extensionparams
;
}
@JsonAnySetter
public
void
set
(
String
field
,
Object
value
)
{
field
=
field
.
toLowerCase
();
Hashtable
<
String
,
String
>
keys
=
DEFieldCacheMap
.
getFieldKeys
(
this
.
getClass
().
getName
());
if
(
keys
.
containsKey
(
field
))
getMap
().
put
(
keys
.
get
(
field
),
value
);
else
this
.
extensionparams
.
put
(
field
,
value
);
}
}
\ No newline at end of file
ibzdict-util/src/main/java/cn/ibizlab/util/domain/EntityMP.java
浏览文件 @
5832f911
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.fasterxml.jackson.annotation.JsonIgnore
;
import
java.util.HashSet
;
import
java.util.Set
;
public
class
EntityMP
extends
EntityBase
{
@JsonIgnore
@JSONField
(
serialize
=
false
)
@TableField
(
exist
=
false
)
private
Set
<
String
>
focusNull
;
public
Set
<
String
>
getFocusNull
()
{
if
(
focusNull
==
null
)
focusNull
=
new
HashSet
<>();
return
focusNull
;
}
public
void
setFocusNull
(
Set
<
String
>
focusNull
)
{
this
.
focusNull
=
focusNull
;
}
@Override
public
void
modify
(
String
field
,
Object
val
)
{
super
.
modify
(
field
,
val
);
if
(
val
==
null
)
this
.
getFocusNull
().
add
(
field
.
toLowerCase
());
else
this
.
getFocusNull
().
remove
(
field
.
toLowerCase
());
}
public
UpdateWrapper
getUpdateWrapper
(
boolean
clean
)
{
UpdateWrapper
wrapper
=
new
UpdateWrapper
();
...
...
@@ -39,8 +12,9 @@ public class EntityMP extends EntityBase {
wrapper
.
set
(
nullField
,
null
);
}
if
(
clean
)
focusNull
.
clear
();
getFocusNull
()
.
clear
();
return
wrapper
;
}
}
ibzdict-util/src/main/java/cn/ibizlab/util/helper/DEFieldCacheMap.java
浏览文件 @
5832f911
...
...
@@ -13,6 +13,15 @@ public class DEFieldCacheMap {
private
static
Hashtable
<
String
,
Hashtable
<
String
,
Field
>>
cacheMap
=
new
Hashtable
<>();
private
static
Hashtable
<
String
,
List
<
Field
>>
cacheList
=
new
Hashtable
<>();
private
static
Hashtable
<
String
,
Hashtable
<
String
,
String
>>
cacheKey
=
new
Hashtable
<>();
private
static
Object
objLock1
=
new
Object
();
private
static
Object
objLock2
=
new
Object
();
private
static
Object
objLock3
=
new
Object
();
/**
* 将实体对象中的属性存入缓存中
* @param className
...
...
@@ -21,16 +30,24 @@ public class DEFieldCacheMap {
public
static
Hashtable
<
String
,
Field
>
getFieldMap
(
String
className
)
{
if
(
className
.
indexOf
(
"_$"
)>
0
)
className
=
className
.
substring
(
0
,
className
.
lastIndexOf
(
"_$"
));
Class
clazz
=
null
;
try
{
clazz
=
Class
.
forName
(
className
);
}
catch
(
Exception
ex
)
{
return
new
Hashtable
<
String
,
Field
>();
}
if
(
cacheMap
.
containsKey
(
className
))
return
cacheMap
.
get
(
className
);
synchronized
(
DEFieldCacheMap
.
class
)
{
synchronized
(
objLock1
)
{
if
(
cacheMap
.
containsKey
(
className
))
return
cacheMap
.
get
(
className
);
Class
clazz
=
null
;
try
{
clazz
=
Class
.
forName
(
className
);
}
catch
(
Exception
ex
)
{
cacheMap
.
put
(
className
,
new
Hashtable
<
String
,
Field
>());
return
cacheMap
.
get
(
className
);
}
Hashtable
<
String
,
Field
>
result
=
cacheMap
.
get
(
className
);
if
(
result
==
null
)
{
result
=
new
Hashtable
<
String
,
Field
>();
...
...
@@ -52,16 +69,51 @@ public class DEFieldCacheMap {
public
static
List
<
Field
>
getFields
(
String
className
)
{
if
(
className
.
indexOf
(
"_$"
)>
0
)
className
=
className
.
substring
(
0
,
className
.
lastIndexOf
(
"_$"
));
Hashtable
<
String
,
Field
>
fieldmap
=
cacheMap
.
get
(
className
);
if
(
fieldmap
==
null
)
fieldmap
=
DEFieldCacheMap
.
getFieldMap
(
className
);
Iterator
it
=
fieldmap
.
keySet
().
iterator
();
List
<
Field
>
list
=
new
ArrayList
<
Field
>();
while
(
it
.
hasNext
())
{
Object
key
=
it
.
next
();
if
(
fieldmap
.
get
(
key
.
toString
())!=
null
)
list
.
add
(
fieldmap
.
get
(
key
.
toString
()));
if
(
cacheList
.
containsKey
(
className
))
return
cacheList
.
get
(
className
);
synchronized
(
objLock2
)
{
if
(
cacheList
.
containsKey
(
className
))
return
cacheList
.
get
(
className
);
Hashtable
<
String
,
Field
>
fieldmap
=
DEFieldCacheMap
.
getFieldMap
(
className
);
Iterator
it
=
fieldmap
.
keySet
().
iterator
();
List
<
Field
>
list
=
new
ArrayList
<
Field
>();
while
(
it
.
hasNext
())
{
Object
key
=
it
.
next
();
if
(
fieldmap
.
get
(
key
.
toString
())!=
null
)
list
.
add
(
fieldmap
.
get
(
key
.
toString
()));
}
cacheList
.
put
(
className
,
list
);
return
list
;
}
}
/**
* 从缓存中查询实体对象属性列表
* @param className
* @return
*/
public
static
Hashtable
<
String
,
String
>
getFieldKeys
(
String
className
)
{
if
(
className
.
indexOf
(
"_$"
)>
0
)
className
=
className
.
substring
(
0
,
className
.
lastIndexOf
(
"_$"
));
if
(
cacheKey
.
containsKey
(
className
))
return
cacheKey
.
get
(
className
);
synchronized
(
objLock3
)
{
if
(
cacheKey
.
containsKey
(
className
))
return
cacheKey
.
get
(
className
);
Hashtable
<
String
,
Field
>
fieldmap
=
DEFieldCacheMap
.
getFieldMap
(
className
);
Iterator
it
=
fieldmap
.
keySet
().
iterator
();
Hashtable
<
String
,
String
>
list
=
new
Hashtable
<
String
,
String
>();
while
(
it
.
hasNext
())
{
Object
key
=
it
.
next
();
list
.
put
(
key
.
toString
().
toLowerCase
(),
key
.
toString
());
}
cacheKey
.
put
(
className
,
list
);
return
list
;
}
return
list
;
}
}
\ No newline at end of file
ibzdict-util/src/main/java/cn/ibizlab/util/helper/JSR310DateConverters.java
0 → 100644
浏览文件 @
5832f911
package
cn
.
ibizlab
.
util
.
helper
;
import
org.springframework.core.convert.converter.Converter
;
import
java.sql.Timestamp
;
import
java.time.*
;
import
java.util.Date
;
/**
* <p>JSR310DateConverters class.</p>
*/
public
final
class
JSR310DateConverters
{
private
JSR310DateConverters
()
{
}
public
static
class
TimestampToDateConverter
implements
Converter
<
Timestamp
,
Date
>
{
public
static
final
TimestampToDateConverter
INSTANCE
=
new
TimestampToDateConverter
();
private
TimestampToDateConverter
()
{
}
@Override
public
Date
convert
(
Timestamp
source
)
{
return
source
==
null
?
null
:
new
Date
(
source
.
getTime
());
}
}
public
static
class
DateToTimestampConverter
implements
Converter
<
Date
,
Timestamp
>
{
public
static
final
DateToTimestampConverter
INSTANCE
=
new
DateToTimestampConverter
();
private
DateToTimestampConverter
()
{
}
@Override
public
Timestamp
convert
(
Date
source
)
{
return
source
==
null
?
null
:
new
Timestamp
(
source
.
getTime
());
}
}
public
static
class
LocalDateToDateConverter
implements
Converter
<
LocalDate
,
Date
>
{
public
static
final
LocalDateToDateConverter
INSTANCE
=
new
LocalDateToDateConverter
();
private
LocalDateToDateConverter
()
{
}
@Override
public
Date
convert
(
LocalDate
source
)
{
return
source
==
null
?
null
:
Date
.
from
(
source
.
atStartOfDay
(
ZoneId
.
systemDefault
()).
toInstant
());
}
}
public
static
class
DateToLocalDateConverter
implements
Converter
<
Date
,
LocalDate
>
{
public
static
final
DateToLocalDateConverter
INSTANCE
=
new
DateToLocalDateConverter
();
private
DateToLocalDateConverter
()
{
}
@Override
public
LocalDate
convert
(
Date
source
)
{
return
source
==
null
?
null
:
ZonedDateTime
.
ofInstant
(
source
.
toInstant
(),
ZoneId
.
systemDefault
())
.
toLocalDate
();
}
}
public
static
class
ZonedDateTimeToDateConverter
implements
Converter
<
ZonedDateTime
,
Date
>
{
public
static
final
ZonedDateTimeToDateConverter
INSTANCE
=
new
ZonedDateTimeToDateConverter
();
private
ZonedDateTimeToDateConverter
()
{
}
@Override
public
Date
convert
(
ZonedDateTime
source
)
{
return
source
==
null
?
null
:
Date
.
from
(
source
.
toInstant
());
}
}
public
static
class
DateToZonedDateTimeConverter
implements
Converter
<
Date
,
ZonedDateTime
>
{
public
static
final
DateToZonedDateTimeConverter
INSTANCE
=
new
DateToZonedDateTimeConverter
();
private
DateToZonedDateTimeConverter
()
{
}
@Override
public
ZonedDateTime
convert
(
Date
source
)
{
return
source
==
null
?
null
:
ZonedDateTime
.
ofInstant
(
source
.
toInstant
(),
ZoneId
.
systemDefault
());
}
}
public
static
class
LocalDateTimeToDateConverter
implements
Converter
<
LocalDateTime
,
Date
>
{
public
static
final
LocalDateTimeToDateConverter
INSTANCE
=
new
LocalDateTimeToDateConverter
();
private
LocalDateTimeToDateConverter
()
{
}
@Override
public
Date
convert
(
LocalDateTime
source
)
{
return
source
==
null
?
null
:
Date
.
from
(
source
.
atZone
(
ZoneId
.
systemDefault
()).
toInstant
());
}
}
public
static
class
DateToLocalDateTimeConverter
implements
Converter
<
Date
,
LocalDateTime
>
{
public
static
final
DateToLocalDateTimeConverter
INSTANCE
=
new
DateToLocalDateTimeConverter
();
private
DateToLocalDateTimeConverter
()
{
}
@Override
public
LocalDateTime
convert
(
Date
source
)
{
return
source
==
null
?
null
:
LocalDateTime
.
ofInstant
(
source
.
toInstant
(),
ZoneId
.
systemDefault
());
}
}
public
static
class
DurationToLongConverter
implements
Converter
<
Duration
,
Long
>
{
public
static
final
DurationToLongConverter
INSTANCE
=
new
DurationToLongConverter
();
private
DurationToLongConverter
()
{
}
@Override
public
Long
convert
(
Duration
source
)
{
return
source
==
null
?
null
:
source
.
toNanos
();
}
}
public
static
class
LongToDurationConverter
implements
Converter
<
Long
,
Duration
>
{
public
static
final
LongToDurationConverter
INSTANCE
=
new
LongToDurationConverter
();
private
LongToDurationConverter
()
{
}
@Override
public
Duration
convert
(
Long
source
)
{
return
source
==
null
?
null
:
Duration
.
ofNanos
(
source
);
}
}
}
\ No newline at end of file
ibzdict-util/src/main/java/cn/ibizlab/util/rest/AuthenticationController.java
浏览文件 @
5832f911
...
...
@@ -41,12 +41,6 @@ public class AuthenticationController
public
ResponseEntity
<
AuthenticationInfo
>
login
(
@Validated
@RequestBody
AuthorizationLogin
authorizationLogin
){
userService
.
resetByUsername
(
authorizationLogin
.
getUsername
());
final
AuthenticationUser
authuserdetail
=
(
AuthenticationUser
)
userDetailsService
.
loadUserByUsername
(
authorizationLogin
.
getUsername
());
String
password
=
authorizationLogin
.
getPassword
();
if
(
pwencry
)
password
=
DigestUtils
.
md5DigestAsHex
(
authorizationLogin
.
getPassword
().
getBytes
());
if
(!
authuserdetail
.
getPassword
().
equals
(
password
)){
throw
new
RuntimeException
(
"用户名密码错误"
);
}
// 生成令牌
final
String
token
=
jwtTokenUtil
.
generateToken
(
authuserdetail
);
// 返回 token
...
...
ibzdict-util/src/main/java/cn/ibizlab/util/service/AuthenticationUserService.java
浏览文件 @
5832f911
...
...
@@ -9,7 +9,7 @@ import org.springframework.stereotype.Service;
public
class
AuthenticationUserService
implements
UserDetailsService
{
@Autowired
private
IBZUSER
Service
userService
;
private
SimpleUser
Service
userService
;
@Override
public
UserDetails
loadUserByUsername
(
String
username
){
...
...
ibzdict-util/src/main/java/cn/ibizlab/util/service/SimpleUserService.java
0 → 100644
浏览文件 @
5832f911
package
cn
.
ibizlab
.
util
.
service
;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
org.springframework.stereotype.Service
;
/**
* 实体[IBZUSER] 服务对象接口实现
*/
@Service
public
class
SimpleUserService
{
public
AuthenticationUser
getByUsername
(
String
username
)
{
AuthenticationUser
user
=
new
AuthenticationUser
();
user
.
setUsername
(
username
);
return
user
;
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录