2021年12月13日17:10:05
parent
c7680d4741
commit
193297de43
|
|
@ -0,0 +1,77 @@
|
|||
package com.zhangmeng.admin.manager.controller;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zhangmeng.admin.manager.feign.FictionFeign;
|
||||
import com.zhangmeng.model.base.baseController.BaseController;
|
||||
import com.zhangmeng.model.dto.system.SysConstant;
|
||||
import com.zhangmeng.model.entity.Fiction;
|
||||
import com.zhangmeng.model.entity.FictionChapter;
|
||||
import com.zhangmeng.model.entity.FictionDetails;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/fiction")
|
||||
public class FictionController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private FictionFeign fictionFeign;
|
||||
|
||||
@GetMapping("/index")
|
||||
public ModelAndView fiction_index(Model model, Integer pageNum, Integer pageSize) {
|
||||
|
||||
if (pageNum == null || pageSize == null) {
|
||||
pageNum = pageNum == null ? 1 : pageNum;
|
||||
pageSize = pageSize == null ? 10 : pageSize;
|
||||
}
|
||||
|
||||
PageHelper.startPage(pageNum, pageSize, "addTime desc");
|
||||
List<Fiction> fictionList = this.fictionFeign.findAll();
|
||||
PageInfo<Fiction> pageInfo = new PageInfo<>(fictionList);
|
||||
|
||||
if (pageInfo.getPrePage() == 0) {
|
||||
pageInfo.setPrePage(1);
|
||||
}
|
||||
if (pageInfo.getNextPage() == 0) {
|
||||
pageInfo.setNextPage(1);
|
||||
}
|
||||
|
||||
model.addAttribute("pageInfo", pageInfo);
|
||||
return this.jumpPage("xiaoshuo/index");
|
||||
}
|
||||
|
||||
@GetMapping("/chapter/{id}")
|
||||
public ModelAndView chapter(Model model, @PathVariable Long id) {
|
||||
Fiction fiction = this.fictionFeign.findById(id);
|
||||
model.addAttribute("fiction", fiction);
|
||||
List<FictionChapter> fictionChapterList = this.fictionFeign.findByFictionId(id);
|
||||
model.addAttribute("fictionChapter", fictionChapterList.get(0));
|
||||
model.addAttribute("fictionChapterList", fictionChapterList);
|
||||
return this.jumpPage("xiaoshuo/fiction_chapter");
|
||||
}
|
||||
|
||||
@GetMapping("/details/{chapter_id}")
|
||||
public ModelAndView details(Model model, @PathVariable String chapter_id) {
|
||||
|
||||
String replace = chapter_id.replace(",", "");
|
||||
Long id = Long.parseLong(replace);
|
||||
List<FictionDetails> fictionDetailsList = this.fictionFeign.fictionDetailsId(id);
|
||||
if (fictionDetailsList.size() > 0) {
|
||||
FictionDetails fictionDetails = fictionDetailsList.get(0);
|
||||
String content = fictionDetails.getContent();
|
||||
content = "<br> " + content;
|
||||
String replace1 = content.replace(" ", "<br><br><br> ");
|
||||
fictionDetails.setContent(replace1);
|
||||
model.addAttribute("fictionDetails", fictionDetails);
|
||||
}
|
||||
return this.jumpPage("xiaoshuo/fiction_details");
|
||||
}
|
||||
}
|
||||
|
|
@ -175,57 +175,7 @@ public class UrlRequestController extends BaseController {
|
|||
return this.jumpPage("admin/fiction/fiction_add");
|
||||
}
|
||||
|
||||
@GetMapping(SysConstant.fiction_prefix + "/chapter/{id}")
|
||||
public ModelAndView chapter(Model model, @PathVariable Long id) {
|
||||
|
||||
Fiction fiction = this.fictionFeign.findById(id);
|
||||
model.addAttribute("fiction", fiction);
|
||||
List<FictionChapter> fictionChapterList = this.fictionFeign.findByFictionId(id);
|
||||
model.addAttribute("fictionChapter", fictionChapterList.get(0));
|
||||
model.addAttribute("fictionChapterList", fictionChapterList);
|
||||
return this.jumpPage("xiaoshuo/fiction_chapter");
|
||||
}
|
||||
|
||||
@GetMapping(SysConstant.fiction_prefix + "/details/{chapter_id}")
|
||||
public ModelAndView details(Model model, @PathVariable String chapter_id) {
|
||||
|
||||
String replace = chapter_id.replace(",", "");
|
||||
Long id = Long.parseLong(replace);
|
||||
List<FictionDetails> fictionDetailsList = this.fictionFeign.fictionDetailsId(id);
|
||||
if (fictionDetailsList.size() > 0) {
|
||||
FictionDetails fictionDetails = fictionDetailsList.get(0);
|
||||
String content = fictionDetails.getContent();
|
||||
content = "<br> " + content;
|
||||
String replace1 = content.replace(" ", "<br><br><br> ");
|
||||
fictionDetails.setContent(replace1);
|
||||
model.addAttribute("fictionDetails", fictionDetails);
|
||||
}
|
||||
return this.jumpPage("xiaoshuo/fiction_details");
|
||||
}
|
||||
|
||||
@ApiIgnore
|
||||
@GetMapping(SysConstant.fiction_prefix + "/index")
|
||||
public ModelAndView fiction_index(Model model, Integer pageNum, Integer pageSize) {
|
||||
|
||||
if (pageNum == null || pageSize == null) {
|
||||
pageNum = pageNum == null ? 1 : pageNum;
|
||||
pageSize = pageSize == null ? 10 : pageSize;
|
||||
}
|
||||
|
||||
PageHelper.startPage(pageNum, pageSize, "addTime desc");
|
||||
List<Fiction> fictionList = this.fictionFeign.findAll();
|
||||
PageInfo<Fiction> pageInfo = new PageInfo<>(fictionList);
|
||||
|
||||
if (pageInfo.getPrePage() == 0) {
|
||||
pageInfo.setPrePage(1);
|
||||
}
|
||||
if (pageInfo.getNextPage() == 0) {
|
||||
pageInfo.setNextPage(1);
|
||||
}
|
||||
|
||||
model.addAttribute("pageInfo", pageInfo);
|
||||
return this.jumpPage("xiaoshuo/index");
|
||||
}
|
||||
|
||||
@GetMapping(SysConstant.fictionCollection_prefix + "/index")
|
||||
public ModelAndView fictionCollection_index() {
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ body{
|
|||
}
|
||||
.blog-author{
|
||||
text-align: right;
|
||||
margin: 5px 0px;
|
||||
margin: 70px 0px;
|
||||
}
|
||||
.blog-des{
|
||||
margin-top: -10%;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
</a>
|
||||
<a href="/mystyle-cloud-web-blog/blog/index" class="active m-item item m-mobile-hide"><i class="mini home icon"></i> 首页</a>
|
||||
<a href="/mystyle-cloud-web-blog/category/category_list" class="m-item item m-mobile-hide"><i class="mini idea icon"></i> 分类</a>
|
||||
<a href="/mystyle-cloud-web-blog/fiction/index" class="m-item item m-mobile-hide"><i class="mini idea icon"></i> 小说</a>
|
||||
<a href="/mystyle-cloud-web-blog/blog/about" class="m-item item m-mobile-hide"><i class="mini info icon"></i> 关于我</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -32,13 +32,13 @@
|
|||
<div class="nav">
|
||||
<#if fictionChapterList ??>
|
||||
<#list fictionChapterList as fictionChapter>
|
||||
<li><a href="/fiction/details/${fictionChapter.id}" target="right">${fictionChapter.title!}</a></li>
|
||||
<li><a href="/mystyle-cloud-web-blog/fiction/details/${fictionChapter.id}" target="right">${fictionChapter.title!}</a></li>
|
||||
</#list>
|
||||
</#if>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-rit">
|
||||
<iframe name="right" id="iframepage" src="/fiction/details/${fictionChapter.id!}" width="100%" height="100%" frameborder="0" ranat="server"></iframe>
|
||||
<iframe name="right" id="iframepage" src="/mystyle-cloud-web-blog/fiction/details/${fictionChapter.id!}" width="100%" height="100%" frameborder="0" ranat="server"></iframe>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="${springMacroRequestContext.contextPath}/mystyle-cloud-web-blog/js/jquery.min.js"></script>
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
<#if pageInfo.getList() ??>
|
||||
<#list pageInfo.getList() as fiction>
|
||||
<div class="blog-item">
|
||||
<p class="blog-title"><a href="/fiction/chapter/${fiction.id!}">${fiction.bookName!}</a></p>
|
||||
<p class="blog-title"><a href="/mystyle-cloud-web-blog/fiction/chapter/${fiction.id!}">${fiction.bookName!}</a></p>
|
||||
<p class="blog-author">—— ${fiction.author!} ${fiction.addTime?string('yyyy-MM-dd hh:mm:ss')}</p>
|
||||
<img class="blog-img" src="${fiction.main_image_path!}" width="30%" height="30%"/>
|
||||
<p class="blog-des">${fiction.intro!}</p>
|
||||
|
|
|
|||
|
|
@ -104,7 +104,10 @@ public class FictionController extends BaseController implements FictionControll
|
|||
@Override
|
||||
@GetMapping("/findByFictionId")
|
||||
public List<FictionChapter> findByFictionId(@RequestParam("id") Long id) {
|
||||
return null;
|
||||
Condition condition = new Condition(FictionChapter.class);
|
||||
Example.Criteria criteria = condition.createCriteria();
|
||||
criteria.andEqualTo("fiction_id",id);
|
||||
return this.fictionChapterService.findByCondition(condition);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue