diff --git a/novel-common/pom.xml b/novel-common/pom.xml index b3b3a12..95e039d 100644 --- a/novel-common/pom.xml +++ b/novel-common/pom.xml @@ -123,6 +123,12 @@ true + + org.springframework.boot + spring-boot-configuration-processor + true + + diff --git a/novel-front/src/main/java/com/java2nb/novel/controller/BookController.java b/novel-front/src/main/java/com/java2nb/novel/controller/BookController.java index 3b157af..a55a4e3 100644 --- a/novel-front/src/main/java/com/java2nb/novel/controller/BookController.java +++ b/novel-front/src/main/java/com/java2nb/novel/controller/BookController.java @@ -5,7 +5,7 @@ import com.java2nb.novel.core.bean.ResultBean; import com.java2nb.novel.core.bean.UserDetails; import com.java2nb.novel.core.enums.ResponseStatus; 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.vo.BookVO; import lombok.RequiredArgsConstructor; @@ -79,7 +79,7 @@ public class BookController extends BaseController{ * 分页搜索 * */ @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 pageInfo = bookService.searchByPage(bookSP,page,pageSize); return ResultBean.ok(pageInfo); } diff --git a/novel-front/src/main/java/com/java2nb/novel/controller/PayController.java b/novel-front/src/main/java/com/java2nb/novel/controller/PayController.java index 4fd2210..7f61b23 100644 --- a/novel-front/src/main/java/com/java2nb/novel/controller/PayController.java +++ b/novel-front/src/main/java/com/java2nb/novel/controller/PayController.java @@ -5,7 +5,7 @@ import com.alipay.api.DefaultAlipayClient; import com.alipay.api.internal.util.AlipaySignature; import com.alipay.api.request.AlipayTradePagePayRequest; 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 lombok.RequiredArgsConstructor; import lombok.SneakyThrows; @@ -31,7 +31,7 @@ import java.util.Map; public class PayController extends BaseController { - private final AlipayConfig alipayConfig; + private final AlipayProperties alipayConfig; private final OrderService orderService; diff --git a/novel-front/src/main/java/com/java2nb/novel/core/config/AlipayConfig.java b/novel-front/src/main/java/com/java2nb/novel/core/config/AlipayProperties.java similarity index 94% rename from novel-front/src/main/java/com/java2nb/novel/core/config/AlipayConfig.java rename to novel-front/src/main/java/com/java2nb/novel/core/config/AlipayProperties.java index 0d31fa8..597cdbc 100644 --- a/novel-front/src/main/java/com/java2nb/novel/core/config/AlipayConfig.java +++ b/novel-front/src/main/java/com/java2nb/novel/core/config/AlipayProperties.java @@ -10,7 +10,7 @@ import org.springframework.stereotype.Component; @Data @Component @ConfigurationProperties(prefix="alipay") -public class AlipayConfig { +public class AlipayProperties { private String appId; private String merchantPrivateKey; diff --git a/novel-front/src/main/java/com/java2nb/novel/core/config/AuthorIncomeConfig.java b/novel-front/src/main/java/com/java2nb/novel/core/config/AuthorIncomeProperties.java similarity index 86% rename from novel-front/src/main/java/com/java2nb/novel/core/config/AuthorIncomeConfig.java rename to novel-front/src/main/java/com/java2nb/novel/core/config/AuthorIncomeProperties.java index 1fc1743..1ce42b0 100644 --- a/novel-front/src/main/java/com/java2nb/novel/core/config/AuthorIncomeConfig.java +++ b/novel-front/src/main/java/com/java2nb/novel/core/config/AuthorIncomeProperties.java @@ -7,13 +7,13 @@ import org.springframework.stereotype.Component; import java.math.BigDecimal; /** - * 作家收入配置 + * 作家收入配置属性 * @author cd */ @Component @Data @ConfigurationProperties(prefix = "author.income") -public class AuthorIncomeConfig { +public class AuthorIncomeProperties { private BigDecimal taxRate; diff --git a/novel-front/src/main/java/com/java2nb/novel/core/config/BookPriceConfig.java b/novel-front/src/main/java/com/java2nb/novel/core/config/BookPriceProperties.java similarity index 85% rename from novel-front/src/main/java/com/java2nb/novel/core/config/BookPriceConfig.java rename to novel-front/src/main/java/com/java2nb/novel/core/config/BookPriceProperties.java index 6a2c7fa..305f2b6 100644 --- a/novel-front/src/main/java/com/java2nb/novel/core/config/BookPriceConfig.java +++ b/novel-front/src/main/java/com/java2nb/novel/core/config/BookPriceProperties.java @@ -7,13 +7,13 @@ import org.springframework.stereotype.Component; import java.math.BigDecimal; /** - * 章节费用配置 + * 章节费用配置属性 * @author cd */ @Component @Data @ConfigurationProperties(prefix = "book.price") -public class BookPriceConfig { +public class BookPriceProperties { private BigDecimal wordCount; diff --git a/novel-front/src/main/java/com/java2nb/novel/core/config/FdfsConfiguration.java b/novel-front/src/main/java/com/java2nb/novel/core/config/FdfsConfig.java similarity index 91% rename from novel-front/src/main/java/com/java2nb/novel/core/config/FdfsConfiguration.java rename to novel-front/src/main/java/com/java2nb/novel/core/config/FdfsConfig.java index 485ad08..89711fa 100644 --- a/novel-front/src/main/java/com/java2nb/novel/core/config/FdfsConfiguration.java +++ b/novel-front/src/main/java/com/java2nb/novel/core/config/FdfsConfig.java @@ -9,5 +9,5 @@ import org.springframework.jmx.support.RegistrationPolicy; */ @Configuration @EnableMBeanExport(registration= RegistrationPolicy.IGNORE_EXISTING) -public class FdfsConfiguration { +public class FdfsConfig { } diff --git a/novel-front/src/main/java/com/java2nb/novel/core/config/ThreadPoolConfig.java b/novel-front/src/main/java/com/java2nb/novel/core/config/ThreadPoolConfig.java new file mode 100644 index 0000000..8548372 --- /dev/null +++ b/novel-front/src/main/java/com/java2nb/novel/core/config/ThreadPoolConfig.java @@ -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()); + } + +} diff --git a/novel-front/src/main/java/com/java2nb/novel/core/config/ThreadPoolProperties.java b/novel-front/src/main/java/com/java2nb/novel/core/config/ThreadPoolProperties.java new file mode 100644 index 0000000..00ae748 --- /dev/null +++ b/novel-front/src/main/java/com/java2nb/novel/core/config/ThreadPoolProperties.java @@ -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; + + +} diff --git a/novel-front/src/main/java/com/java2nb/novel/core/config/WebsiteConfig.java b/novel-front/src/main/java/com/java2nb/novel/core/config/WebsiteProperties.java similarity index 92% rename from novel-front/src/main/java/com/java2nb/novel/core/config/WebsiteConfig.java rename to novel-front/src/main/java/com/java2nb/novel/core/config/WebsiteProperties.java index a5d2d6b..a839a3c 100644 --- a/novel-front/src/main/java/com/java2nb/novel/core/config/WebsiteConfig.java +++ b/novel-front/src/main/java/com/java2nb/novel/core/config/WebsiteProperties.java @@ -10,7 +10,7 @@ import org.springframework.stereotype.Component; @Data @Component @ConfigurationProperties(prefix="website") -public class WebsiteConfig { +public class WebsiteProperties { private String name; private String domain; diff --git a/novel-front/src/main/java/com/java2nb/novel/core/listener/StarterListener.java b/novel-front/src/main/java/com/java2nb/novel/core/listener/StarterListener.java index 8dbf825..7ae5c58 100644 --- a/novel-front/src/main/java/com/java2nb/novel/core/listener/StarterListener.java +++ b/novel-front/src/main/java/com/java2nb/novel/core/listener/StarterListener.java @@ -1,6 +1,6 @@ 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.extern.slf4j.Slf4j; @@ -17,7 +17,7 @@ import javax.servlet.annotation.WebListener; @RequiredArgsConstructor public class StarterListener implements ServletContextListener { - private final WebsiteConfig websiteConfig; + private final WebsiteProperties websiteConfig; @Override diff --git a/novel-front/src/main/java/com/java2nb/novel/core/schedule/DailyIncomeStaSchedule.java b/novel-front/src/main/java/com/java2nb/novel/core/schedule/DailyIncomeStaSchedule.java index 8ffde36..f97fd5a 100644 --- a/novel-front/src/main/java/com/java2nb/novel/core/schedule/DailyIncomeStaSchedule.java +++ b/novel-front/src/main/java/com/java2nb/novel/core/schedule/DailyIncomeStaSchedule.java @@ -1,7 +1,6 @@ package com.java2nb.novel.core.schedule; -import com.java2nb.novel.core.config.AuthorIncomeConfig; import com.java2nb.novel.core.utils.DateUtil; import com.java2nb.novel.entity.Author; import com.java2nb.novel.entity.AuthorIncomeDetail; diff --git a/novel-front/src/main/java/com/java2nb/novel/core/schedule/MonthIncomeStaSchedule.java b/novel-front/src/main/java/com/java2nb/novel/core/schedule/MonthIncomeStaSchedule.java index c0dc232..51a3f78 100644 --- a/novel-front/src/main/java/com/java2nb/novel/core/schedule/MonthIncomeStaSchedule.java +++ b/novel-front/src/main/java/com/java2nb/novel/core/schedule/MonthIncomeStaSchedule.java @@ -1,19 +1,17 @@ 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.entity.*; import com.java2nb.novel.service.AuthorService; import com.java2nb.novel.service.BookService; -import com.java2nb.novel.service.UserService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import java.math.BigDecimal; -import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -31,7 +29,7 @@ public class MonthIncomeStaSchedule { private final BookService bookService; - private final AuthorIncomeConfig authorIncomeConfig; + private final AuthorIncomeProperties authorIncomeConfig; /** * 每个月1号凌晨2点统计上个月数据 diff --git a/novel-front/src/main/java/com/java2nb/novel/mapper/FrontBookMapper.java b/novel-front/src/main/java/com/java2nb/novel/mapper/FrontBookMapper.java index f71ee81..b249821 100644 --- a/novel-front/src/main/java/com/java2nb/novel/mapper/FrontBookMapper.java +++ b/novel-front/src/main/java/com/java2nb/novel/mapper/FrontBookMapper.java @@ -1,11 +1,10 @@ package com.java2nb.novel.mapper; 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 org.apache.ibatis.annotations.Param; -import java.util.Date; import java.util.List; /** @@ -14,7 +13,7 @@ import java.util.List; public interface FrontBookMapper extends BookMapper { - List searchByPage(BookSP params); + List searchByPage(BookSpVO params); void addVisitCount(@Param("bookId") Long bookId, @Param("visitCount") Integer visitCount); diff --git a/novel-front/src/main/java/com/java2nb/novel/page/PageController.java b/novel-front/src/main/java/com/java2nb/novel/page/PageController.java index e51d72a..90dee93 100644 --- a/novel-front/src/main/java/com/java2nb/novel/page/PageController.java +++ b/novel-front/src/main/java/com/java2nb/novel/page/PageController.java @@ -19,7 +19,10 @@ import org.springframework.web.bind.annotation.RequestMapping; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.io.Serializable; import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ThreadPoolExecutor; /** * @author 11797 @@ -37,6 +40,8 @@ public class PageController extends BaseController { private final UserService userService; + private final ThreadPoolExecutor threadPoolExecutor; + @RequestMapping("{url}.html") public String module(@PathVariable("url") String url) { @@ -44,9 +49,9 @@ public class PageController extends BaseController { } @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); if (user == null) { @@ -56,7 +61,7 @@ public class PageController extends BaseController { boolean isAuthor = authorService.isAuthor(user.getId()); 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"}) public String index() { - return ThreadLocalUtil.getTemplateDir()+"index"; + return ThreadLocalUtil.getTemplateDir() + "index"; } /** * 作品页 - * */ + */ @RequestMapping("book/bookclass.html") public String bookClass() { return "book/bookclass"; @@ -86,129 +91,170 @@ public class PageController extends BaseController { /** * 排行页 - * */ + */ @RequestMapping("book/book_ranking.html") public String bookRank() { - return ThreadLocalUtil.getTemplateDir()+"book/book_ranking"; + return ThreadLocalUtil.getTemplateDir() + "book/book_ranking"; } /** * 详情页 - * */ + */ @SneakyThrows @RequestMapping("/book/{bookId}.html") public String bookDetail(@PathVariable("bookId") Long bookId, Model model) { Book book = bookService.queryBookDetail(bookId); - model.addAttribute("book",book); - if(book.getLastIndexId() != null) { + model.addAttribute("book", book); + if (book.getLastIndexId() != null) { //查询首章目录ID Long firstBookIndexId = bookService.queryFirstBookIndexId(bookId); model.addAttribute("firstBookIndexId", firstBookIndexId); } - return ThreadLocalUtil.getTemplateDir()+"book/book_detail"; + return ThreadLocalUtil.getTemplateDir() + "book/book_detail"; } /** * 目录页 - * */ + */ @SneakyThrows @RequestMapping("/book/indexList-{bookId}.html") public String indexList(@PathVariable("bookId") Long bookId, Model model) { Book book = bookService.queryBookDetail(bookId); - model.addAttribute("book",book); - List bookIndexList = bookService.queryIndexList(bookId,null,1,null); - model.addAttribute("bookIndexList",bookIndexList); - model.addAttribute("bookIndexCount",bookIndexList.size()); - return ThreadLocalUtil.getTemplateDir()+"book/book_index"; + model.addAttribute("book", book); + List bookIndexList = bookService.queryIndexList(bookId, null, 1, null); + model.addAttribute("bookIndexList", bookIndexList); + model.addAttribute("bookIndexCount", bookIndexList.size()); + return ThreadLocalUtil.getTemplateDir() + "book/book_index"; } /** * 内容页 - * */ + */ @SneakyThrows @RequestMapping("/book/{bookId}/{bookIndexId}.html") - public String indexList(@PathVariable("bookId") Long bookId,@PathVariable("bookIndexId") Long bookIndexId, HttpServletRequest request, Model model) { - //查询书籍 - Book book = bookService.queryBookDetail(bookId); - //查询目录 - BookIndex bookIndex = bookService.queryBookIndex(bookIndexId); - model.addAttribute("book",book); - model.addAttribute("bookIndex",bookIndex); - //查询上一章节目录ID - 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); + public String indexList(@PathVariable("bookId") Long bookId, @PathVariable("bookIndexId") Long bookIndexId, HttpServletRequest request, Model model) { - boolean needBuy = false; - //判断该目录是否收费 - if(bookIndex.getIsVip()!=null && bookIndex.getIsVip() == 1 ){ - UserDetails user = getUserDetails(request); - if(user == null){ - //未登录 - return "redirect:/user/login.html?originUrl="+request.getRequestURI(); + + //加载小说基本信息线程 + CompletableFuture bookCompletableFuture = CompletableFuture.supplyAsync(() -> { + //查询书籍 + Book book = bookService.queryBookDetail(bookId); + log.debug("加载小说基本信息线程结束"); + return book; + }, threadPoolExecutor); + + //加载小说章节信息线程 + CompletableFuture bookIndexCompletableFuture = CompletableFuture.supplyAsync(() -> { + //查询目录 + BookIndex bookIndex = bookService.queryBookIndex(bookIndexId); + log.debug("加载小说章节信息线程结束"); + return bookIndex; + }, threadPoolExecutor); + + //加载小说上一章节信息线程,该线程在加载小说章节信息线程执行完毕后才执行 + CompletableFuture preBookIndexIdCompletableFuture = bookIndexCompletableFuture.thenApplyAsync((bookIndex) -> { + //查询上一章节目录ID + Long preBookIndexId = bookService.queryPreBookIndexId(bookId, bookIndex.getIndexNum()); + log.debug("加载小说上一章节信息线程结束"); + return preBookIndexId; + }, threadPoolExecutor); + + //加载小说下一章节信息线程,该线程在加载小说章节信息线程执行完毕后才执行 + CompletableFuture nextBookIndexIdCompletableFuture = bookIndexCompletableFuture.thenApplyAsync((bookIndex) -> { + //查询下一章目录ID + Long nextBookIndexId = bookService.queryNextBookIndexId(bookId, bookIndex.getIndexNum()); + log.debug("加载小说下一章节信息线程结束"); + return nextBookIndexId; + }, threadPoolExecutor); + + //加载小说内容信息线程 + CompletableFuture bookContentCompletableFuture = CompletableFuture.supplyAsync(() -> { + //查询内容 + BookContent bookContent = bookService.queryBookContent(bookIndexId); + log.debug("加载小说内容信息线程结束"); + return bookContent; + }, threadPoolExecutor); + + + //判断用户是否需要购买线程,该线程在加载小说章节信息线程执行完毕后才执行 + CompletableFuture needBuyCompletableFuture = bookIndexCompletableFuture.thenApplyAsync((bookIndex) -> { + //判断该目录是否收费 + if (bookIndex.getIsVip() != null && bookIndex.getIsVip() == 1) { + //收费 + UserDetails user = getUserDetails(request); + if (user == null) { + //未登录,需要购买 + return true; + } + //判断用户是否购买过该目录 + boolean isBuy = userService.queryIsBuyBookIndex(user.getId(), bookIndexId); + if (!isBuy) { + //没有购买过,需要购买 + return true; + } } - //收费,判断用户是否购买过该目录 - boolean isBuy = userService.queryIsBuyBookIndex(user.getId(),bookIndexId); - if(!isBuy){ - //没有购买过,需要购买 - bookContent.setContent(null); - 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") public String commentList(@PathVariable("bookId") Long bookId, Model model) { //查询书籍 Book book = bookService.queryBookDetail(bookId); - model.addAttribute("book",book); + model.addAttribute("book", book); return "book/book_comment"; } /** * 新闻内容页面 - * */ + */ @RequestMapping("/about/newsInfo-{newsId}.html") public String newsInfo(@PathVariable("newsId") Long newsId, Model model) { //查询新闻 News news = newsService.queryNewsInfo(newsId); - model.addAttribute("news",news); + model.addAttribute("news", news); return "about/news_info"; } /** * 作者注册页面 - * */ + */ @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); - if(user == null){ + if (user == null) { //未登录 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); - if(StringUtils.isBlank(errorInfo)){ + if (StringUtils.isBlank(errorInfo)) { //注册成功 return "redirect:/author/index.html"; } - model.addAttribute("LabErr",errorInfo); - model.addAttribute("author",author); + model.addAttribute("LabErr", errorInfo); + model.addAttribute("author", author); } return "author/register"; } diff --git a/novel-front/src/main/java/com/java2nb/novel/service/BookService.java b/novel-front/src/main/java/com/java2nb/novel/service/BookService.java index ced701e..47a5ef8 100644 --- a/novel-front/src/main/java/com/java2nb/novel/service/BookService.java +++ b/novel-front/src/main/java/com/java2nb/novel/service/BookService.java @@ -2,7 +2,7 @@ package com.java2nb.novel.service; 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.BookSettingVO; import com.java2nb.novel.entity.*; @@ -48,7 +48,7 @@ public interface BookService { * @param pageSize 分页大小 * @return 小说集合分页信息 * */ - PageInfo searchByPage(BookSP params, int page, int pageSize); + PageInfo searchByPage(BookSpVO params, int page, int pageSize); /** * 查询小说分类列表 diff --git a/novel-front/src/main/java/com/java2nb/novel/service/SearchService.java b/novel-front/src/main/java/com/java2nb/novel/service/SearchService.java index 381315c..b1c7343 100644 --- a/novel-front/src/main/java/com/java2nb/novel/service/SearchService.java +++ b/novel-front/src/main/java/com/java2nb/novel/service/SearchService.java @@ -3,7 +3,7 @@ package com.java2nb.novel.service; import com.github.pagehelper.PageInfo; import com.java2nb.novel.entity.Book; -import com.java2nb.novel.search.BookSP; +import com.java2nb.novel.vo.BookSpVO; /** * @author 11797 @@ -23,5 +23,5 @@ public interface SearchService { * @param pageSize 每页大小 * @return 分页信息 */ - PageInfo searchBook(BookSP params, int page, int pageSize); + PageInfo searchBook(BookSpVO params, int page, int pageSize); } diff --git a/novel-front/src/main/java/com/java2nb/novel/service/impl/BookServiceImpl.java b/novel-front/src/main/java/com/java2nb/novel/service/impl/BookServiceImpl.java index 8278be7..2d90146 100644 --- a/novel-front/src/main/java/com/java2nb/novel/service/impl/BookServiceImpl.java +++ b/novel-front/src/main/java/com/java2nb/novel/service/impl/BookServiceImpl.java @@ -5,14 +5,14 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.java2nb.novel.core.cache.CacheKey; 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.exception.BusinessException; import com.java2nb.novel.core.utils.*; import com.java2nb.novel.entity.*; import com.java2nb.novel.entity.Book; 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.BookService; import com.java2nb.novel.service.FileService; @@ -89,7 +89,7 @@ public class BookServiceImpl implements BookService { private final FileService fileService; - private final BookPriceConfig bookPriceConfig; + private final BookPriceProperties bookPriceConfig; @SneakyThrows @@ -186,7 +186,7 @@ public class BookServiceImpl implements BookService { } @Override - public PageInfo searchByPage(BookSP params, int page, int pageSize) { + public PageInfo searchByPage(BookSpVO params, int page, int pageSize) { if (params.getUpdatePeriod() != null) { diff --git a/novel-front/src/main/java/com/java2nb/novel/service/impl/SearchServiceImpl.java b/novel-front/src/main/java/com/java2nb/novel/service/impl/SearchServiceImpl.java index 7d7a35c..9def5a0 100644 --- a/novel-front/src/main/java/com/java2nb/novel/service/impl/SearchServiceImpl.java +++ b/novel-front/src/main/java/com/java2nb/novel/service/impl/SearchServiceImpl.java @@ -7,7 +7,7 @@ import com.java2nb.novel.core.enums.ResponseStatus; import com.java2nb.novel.core.exception.BusinessException; import com.java2nb.novel.core.utils.StringUtil; 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.vo.EsBookVO; import io.searchbox.client.JestClient; @@ -71,7 +71,7 @@ public class SearchServiceImpl implements SearchService { @SneakyThrows @Override - public PageInfo searchBook(BookSP params, int page, int pageSize) { + public PageInfo searchBook(BookSpVO params, int page, int pageSize) { List bookList = new ArrayList<>(0); //使用搜索引擎搜索 diff --git a/novel-front/src/main/java/com/java2nb/novel/search/BookSP.java b/novel-front/src/main/java/com/java2nb/novel/vo/BookSpVO.java similarity index 88% rename from novel-front/src/main/java/com/java2nb/novel/search/BookSP.java rename to novel-front/src/main/java/com/java2nb/novel/vo/BookSpVO.java index 04dcdcb..5bf6400 100644 --- a/novel-front/src/main/java/com/java2nb/novel/search/BookSP.java +++ b/novel-front/src/main/java/com/java2nb/novel/vo/BookSpVO.java @@ -1,4 +1,4 @@ -package com.java2nb.novel.search; +package com.java2nb.novel.vo; import lombok.Data; @@ -9,7 +9,7 @@ import java.util.Date; * @author 11797 */ @Data -public class BookSP { +public class BookSpVO { private String keyword; diff --git a/novel-front/src/main/java/com/java2nb/novel/vo/EsBookVO.java b/novel-front/src/main/java/com/java2nb/novel/vo/EsBookVO.java index 55c5a41..2597a14 100644 --- a/novel-front/src/main/java/com/java2nb/novel/vo/EsBookVO.java +++ b/novel-front/src/main/java/com/java2nb/novel/vo/EsBookVO.java @@ -1,13 +1,7 @@ package com.java2nb.novel.vo; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.java2nb.novel.entity.Book; import lombok.Data; -import javax.annotation.Generated; -import java.io.Serializable; -import java.util.Date; - /** * @author Administrator */ diff --git a/novel-front/src/main/resources/application-dev.yml b/novel-front/src/main/resources/application-dev.yml index dbae974..5eaafb4 100644 --- a/novel-front/src/main/resources/application-dev.yml +++ b/novel-front/src/main/resources/application-dev.yml @@ -7,4 +7,16 @@ pic: save: type: 1 #图片保存方式, 1不保存,使用爬取的网络图片 ,2保存在自己的存储介质 storage: local #存储介质,local:本地,OSS:阿里云对象存储,fastDfs:分布式文件系统 - path: /Users/xiongxiaoyang/java #图片保存路径 \ No newline at end of file + path: /Users/xiongxiaoyang/java #图片保存路径 + + + +#线程池配置 +thread: + pool: + #核心线程池数量 + core-pool-size: 10 + #最大线程池数量 + maximum-pool-size: 20 + #线程超时时间(分钟) + keep-alive-time: 10 \ No newline at end of file diff --git a/novel-front/src/main/resources/application-prod.yml b/novel-front/src/main/resources/application-prod.yml index 5ad5404..4a42dbf 100644 --- a/novel-front/src/main/resources/application-prod.yml +++ b/novel-front/src/main/resources/application-prod.yml @@ -22,3 +22,14 @@ pic: path: /var/pic #图片保存路径 +#线程池配置 +thread: + pool: + #核心线程池数量 + core-pool-size: 5 + #最大线程池数量 + maximum-pool-size: 10 + #线程超时时间(分钟) + keep-alive-time: 10 + + diff --git a/novel-front/src/main/resources/mybatis/mapping/BookMapper.xml b/novel-front/src/main/resources/mybatis/mapping/BookMapper.xml index dfc1171..dae223a 100644 --- a/novel-front/src/main/resources/mybatis/mapping/BookMapper.xml +++ b/novel-front/src/main/resources/mybatis/mapping/BookMapper.xml @@ -3,7 +3,7 @@ - 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 from book where word_count > 0 diff --git a/novel-front/src/main/resources/templates/book/book_content.html b/novel-front/src/main/resources/templates/book/book_content.html index b254f93..8d46d77 100644 --- a/novel-front/src/main/resources/templates/book/book_content.html +++ b/novel-front/src/main/resources/templates/book/book_content.html @@ -348,6 +348,7 @@ } else if(data.code == 1001){ //未登录 + location.href = '/user/login.html?originUrl='+decodeURIComponent(location.href); }else { layer.alert(data.msg); diff --git a/novel-front/src/main/resources/templates/mobile/book/book_content.html b/novel-front/src/main/resources/templates/mobile/book/book_content.html index dfa6a02..c601880 100644 --- a/novel-front/src/main/resources/templates/mobile/book/book_content.html +++ b/novel-front/src/main/resources/templates/mobile/book/book_content.html @@ -341,6 +341,8 @@ } else if(data.code == 1001){ //未登录 + location.href = '/user/login.html?originUrl='+decodeURIComponent(location.href); + }else { layer.alert(data.msg);