bookIndices = bookIndexMapper.selectByExample(example);
- if(bookIndices.size()>0){
+ if (bookIndices.size() > 0) {
result.add(bookIndices.get(0).getIndexNum());
- }else{
+ } else {
result.add(indexNum);
}
example = new BookIndexExample();
example.createCriteria().andBookIdEqualTo(bookId).andIndexNumLessThan(indexNum);
example.setOrderByClause("index_num DESC");
bookIndices = bookIndexMapper.selectByExample(example);
- if(bookIndices.size()>0){
+ if (bookIndices.size() > 0) {
result.add(bookIndices.get(0).getIndexNum());
- }else{
+ } else {
result.add(indexNum);
}
return result;
diff --git a/src/main/java/xyz/zinglizingli/books/util/RandomValueUtil.java b/src/main/java/xyz/zinglizingli/books/util/RandomValueUtil.java
index 7ab1ced..ce5ccc6 100644
--- a/src/main/java/xyz/zinglizingli/books/util/RandomValueUtil.java
+++ b/src/main/java/xyz/zinglizingli/books/util/RandomValueUtil.java
@@ -5,14 +5,8 @@ package xyz.zinglizingli.books.util;
/****
*
- * Project Name:recruit-helper-util
- * 随机数生成工具类,主要包括
+ * 随机数生成工具类,主要包括
* 中文姓名,性别,Email,手机号,住址
- * @ClassName: RandomValueUtil
- * @date 2018年5月23日 下午2:11:12
- *
- * @version 1.0
- * @since
*/
public class RandomValueUtil {
@@ -31,10 +25,6 @@ public class RandomValueUtil {
*
* Project Name: recruit-helper-util
*
随机生成Email
- *
- * @date 2018年5月23日 下午2:13:06
- * @version v1.0
- * @since
* @param lMin
* 最小长度
* @param lMax
@@ -72,13 +62,7 @@ public class RandomValueUtil {
/***
*
- * Project Name: recruit-helper-util
- *
随机生成手机号码
- *
- * @date 2018年5月23日 下午2:14:17
- * @version v1.0
- * @since
- * @return
+ * 随机生成手机号码
*/
public static String getTelephone() {
int index=getNum(0,telFirst.length-1);
@@ -90,13 +74,7 @@ public class RandomValueUtil {
/***
*
- * Project Name: recruit-helper-util
*
随机生成8位电话号码
- *
- * @date 2018年5月23日 下午2:15:31
- * @version v1.0
- * @since
- * @return
*/
public static String getLandline() {
int index=getNum(0,telFirst.length-1);
@@ -115,13 +93,8 @@ public class RandomValueUtil {
/***
*
- * Project Name: recruit-helper-util
*
返回中文姓名
*
- * @date 2018年5月23日 下午2:16:16
- * @version v1.0
- * @since
- * @return
*/
public static String getChineseName() {
int index = getNum(0, firstName.length() - 1);
diff --git a/src/main/java/xyz/zinglizingli/books/web/BookController.java b/src/main/java/xyz/zinglizingli/books/web/BookController.java
index 86168bf..60282ab 100644
--- a/src/main/java/xyz/zinglizingli/books/web/BookController.java
+++ b/src/main/java/xyz/zinglizingli/books/web/BookController.java
@@ -1,16 +1,24 @@
package xyz.zinglizingli.books.web;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.PageInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.client.RestTemplate;
import xyz.zinglizingli.books.constant.CacheKeyConstans;
import xyz.zinglizingli.books.po.Book;
import xyz.zinglizingli.books.po.BookContent;
@@ -19,15 +27,19 @@ import xyz.zinglizingli.books.po.ScreenBullet;
import xyz.zinglizingli.books.service.BookService;
import xyz.zinglizingli.books.vo.BookVO;
import xyz.zinglizingli.search.cache.CommonCacheUtil;
+import xyz.zinglizingli.search.utils.RestTemplateUtil;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.FileInputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
@Controller
@RequestMapping("book")
@@ -41,6 +53,9 @@ public class BookController {
private CommonCacheUtil commonCacheUtil;
+ private Logger log = LoggerFactory.getLogger(BookController.class);
+
+
@RequestMapping("index.html")
public String index(ModelMap modelMap) {
List hotBooks = (List) commonCacheUtil.getObject(CacheKeyConstans.HOT_BOOK_LIST_KEY);
@@ -181,13 +196,15 @@ public class BookController {
int minIndexNum = 0;
//查询最小目录号
List integers = bookService.queryMaxAndMinIndexNum(bookId);
- if(integers.size()>1){
+ if (integers.size() > 1) {
minIndexNum = integers.get(1);
}
+
BookVO bookvo = new BookVO();
BeanUtils.copyProperties(book, bookvo);
bookvo.setCateName(bookService.getCatNameById(bookvo.getCatid()));
+
modelMap.put("bookId", bookId);
modelMap.put("book", bookvo);
modelMap.put("minIndexNum", minIndexNum);
@@ -213,17 +230,17 @@ public class BookController {
public String bookContent(@PathVariable("bookId") Long bookId, @PathVariable("indexNum") Integer indexNum, ModelMap modelMap) {
BookContent bookContent = bookService.queryBookContent(bookId, indexNum);
String indexName;
- if(bookContent==null) {
+ if (bookContent == null) {
bookContent = new BookContent();
bookContent.setId(-1l);
bookContent.setBookId(bookId);
bookContent.setIndexNum(indexNum);
bookContent.setContent("正在手打中,请稍等片刻,内容更新后,需要重新刷新页面,才能获取最新更新");
- indexName="更新中。。。";
- }else{
+ indexName = "更新中。。。";
+ } else {
indexName = bookService.queryIndexNameByBookIdAndIndexNum(bookId, indexNum);
}
- List preAndNextIndexNum = bookService.queryPreAndNextIndexNum(bookId,indexNum);
+ List preAndNextIndexNum = bookService.queryPreAndNextIndexNum(bookId, indexNum);
modelMap.put("nextIndexNum", preAndNextIndexNum.get(0));
modelMap.put("preIndexNum", preAndNextIndexNum.get(1));
modelMap.put("bookContent", bookContent);
@@ -233,6 +250,7 @@ public class BookController {
return "books/book_content";
}
+
@RequestMapping("addVisit")
@ResponseBody
public String addVisit(@RequestParam("bookId") Long bookId) {
@@ -323,4 +341,6 @@ public class BookController {
}
-}
+
+
+}
\ No newline at end of file
diff --git a/src/main/java/xyz/zinglizingli/search/filter/SearchFilter.java b/src/main/java/xyz/zinglizingli/search/filter/SearchFilter.java
index ab902f4..0a418f4 100644
--- a/src/main/java/xyz/zinglizingli/search/filter/SearchFilter.java
+++ b/src/main/java/xyz/zinglizingli/search/filter/SearchFilter.java
@@ -110,15 +110,6 @@ public class SearchFilter implements Filter {
try {
- if (requestURL.contains("http://book.zinglizingli.xyz")) {
- if(requestURI.matches("/*|(/index\\.html)")){
- req.getRequestDispatcher("/book/index.html").forward(servletRequest,servletResponse);
- return;
- }
-
- filterChain.doFilter(servletRequest, servletResponse);
- return;
- }
if (requestURL.matches("http://m.zinglizingli.xyz(/*|(/index\\.html))") || requestURI.startsWith("/static/")) {
filterChain.doFilter(req, resp);
diff --git a/src/main/java/xyz/zinglizingli/search/schedule/CrawlBooksSchedule.java b/src/main/java/xyz/zinglizingli/search/schedule/CrawlBooksSchedule.java
index f798f80..903ce7f 100644
--- a/src/main/java/xyz/zinglizingli/search/schedule/CrawlBooksSchedule.java
+++ b/src/main/java/xyz/zinglizingli/search/schedule/CrawlBooksSchedule.java
@@ -361,7 +361,7 @@ public class CrawlBooksSchedule {
}
- @Scheduled(cron = "0 0 2 * * ?")
+ //@Scheduled(cron = "0 0 2 * * ?")磁盘空间不足,暂时不抓新书
//暂定2小说,只爬分类前3本书,一共3*7=21本书,爬等以后书籍多了之后,会适当缩短更新间隔
public void crawBquge11BooksAtNight() throws Exception {
final String baseUrl = "https://m.biqudao.com";
diff --git a/src/main/java/xyz/zinglizingli/search/schedule/SendEmaillSchedule.java b/src/main/java/xyz/zinglizingli/search/schedule/SendEmaillSchedule.java
index da0c828..f656931 100644
--- a/src/main/java/xyz/zinglizingli/search/schedule/SendEmaillSchedule.java
+++ b/src/main/java/xyz/zinglizingli/search/schedule/SendEmaillSchedule.java
@@ -46,7 +46,7 @@ public class SendEmaillSchedule {
private Logger log = LoggerFactory.getLogger(SendEmaillSchedule.class);
- @Scheduled(cron = "0 10 17 * * *")
+ // @Scheduled(fixedRate = 1000*60*60*24)
public void sendEmaill() {
System.out.println("SendEmaillSchedule。。。。。。。。。。。。。。。");
@@ -62,7 +62,7 @@ public class SendEmaillSchedule {
+"
";
mailService.sendHtmlMail(email, subject, content);
try {
- Thread.sleep(new Random().nextInt(1000*60)+1000*60);
+ Thread.sleep(new Random().nextInt(1000*60*10)+1000*60);
} catch (InterruptedException e) {
log.error(e.getMessage(),e);
}
diff --git a/src/main/java/xyz/zinglizingli/search/schedule/SendUrlSchedule.java b/src/main/java/xyz/zinglizingli/search/schedule/SendUrlSchedule.java
index 785eec4..14fbbd8 100644
--- a/src/main/java/xyz/zinglizingli/search/schedule/SendUrlSchedule.java
+++ b/src/main/java/xyz/zinglizingli/search/schedule/SendUrlSchedule.java
@@ -44,7 +44,7 @@ public class SendUrlSchedule {
private Logger log = LoggerFactory.getLogger(SendUrlSchedule.class);
- @Scheduled(cron = "0 0 1 * * 5")
+ @Scheduled(cron = "0 0 1 * * 1")
public void sendAllBookToBaidu() {
System.out.println("sendAllBookToBaidu。。。。。。。。。。。。。。。");
@@ -70,6 +70,11 @@ public class SendUrlSchedule {
System.out.println("推送数据:" + reqBody);
ResponseEntity stringResponseEntity = restTemplate.postForEntity("http://data.zz.baidu.com/urls?site=www.zinglizingli.xyz&token=IuK7oVrPKe3U606x", request, String.class);
System.out.println("推送URL结果:code:" + stringResponseEntity.getStatusCode().value() + ",body:" + stringResponseEntity.getBody());
+ Thread.sleep(1000 * 10);
+ System.out.println("推送数据:" + reqBody);
+ stringResponseEntity = restTemplate.postForEntity("http://data.zz.baidu.com/urls?appid=1643715155923937&token=fkEcTlId6Cf21Sz3&type=batch", request, String.class);
+ System.out.println("推送URL结果:code:" + stringResponseEntity.getStatusCode().value() + ",body:" + stringResponseEntity.getBody());
+
reqBody = "";
Thread.sleep(1000 * 10);
}
diff --git a/src/main/java/xyz/zinglizingli/search/schedule/SendWeiboSchedule.java b/src/main/java/xyz/zinglizingli/search/schedule/SendWeiboSchedule.java
index 585070c..43f93b4 100644
--- a/src/main/java/xyz/zinglizingli/search/schedule/SendWeiboSchedule.java
+++ b/src/main/java/xyz/zinglizingli/search/schedule/SendWeiboSchedule.java
@@ -446,13 +446,14 @@ public class SendWeiboSchedule {
private String sendOneSiteWeibo(RestTemplate template, String bookName, String indexName, String author, String desc, String wapName, String bookNum, String href) {
String baseUrl = "http://service.weibo.com/share/aj_share.php";
Map param = new HashMap<>();
- String content = bookName + "小说最新章节列表," + bookName + "小说免费在线阅读," + bookName +
+ /*String content = bookName + "小说最新章节列表," + bookName + "小说免费在线阅读," + bookName +
"小说TXT下载,尽在" + wapName +href+ "\n";
if(indexName != null){
content+=("最新章节:"+indexName+"\n");
}
content = content + "作者:"+(author.replace("作者:","")) + "\n";
- content += ("简介:"+desc.replace("简介:",""));
+ content += ("简介:"+desc.replace("简介:",""));*/
+ String content = bookName+"最新章节,小说"+bookName+"("+author.replace("作者:","")+")手机阅读,小说"+bookName+"TXT下载 - "+href;
param.put("content", content );
param.put("styleid", "1");
param.put("from", "share");
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index ad7782e..882d0e6 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -3,9 +3,15 @@ server:
spring:
datasource:
- url: jdbc:mysql://127.0.0.1:3306/books?useUnicode=true&characterEncoding=utf-8
- username: books
- password: books
+# url: jdbc:mysql://148.70.59.92:3306/books?useUnicode=true&characterEncoding=utf-8&useSSL=false
+# username: xiongxiaoyang
+# password: Lzslov123!
+ url: jdbc:mysql://127.0.0.1:3306/books?useUnicode=true&characterEncoding=utf-8&useSSL=false
+ username: xiongxiaoyang
+ password: Lzslov123!
+# url: jdbc:mysql://127.0.0.1:3306/books?useUnicode=true&characterEncoding=utf-8
+# username: books
+# password: books
cache:
ehcache:
config: classpath:ehcache.xml
@@ -13,15 +19,15 @@ spring:
mode: LEGACYHTML5 #去除thymeleaf的html严格校验thymeleaf.mode=LEGACYHTML5
cache: true # 是否开启模板缓存,默认true,建议在开发时关闭缓存,不然没法看到实时页面
freemarker:
- template-loader-path: classpath:/templates #设定thymeleaf文件路径 默认为src/main/resources/templatestemplate-loader-path=classpath:/templates
+ template-loader-path: classpath:/templates #设定freemarker文件路径 默认为src/main/resources/templatestemplate-loader-path=classpath:/templates
charset: UTF-8 # 模板编码
#邮箱服务器
mail:
host: smtp.163.com
#邮箱账户
- username:
- #你的QQ邮箱第三方授权码
- password:
+ username: 13560421324@163.com
+ #邮箱第三方授权码
+ password: xiong13560421324
#编码类型
default-encoding: UTF-8
port: 465
@@ -63,4 +69,4 @@ baidu:
browser:
- cookie: SINAGLOBAL=5945695441587.724.1559298271897; __guid=109181959.2094437407894937900.1565875017257.2095; un=13560421324; _s_tentry=-; Apache=8157572449986.1455.1566918991846; ULV=1566918991855:7:6:1:8157572449986.1455.1566918991846:1566086532731; login_sid_t=0cc80b9f5ea5f473e83fce3054291c03; cross_origin_proto=SSL; un=13560421324; YF-Widget-G0=4aade6ec367f09ec0a5eec921227137f; WBtopGlobal_register_version=307744aa77dd5677; SSOLoginState=1566928337; wvr=6; UOR=,,www.zinglizingli.xyz; SUBP=0033WrSXqPxfM725Ws9jqgMF55529P9D9WFRg9065OjUyD0aaGsKRxPW5JpX5KMhUgL.Fo-f1hB7SKMp1h52dJLoI0qLxK-L1KqL1-eLxKMLB.-L122LxKMLB.-L122LxK-LBo5L12qLxKnLB-qLBoBLxKMLB.BL1K2t; ALF=1599046395; SCF=AsBEGOtiUG1hPLyZCxI1FunZd9Hg9hWWkgyzcAZjG6AxOiKPAEM99ZxY8qofeWw3xoU_Wh3OqNzt4BSkCAyD_8o.; SUB=_2A25waj8tDeRhGeNL41YR9SnNwzyIHXVTHhflrDV8PUNbmtANLXXAkW9NSM603mvU3tqplLCrqvedw1Q29U_TkxRA; SUHB=0xnyhR4nBtqt14; monitor_count=2; webim_unReadCount=%7B%22time%22%3A1567510495487%2C%22dm_pub_total%22%3A2%2C%22chat_group_client%22%3A0%2C%22allcountNum%22%3A36%2C%22msgbox%22%3A0%7D
\ No newline at end of file
+ cookie: SINAGLOBAL=5945695441587.724.1559298271897; __guid=109181959.2094437407894937900.1565875017257.2095; un=13560421324; _s_tentry=login.sina.com.cn; Apache=967339021599.2916.1567743040489; ULV=1567743040504:8:1:1:967339021599.2916.1567743040489:1566918991855; login_sid_t=d172b083637b1186ebcd624a1259a05f; cross_origin_proto=SSL; appkey=; SSOLoginState=1567744755; YF-Widget-G0=4a4609df0e4ef6187a7b4717d4e6cf12; wvr=6; WBtopGlobal_register_version=307744aa77dd5677; un=13560421324; SCF=AsBEGOtiUG1hPLyZCxI1FunZd9Hg9hWWkgyzcAZjG6AxlhR9sKuWXBhvg1TG9iDWygqPlKun5aazN3Jc6Rky8lQ.; SUB=_2A25wfnGoDeRhGeNL41YR9SnNwzyIHXVTCuRgrDV8PUJbmtANLRWgkW9NSM603g9LJN13ACge6_UUjKxvhLP4TXZi; SUBP=0033WrSXqPxfM725Ws9jqgMF55529P9D9WFRg9065OjUyD0aaGsKRxPW5JpX5K-hUgL.Fo-f1hB7SKMp1h52dJLoI0qLxK-L1KqL1-eLxKMLB.-L122LxKMLB.-L122LxK-LBo5L12qLxKnLB-qLBoBLxKMLB.BL1K2t; SUHB=0XDVz5Bh1mkWFA; ALF=1599812938; UOR=,,sf.zinglizingli.xyz; monitor_count=13; webim_unReadCount=%7B%22time%22%3A1568285775036%2C%22dm_pub_total%22%3A1%2C%22chat_group_client%22%3A0%2C%22allcountNum%22%3A29%2C%22msgbox%22%3A0%7D
\ No newline at end of file
diff --git a/src/main/resources/mybatis/mapping/BookMapper.xml b/src/main/resources/mybatis/mapping/BookMapper.xml
index b979dcf..9b39724 100644
--- a/src/main/resources/mybatis/mapping/BookMapper.xml
+++ b/src/main/resources/mybatis/mapping/BookMapper.xml
@@ -354,7 +354,8 @@