Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz4j Spring R7
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7后台标准模板
iBiz4j Spring R7
提交
b455b6db
提交
b455b6db
编写于
5月 10, 2021
作者:
lengyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
支持Saas模式4,L2统一登出
上级
a1ef8a79
变更
5
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
262 行增加
和
2 行删除
+262
-2
CusCaffeineCache.java.ftl
.../%SYS_PKGPATH%/util/cache/cache/CusCaffeineCache.java.ftl
+45
-0
CusRedisCache.java.ftl
...ava/%SYS_PKGPATH%/util/cache/cache/CusRedisCache.java.ftl
+16
-0
LayeringCacheManager.java.ftl
...TH%/util/cache/cacheManager/LayeringCacheManager.java.ftl
+2
-1
Globs.java.ftl
...il/src/main/java/%SYS_PKGPATH%/util/helper/Globs.java.ftl
+198
-0
AuthenticationUserService.java.ftl
..._PKGPATH%/util/service/AuthenticationUserService.java.ftl
+1
-1
未找到文件。
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/cache/cache/CusCaffeineCache.java.ftl
0 → 100644
浏览文件 @
b455b6db
<#
ibiztemplate
>
TARGET
=
PSSYSTEM
</#
ibiztemplate
>
package
${
pub
.
getPKGCodeName
()}.
util
.
cache
.
cache
;
import
${
pub
.
getPKGCodeName
()}..
util
.
helper
.
Globs
;
import
org
.
springframework
.
cache
.
caffeine
.
CaffeineCache
;
import
com
.
github
.
benmanes
.
caffeine
.
cache
.
Cache
;
import
javax
.
validation
.
constraints
.
NotNull
;
import
java
.
util
.
Set
;
import
java
.
util
.
stream
.
Collectors
;
/**
*
自定义的
Caffeine
缓存
*/
public
class
CusCaffeineCache
extends
CaffeineCache
{
public
CusCaffeineCache
(
String
name
,
Cache
<
Object
,
Object
>
cache
)
{
super
(
name
,
cache
);
}
public
CusCaffeineCache
(
String
name
,
Cache
<
Object
,
Object
>
cache
,
boolean
allowNullValues
)
{
super
(
name
,
cache
,
allowNullValues
);
}
@
Override
public
void
evict
(@
NotNull
Object
key
)
{
if
(
key
instanceof
String
&&
((
String
)
key
).
startsWith
(
"glob:"
))
{
String
globPattern
=
((
String
)
key
).
split
(
"glob:"
)[
1
];
//
将
Glob
匹配转换成正则匹配
String
regexPattern
=
Globs
.
toUnixRegexPattern
(
globPattern
);
//
String
regexPattern
=
Globs
.
toWindowsRegexPattern
(
globPattern
);
Cache
<
Object
,
Object
>
cache
=
super
.
getNativeCache
();
Set
<
Object
>
keySet
=
cache
.
asMap
().
keySet
();
keySet
=
keySet
.
stream
().
filter
(
o
->
o
.
toString
().
matches
(
regexPattern
)).
collect
(
Collectors
.
toSet
());
cache
.
invalidateAll
(
keySet
);
}
else
{
super
.
evict
(
key
);
}
}
}
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/cache/cache/CusRedisCache.java.ftl
浏览文件 @
b455b6db
...
@@ -7,6 +7,8 @@ import org.springframework.data.redis.cache.RedisCache;
...
@@ -7,6 +7,8 @@ import org.springframework.data.redis.cache.RedisCache;
import
org
.
springframework
.
data
.
redis
.
cache
.
RedisCacheConfiguration
;
import
org
.
springframework
.
data
.
redis
.
cache
.
RedisCacheConfiguration
;
import
org
.
springframework
.
data
.
redis
.
cache
.
RedisCacheWriter
;
import
org
.
springframework
.
data
.
redis
.
cache
.
RedisCacheWriter
;
import
javax
.
validation
.
constraints
.
NotNull
;
/**
/**
*
自定义的
redis
缓存
*
自定义的
redis
缓存
*/
*/
...
@@ -15,4 +17,18 @@ public class CusRedisCache extends RedisCache {
...
@@ -15,4 +17,18 @@ public class CusRedisCache extends RedisCache {
public
CusRedisCache
(
String
name
,
RedisCacheWriter
redisCacheWriter
,
RedisCacheConfiguration
configuration
)
{
public
CusRedisCache
(
String
name
,
RedisCacheWriter
redisCacheWriter
,
RedisCacheConfiguration
configuration
)
{
super
(
name
,
redisCacheWriter
,
configuration
);
super
(
name
,
redisCacheWriter
,
configuration
);
}
}
@
Override
public
void
evict
(@
NotNull
Object
key
)
{
if
(
key
instanceof
String
&&
((
String
)
key
).
startsWith
(
"glob:"
))
{
String
globPattern
=
((
String
)
key
).
split
(
"glob:"
)[
1
];
byte
[]
globPatternBytes
=
super
.
getCacheConfiguration
().
getConversionService
().
convert
(
globPattern
,
byte
[].
class
);
if
(
globPatternBytes
!=null){
super
.
getNativeCache
().
clean
(
super
.
getName
(),
globPatternBytes
);
}
}
else
{
super
.
evict
(
key
);
}
}
}
}
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/cache/cacheManager/LayeringCacheManager.java.ftl
浏览文件 @
b455b6db
...
@@ -18,6 +18,7 @@ import java.util.Collections;
...
@@ -18,6 +18,7 @@ import java.util.Collections;
import
java
.
util
.
concurrent
.
ConcurrentHashMap
;
import
java
.
util
.
concurrent
.
ConcurrentHashMap
;
import
java
.
util
.
concurrent
.
ConcurrentMap
;
import
java
.
util
.
concurrent
.
ConcurrentMap
;
import
java
.
util
.
concurrent
.
TimeUnit
;
import
java
.
util
.
concurrent
.
TimeUnit
;
import
${
pub
.
getPKGCodeName
()}.
util
.
cache
.
cache
.
CusCaffeineCache
;
import
${
pub
.
getPKGCodeName
()}.
util
.
cache
.
cache
.
CusRedisCache
;
import
${
pub
.
getPKGCodeName
()}.
util
.
cache
.
cache
.
CusRedisCache
;
import
${
pub
.
getPKGCodeName
()}.
util
.
cache
.
cache
.
LayeringCache
;
import
${
pub
.
getPKGCodeName
()}.
util
.
cache
.
cache
.
LayeringCache
;
...
@@ -83,7 +84,7 @@ public class LayeringCacheManager implements CacheManager {
...
@@ -83,7 +84,7 @@ public class LayeringCacheManager implements CacheManager {
*
@
return
*
@
return
*/
*/
protected
Cache
createCache
(
String
cacheName
)
{
protected
Cache
createCache
(
String
cacheName
)
{
return
new
LayeringCache
(
cacheName
,
new
CaffeineCache
(
cacheName
,
this
.
cacheBuilder
.
build
(),
true
),
new
CusRedisCache
(
cacheName
,
redisCacheWriter
,
redisConfiguration
),
redisTemplate
);
return
new
LayeringCache
(
cacheName
,
new
C
usC
affeineCache
(
cacheName
,
this
.
cacheBuilder
.
build
(),
true
),
new
CusRedisCache
(
cacheName
,
redisCacheWriter
,
redisConfiguration
),
redisTemplate
);
}
}
/**
/**
...
...
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/helper/Globs.java.ftl
0 → 100644
浏览文件 @
b455b6db
<#
ibiztemplate
>
TARGET
=
PSSYSTEM
</#
ibiztemplate
>
package
${
pub
.
getPKGCodeName
()}.
util
.
helper
;
import
java
.
util
.
regex
.
PatternSyntaxException
;
/**
*
Copy
from
class
sun
.
nio
.
fs
.
Globs
*/
public
class
Globs
{
private
Globs
()
{
}
private
static
final
String
regexMetaChars
=
".^$+{[]|()"
;
private
static
final
String
globMetaChars
=
"
\\
*?[{"
;
private
static
boolean
isRegexMeta
(
char
c
)
{
return
regexMetaChars
.
indexOf
(
c
)
!= -1;
}
private
static
boolean
isGlobMeta
(
char
c
)
{
return
globMetaChars
.
indexOf
(
c
)
!= -1;
}
private
static
char
EOL
=
0
;
//
TBD
private
static
char
next
(
String
glob
,
int
i
)
{
if
(
i
<
glob
.
length
())
{
return
glob
.
charAt
(
i
);
}
return
EOL
;
}
/**
*
Creates
a
regex
pattern
from
the
given
glob
expression
.
*
*
@
throws
PatternSyntaxException
*/
private
static
String
toRegexPattern
(
String
globPattern
,
boolean
isDos
)
{
boolean
inGroup
=
false
;
StringBuilder
regex
=
new
StringBuilder
(
"^"
);
int
i
=
0
;
while
(
i
<
globPattern
.
length
())
{
char
c
=
globPattern
.
charAt
(
i
++);
switch
(
c
)
{
case
'\\'
:
//
escape
special
characters
if
(
i
==
globPattern
.
length
())
{
throw
new
PatternSyntaxException
(
"No character to escape"
,
globPattern
,
i
-
1
);
}
char
next
=
globPattern
.
charAt
(
i
++);
if
(
isGlobMeta
(
next
)
||
isRegexMeta
(
next
))
{
regex
.
append
(
'\\'
);
}
regex
.
append
(
next
);
break
;
case
'/'
:
if
(
isDos
)
{
regex
.
append
(
"
\\\\
"
);
}
else
{
regex
.
append
(
c
);
}
break
;
case
'['
:
//
don
't match name separator in class
if (isDos) {
regex.append("[[^\\\\]&&[");
} else {
regex.append("[[^/]&&[");
}
if (next(globPattern, i) == '
^
') {
// escape the regex negation char if it appears
regex.append("\\^");
i++;
} else {
// negation
if (next(globPattern, i) == '
!') {
regex
.
append
(
'^'
);
i
++;
}
//
hyphen
allowed
at
start
if
(
next
(
globPattern
,
i
)
==
'-'
)
{
regex
.
append
(
'-'
);
i
++;
}
}
boolean
hasRangeStart
=
false
;
char
last
=
0
;
while
(
i
<
globPattern
.
length
())
{
c
=
globPattern
.
charAt
(
i
++);
if
(
c
==
']'
)
{
break
;
}
if
(
c
==
'/'
||
(
isDos
&&
c
==
'\\'
))
{
throw
new
PatternSyntaxException
(
"Explicit 'name separator' in class"
,
globPattern
,
i
-
1
);
}
//
TBD
:
how
to
specify
']'
in
a
class
?
if
(
c
==
'\\'
||
c
==
'['
||
c
==
'&'
&&
next
(
globPattern
,
i
)
==
'&'
)
{
//
escape
'\'
,
'['
or
"&&"
for
regex
class
regex
.
append
(
'\\'
);
}
regex
.
append
(
c
);
if
(
c
==
'-'
)
{
if
(
!hasRangeStart) {
throw
new
PatternSyntaxException
(
"Invalid range"
,
globPattern
,
i
-
1
);
}
if
((
c
=
next
(
globPattern
,
i
++))
==
EOL
||
c
==
']'
)
{
break
;
}
if
(
c
<
last
)
{
throw
new
PatternSyntaxException
(
"Invalid range"
,
globPattern
,
i
-
3
);
}
regex
.
append
(
c
);
hasRangeStart
=
false
;
}
else
{
hasRangeStart
=
true
;
last
=
c
;
}
}
if
(
c
!= ']') {
throw
new
PatternSyntaxException
(
"Missing ']"
,
globPattern
,
i
-
1
);
}
regex
.
append
(
"]]"
);
break
;
case
'{'
:
if
(
inGroup
)
{
throw
new
PatternSyntaxException
(
"Cannot nest groups"
,
globPattern
,
i
-
1
);
}
regex
.
append
(
"(?:(?:"
);
inGroup
=
true
;
break
;
case
'}'
:
if
(
inGroup
)
{
regex
.
append
(
"))"
);
inGroup
=
false
;
}
else
{
regex
.
append
(
'}'
);
}
break
;
case
','
:
if
(
inGroup
)
{
regex
.
append
(
")|(?:"
);
}
else
{
regex
.
append
(
','
);
}
break
;
case
'*'
:
if
(
next
(
globPattern
,
i
)
==
'*'
)
{
//
crosses
directory
boundaries
regex
.
append
(
".*"
);
i
++;
}
else
{
//
within
directory
boundary
if
(
isDos
)
{
regex
.
append
(
"[^
\\\\
]*"
);
}
else
{
regex
.
append
(
"[^/]*"
);
}
}
break
;
case
'?'
:
if
(
isDos
)
{
regex
.
append
(
"[^
\\\\
]"
);
}
else
{
regex
.
append
(
"[^/]"
);
}
break
;
default
:
if
(
isRegexMeta
(
c
))
{
regex
.
append
(
'\\'
);
}
regex
.
append
(
c
);
}
}
if
(
inGroup
)
{
throw
new
PatternSyntaxException
(
"Missing '}"
,
globPattern
,
i
-
1
);
}
return
regex
.
append
(
'$'
).
toString
();
}
public
static
String
toUnixRegexPattern
(
String
globPattern
)
{
return
toRegexPattern
(
globPattern
,
false
);
}
public
static
String
toWindowsRegexPattern
(
String
globPattern
)
{
return
toRegexPattern
(
globPattern
,
true
);
}
}
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/service/AuthenticationUserService.java.ftl
浏览文件 @
b455b6db
...
@@ -42,7 +42,7 @@ public interface AuthenticationUserService extends UserDetailsService {
...
@@ -42,7 +42,7 @@ public interface AuthenticationUserService extends UserDetailsService {
default
void
resetByUsername
(
String
username
){}
default
void
resetByUsername
(
String
username
){}
<#
if
sys
.
getSaaSMode
()==
4
>
<#
if
sys
.
getSaaSMode
()==
4
>
@
CacheEvict
(
value
=
"ibzuaa_users"
,
key
=
"
#p0+':'+#p1+'
:getByUsername:'+#p2"
)
@
CacheEvict
(
value
=
"ibzuaa_users"
,
key
=
"
'glob:*
:getByUsername:'+#p2"
)
default
void
resetByUsername
(
String
srfsystem
,
String
srforgid
,
String
username
){
default
void
resetByUsername
(
String
srfsystem
,
String
srforgid
,
String
username
){
}
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录