Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
workflow
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
2
议题
2
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄夏豪
workflow
Commits
2c0fad42
提交
2c0fad42
authored
3月 23, 2021
作者:
ww1xhqc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[数据模型] 用MockMVC Post请求测试成功两个接口
上级
2eca9b9d
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
103 行增加
和
31 行删除
+103
-31
pom.xml
pom.xml
+5
-1
ModelController.java
.../workflowcore/model_layer/controller/ModelController.java
+5
-5
ColumnInfo.java
.../com/tykj/workflowcore/model_layer/entity/ColumnInfo.java
+1
-1
TableInfo.java
...a/com/tykj/workflowcore/model_layer/entity/TableInfo.java
+1
-1
TableVO.java
.../com/tykj/workflowcore/model_layer/entity/vo/TableVO.java
+2
-0
ModelImpl.java
...tykj/workflowcore/model_layer/service/impl/ModelImpl.java
+7
-6
application.yml
src/main/resources/application.yml
+1
-1
db.setting
src/main/resources/db.setting
+0
-15
WorkflowCoreApplicationTests.java
...a/com/tykj/workflowcore/WorkflowCoreApplicationTests.java
+81
-1
没有找到文件。
pom.xml
浏览文件 @
2c0fad42
...
@@ -100,7 +100,11 @@
...
@@ -100,7 +100,11 @@
<groupId>
com.fasterxml.jackson.core
</groupId>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-core
</artifactId>
<artifactId>
jackson-core
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<scope>
test
</scope>
</dependency>
</dependencies>
</dependencies>
...
...
src/main/java/com/tykj/workflowcore/model_layer/controller/ModelController.java
浏览文件 @
2c0fad42
...
@@ -45,8 +45,8 @@ public class ModelController {
...
@@ -45,8 +45,8 @@ public class ModelController {
* @Date 16:19 2021/3/4
* @Date 16:19 2021/3/4
**/
**/
@ApiOperation
(
"得到所有数据表信息"
)
@ApiOperation
(
"得到所有数据表信息"
)
@
Ge
tMapping
(
"/getAllEntity"
)
@
Pos
tMapping
(
"/getAllEntity"
)
public
ResponseEntity
getAllEntity
(
SearchTableInfoVo
searchTableInfoVo
)
{
public
ResponseEntity
getAllEntity
(
@RequestBody
SearchTableInfoVo
searchTableInfoVo
)
{
Page
<
TableInfo
>
tableInfos
=
null
;
Page
<
TableInfo
>
tableInfos
=
null
;
try
{
try
{
tableInfos
=
modelService
.
listAllEntities
(
searchTableInfoVo
);
tableInfos
=
modelService
.
listAllEntities
(
searchTableInfoVo
);
...
@@ -64,9 +64,9 @@ public class ModelController {
...
@@ -64,9 +64,9 @@ public class ModelController {
* @Description 根据表名得到所有字段名
* @Description 根据表名得到所有字段名
* @Date 16:20 2021/3/4
* @Date 16:20 2021/3/4
**/
**/
@ApiOperation
(
"根据表名
获查询
所有字段"
)
@ApiOperation
(
"根据表名
或者id查询表中
所有字段"
)
@
Ge
tMapping
(
"/getAllField"
)
@
Pos
tMapping
(
"/getAllField"
)
public
ResponseEntity
getFields
(
SearchColumnInfoVo
searchColumnInfoVo
)
{
public
ResponseEntity
getFields
(
@RequestBody
SearchColumnInfoVo
searchColumnInfoVo
)
{
return
ResultUtil
.
success
(
modelService
.
showModelFields
(
searchColumnInfoVo
),
""
);
return
ResultUtil
.
success
(
modelService
.
showModelFields
(
searchColumnInfoVo
),
""
);
}
}
...
...
src/main/java/com/tykj/workflowcore/model_layer/entity/ColumnInfo.java
浏览文件 @
2c0fad42
...
@@ -23,7 +23,7 @@ import java.io.Serializable;
...
@@ -23,7 +23,7 @@ import java.io.Serializable;
@Data
@Data
@SQLDelete
(
sql
=
"update column_info set deleted = 1 where id = ?"
)
@SQLDelete
(
sql
=
"update column_info set deleted = 1 where id = ?"
)
@Where
(
clause
=
"deleted = 0"
)
@Where
(
clause
=
"deleted = 0"
)
public
class
ColumnInfo
extends
BaseEntity
implements
Serializable
{
public
class
ColumnInfo
extends
BaseEntity
{
/**
/**
* 是否primary key, 0是,1否
* 是否primary key, 0是,1否
...
...
src/main/java/com/tykj/workflowcore/model_layer/entity/TableInfo.java
浏览文件 @
2c0fad42
...
@@ -25,7 +25,7 @@ import java.io.Serializable;
...
@@ -25,7 +25,7 @@ import java.io.Serializable;
@Data
@Data
@SQLDelete
(
sql
=
"update table_info set deleted = 1 where id = ?"
)
@SQLDelete
(
sql
=
"update table_info set deleted = 1 where id = ?"
)
@Where
(
clause
=
"deleted = 0"
)
@Where
(
clause
=
"deleted = 0"
)
public
class
TableInfo
extends
BaseEntity
implements
Serializable
{
public
class
TableInfo
extends
BaseEntity
{
@ApiModelProperty
(
"表名,不能为空"
)
@ApiModelProperty
(
"表名,不能为空"
)
...
...
src/main/java/com/tykj/workflowcore/model_layer/entity/vo/TableVO.java
浏览文件 @
2c0fad42
...
@@ -21,6 +21,8 @@ public class TableVO {
...
@@ -21,6 +21,8 @@ public class TableVO {
private
String
modelTitle
;
private
String
modelTitle
;
@ApiModelProperty
(
"表名"
)
@ApiModelProperty
(
"表名"
)
private
String
modelName
;
private
String
modelName
;
@ApiModelProperty
(
"详细描述"
)
private
String
description
;
/**
/**
* 0扫描,1自建,2扫描后自选
* 0扫描,1自建,2扫描后自选
*/
*/
...
...
src/main/java/com/tykj/workflowcore/model_layer/service/impl/ModelImpl.java
浏览文件 @
2c0fad42
...
@@ -13,6 +13,7 @@ import com.tykj.workflowcore.model_layer.utils.CreateTableUtil;
...
@@ -13,6 +13,7 @@ import com.tykj.workflowcore.model_layer.utils.CreateTableUtil;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.hibernate.Session
;
import
org.hibernate.Session
;
import
org.hibernate.internal.SessionImpl
;
import
org.hibernate.internal.SessionImpl
;
...
@@ -81,25 +82,25 @@ public class ModelImpl implements ModelService {
...
@@ -81,25 +82,25 @@ public class ModelImpl implements ModelService {
@Override
@Override
public
Page
<
TableInfo
>
listAllEntities
(
SearchTableInfoVo
searchTableInfoVo
)
{
public
Page
<
TableInfo
>
listAllEntities
(
SearchTableInfoVo
searchTableInfoVo
)
{
PredicateBuilder
<
TableInfo
>
and
=
Specifications
.
and
();
PredicateBuilder
<
TableInfo
>
and
=
Specifications
.
and
();
and
.
like
(
searchTableInfoVo
.
getModelName
()
!=
null
,
"modelName"
,
"%"
+
searchTableInfoVo
.
getModelName
()
+
"%"
);
and
.
like
(
searchTableInfoVo
.
getModelName
()
!=
null
&&
StringUtils
.
isNotEmpty
(
searchTableInfoVo
.
getModelName
())
,
"modelName"
,
"%"
+
searchTableInfoVo
.
getModelName
()
+
"%"
);
and
.
like
(
searchTableInfoVo
.
getModelTitle
()
!=
null
,
"modelTitle"
,
"%"
+
searchTableInfoVo
.
getModelTitle
()
+
"%"
);
and
.
like
(
searchTableInfoVo
.
getModelTitle
()
!=
null
&&
StringUtils
.
isNotEmpty
(
searchTableInfoVo
.
getModelTitle
())
,
"modelTitle"
,
"%"
+
searchTableInfoVo
.
getModelTitle
()
+
"%"
);
and
.
eq
(
searchTableInfoVo
.
getModelType
()
!=
null
,
"modelType"
,
searchTableInfoVo
.
getModelType
());
and
.
eq
(
searchTableInfoVo
.
getModelType
()
!=
null
,
"modelType"
,
searchTableInfoVo
.
getModelType
());
return
tableInfoDao
.
findAll
(
and
.
build
(),
searchTableInfoVo
.
getPageable
());
return
tableInfoDao
.
findAll
(
and
.
build
(),
searchTableInfoVo
.
getPageable
());
}
}
/**
/**
* @param
S
earchColumnInfoVo
* @param
s
earchColumnInfoVo
* @return java.util.List<com.tykj.workflowcore.model_layer.model.ColumnInfo>
* @return java.util.List<com.tykj.workflowcore.model_layer.model.ColumnInfo>
* @Author WWW
* @Author WWW
* @Description 根据表名得到所有字段名
* @Description 根据表名得到所有字段名
* @Date 16:15 2021/3/5
* @Date 16:15 2021/3/5
**/
**/
@Override
@Override
public
List
<
ColumnInfo
>
showModelFields
(
SearchColumnInfoVo
S
earchColumnInfoVo
)
{
public
List
<
ColumnInfo
>
showModelFields
(
SearchColumnInfoVo
s
earchColumnInfoVo
)
{
PredicateBuilder
<
ColumnInfo
>
and
=
Specifications
.
and
();
PredicateBuilder
<
ColumnInfo
>
and
=
Specifications
.
and
();
and
.
eq
(
SearchColumnInfoVo
.
getDbId
()
!=
null
,
"dbId"
,
S
earchColumnInfoVo
.
getDbId
());
and
.
eq
(
searchColumnInfoVo
.
getDbId
()
!=
null
,
"dbId"
,
s
earchColumnInfoVo
.
getDbId
());
and
.
eq
(
SearchColumnInfoVo
.
getDbName
()
!=
null
,
"dbName"
,
S
earchColumnInfoVo
.
getDbName
());
and
.
eq
(
searchColumnInfoVo
.
getDbName
()
!=
null
&&
StringUtils
.
isNotEmpty
(
searchColumnInfoVo
.
getDbName
()),
"dbName"
,
s
earchColumnInfoVo
.
getDbName
());
return
columnInfoDao
.
findAll
(
and
.
build
());
return
columnInfoDao
.
findAll
(
and
.
build
());
}
}
...
...
src/main/resources/application.yml
浏览文件 @
2c0fad42
...
@@ -2,7 +2,7 @@ spring:
...
@@ -2,7 +2,7 @@ spring:
datasource
:
datasource
:
username
:
root
username
:
root
password
:
Huang123+
password
:
Huang123+
url
:
jdbc:mysql://47.106.142.73:3306/www2?useSSL=false&serverTimezone=
UTC
&characterEncoding=utf-8&nullCatalogMeansCurrent=true
url
:
jdbc:mysql://47.106.142.73:3306/www2?useSSL=false&serverTimezone=
Asia/Shanghai
&characterEncoding=utf-8&nullCatalogMeansCurrent=true
driver-class-name
:
com.mysql.cj.jdbc.Driver
driver-class-name
:
com.mysql.cj.jdbc.Driver
jpa
:
jpa
:
show-sql
:
true
show-sql
:
true
...
...
src/main/resources/db.setting
deleted
100644 → 0
浏览文件 @
2eca9b9d
## db.setting文件
url = jdbc:mysql://47.106.142.73:3306/www2?useSSL=false&serverTimezone=UTC&characterEncoding=utf-8&nullCatalogMeansCurrent=true
user = root
pass = Huang123+
## 可选配置
# 是否在日志中显示执行的SQL
showSql = true
# 是否格式化显示的SQL
formatSql = true
# 是否显示SQL参数
showParams = true
# 打印SQL的日志等级,默认debug,可以是info、warn、error
sqlLevel = info
\ No newline at end of file
src/main/test/java/com/tykj/workflowcore/WorkflowCoreApplicationTests.java
浏览文件 @
2c0fad42
package
com
.
tykj
.
workflowcore
;
package
com
.
tykj
.
workflowcore
;
import
com.tykj.workflowcore.model_layer.controller.ModelController
;
import
org.aspectj.lang.annotation.Before
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.http.MediaType
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.RequestBuilder
;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
@SpringBootTest
import
javax.print.attribute.standard.Media
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
not
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultHandlers
.
print
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
content
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
webEnvironment
=
SpringBootTest
.
WebEnvironment
.
RANDOM_PORT
)
@AutoConfigureMockMvc
class
WorkflowCoreApplicationTests
{
class
WorkflowCoreApplicationTests
{
@Autowired
ModelController
modelController
;
@Autowired
MockMvc
mockMvc
;
@Before
(
""
)
public
void
setUp
()
{
mockMvc
=
MockMvcBuilders
.
standaloneSetup
(
modelController
).
build
();
}
@Test
@Test
void
contextLoads
()
{
void
contextLoads
()
{
System
.
out
.
println
(
"11111111111111111111111"
);
}
//#####################################模型层测试 start##############################################
RequestBuilder
request
;
@Test
public
void
SearchTableVOTest
()
throws
Exception
{
String
SearchTableinfo_Json
=
"{\n"
+
" \"modelName\":\"peop\",\n"
+
" \"modelTitle\":\"\",\n"
+
" \"modelType\":\"\"\n"
+
"}"
;
request
=
post
(
"/model/getAllEntity/"
)
.
contentType
(
MediaType
.
APPLICATION_JSON
)
.
content
(
SearchTableinfo_Json
)
// 设置返回值类型为utf-8,否则默认为ISO-8859-1
.
accept
(
MediaType
.
APPLICATION_JSON_UTF8_VALUE
);
mockMvc
.
perform
(
request
).
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
string
(
not
(
""
)))
//条件
.
andExpect
(
content
().
string
(
not
(
"[]"
)))
.
andDo
(
print
());
//打印输出结果
}
@Test
public
void
testSearchColumnVO
()
throws
Exception
{
String
searchColumnV0_json
=
"{\n"
+
"\"dbId\":2\n"
+
"}"
;
String
searchColumnV0_json2
=
"{\n"
+
"\"dbName\":\"techer\"\n"
+
"}"
;
request
=
post
(
"/model/getAllField/"
)
.
contentType
(
MediaType
.
APPLICATION_JSON
)
.
content
(
searchColumnV0_json2
)
// 设置返回值类型为utf-8,否则默认为ISO-8859-1
.
accept
(
MediaType
.
APPLICATION_JSON_UTF8_VALUE
);
mockMvc
.
perform
(
request
).
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
string
(
not
(
""
)))
.
andExpect
(
content
().
string
(
not
(
"[]"
)))
.
andDo
(
print
());
//打印输出结果
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论