Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
workflow-core
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄夏豪
workflow-core
Commits
d637cf76
提交
d637cf76
authored
3月 11, 2021
作者:
黄夏豪
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/master'
上级
ad874b3a
74d33fab
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
51 行增加
和
25 行删除
+51
-25
ApiService.java
...in/java/com/tykj/workflowcore/api/service/ApiService.java
+0
-11
ModelController.java
.../workflowcore/model_layer/controller/ModelController.java
+20
-2
ModelService.java
...m/tykj/workflowcore/model_layer/service/ModelService.java
+3
-1
ModelImpl.java
...tykj/workflowcore/model_layer/service/impl/ModelImpl.java
+22
-10
CreatTableUtil.java
...m/tykj/workflowcore/model_layer/utils/CreatTableUtil.java
+6
-1
没有找到文件。
src/main/java/com/tykj/workflowcore/api/service/ApiService.java
浏览文件 @
d637cf76
...
...
@@ -11,12 +11,9 @@ import com.tykj.workflowcore.base.util.ClassUtil;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
java.io.File
;
import
java.io.IOException
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.net.URL
;
import
java.util.*
;
import
java.util.stream.Collectors
;
...
...
@@ -40,14 +37,6 @@ public class ApiService {
* @return 结构化列表数据,内容为带有指定注解的方法列表,也就是列出主项目中可调用的方法。
*/
public
List
<
ClassInfo
>
findAll
()
{
List
<
ClassInfo
>
classInfos
=
load
();
for
(
ClassInfo
classInfo
:
classInfos
)
{
System
.
out
.
println
(
classInfo
);
}
return
classInfos
;
}
private
List
<
ClassInfo
>
load
()
{
//获取所有类
List
<
Class
<?>>
classes
=
ClassUtil
.
loadClassByLoader
(
getClass
().
getClassLoader
());
return
classes
.
stream
()
...
...
src/main/java/com/tykj/workflowcore/model_layer/controller/ModelController.java
浏览文件 @
d637cf76
...
...
@@ -29,6 +29,7 @@ import java.util.Map;
@RequestMapping
(
"/model"
)
@Api
(
"数据模型层接口"
)
public
class
ModelController
{
@Autowired
private
ModelService
modelService
;
...
...
@@ -61,7 +62,7 @@ public class ModelController {
* @Description 根据表名得到所有字段名
* @Date 16:20 2021/3/4
**/
@ApiOperation
(
"根据表名获
得表
所有字段"
)
@ApiOperation
(
"根据表名获
查询
所有字段"
)
@GetMapping
(
"/getAllField"
)
public
ResponseEntity
getFields
(
String
tableName
)
{
if
(
tableName
!=
null
&&
tableName
!=
""
)
{
...
...
@@ -90,7 +91,7 @@ public class ModelController {
}
modelService
.
NewTable
(
tableVO
);
return
ResultUtil
.
success
(
"
新建成功"
,
"
"
);
return
ResultUtil
.
success
(
"
"
,
"新建成功
"
);
}
...
...
@@ -109,5 +110,22 @@ public class ModelController {
return
ResultUtil
.
success
(
"数据插入成功"
,
""
);
}
/**
* @Author WWW
* @Description 根据表名查询所有数据
* @Date 9:30 2021/3/11
* @param tableName
* @return org.springframework.http.ResponseEntity
**/
@ApiOperation
(
"根据表名查询所有数据"
)
@GetMapping
(
"/getAll"
)
public
ResponseEntity
getAll
(
String
tableName
)
{
try
{
return
ResultUtil
.
success
(
modelService
.
findAllByName
(
tableName
),
""
);
}
catch
(
SQLException
throwables
)
{
throwables
.
printStackTrace
();
}
return
ResultUtil
.
success
(
null
,
"获取失败"
);
}
}
src/main/java/com/tykj/workflowcore/model_layer/service/ModelService.java
浏览文件 @
d637cf76
...
...
@@ -34,7 +34,9 @@ public interface ModelService {
TableVO
NewTable
(
TableVO
tableVO
);
int
putValueByEntityName
(
Map
<
String
,
Object
>
map
);
int
putValueByEntityName
(
Map
<
String
,
Object
>
map
);
void
swaggerScan
(
List
<
Class
<?>>
classList
);
List
findAllByName
(
String
name
)
throws
SQLException
;
}
src/main/java/com/tykj/workflowcore/model_layer/service/impl/ModelImpl.java
浏览文件 @
d637cf76
package
com
.
tykj
.
workflowcore
.
model_layer
.
service
.
impl
;
import
cn.hutool.db.Db
;
import
com.fasterxml.jackson.annotation.JsonTypeInfo
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
...
...
@@ -37,12 +38,12 @@ import javax.persistence.Id;
import
javax.persistence.criteria.*
;
import
java.lang.reflect.Field
;
import
java.sql.SQLException
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
static
com
.
tykj
.
workflowcore
.
model_layer
.
utils
.
CreatTableUtil
.
CreatTable
;
import
static
com
.
tykj
.
workflowcore
.
model_layer
.
utils
.
CreatTableUtil
.
getClassName
;
import
static
com
.
tykj
.
workflowcore
.
model_layer
.
utils
.
CreatTableUtil
.*;
/**
...
...
@@ -136,7 +137,7 @@ public class ModelImpl implements ModelService {
TableInfo
tableInfo
=
new
TableInfo
();
tableInfo
.
setName
(
tableVO
.
getModelName
());
tableInfo
.
setName
(
tableVO
.
getModelName
()
+
"_"
);
tableInfo
.
setCnName
(
tableVO
.
getModelTitle
());
tableInfo
.
setXML
(
XML_MAPPING
);
...
...
@@ -284,7 +285,7 @@ public class ModelImpl implements ModelService {
if
(
declaredField
.
isAnnotationPresent
(
javax
.
persistence
.
Id
.
class
)){
columnVO
.
setPrimarykey
(
0
);
}
columnVO
.
setFiledType
(
ge
nericType
.
toString
(
));
columnVO
.
setFiledType
(
ge
tTypeName
(
genericType
.
toString
()
));
columnVO
.
setFieldName
(
getClassName
(
declaredField
.
toString
()));
//获得属性中文描述
...
...
@@ -321,13 +322,16 @@ public class ModelImpl implements ModelService {
columnInfo
.
setLength
(
columnVO
.
getFiledLength
());
columnInfo
.
setCnName
(
columnVO
.
getFiledDescription
());
columnInfo
.
setPrimarykey
(
columnVO
.
getPrimarykey
());
//暂定 简单类型
if
(
genericType
.
toString
().
equals
(
"class java.lang.String"
))
{
columnInfo
.
setLength
(
255
);
}
else
if
(
genericType
.
toString
().
equals
(
"class java.lang.Integer"
)&&
genericType
.
toString
().
equals
(
"int"
))
{
columnInfo
.
setLength
(
11
);
}
else
{
}
else
if
(
genericType
.
toString
().
equals
(
"class java.lang.Double"
))
{
columnInfo
.
setLength
(
10
);
}
else
{
columnInfo
.
setLength
(
0
);
}
columnInfo
.
setDbName
(
className
);
...
...
@@ -344,21 +348,29 @@ public class ModelImpl implements ModelService {
}
}
public
boolean
checkRepeat
(
String
table
_n
ame
)
{
public
boolean
checkRepeat
(
String
table
N
ame
)
{
Specification
spec
=
(
Specification
)
(
root
,
criteriaQuery
,
criteriaBuilder
)
->
{
Path
name
=
root
.
get
(
"name"
);
Predicate
equal
=
criteriaBuilder
.
equal
(
name
,
table
_n
ame
);
Predicate
equal
=
criteriaBuilder
.
equal
(
name
,
table
N
ame
);
return
equal
;
};
List
<
TableInfo
>
all
=
tableInfoDao
.
findAll
(
spec
);
for
(
TableInfo
tableInfo
:
all
)
{
String
name
=
tableInfo
.
getName
();
if
(
table_name
.
equals
(
name
))
{
if
(
tableName
.
equals
(
name
))
{
return
false
;
}
}
return
true
;
}
@Override
public
List
findAllByName
(
String
name
)
throws
SQLException
{
if
(
name
!=
null
&&
name
!=
""
){
return
Db
.
use
().
findAll
(
name
);
}
return
null
;
}
}
src/main/java/com/tykj/workflowcore/model_layer/utils/CreatTableUtil.java
浏览文件 @
d637cf76
...
...
@@ -79,10 +79,15 @@ public class CreatTableUtil {
}
//处理.
public
static
String
getClassName
(
String
aClass
){
int
i
=
aClass
.
lastIndexOf
(
"."
);
String
substring
=
aClass
.
substring
(
i
+
1
);
return
substring
;
}
// 处理带空格的class
public
static
String
getTypeName
(
String
aClass
){
return
aClass
.
replace
(
"class "
,
""
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论