main
parent
dcbb255c15
commit
6969180802
@ -1,26 +1,73 @@
|
||||
package com.tamguo.web;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.baomidou.mybatisplus.mapper.Condition;
|
||||
import com.tamguo.common.utils.Result;
|
||||
import com.tamguo.modules.book.model.BookEntity;
|
||||
import com.tamguo.modules.book.model.DocumentEntity;
|
||||
import com.tamguo.modules.book.service.IBookService;
|
||||
import com.tamguo.modules.book.service.IDocumentService;
|
||||
|
||||
@Controller
|
||||
public class BookController {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Autowired
|
||||
private IBookService iBookService;
|
||||
@Autowired
|
||||
private IDocumentService iDocumentService;
|
||||
|
||||
@RequestMapping(value="book/{id}" , method=RequestMethod.GET)
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestMapping(value="book/{id}.html" , method=RequestMethod.GET)
|
||||
public ModelAndView book(@PathVariable String id , ModelAndView model) {
|
||||
BookEntity book = iBookService.selectById(id);
|
||||
model.addObject("book", book);
|
||||
model.setViewName("book/book");
|
||||
|
||||
// 查询第一章
|
||||
List<DocumentEntity> documentList = iDocumentService.selectList(Condition.create().eq("book_id", id).eq("parent_id", "0").orderAsc(Arrays.asList("create_date")));
|
||||
if(!CollectionUtils.isEmpty(documentList)) {
|
||||
model.addObject("document", documentList.get(0));
|
||||
}
|
||||
model.addObject("documentList", iDocumentService.selectList(Condition.create().eq("book_id", id).orderAsc(Arrays.asList("create_date"))));
|
||||
return model;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestMapping(value="document/{id}.html" , method=RequestMethod.GET)
|
||||
public ModelAndView document(@PathVariable String id , ModelAndView model) {
|
||||
model.setViewName("book/document");
|
||||
DocumentEntity document = iDocumentService.selectById(id);
|
||||
List<DocumentEntity> documentList = iDocumentService.selectList(Condition.create().eq("book_id", document.getBookId()).orderAsc(Arrays.asList("create_date")));
|
||||
model.addObject("documentList", documentList);
|
||||
model.addObject("document", document);
|
||||
model.addObject("book", iBookService.selectById(document.getBookId()));
|
||||
return model;
|
||||
}
|
||||
|
||||
@RequestMapping(value="document/{id}" , method=RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Result getDocument(@PathVariable String id) {
|
||||
try {
|
||||
DocumentEntity document = iDocumentService.selectById(id);
|
||||
return Result.result(0, document, "查询成功!");
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage() , e);
|
||||
return Result.result(1, null, "查询失败!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,251 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<title th:text="${document.name + '-探果网'}">测试项目类型 - 探果网</title>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta name="author" content="tamguo" />
|
||||
<meta name="site" content="https://www.tamguo.com" />
|
||||
<meta name="keywords" th:content="${document.name}">
|
||||
<meta name="description" th:content="${document.name}">
|
||||
<link th:href="${domainName + 'bootstrap/css/bootstrap.min.css'}" rel="stylesheet">
|
||||
<link th:href="${domainName + 'jstree/3.3.4/themes/default/style.min.css'}" rel="stylesheet">
|
||||
<link th:href="${domainName + 'font-awesome/css/font-awesome.min.css'}" rel="stylesheet">
|
||||
<link th:href="${domainName + 'nprogress/nprogress.css'}" rel="stylesheet">
|
||||
<link th:href="${domainName + 'css/kancloud.css'}" rel="stylesheet">
|
||||
<link th:href="${domainName + 'css/jstree.css'}" rel="stylesheet">
|
||||
<link th:href="${domainName + 'editor.md/lib/mermaid/mermaid.css'}" rel="stylesheet">
|
||||
<link th:href="${domainName + 'editor.md/lib/sequence/sequence-diagram-min.css'}" rel="stylesheet">
|
||||
<link th:href="${domainName + 'editor.md/css/editormd.preview.css'}" rel="stylesheet">
|
||||
<link th:href="${domainName + 'css/markdown.preview.css'}" rel="stylesheet">
|
||||
<link th:href="${domainName + 'editor.md/lib/highlight/styles/github.css'}" rel="stylesheet">
|
||||
<link th:href="${domainName + 'katex/katex.min.css'}" rel="stylesheet">
|
||||
<link th:href="${domainName + 'css/print.css'}" media="print" rel="stylesheet">
|
||||
|
||||
<script type="text/javascript">window.book={"identify":"simon"};</script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="m-manual manual-mode-view manual-reader">
|
||||
<header class="navbar navbar-static-top manual-head" role="banner">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header pull-left manual-title">
|
||||
<span class="slidebar" id="slidebar"><i class="fa fa-align-justify"></i></span>
|
||||
<a href="https://www.tamguo.com" th:title="${document.name}" class="book-title" th:text="${document.name}">高中理科数学必修一</a>
|
||||
<span style="font-size: 12px;font-weight: 100;"></span>
|
||||
</div>
|
||||
<div class="navbar-header pull-right manual-menu">
|
||||
<a href="javascript:window.print();" id="printSinglePage" class="btn btn-default" style="margin-right: 10px;"><i class="fa fa-print"></i> 打印</a>
|
||||
|
||||
<div class="dropdown pull-right" style="margin-right: 10px;">
|
||||
<a href="https://www.tamguo.com" class="btn btn-default"><i class="fa fa-home" aria-hidden="true"></i> 首页</a>
|
||||
</div>
|
||||
<div class="dropdown pull-right" style="margin-right: 10px;">
|
||||
<button type="button" class="btn btn-success" data-toggle="modal" data-target="#shareProject"><i class="fa fa-share-square" aria-hidden="true"></i> 分享</button>
|
||||
</div>
|
||||
|
||||
<div class="dropdown pull-right" style="margin-right: 10px;">
|
||||
<button type="button" class="btn btn-primary" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="fa fa-cloud-download" aria-hidden="true"></i> 下载 <span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel" style="margin-top: -5px;">
|
||||
<li><a href="https://www.tamguo.com/export/simon?output=pdf" target="_blank">PDF</a> </li>
|
||||
<li><a href="https://www.tamguo.com/export/simon?output=epub" target="_blank">EPUB</a> </li>
|
||||
<li><a href="https://www.tamguo.com/export/simon?output=mobi" target="_blank">MOBI</a> </li>
|
||||
<li><a href="https://www.tamguo.com/export/simon?output=docx" target="_blank">Word</a> </li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<article class="container-fluid manual-body">
|
||||
<div class="manual-left">
|
||||
<div class="manual-tab">
|
||||
<div class="tab-navg">
|
||||
<span data-mode="view" class="navg-item active"><i class="fa fa-align-justify"></i><b class="text">目录</b></span>
|
||||
<span data-mode="search" class="navg-item"><i class="fa fa-search"></i><b class="text">搜索</b></span>
|
||||
</div>
|
||||
<div class="tab-util">
|
||||
<span class="manual-fullscreen-switch">
|
||||
<b class="open fa fa-angle-right" title="展开"></b>
|
||||
<b class="close fa fa-angle-left" title="关闭"></b>
|
||||
</span>
|
||||
</div>
|
||||
<div class="tab-wrap">
|
||||
<div class="tab-item manual-catalog">
|
||||
<div class="catalog-list read-book-preview" id="sidebar">
|
||||
<ul th:if="${doc.parentId} eq '0'" th:each="doc,status:${documentList}">
|
||||
<li th:id="${doc.id}">
|
||||
<a th:href="${domainName + 'document/' + doc.id}" th:title="${doc.id}" th:text="${doc.name}">测试项目类型</a>
|
||||
<ul>
|
||||
<li th:if="${d.parentId == doc.id}" th:id="${d.id}" th:each="d,status:${documentList}">
|
||||
<a th:href="${domainName + 'document/' + d.id}" th:title="${d.id}" th:text="${d.name}" th:class="${d.id == document.id ? 'jstree-clicked' : ''}">普通文档类型</a>
|
||||
<!-- <ul>
|
||||
<li th:id="${dd.id}" th:each="dd,status:${d.children}">
|
||||
<a th:href="${domainName + 'document/' + dd.id + '.html'}" th:title="${dd.id}" data-version="1541647449" th:text="${dd.name}" th:class="${dd.id == document.id ? 'jstree-clicked' : ''}">普通文档类型</a>
|
||||
<ul>
|
||||
<li th:id="${ddd.id}" th:each="ddd,status:${dd.children}">
|
||||
<a th:href="${domainName + 'document/' + ddd.id + '.html'}" th:title="${ddd.id}" data-version="1541647449" th:text="${ddd.name}" th:class="${ddd.id == document.id ? 'jstree-clicked' : ''}" >普通文档类型</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul> -->
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="tab-item manual-search">
|
||||
<div class="search-container">
|
||||
<div class="search-form">
|
||||
<form id="searchForm" action="https://www.tamguo.com" method="post">
|
||||
<div class="form-group">
|
||||
<input type="search" placeholder="请输入搜索关键字" class="form-control" name="keyword">
|
||||
<button type="submit" class="btn btn-default btn-search" id="btnSearch">
|
||||
<i class="fa fa-search"></i>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="search-result">
|
||||
<div class="search-empty">
|
||||
<i class="fa fa-search-plus" aria-hidden="true"></i>
|
||||
<b class="text">暂无相关搜索结果!</b>
|
||||
</div>
|
||||
<ul class="search-list" id="searchList">
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="m-copyright">
|
||||
<p>
|
||||
本文档使用 <a href="https://www.tamguo.com" target="_blank">探果网</a> 发布
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="manual-right">
|
||||
<div class="manual-article">
|
||||
<div class="article-head">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
|
||||
</div>
|
||||
<div class="col-md-8 text-center">
|
||||
<h1 id="article-title" th:text="${document.name}">测试项目类型</h1>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="article-content">
|
||||
<div class="article-body editor-content" id="page-content">
|
||||
<article class="markdown-article-inner" th:utext="${document.content}">
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<div class="jump-top">
|
||||
<a href="javascript:;" class="view-backtop"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="manual-progress"><b class="progress-bar"></b></div>
|
||||
</article>
|
||||
<div class="manual-mask"></div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="shareProject" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
||||
<h4 class="modal-title" id="myModalLabel">项目分享</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 text-center" id="shareQrcode" style="padding-bottom: 15px;">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password" class="col-sm-2 control-label">项目地址</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" th:value="${domainName + 'document/' + document.id + '.html'}" class="form-control" onmouseover="this.select()" id="projectUrl" title="项目地址">
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal fade" id="downloadBookModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
||||
<h4 class="modal-title" id="myModalLabel">项目分享</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 text-center" style="padding-bottom: 15px;">
|
||||
<img src="https://www.tamguo.com" alt="扫一扫手机阅读" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password" class="col-sm-2 control-label">项目地址</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" value="http://www.tamguo.com" class="form-control" onmouseover="this.select()" id="projectUrl" title="项目地址">
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script th:src="${domainName + 'jquery/1.12.4/jquery.min.js'}"></script>
|
||||
<script th:src="${domainName + 'bootstrap/js/bootstrap.min.js'}"></script>
|
||||
<script th:src="${domainName + 'js/jquery.form.js'}" type="text/javascript"></script>
|
||||
<script th:src="${domainName + 'layer/layer.js'}" type="text/javascript"></script>
|
||||
<script th:src="${domainName + 'jstree/3.3.4/jstree.min.js'}" type="text/javascript"></script>
|
||||
<script th:src="${domainName + 'nprogress/nprogress.js'}" type="text/javascript"></script>
|
||||
<script th:src="${domainName + 'editor.md/lib/highlight/highlight.js'}" type="text/javascript"></script>
|
||||
<script th:src="${domainName + 'js/jquery.highlight.js'}" type="text/javascript"></script>
|
||||
<script th:src="${domainName + 'js/kancloud.js'}" type="text/javascript"></script>
|
||||
<script th:src="${domainName + 'js/splitbar.js'}" type="text/javascript"></script>
|
||||
<script th:src="${domainName + 'js/jquery.qrcode.min.js'}" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
$("#searchList").on("click","a",function () {
|
||||
var id = $(this).attr("data-id");
|
||||
var url = "[[${domainName}]]" + "/document/[[${document.id}]].html";
|
||||
$(this).parent("li").siblings().find("a").removeClass("active");
|
||||
$(this).addClass("active");
|
||||
loadDocument(url,id,function (body) {
|
||||
return $(body).highlight(window.keyword);
|
||||
});
|
||||
});
|
||||
|
||||
$("#shareQrcode").qrcode($("#projectUrl").val());
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in new issue