Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataDeclaration
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄夏豪
dataDeclaration
Commits
969e2186
提交
969e2186
authored
5月 19, 2021
作者:
ww1xhqc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[数据模型] 版本类相关
上级
26415330
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
98 行增加
和
1 行删除
+98
-1
VersionController.java
...va/com/tykj/model_layer/controller/VersionController.java
+0
-1
VersionServiceImpl.java
...com/tykj/model_layer/service/impl/VersionServiceImpl.java
+98
-0
没有找到文件。
src/main/java/com/tykj/model_layer/controller/VersionController.java
浏览文件 @
969e2186
...
...
@@ -36,7 +36,6 @@ public class VersionController {
@RequestMapping
(
"/goBack"
)
public
ResponseEntity
goBack
(
Integer
integer
){
return
ResultUtil
.
success
(
""
);
}
}
src/main/java/com/tykj/model_layer/service/impl/VersionServiceImpl.java
0 → 100644
浏览文件 @
969e2186
package
com
.
tykj
.
model_layer
.
service
.
impl
;
import
com.alibaba.fastjson.JSONArray
;
import
com.tykj.base.result.ApiException
;
import
com.tykj.model_layer.dao.ColumnInfoDao
;
import
com.tykj.model_layer.dao.TableInfoDao
;
import
com.tykj.model_layer.dao.VersionDao
;
import
com.tykj.model_layer.entity.ColumnInfo
;
import
com.tykj.model_layer.entity.TableInfo
;
import
com.tykj.model_layer.entity.Version
;
import
com.tykj.model_layer.entity.vo.QueryCondition
;
import
com.tykj.model_layer.entity.vo.VersionVO
;
import
com.tykj.model_layer.service.VersionService
;
import
com.tykj.model_layer.utils.SessionUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.checkerframework.checker.units.qual.A
;
import
org.hibernate.Session
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
/**
* @Description TODO
* @Author WWW
* @Date 2021/5/19 13:57
*/
@Service
public
class
VersionServiceImpl
implements
VersionService
{
@Autowired
VersionDao
versionDao
;
@Autowired
ColumnInfoDao
columnInfoDao
;
@Autowired
SessionUtil
sessionUtil
;
@Autowired
TableInfoDao
tableInfoDao
;
@Override
public
Version
addVersion
(
VersionVO
versionVO
)
{
Version
version
=
new
Version
();
version
.
setVersionId
(
versionVO
.
getVersionId
());
version
.
setDbId
(
versionVO
.
getDbId
());
version
.
setVersionDesc
(
versionVO
.
getVersionDesc
());
List
<
Integer
>
collect
=
columnInfoDao
.
findAllByDbId
(
versionVO
.
getDbId
()).
stream
()
.
map
(
ColumnInfo:
:
getId
)
.
collect
(
Collectors
.
toList
());
version
.
setIds
(
JSONArray
.
toJSONString
(
collect
));
return
versionDao
.
save
(
version
);
}
@Override
public
void
delVersion
(
Integer
id
)
{
versionDao
.
deleteById
(
id
);
}
@Override
public
void
goback
(
Integer
id
)
{
Optional
<
Version
>
byId
=
versionDao
.
findById
(
id
);
if
(
byId
.
isPresent
()){
Version
version
=
byId
.
get
();
//生成回退前版本
VersionVO
versionVo
=
new
VersionVO
();
versionVo
.
setVersionId
(
"回退前版本"
);
versionVo
.
setVersionDesc
(
"回退前版本"
);
versionVo
.
setDbId
(
version
.
getDbId
());
addVersion
(
versionVo
);
//回退
TableInfo
tableInfo
=
tableInfoDao
.
getOne
(
version
.
getDbId
());
Session
session
=
sessionUtil
.
getSession
();
session
.
getTransaction
().
begin
();
StringBuilder
result
=
new
StringBuilder
(
"delete "
);
result
.
append
(
"entity "
);
result
.
append
(
" from "
).
append
(
tableInfo
.
getModelName
()).
append
(
" entity "
);
result
.
append
(
"where entity.id in "
+
version
.
getIds
());
session
.
createQuery
(
result
.
toString
());
session
.
getTransaction
().
commit
();
session
.
close
();
}
else
{
throw
new
ApiException
(
"版本不存在"
);
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论