Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdict
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdict
提交
ddcd41ec
提交
ddcd41ec
编写于
8月 05, 2020
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
代码表
上级
1e074cf1
变更
8
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
255 行增加
和
0 行删除
+255
-0
webSecurityConfig.java
...rc/main/java/cn/ibizlab/web/config/webSecurityConfig.java
+1
-0
DevBootSecurityConfig.java
...rc/main/java/cn/ibizlab/config/DevBootSecurityConfig.java
+1
-0
CacheRefreshAspect.java
...izlab/core/dict/extensions/aspect/CacheRefreshAspect.java
+52
-0
DictCoreService.java
...ibizlab/core/dict/extensions/service/DictCoreService.java
+75
-0
Catalog.java
...main/java/cn/ibizlab/core/dict/extensions/vo/Catalog.java
+44
-0
Option.java
.../main/java/cn/ibizlab/core/dict/extensions/vo/Option.java
+13
-0
apiSecurityConfig.java
...rc/main/java/cn/ibizlab/api/config/apiSecurityConfig.java
+1
-0
DictCoreResource.java
...java/cn/ibizlab/api/rest/extensions/DictCoreResource.java
+68
-0
未找到文件。
ibzdict-app/ibzdict-app-web/src/main/java/cn/ibizlab/web/config/webSecurityConfig.java
浏览文件 @
ddcd41ec
...
...
@@ -117,6 +117,7 @@ public class webSecurityConfig extends WebSecurityConfigurerAdapter {
.
antMatchers
(
"/"
+
downloadpath
+
"/**"
).
permitAll
()
.
antMatchers
(
"/"
+
uploadpath
).
permitAll
()
.
antMatchers
(
"/"
+
previewpath
+
"/**"
).
permitAll
()
.
antMatchers
(
"/dictionarys/**"
).
permitAll
()
// 所有请求都需要认证
.
anyRequest
().
authenticated
()
// 防止iframe 造成跨域
...
...
ibzdict-boot/src/main/java/cn/ibizlab/config/DevBootSecurityConfig.java
浏览文件 @
ddcd41ec
...
...
@@ -114,6 +114,7 @@ public class DevBootSecurityConfig extends WebSecurityConfigurerAdapter {
.
antMatchers
(
"/"
+
downloadpath
+
"/**"
).
permitAll
()
.
antMatchers
(
"/"
+
uploadpath
).
permitAll
()
.
antMatchers
(
"/"
+
previewpath
+
"/**"
).
permitAll
()
.
antMatchers
(
"/dictionarys/**"
).
permitAll
()
.
anyRequest
().
authenticated
()
// 防止iframe 造成跨域
.
and
().
headers
().
frameOptions
().
disable
();
...
...
ibzdict-core/src/main/java/cn/ibizlab/core/dict/extensions/aspect/CacheRefreshAspect.java
0 → 100644
浏览文件 @
ddcd41ec
package
cn
.
ibizlab
.
core
.
dict
.
extensions
.
aspect
;
import
cn.ibizlab.core.dict.domain.DictCatalog
;
import
cn.ibizlab.core.dict.extensions.service.DictCoreService
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Before
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.StringUtils
;
@Aspect
@Order
(
0
)
@Component
public
class
CacheRefreshAspect
{
@Autowired
@Lazy
private
DictCoreService
dictCoreService
;
@Before
(
value
=
"execution(* cn.ibizlab.core.dict.service.IDictCatalogService.update(..))"
)
public
void
BeforeUpdateEmp
(
JoinPoint
point
)
throws
Exception
{
refreshDictCache
(
point
);
}
@Before
(
value
=
"execution(* cn.ibizlab.core.dict.service.IDictCatalogService.save(..))"
)
public
void
BeforeSaveEmp
(
JoinPoint
point
)
throws
Exception
{
refreshDictCache
(
point
);
}
private
void
refreshDictCache
(
JoinPoint
point
)
{
Object
[]
args
=
point
.
getArgs
();
if
(
args
.
length
>
0
)
{
Object
obj
=
args
[
0
];
if
(
obj
instanceof
DictCatalog
)
{
String
code
=((
DictCatalog
)
obj
).
getCode
();
if
(!
StringUtils
.
isEmpty
(
code
))
dictCoreService
.
resetDictCatalog
(
code
);
}
}
}
}
ibzdict-core/src/main/java/cn/ibizlab/core/dict/extensions/service/DictCoreService.java
浏览文件 @
ddcd41ec
package
cn
.
ibizlab
.
core
.
dict
.
extensions
.
service
;
import
cn.ibizlab.core.dict.domain.DictCatalog
;
import
cn.ibizlab.core.dict.domain.DictOption
;
import
cn.ibizlab.core.dict.extensions.vo.Catalog
;
import
cn.ibizlab.core.dict.extensions.vo.Option
;
import
cn.ibizlab.core.dict.service.IDictCatalogService
;
import
cn.ibizlab.core.dict.service.IDictOptionService
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
java.sql.Wrapper
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Slf4j
@Service
public
class
DictCoreService
{
@Autowired
private
IDictCatalogService
dictCatalogService
;
@Autowired
private
IDictOptionService
optionService
;
@Cacheable
(
value
=
"dictcatalog"
,
key
=
"'dict:'+#p0"
)
public
Catalog
getDictCatalog
(
String
code
)
{
Catalog
catalog
=
new
Catalog
();
DictCatalog
dictCatalog
=
dictCatalogService
.
getOne
(
Wrappers
.<
DictCatalog
>
query
().
eq
(
"ccode"
,
code
));
catalog
.
setCode
(
dictCatalog
.
getCode
()).
setName
(
dictCatalog
.
getName
());
List
<
Option
>
list
=
new
ArrayList
<>();
optionService
.
list
(
Wrappers
.<
DictOption
>
query
().
eq
(
"catalog_id"
,
dictCatalog
.
getId
()).
orderByAsc
(
"showorder"
)).
forEach
(
item
->{
Map
<
String
,
Object
>
extension
=
new
HashMap
<>();
if
(!
StringUtils
.
isEmpty
(
item
.
getExtension
()))
extension
=
JSONObject
.
parseObject
(
item
.
getExtension
(),
Map
.
class
);
list
.
add
(
new
Option
().
setValue
(
item
.
getValue
()).
setId
(
item
.
getValue
())
.
setDisabled
(((
item
.
getDisabled
()!=
null
&&
item
.
getDisabled
()==
1
)||(
item
.
getExpired
()!=
null
&&
item
.
getExpired
()==
1
))?
true
:
false
)
.
setFilter
(
item
.
getFilter
()).
setIconClass
(
item
.
getIconClass
()).
setLabel
(
item
.
getLabel
()).
setParent
(
item
.
getParent
()).
setExtension
(
extension
)
);
});
List
<
Option
>
codeItemTreeList
=
new
ArrayList
<
Option
>();
codeItemTreeList
=
loop
(
list
,
""
);
catalog
.
setOptions
(
codeItemTreeList
);
return
catalog
;
}
@CacheEvict
(
value
=
"dictcatalog"
,
key
=
"'dict:'+#p0"
)
public
void
resetDictCatalog
(
String
code
)
{
}
public
List
<
Option
>
loop
(
List
<
Option
>
listCodeItem
,
Object
parentValue
)
{
List
<
Option
>
trees
=
new
ArrayList
<
Option
>();
for
(
Option
codeItem
:
listCodeItem
)
{
String
codeItemParentValue
=
codeItem
.
getParent
();
if
(
StringUtils
.
isEmpty
(
codeItemParentValue
))
{
codeItemParentValue
=
""
;
}
if
(
parentValue
.
equals
(
codeItemParentValue
))
{
List
<
Option
>
childCodeItem
=
loop
(
listCodeItem
,
codeItem
.
getValue
());
if
(
childCodeItem
.
size
()
>
0
)
{
codeItem
.
setChildren
(
childCodeItem
);
}
trees
.
add
(
codeItem
);
}
}
return
trees
;
}
}
ibzdict-core/src/main/java/cn/ibizlab/core/dict/extensions/vo/Catalog.java
0 → 100644
浏览文件 @
ddcd41ec
package
cn
.
ibizlab
.
core
.
dict
.
extensions
.
vo
;
import
cn.ibizlab.util.annotation.DEField
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Accessors
(
chain
=
true
)
public
class
Catalog
{
private
String
code
;
private
String
name
;
@JSONField
(
name
=
"srfkey"
)
@JsonProperty
(
"srfkey"
)
public
String
getSrfkey
()
{
return
code
;
}
@JSONField
(
name
=
"emptytext"
)
@JsonProperty
(
"emptytext"
)
public
String
getEmptytext
()
{
return
""
;
}
private
List
<
Option
>
options
=
new
ArrayList
<>();
}
ibzdict-core/src/main/java/cn/ibizlab/core/dict/extensions/vo/Option.java
浏览文件 @
ddcd41ec
package
cn
.
ibizlab
.
core
.
dict
.
extensions
.
vo
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
...
...
@@ -23,5 +26,15 @@ public class Option
private
String
iconClass
;
private
String
filter
;
private
Boolean
disabled
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
String
parent
;
private
Map
<
String
,
Object
>
extension
;
@JSONField
(
name
=
"text"
)
@JsonProperty
(
"text"
)
public
String
getText
()
{
return
label
;
}
}
ibzdict-provider/ibzdict-provider-api/src/main/java/cn/ibizlab/api/config/apiSecurityConfig.java
浏览文件 @
ddcd41ec
...
...
@@ -119,6 +119,7 @@ public class apiSecurityConfig extends WebSecurityConfigurerAdapter {
.
antMatchers
(
"/"
+
downloadpath
+
"/**"
).
permitAll
()
.
antMatchers
(
"/"
+
uploadpath
).
permitAll
()
.
antMatchers
(
"/"
+
previewpath
+
"/**"
).
permitAll
()
.
antMatchers
(
"/dictionarys/**"
).
permitAll
()
// 所有请求都需要认证
.
anyRequest
().
authenticated
()
// 防止iframe 造成跨域
...
...
ibzdict-provider/ibzdict-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/DictCoreResource.java
0 → 100644
浏览文件 @
ddcd41ec
package
cn
.
ibizlab
.
api
.
rest
.
extensions
;
import
cn.ibizlab.api.dto.DictCatalogDTO
;
import
cn.ibizlab.api.mapping.DictCatalogMapping
;
import
cn.ibizlab.core.dict.domain.DictCatalog
;
import
cn.ibizlab.core.dict.extensions.service.DictCoreService
;
import
cn.ibizlab.core.dict.extensions.vo.Catalog
;
import
cn.ibizlab.core.dict.extensions.vo.Option
;
import
cn.ibizlab.core.dict.filter.DictCatalogSearchContext
;
import
cn.ibizlab.core.dict.service.IDictCatalogService
;
import
cn.ibizlab.util.annotation.VersionCheck
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
@Slf4j
@RestController
@RequestMapping
(
""
)
public
class
DictCoreResource
{
@Autowired
private
IDictCatalogService
dictcatalogService
;
@Autowired
@Lazy
private
DictCatalogMapping
dictcatalogMapping
;
@Autowired
@Lazy
private
DictCoreService
dictCoreService
;
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/dictionarys/catalogs/{code}"
)
public
ResponseEntity
<
Catalog
>
getCatalogs
(
@PathVariable
(
"code"
)
String
code
)
{
Catalog
catalog
=
dictCoreService
.
getDictCatalog
(
code
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
catalog
);
}
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/dictionarys/catalogs/{code}/options"
)
public
ResponseEntity
<
List
<
Option
>>
getOptions
(
@PathVariable
(
"code"
)
String
code
)
{
Catalog
catalog
=
dictCoreService
.
getDictCatalog
(
code
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
catalog
.
getOptions
());
}
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/dictionarys/catalogs"
)
public
ResponseEntity
<
Boolean
>
save
(
@RequestBody
DictCatalogDTO
dictcatalogdto
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
dictcatalogService
.
save
(
dictcatalogMapping
.
toDomain
(
dictcatalogdto
)));
}
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/dictionarys/catalogs/savebatch"
)
public
ResponseEntity
<
Boolean
>
saveBatch
(
@RequestBody
List
<
DictCatalogDTO
>
dictcatalogdtos
)
{
dictcatalogService
.
saveBatch
(
dictcatalogMapping
.
toDomain
(
dictcatalogdtos
));
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
true
);
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录