Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzlite
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzlite
提交
381669ad
提交
381669ad
编写于
9月 16, 2020
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
lite
上级
ed3832ae
变更
8
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
447 行增加
和
1 行删除
+447
-1
EntityModel.java
...a/cn/ibizlab/core/lite/extensions/domain/EntityModel.java
+83
-0
FieldModel.java
...va/cn/ibizlab/core/lite/extensions/domain/FieldModel.java
+28
-0
Lookup.java
...n/java/cn/ibizlab/core/lite/extensions/domain/Lookup.java
+23
-0
RelationshipModel.java
...bizlab/core/lite/extensions/domain/RelationshipModel.java
+31
-0
LiteModelService.java
...bizlab/core/lite/extensions/service/LiteModelService.java
+140
-0
LiteStorage.java
...ava/cn/ibizlab/core/lite/extensions/util/LiteStorage.java
+85
-0
apiSecurityConfig.java
...rc/main/java/cn/ibizlab/api/config/apiSecurityConfig.java
+2
-1
LiteCoreResource.java
...java/cn/ibizlab/api/rest/extensions/LiteCoreResource.java
+55
-0
未找到文件。
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/EntityModel.java
0 → 100644
浏览文件 @
381669ad
package
cn
.
ibizlab
.
core
.
lite
.
extensions
.
domain
;
import
cn.ibizlab.core.lite.domain.MetaDataSet
;
import
cn.ibizlab.core.lite.domain.MetaEntity
;
import
cn.ibizlab.core.lite.domain.MetaField
;
import
cn.ibizlab.core.lite.domain.MetaRelationship
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
org.springframework.util.StringUtils
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
@Getter
@Setter
@NoArgsConstructor
@JsonIgnoreProperties
(
value
=
"handler"
)
public
class
EntityModel
{
private
String
entityId
;
private
String
codeName
;
private
String
entityName
;
private
String
tableName
;
private
String
logicName
;
private
String
systemId
;
private
MetaEntity
entity
;
private
List
<
MetaDataSet
>
dataSets
;
private
List
<
FieldModel
>
fields
;
private
List
<
RelationshipModel
>
references
;
private
List
<
RelationshipModel
>
nesteds
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
Map
<
String
,
FieldModel
>
fieldMap
=
null
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Map
<
String
,
FieldModel
>
getFieldMap
()
{
if
(
fields
!=
null
&&
fieldMap
==
null
)
{
fieldMap
=
new
HashMap
<>();
fields
.
forEach
(
field
->{
fieldMap
.
put
(
field
.
getColumnName
(),
field
);
fieldMap
.
put
(
field
.
getCodeName
(),
field
);
});
}
return
fieldMap
;
}
public
FieldModel
getField
(
String
name
)
{
if
(
StringUtils
.
isEmpty
(
name
))
return
null
;
if
(
fields
==
null
)
return
null
;
if
(
getFieldMap
()!=
null
)
return
getFieldMap
().
get
(
name
);
return
null
;
}
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/FieldModel.java
0 → 100644
浏览文件 @
381669ad
package
cn
.
ibizlab
.
core
.
lite
.
extensions
.
domain
;
import
cn.ibizlab.core.lite.domain.MetaField
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
@Getter
@Setter
@NoArgsConstructor
@JsonIgnoreProperties
(
value
=
"handler"
)
public
class
FieldModel
{
private
String
columnName
;
private
String
codeName
;
private
String
unionName
;
private
String
showName
;
private
String
comment
;
private
MetaField
field
;
private
RelationshipModel
reference
;
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/Lookup.java
0 → 100644
浏览文件 @
381669ad
package
cn
.
ibizlab
.
core
.
lite
.
extensions
.
domain
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
@Getter
@Setter
@NoArgsConstructor
@JsonIgnoreProperties
(
value
=
"handler"
)
public
class
Lookup
{
private
String
mainEntityName
;
private
String
fieldName
;
private
String
refCodeName
;
private
String
refEntityName
;
private
String
refFieldName
;
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/domain/RelationshipModel.java
0 → 100644
浏览文件 @
381669ad
package
cn
.
ibizlab
.
core
.
lite
.
extensions
.
domain
;
import
cn.ibizlab.core.lite.domain.MetaRelationship
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
@Getter
@Setter
@NoArgsConstructor
@JsonIgnoreProperties
(
value
=
"handler"
)
public
class
RelationshipModel
{
private
String
codeName
;
private
String
entityName
;
private
String
entityCodeName
;
private
String
entityLogicName
;
private
String
systemId
;
private
String
dataSourceName
;
private
String
tableName
;
private
String
entityId
;
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/service/LiteModelService.java
0 → 100644
浏览文件 @
381669ad
package
cn
.
ibizlab
.
core
.
lite
.
extensions
.
service
;
import
cn.ibizlab.core.lite.domain.DstSystem
;
import
cn.ibizlab.core.lite.domain.MetaEntity
;
import
cn.ibizlab.core.lite.domain.MetaRelationship
;
import
cn.ibizlab.core.lite.extensions.domain.EntityModel
;
import
cn.ibizlab.core.lite.extensions.domain.FieldModel
;
import
cn.ibizlab.core.lite.extensions.domain.RelationshipModel
;
import
cn.ibizlab.core.lite.extensions.util.LiteStorage
;
import
cn.ibizlab.core.lite.service.*
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
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
javax.annotation.PostConstruct
;
import
java.sql.Wrapper
;
import
java.util.ArrayList
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
@Service
public
class
LiteModelService
{
@PostConstruct
public
void
init
(){
LiteStorage
.
setLiteModelService
(
this
);
}
@Autowired
private
IMetaEntityService
metaEntityService
;
public
IMetaEntityService
getMetaEntityService
()
{
return
metaEntityService
;
}
@Autowired
private
IMetaFieldService
metaFieldService
;
@Autowired
private
IMetaRelationshipService
metaRelationshipService
;
@Autowired
private
IDstSystemService
dstSystemService
;
@Autowired
private
IDstDataSourceService
dstDataSourceService
;
@Autowired
private
IMetaDataSetService
metaDataSetService
;
@Cacheable
(
value
=
"entitymodel"
,
key
=
"'row:'+#p0+'.'+#p1"
)
public
EntityModel
getEntityModel
(
String
systemId
,
String
name
)
{
MetaEntity
entity
=
LiteStorage
.
getMetaEntity
(
String
.
format
(
"%1$s.%2$s"
,
systemId
,
name
));
EntityModel
entityModel
=
new
EntityModel
();
entityModel
.
setEntity
(
entity
);
entityModel
.
setDataSets
(
metaDataSetService
.
selectByEntityId
(
entity
.
getEntityId
()));
Map
<
String
,
RelationshipModel
>
parentSet
=
new
LinkedHashMap
();
List
<
RelationshipModel
>
references
=
new
ArrayList
<>();
metaRelationshipService
.
selectByEntityId
(
entity
.
getEntityId
()).
forEach
(
item
->
{
RelationshipModel
model
=
new
RelationshipModel
();
MetaEntity
parentEntity
=
LiteStorage
.
getMetaEntity
(
item
.
getRefEntityId
());
if
(
parentEntity
!=
null
){
model
.
setCodeName
(
item
.
getCodeName
());
model
.
setDataSourceName
(
parentEntity
.
getDsName
());
model
.
setEntityCodeName
(
parentEntity
.
getCodeName
());
model
.
setEntityId
(
parentEntity
.
getEntityId
());
model
.
setEntityLogicName
(
parentEntity
.
getLogicName
());
model
.
setEntityName
(
parentEntity
.
getEntityName
());
model
.
setSystemId
(
parentEntity
.
getSystemId
());
model
.
setTableName
(
parentEntity
.
getTableName
());
parentSet
.
put
(
item
.
getId
(),
model
);
references
.
add
(
model
);
}
});
entityModel
.
setReferences
(
references
);
List
<
RelationshipModel
>
nesteds
=
new
ArrayList
<>();
metaRelationshipService
.
selectByRefEntityId
(
entity
.
getEntityId
()).
forEach
(
item
->
{
RelationshipModel
model
=
new
RelationshipModel
();
MetaEntity
subEntity
=
LiteStorage
.
getMetaEntity
(
item
.
getEntityId
());
if
(
subEntity
!=
null
){
model
.
setCodeName
(
StringUtils
.
isEmpty
(
item
.
getNestedName
())?
item
.
getCodeName
()+
"_"
+
item
.
getEntityName
():
item
.
getNestedName
());
model
.
setDataSourceName
(
subEntity
.
getDsName
());
model
.
setEntityCodeName
(
subEntity
.
getCodeName
());
model
.
setEntityId
(
subEntity
.
getEntityId
());
model
.
setEntityLogicName
(
subEntity
.
getLogicName
());
model
.
setEntityName
(
subEntity
.
getEntityName
());
model
.
setSystemId
(
subEntity
.
getSystemId
());
model
.
setTableName
(
subEntity
.
getTableName
());
nesteds
.
add
(
model
);
}
});
entityModel
.
setNesteds
(
nesteds
);
List
<
FieldModel
>
fields
=
new
ArrayList
<>();
metaFieldService
.
selectByEntityId
(
entity
.
getEntityId
()).
forEach
(
item
->
{
FieldModel
model
=
new
FieldModel
();
model
.
setField
(
item
);
model
.
setCodeName
(
item
.
getCodeName
());
model
.
setColumnName
(
item
.
getFieldName
());
model
.
setComment
(
item
.
getFieldLogicName
());
model
.
setShowName
(
item
.
getFieldShowName
());
model
.
setUnionName
(
item
.
getFieldUniName
());
if
((!
StringUtils
.
isEmpty
(
item
.
getRelationId
()))&&(
parentSet
.
containsKey
(
item
.
getRelationId
())))
model
.
setReference
(
parentSet
.
get
(
item
.
getRelationId
()));
fields
.
add
(
model
);
});
entityModel
.
setFields
(
fields
);
return
entityModel
;
}
@CacheEvict
(
value
=
"entitymodel"
,
key
=
"'row:'+#p0+'.'+#p1"
)
public
void
resetEntityModel
(
String
systemId
,
String
name
)
{
LiteStorage
.
resetMetaEntity
(
String
.
format
(
"%1$s.%2$s"
,
systemId
,
name
));
}
public
void
initMetaEntity
()
{
metaEntityService
.
list
().
forEach
(
metaEntity
->
{
LiteStorage
.
putMetaEntity
(
metaEntity
);
});
}
}
ibzlite-core/src/main/java/cn/ibizlab/core/lite/extensions/util/LiteStorage.java
0 → 100644
浏览文件 @
381669ad
package
cn
.
ibizlab
.
core
.
lite
.
extensions
.
util
;
import
cn.ibizlab.core.lite.domain.MetaEntity
;
import
cn.ibizlab.core.lite.extensions.service.LiteModelService
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
LiteStorage
{
private
static
Map
<
String
,
MetaEntity
>
metaEntityStorage
=
new
HashMap
<
String
,
MetaEntity
>();
private
static
Object
entityLock
=
new
Object
();
public
static
Map
<
String
,
MetaEntity
>
putMetaEntity
(
MetaEntity
metaEntity
)
{
synchronized
(
entityLock
)
{
metaEntityStorage
.
put
(
metaEntity
.
getEntityId
(),
metaEntity
);
metaEntityStorage
.
put
(
String
.
format
(
"%1$s.%2$s"
,
metaEntity
.
getSystemId
(),
metaEntity
.
getEntityName
()),
metaEntity
);
metaEntityStorage
.
put
(
String
.
format
(
"%1$s.%2$s"
,
metaEntity
.
getSystemId
(),
metaEntity
.
getCodeName
()),
metaEntity
);
return
metaEntityStorage
;
}
}
private
static
LiteModelService
service
;
public
static
void
setLiteModelService
(
LiteModelService
service
)
{
if
(
LiteStorage
.
service
==
null
)
LiteStorage
.
service
=
service
;
}
public
static
MetaEntity
getMetaEntity
(
String
name
)
{
synchronized
(
entityLock
)
{
if
(
metaEntityStorage
.
containsKey
(
name
))
return
metaEntityStorage
.
get
(
name
);
else
if
(
name
.
contains
(
"."
))
{
String
[]
args
=
name
.
split
(
"."
);
String
systemId
=
args
[
0
];
String
code
=
args
[
1
];
MetaEntity
metaEntity
=
service
.
getMetaEntityService
().
getOne
(
Wrappers
.<
MetaEntity
>
lambdaQuery
().
and
(
wrapper
->
wrapper
.
eq
(
MetaEntity:
:
getSystemId
,
systemId
).
or
().
eq
(
MetaEntity:
:
getSystemName
,
systemId
)).
and
(
wrapper
->
wrapper
.
eq
(
MetaEntity:
:
getEntityName
,
code
).
or
().
eq
(
MetaEntity:
:
getCodeName
,
code
))
,
false
);
if
(
metaEntity
!=
null
)
{
metaEntityStorage
.
put
(
metaEntity
.
getEntityId
(),
metaEntity
);
metaEntityStorage
.
put
(
String
.
format
(
"%1$s.%2$s"
,
metaEntity
.
getSystemId
(),
metaEntity
.
getEntityName
()),
metaEntity
);
metaEntityStorage
.
put
(
String
.
format
(
"%1$s.%2$s"
,
metaEntity
.
getSystemId
(),
metaEntity
.
getCodeName
()),
metaEntity
);
return
metaEntity
;
}
}
else
{
MetaEntity
metaEntity
=
service
.
getMetaEntityService
().
getById
(
name
);
if
(
metaEntity
!=
null
)
{
metaEntityStorage
.
put
(
metaEntity
.
getEntityId
(),
metaEntity
);
metaEntityStorage
.
put
(
String
.
format
(
"%1$s.%2$s"
,
metaEntity
.
getSystemId
(),
metaEntity
.
getEntityName
()),
metaEntity
);
metaEntityStorage
.
put
(
String
.
format
(
"%1$s.%2$s"
,
metaEntity
.
getSystemId
(),
metaEntity
.
getCodeName
()),
metaEntity
);
return
metaEntity
;
}
}
}
return
null
;
}
public
static
void
resetMetaEntity
(
String
name
)
{
MetaEntity
metaEntity
=
getMetaEntity
(
name
);
if
(
metaEntity
!=
null
)
{
synchronized
(
entityLock
)
{
metaEntityStorage
.
remove
(
metaEntity
.
getEntityId
());
metaEntityStorage
.
remove
(
String
.
format
(
"%1$s.%2$s"
,
metaEntity
.
getSystemId
(),
metaEntity
.
getEntityName
()));
metaEntityStorage
.
remove
(
String
.
format
(
"%1$s.%2$s"
,
metaEntity
.
getSystemId
(),
metaEntity
.
getCodeName
()));
}
}
}
}
ibzlite-provider/ibzlite-provider-api/src/main/java/cn/ibizlab/api/config/apiSecurityConfig.java
浏览文件 @
381669ad
...
@@ -121,7 +121,8 @@ public class apiSecurityConfig extends WebSecurityConfigurerAdapter {
...
@@ -121,7 +121,8 @@ public class apiSecurityConfig extends WebSecurityConfigurerAdapter {
// 文件操作
// 文件操作
.
antMatchers
(
"/"
+
downloadpath
+
"/**"
).
permitAll
()
.
antMatchers
(
"/"
+
downloadpath
+
"/**"
).
permitAll
()
.
antMatchers
(
"/"
+
uploadpath
).
permitAll
()
.
antMatchers
(
"/"
+
uploadpath
).
permitAll
()
.
antMatchers
(
"/"
+
previewpath
+
"/**"
).
permitAll
();
.
antMatchers
(
"/"
+
previewpath
+
"/**"
).
permitAll
()
.
antMatchers
(
"/lite/**"
).
permitAll
();
for
(
String
excludePattern
:
excludesPattern
)
{
for
(
String
excludePattern
:
excludesPattern
)
{
authenticationTokenFilter
.
addExcludePattern
(
excludePattern
);
authenticationTokenFilter
.
addExcludePattern
(
excludePattern
);
...
...
ibzlite-provider/ibzlite-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/LiteCoreResource.java
0 → 100644
浏览文件 @
381669ad
package
cn
.
ibizlab
.
api
.
rest
.
extensions
;
import
cn.ibizlab.api.dto.DstAPIDTO
;
import
cn.ibizlab.core.lite.domain.DstAPI
;
import
cn.ibizlab.core.lite.domain.DstComponent
;
import
cn.ibizlab.core.lite.domain.MetaEntity
;
import
cn.ibizlab.core.lite.extensions.domain.EntityModel
;
import
cn.ibizlab.core.lite.extensions.service.LiteModelService
;
import
cn.ibizlab.core.lite.service.IDstComponentService
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
com.alibaba.fastjson.JSON
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
io.swagger.annotations.Api
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
@Slf4j
@Api
(
tags
=
{
"接口"
})
@RestController
(
"api-litecore"
)
@RequestMapping
(
""
)
public
class
LiteCoreResource
{
@Autowired
private
LiteModelService
liteModelService
;
@Autowired
private
IDstComponentService
dstComponentService
;
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/lite/{system}/entitys/{entity}"
)
public
ResponseEntity
<
EntityModel
>
getEntityModel
(
@PathVariable
(
"system"
)
String
system
,
@PathVariable
(
"entity"
)
String
entity
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
liteModelService
.
getEntityModel
(
system
,
entity
));
}
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/lite/{app}/components/{component}"
)
public
ResponseEntity
<
JSON
>
getComponent
(
@PathVariable
(
"app"
)
String
app
,
@PathVariable
(
"component"
)
String
component
)
{
DstComponent
dstComponent
=
dstComponentService
.
getOne
(
Wrappers
.<
DstComponent
>
lambdaQuery
().
eq
(
DstComponent:
:
getAppId
,
app
).
and
(
wrapper
->
wrapper
.
eq
(
DstComponent:
:
getCodeName
,
component
).
or
().
eq
(
DstComponent:
:
getName
,
component
)),
true
);
if
(
StringUtils
.
isEmpty
(
dstComponent
.
getConfig
()))
throw
new
BadRequestAlertException
(
"未找到配置"
,
"DstComponent"
,
component
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
JSON
.
parseObject
(
dstComponent
.
getConfig
()));
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录