Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
data-house
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄承天
data-house
Commits
be225009
提交
be225009
authored
10月 22, 2021
作者:
黄承天
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
初始提交
上级
89454ce0
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
219 行增加
和
2 行删除
+219
-2
DataController.java
...in/java/com/tykj/datahouse/controller/DataController.java
+47
-0
TableInfoController.java
...va/com/tykj/datahouse/controller/TableInfoController.java
+1
-1
DatahouseApplicationTests.java
...st/java/com/tykj/datahouse/DatahouseApplicationTests.java
+171
-1
没有找到文件。
src/main/java/com/tykj/datahouse/controller/DataController.java
0 → 100644
浏览文件 @
be225009
package
com
.
tykj
.
datahouse
.
controller
;
import
com.tykj.datahouse.base.result.ResultObj
;
import
com.tykj.datahouse.base.result.ResultUtil
;
import
com.tykj.datahouse.service.TableInfoService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Map
;
@Api
(
tags
=
"数据操作API"
)
@CrossOrigin
@RequestMapping
(
"/data"
)
@RestController
public
class
DataController
{
@Autowired
private
TableInfoService
tableInfoService
;
@PostMapping
(
"/{tableId}"
)
@ApiOperation
(
"在指定表中新插入一条数据"
)
public
ResponseEntity
<
ResultObj
<
Object
>>
createTable
(
@PathVariable
Integer
tableId
,
@RequestBody
Map
<
String
,
Object
>
row
)
{
tableInfoService
.
insertData
(
tableId
,
row
);
return
ResultUtil
.
success
(
"操作成功"
);
}
@PutMapping
(
"/{tableId}"
)
@ApiOperation
(
"在指定表中修改一条数据"
)
public
ResponseEntity
<
ResultObj
<
Object
>>
alterTable
(
@PathVariable
Integer
tableId
,
@RequestBody
Map
<
String
,
Object
>
row
)
{
tableInfoService
.
updateData
(
tableId
,
row
);
return
ResultUtil
.
success
(
"操作成功"
);
}
@DeleteMapping
(
"/{tableId}"
)
@ApiOperation
(
"在指定表中删除一条数据"
)
public
ResponseEntity
<
ResultObj
<
Object
>>
dropTable
(
@PathVariable
Integer
tableId
,
@RequestBody
Map
<
String
,
Object
>
row
)
{
tableInfoService
.
deleteData
(
tableId
,
row
);
return
ResultUtil
.
success
(
"操作成功"
);
}
}
src/main/java/com/tykj/datahouse/controller/TableInfoController.java
浏览文件 @
be225009
...
@@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.*;
...
@@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.*;
import
java.util.List
;
import
java.util.List
;
@Api
(
tags
=
"
基础模型接口
"
)
@Api
(
tags
=
"
表信息API
"
)
@CrossOrigin
@CrossOrigin
@RequestMapping
(
"/table"
)
@RequestMapping
(
"/table"
)
@RestController
@RestController
...
...
src/test/java/com/tykj/datahouse/DatahouseApplicationTests.java
浏览文件 @
be225009
package
com
.
tykj
.
datahouse
;
package
com
.
tykj
.
datahouse
;
import
com.tykj.datahouse.entity.ColumnInfo
;
import
com.tykj.datahouse.entity.TableInfo
;
import
com.tykj.datahouse.repository.ColumnInfoRepository
;
import
com.tykj.datahouse.repository.TableInfoRepository
;
import
com.tykj.datahouse.service.TableInfoService
;
import
org.assertj.core.util.Lists
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
java.util.HashMap
;
import
java.util.Map
;
@SpringBootTest
@SpringBootTest
class
DatahouseApplicationTests
{
class
DatahouseApplicationTests
{
@Autowired
JdbcTemplate
jdbcTemplate
;
@Autowired
TableInfoService
tableInfoService
;
@Test
@Test
void
contextLoads
()
{
void
test
()
{
tableInfoService
.
updateData
(
2
,
row
());
print
();
}
Map
<
String
,
Object
>
row
()
{
Map
<
String
,
Object
>
row
=
new
HashMap
<>();
row
.
put
(
"id"
,
1
);
row
.
put
(
"name"
,
"c"
);
row
.
put
(
"age"
,
20
);
return
row
;
}
ColumnInfo
columnInfo
()
{
return
new
ColumnInfo
(
null
,
false
,
"name"
,
"名字"
,
"varchar"
,
255
,
true
,
""
,
1
);
}
ColumnInfo
columnInfo2
()
{
return
new
ColumnInfo
(
null
,
false
,
"name2"
,
"名字"
,
"varchar"
,
255
,
true
,
""
,
1
);
}
ColumnInfo
columnInfo3
()
{
return
new
ColumnInfo
(
null
,
false
,
"name3"
,
"名字"
,
"varchar"
,
255
,
true
,
""
,
1
);
}
TableInfo
oTableInfo
()
{
return
new
TableInfo
(
null
,
null
,
null
,
"student"
,
"学生"
,
""
,
Lists
.
newArrayList
(
new
ColumnInfo
(
null
,
true
,
"id"
,
"主键"
,
"int"
,
null
,
true
,
""
,
1
),
new
ColumnInfo
(
null
,
false
,
"name"
,
"名字"
,
"varchar"
,
255
,
true
,
""
,
1
),
new
ColumnInfo
(
null
,
false
,
"age"
,
"年龄"
,
"int"
,
null
,
false
,
""
,
1
)
)
);
}
TableInfo
tableInfo
()
{
return
new
TableInfo
(
1
,
null
,
null
,
"student"
,
"学生"
,
""
,
Lists
.
newArrayList
(
new
ColumnInfo
(
1
,
true
,
"id"
,
"主键"
,
"int"
,
null
,
true
,
""
,
1
),
new
ColumnInfo
(
2
,
false
,
"name2"
,
"名字"
,
"varchar"
,
11
,
true
,
""
,
1
),
new
ColumnInfo
(
null
,
false
,
"age2"
,
"年龄"
,
"int"
,
null
,
false
,
""
,
1
)
)
);
}
void
print
()
{
for
(
TableInfo
tableInfo
:
tableInfoService
.
findAll
())
{
System
.
out
.
println
(
"-----------------------------------"
);
System
.
out
.
println
(
tableInfo
);
for
(
ColumnInfo
columnInfo
:
tableInfo
.
getColumnInfos
())
{
System
.
out
.
println
(
columnInfo
);
}
}
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论