提交 501b84c2 编写于 作者: yubinCloud's avatar yubinCloud

8-11 增加读取文档内容的功能

上级 c55b2c98
......@@ -55,4 +55,15 @@ public class DocController {
docService.deleteDocs(docDeleteReqDto.getIds());
return new RestfulModel<>(ErrorCode.SUCCESS, "", 0);
}
/**
* 读取文档的内容
* @param docId 所要读取的文档的 id
* @return 读取到的内容
*/
@GetMapping("/read-content/{docId}")
public RestfulModel<String> readDocContent(@PathVariable Long docId) {
String docContent = docService.readDocContent(docId);
return new RestfulModel<>(0, "", docContent);
}
}
......@@ -103,4 +103,16 @@ public class DocService {
criteria.andIdIn(idList);
docMapper.deleteByExample(docExample);
}
/**
* 读取一篇文档的内容
* @param docId 所要读取的文档的id
* @return 该文档的内容
*/
public String readDocContent(Long docId) {
Content content = contentMapper.selectByPrimaryKey(docId);
if (content == null)
return "";
return content.getContent();
}
}
......@@ -240,6 +240,20 @@ export default defineComponent({
}
};
/**
* 内容查询
**/
const handleQueryContent = () => {
axios.get("/doc/read-content/" + doc.value.id).then((response) => {
const respData = response.data;
if (respData.code === 0) {
textEditor.txt.html(respData.data);
} else {
message.error(respData.msg);
}
});
};
/**
* 编辑
......@@ -247,6 +261,7 @@ export default defineComponent({
const edit = (record: any) => {
modalVisible.value = true;
doc.value = Tool.copy(record);
handleQueryContent();
// 不能选择当前节点及其所有子孙节点,作为父节点,会使树断开
treeSelectData.value = Tool.copy(level1.value);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册