Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yubinCloud
fairy-wiki
提交
c08bf8e2
F
fairy-wiki
项目概览
yubinCloud
/
fairy-wiki
通知
4
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
fairy-wiki
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c08bf8e2
编写于
4月 24, 2021
作者:
yubinCloud
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8-10 增加保存文档内容的功能
上级
bf287ac9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
24 addition
and
3 deletion
+24
-3
src/main/java/io/github/yubincloud/fairywiki/service/DocService.java
...va/io/github/yubincloud/fairywiki/service/DocService.java
+17
-1
web/src/models.ts
web/src/models.ts
+1
-0
web/src/views/admin/admin-doc.vue
web/src/views/admin/admin-doc.vue
+6
-2
未找到文件。
src/main/java/io/github/yubincloud/fairywiki/service/DocService.java
浏览文件 @
c08bf8e2
...
...
@@ -2,12 +2,14 @@ package io.github.yubincloud.fairywiki.service;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
io.github.yubincloud.fairywiki.domain.Content
;
import
io.github.yubincloud.fairywiki.domain.Doc
;
import
io.github.yubincloud.fairywiki.domain.DocExample
;
import
io.github.yubincloud.fairywiki.dto.req.DocQueryReqDto
;
import
io.github.yubincloud.fairywiki.dto.req.DocSaveReqDto
;
import
io.github.yubincloud.fairywiki.dto.resp.DocQueryRespDto
;
import
io.github.yubincloud.fairywiki.dto.resp.PageRespDto
;
import
io.github.yubincloud.fairywiki.mapper.ContentMapper
;
import
io.github.yubincloud.fairywiki.mapper.DocMapper
;
import
io.github.yubincloud.fairywiki.utils.CopyUtil
;
import
io.github.yubincloud.fairywiki.utils.SnowFlake
;
...
...
@@ -27,6 +29,9 @@ public class DocService {
@Resource
private
DocMapper
docMapper
;
@Resource
private
ContentMapper
contentMapper
;
@Resource
private
SnowFlake
snowFlake
;
...
...
@@ -69,11 +74,22 @@ public class DocService {
*/
public
void
save
(
DocSaveReqDto
reqDto
)
{
Doc
docRecord
=
CopyUtil
.
copy
(
reqDto
,
Doc
.
class
);
Content
docContent
=
CopyUtil
.
copy
(
reqDto
,
Content
.
class
);
if
(
ObjectUtils
.
isEmpty
(
docRecord
.
getId
()))
{
// 判断 id 是否为空
docRecord
.
setId
(
snowFlake
.
nextId
());
// 新增
Long
docId
=
snowFlake
.
nextId
();
docRecord
.
setId
(
docId
);
docMapper
.
insertSelective
(
docRecord
);
docContent
.
setId
(
docId
);
contentMapper
.
insertSelective
(
docContent
);
}
else
{
// 更新
docMapper
.
updateByPrimaryKey
(
docRecord
);
int
count
=
contentMapper
.
updateByPrimaryKeyWithBLOBs
(
docContent
);
// 带大字段的更新
if
(
count
==
0
)
{
contentMapper
.
insert
(
docContent
);
}
}
}
...
...
web/src/models.ts
浏览文件 @
c08bf8e2
...
...
@@ -49,6 +49,7 @@ export interface Doc {
sort
:
number
;
viewCount
:
number
;
voteCount
:
number
;
content
:
string
;
}
/**
...
...
web/src/views/admin/admin-doc.vue
浏览文件 @
c08bf8e2
...
...
@@ -187,12 +187,16 @@ export default defineComponent({
// -------- 表单 ---------
const
treeSelectData
=
ref
();
// 因为树选择组件的属性状态,会随当前编辑的节点而变化,所以单独声明一个响应式变量
treeSelectData
.
value
=
[];
const
doc
=
ref
({});
const
doc
=
ref
();
doc
.
value
=
{};
const
modalVisible
=
ref
(
false
);
const
modalLoading
=
ref
(
false
);
let
textEditor
:
E
;
const
handleSaveDoc
=
()
=>
{
modalLoading
.
value
=
true
;
doc
.
value
.
content
=
textEditor
.
txt
.
html
();
axios
.
post
(
"
/doc/save
"
,
doc
.
value
).
then
((
response
)
=>
{
const
respData
=
response
.
data
;
modalLoading
.
value
=
false
;
...
...
@@ -332,7 +336,7 @@ export default defineComponent({
onMounted
(()
=>
{
handleQuery
();
const
textEditor
=
new
E
(
'
#content
'
);
textEditor
=
new
E
(
'
#content
'
);
textEditor
.
config
.
zIndex
=
0
;
textEditor
.
create
();
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录