小说内容页性能优化

This commit is contained in:
xiongxiaoyang 2021-01-25 14:14:54 +08:00
parent ca6c2aec96
commit b5e0814eb4
26 changed files with 216 additions and 104 deletions

View File

@ -123,6 +123,12 @@
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
</dependencies> </dependencies>

View File

@ -5,7 +5,7 @@ import com.java2nb.novel.core.bean.ResultBean;
import com.java2nb.novel.core.bean.UserDetails; import com.java2nb.novel.core.bean.UserDetails;
import com.java2nb.novel.core.enums.ResponseStatus; import com.java2nb.novel.core.enums.ResponseStatus;
import com.java2nb.novel.entity.BookComment; import com.java2nb.novel.entity.BookComment;
import com.java2nb.novel.search.BookSP; import com.java2nb.novel.vo.BookSpVO;
import com.java2nb.novel.service.BookService; import com.java2nb.novel.service.BookService;
import com.java2nb.novel.vo.BookVO; import com.java2nb.novel.vo.BookVO;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -79,7 +79,7 @@ public class BookController extends BaseController{
* 分页搜索 * 分页搜索
* */ * */
@GetMapping("searchByPage") @GetMapping("searchByPage")
public ResultBean searchByPage(BookSP bookSP, @RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "20") int pageSize){ public ResultBean searchByPage(BookSpVO bookSP, @RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "20") int pageSize){
PageInfo<BookVO> pageInfo = bookService.searchByPage(bookSP,page,pageSize); PageInfo<BookVO> pageInfo = bookService.searchByPage(bookSP,page,pageSize);
return ResultBean.ok(pageInfo); return ResultBean.ok(pageInfo);
} }

View File

@ -5,7 +5,7 @@ import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.internal.util.AlipaySignature; import com.alipay.api.internal.util.AlipaySignature;
import com.alipay.api.request.AlipayTradePagePayRequest; import com.alipay.api.request.AlipayTradePagePayRequest;
import com.java2nb.novel.core.bean.UserDetails; import com.java2nb.novel.core.bean.UserDetails;
import com.java2nb.novel.core.config.AlipayConfig; import com.java2nb.novel.core.config.AlipayProperties;
import com.java2nb.novel.service.OrderService; import com.java2nb.novel.service.OrderService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows; import lombok.SneakyThrows;
@ -31,7 +31,7 @@ import java.util.Map;
public class PayController extends BaseController { public class PayController extends BaseController {
private final AlipayConfig alipayConfig; private final AlipayProperties alipayConfig;
private final OrderService orderService; private final OrderService orderService;

View File

@ -10,7 +10,7 @@ import org.springframework.stereotype.Component;
@Data @Data
@Component @Component
@ConfigurationProperties(prefix="alipay") @ConfigurationProperties(prefix="alipay")
public class AlipayConfig { public class AlipayProperties {
private String appId; private String appId;
private String merchantPrivateKey; private String merchantPrivateKey;

View File

@ -7,13 +7,13 @@ import org.springframework.stereotype.Component;
import java.math.BigDecimal; import java.math.BigDecimal;
/** /**
* 作家收入配置 * 作家收入配置属性
* @author cd * @author cd
*/ */
@Component @Component
@Data @Data
@ConfigurationProperties(prefix = "author.income") @ConfigurationProperties(prefix = "author.income")
public class AuthorIncomeConfig { public class AuthorIncomeProperties {
private BigDecimal taxRate; private BigDecimal taxRate;

View File

@ -7,13 +7,13 @@ import org.springframework.stereotype.Component;
import java.math.BigDecimal; import java.math.BigDecimal;
/** /**
* 章节费用配置 * 章节费用配置属性
* @author cd * @author cd
*/ */
@Component @Component
@Data @Data
@ConfigurationProperties(prefix = "book.price") @ConfigurationProperties(prefix = "book.price")
public class BookPriceConfig { public class BookPriceProperties {
private BigDecimal wordCount; private BigDecimal wordCount;

View File

@ -9,5 +9,5 @@ import org.springframework.jmx.support.RegistrationPolicy;
*/ */
@Configuration @Configuration
@EnableMBeanExport(registration= RegistrationPolicy.IGNORE_EXISTING) @EnableMBeanExport(registration= RegistrationPolicy.IGNORE_EXISTING)
public class FdfsConfiguration { public class FdfsConfig {
} }

View File

@ -0,0 +1,23 @@
package com.java2nb.novel.core.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* 线程池配置
* @author xiongxiaoyang
*/
@Configuration
public class ThreadPoolConfig {
@Bean
public ThreadPoolExecutor threadPoolExecutor(ThreadPoolProperties properties){
return new ThreadPoolExecutor(properties.getCorePoolSize(),properties.getMaximumPoolSize(),properties.getKeepAliveTime()
, TimeUnit.MINUTES, new LinkedBlockingDeque<>(),new ThreadPoolExecutor.AbortPolicy());
}
}

View File

@ -0,0 +1,21 @@
package com.java2nb.novel.core.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* 线程池配置属性
* @author xiongxiaoyang
*/
@Data
@Component
@ConfigurationProperties(prefix = "thread.pool")
public class ThreadPoolProperties {
private Integer corePoolSize;
private Integer maximumPoolSize;
private Long keepAliveTime;
}

View File

@ -10,7 +10,7 @@ import org.springframework.stereotype.Component;
@Data @Data
@Component @Component
@ConfigurationProperties(prefix="website") @ConfigurationProperties(prefix="website")
public class WebsiteConfig { public class WebsiteProperties {
private String name; private String name;
private String domain; private String domain;

View File

@ -1,6 +1,6 @@
package com.java2nb.novel.core.listener; package com.java2nb.novel.core.listener;
import com.java2nb.novel.core.config.WebsiteConfig; import com.java2nb.novel.core.config.WebsiteProperties;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -17,7 +17,7 @@ import javax.servlet.annotation.WebListener;
@RequiredArgsConstructor @RequiredArgsConstructor
public class StarterListener implements ServletContextListener { public class StarterListener implements ServletContextListener {
private final WebsiteConfig websiteConfig; private final WebsiteProperties websiteConfig;
@Override @Override

View File

@ -1,7 +1,6 @@
package com.java2nb.novel.core.schedule; package com.java2nb.novel.core.schedule;
import com.java2nb.novel.core.config.AuthorIncomeConfig;
import com.java2nb.novel.core.utils.DateUtil; import com.java2nb.novel.core.utils.DateUtil;
import com.java2nb.novel.entity.Author; import com.java2nb.novel.entity.Author;
import com.java2nb.novel.entity.AuthorIncomeDetail; import com.java2nb.novel.entity.AuthorIncomeDetail;

View File

@ -1,19 +1,17 @@
package com.java2nb.novel.core.schedule; package com.java2nb.novel.core.schedule;
import com.java2nb.novel.core.config.AuthorIncomeConfig; import com.java2nb.novel.core.config.AuthorIncomeProperties;
import com.java2nb.novel.core.utils.DateUtil; import com.java2nb.novel.core.utils.DateUtil;
import com.java2nb.novel.entity.*; import com.java2nb.novel.entity.*;
import com.java2nb.novel.service.AuthorService; import com.java2nb.novel.service.AuthorService;
import com.java2nb.novel.service.BookService; import com.java2nb.novel.service.BookService;
import com.java2nb.novel.service.UserService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -31,7 +29,7 @@ public class MonthIncomeStaSchedule {
private final BookService bookService; private final BookService bookService;
private final AuthorIncomeConfig authorIncomeConfig; private final AuthorIncomeProperties authorIncomeConfig;
/** /**
* 每个月1号凌晨2点统计上个月数据 * 每个月1号凌晨2点统计上个月数据

View File

@ -1,11 +1,10 @@
package com.java2nb.novel.mapper; package com.java2nb.novel.mapper;
import com.java2nb.novel.entity.Book; import com.java2nb.novel.entity.Book;
import com.java2nb.novel.search.BookSP; import com.java2nb.novel.vo.BookSpVO;
import com.java2nb.novel.vo.BookVO; import com.java2nb.novel.vo.BookVO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -14,7 +13,7 @@ import java.util.List;
public interface FrontBookMapper extends BookMapper { public interface FrontBookMapper extends BookMapper {
List<BookVO> searchByPage(BookSP params); List<BookVO> searchByPage(BookSpVO params);
void addVisitCount(@Param("bookId") Long bookId, @Param("visitCount") Integer visitCount); void addVisitCount(@Param("bookId") Long bookId, @Param("visitCount") Integer visitCount);

View File

@ -19,7 +19,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadPoolExecutor;
/** /**
* @author 11797 * @author 11797
@ -37,6 +40,8 @@ public class PageController extends BaseController {
private final UserService userService; private final UserService userService;
private final ThreadPoolExecutor threadPoolExecutor;
@RequestMapping("{url}.html") @RequestMapping("{url}.html")
public String module(@PathVariable("url") String url) { public String module(@PathVariable("url") String url) {
@ -44,9 +49,9 @@ public class PageController extends BaseController {
} }
@RequestMapping("{module}/{url}.html") @RequestMapping("{module}/{url}.html")
public String module2(@PathVariable("module") String module, @PathVariable("url") String url,HttpServletRequest request) { public String module2(@PathVariable("module") String module, @PathVariable("url") String url, HttpServletRequest request) {
if(request.getRequestURI().startsWith("/author")) { if (request.getRequestURI().startsWith("/author")) {
//访问作者专区 //访问作者专区
UserDetails user = getUserDetails(request); UserDetails user = getUserDetails(request);
if (user == null) { if (user == null) {
@ -56,7 +61,7 @@ public class PageController extends BaseController {
boolean isAuthor = authorService.isAuthor(user.getId()); boolean isAuthor = authorService.isAuthor(user.getId());
if (!isAuthor) { if (!isAuthor) {
return "redirect:/author/register.html" ; return "redirect:/author/register.html";
} }
} }
@ -70,15 +75,15 @@ public class PageController extends BaseController {
/** /**
* 首页 * 首页
* */ */
@RequestMapping(path = {"/", "/index", "/index.html"}) @RequestMapping(path = {"/", "/index", "/index.html"})
public String index() { public String index() {
return ThreadLocalUtil.getTemplateDir()+"index"; return ThreadLocalUtil.getTemplateDir() + "index";
} }
/** /**
* 作品页 * 作品页
* */ */
@RequestMapping("book/bookclass.html") @RequestMapping("book/bookclass.html")
public String bookClass() { public String bookClass() {
return "book/bookclass"; return "book/bookclass";
@ -86,129 +91,170 @@ public class PageController extends BaseController {
/** /**
* 排行页 * 排行页
* */ */
@RequestMapping("book/book_ranking.html") @RequestMapping("book/book_ranking.html")
public String bookRank() { public String bookRank() {
return ThreadLocalUtil.getTemplateDir()+"book/book_ranking"; return ThreadLocalUtil.getTemplateDir() + "book/book_ranking";
} }
/** /**
* 详情页 * 详情页
* */ */
@SneakyThrows @SneakyThrows
@RequestMapping("/book/{bookId}.html") @RequestMapping("/book/{bookId}.html")
public String bookDetail(@PathVariable("bookId") Long bookId, Model model) { public String bookDetail(@PathVariable("bookId") Long bookId, Model model) {
Book book = bookService.queryBookDetail(bookId); Book book = bookService.queryBookDetail(bookId);
model.addAttribute("book",book); model.addAttribute("book", book);
if(book.getLastIndexId() != null) { if (book.getLastIndexId() != null) {
//查询首章目录ID //查询首章目录ID
Long firstBookIndexId = bookService.queryFirstBookIndexId(bookId); Long firstBookIndexId = bookService.queryFirstBookIndexId(bookId);
model.addAttribute("firstBookIndexId", firstBookIndexId); model.addAttribute("firstBookIndexId", firstBookIndexId);
} }
return ThreadLocalUtil.getTemplateDir()+"book/book_detail"; return ThreadLocalUtil.getTemplateDir() + "book/book_detail";
} }
/** /**
* 目录页 * 目录页
* */ */
@SneakyThrows @SneakyThrows
@RequestMapping("/book/indexList-{bookId}.html") @RequestMapping("/book/indexList-{bookId}.html")
public String indexList(@PathVariable("bookId") Long bookId, Model model) { public String indexList(@PathVariable("bookId") Long bookId, Model model) {
Book book = bookService.queryBookDetail(bookId); Book book = bookService.queryBookDetail(bookId);
model.addAttribute("book",book); model.addAttribute("book", book);
List<BookIndex> bookIndexList = bookService.queryIndexList(bookId,null,1,null); List<BookIndex> bookIndexList = bookService.queryIndexList(bookId, null, 1, null);
model.addAttribute("bookIndexList",bookIndexList); model.addAttribute("bookIndexList", bookIndexList);
model.addAttribute("bookIndexCount",bookIndexList.size()); model.addAttribute("bookIndexCount", bookIndexList.size());
return ThreadLocalUtil.getTemplateDir()+"book/book_index"; return ThreadLocalUtil.getTemplateDir() + "book/book_index";
} }
/** /**
* 内容页 * 内容页
* */ */
@SneakyThrows @SneakyThrows
@RequestMapping("/book/{bookId}/{bookIndexId}.html") @RequestMapping("/book/{bookId}/{bookIndexId}.html")
public String indexList(@PathVariable("bookId") Long bookId,@PathVariable("bookIndexId") Long bookIndexId, HttpServletRequest request, Model model) { public String indexList(@PathVariable("bookId") Long bookId, @PathVariable("bookIndexId") Long bookIndexId, HttpServletRequest request, Model model) {
//加载小说基本信息线程
CompletableFuture<Book> bookCompletableFuture = CompletableFuture.supplyAsync(() -> {
//查询书籍 //查询书籍
Book book = bookService.queryBookDetail(bookId); Book book = bookService.queryBookDetail(bookId);
log.debug("加载小说基本信息线程结束");
return book;
}, threadPoolExecutor);
//加载小说章节信息线程
CompletableFuture<BookIndex> bookIndexCompletableFuture = CompletableFuture.supplyAsync(() -> {
//查询目录 //查询目录
BookIndex bookIndex = bookService.queryBookIndex(bookIndexId); BookIndex bookIndex = bookService.queryBookIndex(bookIndexId);
model.addAttribute("book",book); log.debug("加载小说章节信息线程结束");
model.addAttribute("bookIndex",bookIndex); return bookIndex;
//查询上一章节目录ID }, threadPoolExecutor);
Long preBookIndexId = bookService.queryPreBookIndexId(bookId,bookIndex.getIndexNum());
model.addAttribute("preBookIndexId",preBookIndexId);
//查询下一章目录ID
Long nextBookIndexId = bookService.queryNextBookIndexId(bookId,bookIndex.getIndexNum());
model.addAttribute("nextBookIndexId",nextBookIndexId);
//查询内容
BookContent bookContent = bookService.queryBookContent(bookIndex.getId());
model.addAttribute("bookContent",bookContent);
boolean needBuy = false; //加载小说上一章节信息线程该线程在加载小说章节信息线程执行完毕后才执行
CompletableFuture<Long> preBookIndexIdCompletableFuture = bookIndexCompletableFuture.thenApplyAsync((bookIndex) -> {
//查询上一章节目录ID
Long preBookIndexId = bookService.queryPreBookIndexId(bookId, bookIndex.getIndexNum());
log.debug("加载小说上一章节信息线程结束");
return preBookIndexId;
}, threadPoolExecutor);
//加载小说下一章节信息线程该线程在加载小说章节信息线程执行完毕后才执行
CompletableFuture<Long> nextBookIndexIdCompletableFuture = bookIndexCompletableFuture.thenApplyAsync((bookIndex) -> {
//查询下一章目录ID
Long nextBookIndexId = bookService.queryNextBookIndexId(bookId, bookIndex.getIndexNum());
log.debug("加载小说下一章节信息线程结束");
return nextBookIndexId;
}, threadPoolExecutor);
//加载小说内容信息线程
CompletableFuture<BookContent> bookContentCompletableFuture = CompletableFuture.supplyAsync(() -> {
//查询内容
BookContent bookContent = bookService.queryBookContent(bookIndexId);
log.debug("加载小说内容信息线程结束");
return bookContent;
}, threadPoolExecutor);
//判断用户是否需要购买线程该线程在加载小说章节信息线程执行完毕后才执行
CompletableFuture<Boolean> needBuyCompletableFuture = bookIndexCompletableFuture.thenApplyAsync((bookIndex) -> {
//判断该目录是否收费 //判断该目录是否收费
if(bookIndex.getIsVip()!=null && bookIndex.getIsVip() == 1 ){ if (bookIndex.getIsVip() != null && bookIndex.getIsVip() == 1) {
//收费
UserDetails user = getUserDetails(request); UserDetails user = getUserDetails(request);
if(user == null){ if (user == null) {
//未登录 //未登录需要购买
return "redirect:/user/login.html?originUrl="+request.getRequestURI(); return true;
} }
//收费判断用户是否购买过该目录 //判断用户是否购买过该目录
boolean isBuy = userService.queryIsBuyBookIndex(user.getId(),bookIndexId); boolean isBuy = userService.queryIsBuyBookIndex(user.getId(), bookIndexId);
if(!isBuy){ if (!isBuy) {
//没有购买过需要购买 //没有购买过需要购买
bookContent.setContent(null); return true;
needBuy = true;
} }
} }
model.addAttribute("needBuy",needBuy);
return ThreadLocalUtil.getTemplateDir()+"book/book_content"; log.debug("判断用户是否需要购买线程结束");
return false;
}, threadPoolExecutor);
model.addAttribute("book", bookCompletableFuture.get());
model.addAttribute("bookIndex", bookIndexCompletableFuture.get());
model.addAttribute("preBookIndexId", preBookIndexIdCompletableFuture.get());
model.addAttribute("nextBookIndexId", nextBookIndexIdCompletableFuture.get());
model.addAttribute("bookContent", bookContentCompletableFuture.get());
model.addAttribute("needBuy", needBuyCompletableFuture.get());
return ThreadLocalUtil.getTemplateDir() + "book/book_content";
} }
/** /**
* 评论页面 * 评论页面
* */ */
@RequestMapping("/book/comment-{bookId}.html") @RequestMapping("/book/comment-{bookId}.html")
public String commentList(@PathVariable("bookId") Long bookId, Model model) { public String commentList(@PathVariable("bookId") Long bookId, Model model) {
//查询书籍 //查询书籍
Book book = bookService.queryBookDetail(bookId); Book book = bookService.queryBookDetail(bookId);
model.addAttribute("book",book); model.addAttribute("book", book);
return "book/book_comment"; return "book/book_comment";
} }
/** /**
* 新闻内容页面 * 新闻内容页面
* */ */
@RequestMapping("/about/newsInfo-{newsId}.html") @RequestMapping("/about/newsInfo-{newsId}.html")
public String newsInfo(@PathVariable("newsId") Long newsId, Model model) { public String newsInfo(@PathVariable("newsId") Long newsId, Model model) {
//查询新闻 //查询新闻
News news = newsService.queryNewsInfo(newsId); News news = newsService.queryNewsInfo(newsId);
model.addAttribute("news",news); model.addAttribute("news", news);
return "about/news_info"; return "about/news_info";
} }
/** /**
* 作者注册页面 * 作者注册页面
* */ */
@RequestMapping("author/register.html") @RequestMapping("author/register.html")
public String authorRegister(Author author, HttpServletRequest request, Model model){ public String authorRegister(Author author, HttpServletRequest request, Model model) {
UserDetails user = getUserDetails(request); UserDetails user = getUserDetails(request);
if(user == null){ if (user == null) {
//未登录 //未登录
return "redirect:/user/login.html?originUrl=/author/register.html"; return "redirect:/user/login.html?originUrl=/author/register.html";
} }
if(StringUtils.isNotBlank(author.getInviteCode())) { if (StringUtils.isNotBlank(author.getInviteCode())) {
//提交作者注册信息 //提交作者注册信息
String errorInfo = authorService.register(user.getId(), author); String errorInfo = authorService.register(user.getId(), author);
if(StringUtils.isBlank(errorInfo)){ if (StringUtils.isBlank(errorInfo)) {
//注册成功 //注册成功
return "redirect:/author/index.html"; return "redirect:/author/index.html";
} }
model.addAttribute("LabErr",errorInfo); model.addAttribute("LabErr", errorInfo);
model.addAttribute("author",author); model.addAttribute("author", author);
} }
return "author/register"; return "author/register";
} }

View File

@ -2,7 +2,7 @@ package com.java2nb.novel.service;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.java2nb.novel.search.BookSP; import com.java2nb.novel.vo.BookSpVO;
import com.java2nb.novel.vo.BookCommentVO; import com.java2nb.novel.vo.BookCommentVO;
import com.java2nb.novel.vo.BookSettingVO; import com.java2nb.novel.vo.BookSettingVO;
import com.java2nb.novel.entity.*; import com.java2nb.novel.entity.*;
@ -48,7 +48,7 @@ public interface BookService {
* @param pageSize 分页大小 * @param pageSize 分页大小
* @return 小说集合分页信息 * @return 小说集合分页信息
* */ * */
PageInfo searchByPage(BookSP params, int page, int pageSize); PageInfo searchByPage(BookSpVO params, int page, int pageSize);
/** /**
* 查询小说分类列表 * 查询小说分类列表

View File

@ -3,7 +3,7 @@ package com.java2nb.novel.service;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.java2nb.novel.entity.Book; import com.java2nb.novel.entity.Book;
import com.java2nb.novel.search.BookSP; import com.java2nb.novel.vo.BookSpVO;
/** /**
* @author 11797 * @author 11797
@ -23,5 +23,5 @@ public interface SearchService {
* @param pageSize 每页大小 * @param pageSize 每页大小
* @return 分页信息 * @return 分页信息
*/ */
PageInfo searchBook(BookSP params, int page, int pageSize); PageInfo searchBook(BookSpVO params, int page, int pageSize);
} }

View File

@ -5,14 +5,14 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.java2nb.novel.core.cache.CacheKey; import com.java2nb.novel.core.cache.CacheKey;
import com.java2nb.novel.core.cache.CacheService; import com.java2nb.novel.core.cache.CacheService;
import com.java2nb.novel.core.config.BookPriceConfig; import com.java2nb.novel.core.config.BookPriceProperties;
import com.java2nb.novel.core.enums.ResponseStatus; import com.java2nb.novel.core.enums.ResponseStatus;
import com.java2nb.novel.core.exception.BusinessException; import com.java2nb.novel.core.exception.BusinessException;
import com.java2nb.novel.core.utils.*; import com.java2nb.novel.core.utils.*;
import com.java2nb.novel.entity.*; import com.java2nb.novel.entity.*;
import com.java2nb.novel.entity.Book; import com.java2nb.novel.entity.Book;
import com.java2nb.novel.mapper.*; import com.java2nb.novel.mapper.*;
import com.java2nb.novel.search.BookSP; import com.java2nb.novel.vo.BookSpVO;
import com.java2nb.novel.service.AuthorService; import com.java2nb.novel.service.AuthorService;
import com.java2nb.novel.service.BookService; import com.java2nb.novel.service.BookService;
import com.java2nb.novel.service.FileService; import com.java2nb.novel.service.FileService;
@ -89,7 +89,7 @@ public class BookServiceImpl implements BookService {
private final FileService fileService; private final FileService fileService;
private final BookPriceConfig bookPriceConfig; private final BookPriceProperties bookPriceConfig;
@SneakyThrows @SneakyThrows
@ -186,7 +186,7 @@ public class BookServiceImpl implements BookService {
} }
@Override @Override
public PageInfo searchByPage(BookSP params, int page, int pageSize) { public PageInfo searchByPage(BookSpVO params, int page, int pageSize) {
if (params.getUpdatePeriod() != null) { if (params.getUpdatePeriod() != null) {

View File

@ -7,7 +7,7 @@ import com.java2nb.novel.core.enums.ResponseStatus;
import com.java2nb.novel.core.exception.BusinessException; import com.java2nb.novel.core.exception.BusinessException;
import com.java2nb.novel.core.utils.StringUtil; import com.java2nb.novel.core.utils.StringUtil;
import com.java2nb.novel.entity.Book; import com.java2nb.novel.entity.Book;
import com.java2nb.novel.search.BookSP; import com.java2nb.novel.vo.BookSpVO;
import com.java2nb.novel.service.SearchService; import com.java2nb.novel.service.SearchService;
import com.java2nb.novel.vo.EsBookVO; import com.java2nb.novel.vo.EsBookVO;
import io.searchbox.client.JestClient; import io.searchbox.client.JestClient;
@ -71,7 +71,7 @@ public class SearchServiceImpl implements SearchService {
@SneakyThrows @SneakyThrows
@Override @Override
public PageInfo searchBook(BookSP params, int page, int pageSize) { public PageInfo searchBook(BookSpVO params, int page, int pageSize) {
List<EsBookVO> bookList = new ArrayList<>(0); List<EsBookVO> bookList = new ArrayList<>(0);
//使用搜索引擎搜索 //使用搜索引擎搜索

View File

@ -1,4 +1,4 @@
package com.java2nb.novel.search; package com.java2nb.novel.vo;
import lombok.Data; import lombok.Data;
@ -9,7 +9,7 @@ import java.util.Date;
* @author 11797 * @author 11797
*/ */
@Data @Data
public class BookSP { public class BookSpVO {
private String keyword; private String keyword;

View File

@ -1,13 +1,7 @@
package com.java2nb.novel.vo; package com.java2nb.novel.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.java2nb.novel.entity.Book;
import lombok.Data; import lombok.Data;
import javax.annotation.Generated;
import java.io.Serializable;
import java.util.Date;
/** /**
* @author Administrator * @author Administrator
*/ */

View File

@ -8,3 +8,15 @@ pic:
type: 1 #图片保存方式, 1不保存使用爬取的网络图片 2保存在自己的存储介质 type: 1 #图片保存方式, 1不保存使用爬取的网络图片 2保存在自己的存储介质
storage: local #存储介质local本地OSS阿里云对象存储fastDfs分布式文件系统 storage: local #存储介质local本地OSS阿里云对象存储fastDfs分布式文件系统
path: /Users/xiongxiaoyang/java #图片保存路径 path: /Users/xiongxiaoyang/java #图片保存路径
#线程池配置
thread:
pool:
#核心线程池数量
core-pool-size: 10
#最大线程池数量
maximum-pool-size: 20
#线程超时时间分钟
keep-alive-time: 10

View File

@ -22,3 +22,14 @@ pic:
path: /var/pic #图片保存路径 path: /var/pic #图片保存路径
#线程池配置
thread:
pool:
#核心线程池数量
core-pool-size: 5
#最大线程池数量
maximum-pool-size: 10
#线程超时时间分钟
keep-alive-time: 10

View File

@ -3,7 +3,7 @@
<mapper namespace="com.java2nb.novel.mapper.FrontBookMapper"> <mapper namespace="com.java2nb.novel.mapper.FrontBookMapper">
<select id="searchByPage" parameterType="com.java2nb.novel.search.BookSP" resultType="com.java2nb.novel.vo.BookVO"> <select id="searchByPage" parameterType="com.java2nb.novel.vo.BookSpVO" resultType="com.java2nb.novel.vo.BookVO">
select select
id,cat_id,cat_name,book_name,author_id,author_name,word_count,last_index_id,last_index_name,score,pic_url,book_status,last_index_update_time,book_desc id,cat_id,cat_name,book_name,author_id,author_name,word_count,last_index_id,last_index_name,score,pic_url,book_status,last_index_update_time,book_desc
from book where word_count > 0 from book where word_count > 0

View File

@ -348,6 +348,7 @@
} else if(data.code == 1001){ } else if(data.code == 1001){
//未登录 //未登录
location.href = '/user/login.html?originUrl='+decodeURIComponent(location.href);
}else { }else {
layer.alert(data.msg); layer.alert(data.msg);

View File

@ -341,6 +341,8 @@
} else if(data.code == 1001){ } else if(data.code == 1001){
//未登录 //未登录
location.href = '/user/login.html?originUrl='+decodeURIComponent(location.href);
}else { }else {
layer.alert(data.msg); layer.alert(data.msg);