mirror of
https://github.com/201206030/novel-plus.git
synced 2025-04-26 17:20:52 +00:00
文档更新
This commit is contained in:
parent
fe8b554ce4
commit
a9319041a7
18
README.md
18
README.md
@ -40,31 +40,19 @@ Springboot+Mybatis+Mysql+Ehcache+Thymeleaf+Layui
|
||||
|
||||
#### PC站截图
|
||||
|
||||
1. 首页
|
||||
|
||||

|
||||
|
||||
2.列表页
|
||||

|
||||
|
||||

|
||||
|
||||
3.排行页
|
||||
|
||||

|
||||

|
||||
|
||||
4.详情页
|
||||
|
||||

|
||||
|
||||
5.目录页
|
||||

|
||||
|
||||

|
||||
|
||||
6.内容页
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
#### 手机站截图
|
||||
|
||||
|
BIN
assets/1588548668698.gif
Normal file
BIN
assets/1588548668698.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 MiB |
BIN
assets/1588548784395.gif
Normal file
BIN
assets/1588548784395.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 MiB |
BIN
assets/1588548916980.gif
Normal file
BIN
assets/1588548916980.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 263 KiB |
@ -8,6 +8,6 @@ spring:
|
||||
|
||||
admin:
|
||||
username: admin
|
||||
password: admin123456
|
||||
password: admin
|
||||
|
||||
|
||||
|
@ -50,10 +50,10 @@ public class NovelFilter implements Filter {
|
||||
}
|
||||
|
||||
|
||||
String userMark = CookieUtil.getCookie(req,Constants.USER_CLIENT_MARK);
|
||||
String userMark = CookieUtil.getCookie(req,Constants.USER_CLIENT_MARK_KEY);
|
||||
if(userMark == null){
|
||||
userMark = UUIDUtil.getUUID32();
|
||||
CookieUtil.setCookie(resp,Constants.USER_CLIENT_MARK,userMark);
|
||||
CookieUtil.setCookie(resp,Constants.USER_CLIENT_MARK_KEY,userMark);
|
||||
}
|
||||
ThreadLocalUtil.setCientId(userMark);
|
||||
//根据浏览器类型选择前端模板
|
||||
|
@ -17,7 +17,17 @@ public class Constants {
|
||||
public static final String LOCAL_PIC_PREFIX = "/localPic/";
|
||||
|
||||
/**
|
||||
* 用户客户端标识
|
||||
* 用户客户端标识保存key
|
||||
* */
|
||||
public static final String USER_CLIENT_MARK = "userClientMark";
|
||||
public static final String USER_CLIENT_MARK_KEY = "userClientMarkKey";
|
||||
|
||||
/**
|
||||
* Object Json 缓存存在的最小长度
|
||||
* */
|
||||
public static final int OBJECT_JSON_CACHE_EXIST_LENGTH = 5;
|
||||
|
||||
/**
|
||||
* 首页设置的小说数量
|
||||
* */
|
||||
public static final int INDEX_BOOK_SETTING_NUM = 32;
|
||||
}
|
||||
|
@ -22,4 +22,11 @@ public interface FrontBookMapper extends BookMapper {
|
||||
void addCommentCount(@Param("bookId") Long bookId);
|
||||
|
||||
List<Book> queryNetworkPicBooks(@Param("limit") Integer limit,@Param("offset") Integer offset);
|
||||
|
||||
/**
|
||||
* 按评分随机查询小说集合
|
||||
* @param limit 查询条数
|
||||
* @return 小说集合
|
||||
* */
|
||||
List<Book> selectIdsByScoreAndRandom(@Param("limit") int limit);
|
||||
}
|
||||
|
@ -24,11 +24,13 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.mybatis.dynamic.sql.SortSpecification;
|
||||
import org.mybatis.dynamic.sql.render.RenderingStrategies;
|
||||
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import tk.mybatis.orderbyhelper.OrderByHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -76,14 +78,64 @@ public class BookServiceImpl implements BookService {
|
||||
@Override
|
||||
public Map<Byte, List<BookSettingVO>> listBookSettingVO() {
|
||||
String result = cacheService.get(CacheKey.INDEX_BOOK_SETTINGS_KEY);
|
||||
if (result == null || result.length() < 10) {
|
||||
if (result == null || result.length() < Constants.OBJECT_JSON_CACHE_EXIST_LENGTH) {
|
||||
List<BookSettingVO> list = bookSettingMapper.listVO();
|
||||
if(list.size() == 0) {
|
||||
//如果首页小说没有被设置,则初始化首页小说设置
|
||||
list = initIndexBookSetting();
|
||||
}
|
||||
result = new ObjectMapper().writeValueAsString(list.stream().collect(Collectors.groupingBy(BookSettingVO::getType)));
|
||||
cacheService.set(CacheKey.INDEX_BOOK_SETTINGS_KEY, result);
|
||||
}
|
||||
return new ObjectMapper().readValue(result,Map.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化首页小说设置
|
||||
* */
|
||||
private List<BookSettingVO> initIndexBookSetting() {
|
||||
Date currentDate = new Date();
|
||||
List<Book> books = bookMapper.selectIdsByScoreAndRandom(Constants.INDEX_BOOK_SETTING_NUM);
|
||||
if(books.size() == Constants.INDEX_BOOK_SETTING_NUM) {
|
||||
List<BookSetting> bookSettingList = new ArrayList<>(Constants.INDEX_BOOK_SETTING_NUM);
|
||||
List<BookSettingVO> bookSettingVOList = new ArrayList<>(Constants.INDEX_BOOK_SETTING_NUM);
|
||||
for (int i = 0; i < books.size(); i++) {
|
||||
Book book = books.get(i);
|
||||
byte type;
|
||||
if (i < 4) {
|
||||
type = 0;
|
||||
} else if (i < 14) {
|
||||
type = 1;
|
||||
} else if (i < 20) {
|
||||
type = 2;
|
||||
} else if (i < 26) {
|
||||
type = 3;
|
||||
}else{
|
||||
type = 4;
|
||||
}
|
||||
BookSettingVO bookSettingVO = new BookSettingVO();
|
||||
BookSetting bookSetting = new BookSetting();
|
||||
bookSetting.setType(type);
|
||||
bookSetting.setSort((byte) i);
|
||||
bookSetting.setBookId(book.getId());
|
||||
bookSetting.setCreateTime(currentDate);
|
||||
bookSetting.setUpdateTime(currentDate);
|
||||
bookSettingList.add(bookSetting);
|
||||
|
||||
BeanUtils.copyProperties(book,bookSettingVO);
|
||||
BeanUtils.copyProperties(bookSetting,bookSettingVO);
|
||||
bookSettingVOList.add(bookSettingVO);
|
||||
}
|
||||
|
||||
bookSettingMapper.insertMultiple(bookSettingList);
|
||||
|
||||
return bookSettingVOList;
|
||||
}
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Book> listClickRank() {
|
||||
List<Book> result = (List<Book>) cacheService.getObject(CacheKey.INDEX_CLICK_BANK_BOOK_KEY);
|
||||
|
@ -59,5 +59,9 @@
|
||||
limit #{offset},#{limit}
|
||||
</select>
|
||||
|
||||
<select id="selectIdsByScoreAndRandom" parameterType="int" resultType="com.java2nb.novel.entity.Book">
|
||||
|
||||
select id,book_name,author_name,pic_url,book_desc,score from book ORDER BY score,RAND() LIMIT #{limit};
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -1,68 +0,0 @@
|
||||
/*
|
||||
Navicat MySQL Data Transfer
|
||||
|
||||
Source Server : localhost
|
||||
Source Server Version : 50624
|
||||
Source Host : localhost:3306
|
||||
Source Database : novel_biz
|
||||
|
||||
Target Server Type : MYSQL
|
||||
Target Server Version : 50624
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 2020-05-03 05:31:00
|
||||
*/
|
||||
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for book_setting
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `book_setting`;
|
||||
CREATE TABLE `book_setting` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`book_id` bigint(20) DEFAULT NULL COMMENT '小说ID',
|
||||
`sort` tinyint(4) DEFAULT NULL COMMENT '排序号',
|
||||
`type` tinyint(1) DEFAULT NULL COMMENT '类型,0:轮播图,1:顶部小说栏设置,2:本周强推,3:热门推荐,4:精品推荐',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`create_user_id` bigint(20) DEFAULT NULL COMMENT '创建人ID',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
`update_user_id` bigint(20) DEFAULT NULL COMMENT '更新人ID',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=64 DEFAULT CHARSET=utf8mb4 COMMENT='首页小说设置表';
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of book_setting
|
||||
-- ----------------------------
|
||||
INSERT INTO `book_setting` VALUES ('32', '1256560013650870272', '1', '0', '2020-04-27 15:45:58', null, '2020-04-27 15:46:03', null);
|
||||
INSERT INTO `book_setting` VALUES ('33', '1256560647057883136', '2', '0', '2020-04-27 15:46:21', null, '2020-04-27 15:46:24', null);
|
||||
INSERT INTO `book_setting` VALUES ('34', '1256560985525633024', '3', '0', '2020-04-27 15:47:06', null, '2020-04-27 15:47:09', null);
|
||||
INSERT INTO `book_setting` VALUES ('35', '1256562255468609536', '4', '0', '2020-04-27 15:47:24', null, '2020-04-27 15:47:27', null);
|
||||
INSERT INTO `book_setting` VALUES ('36', '1256567122404753408', '1', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('37', '1256562643605307392', '2', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('38', '1256567133926506496', '3', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('39', '1256567122404753408', '4', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('40', '1256567622755860480', '5', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('41', '1256567796077084672', '1', '2', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('42', '1256568783873425408', '2', '2', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('43', '1256569365753413632', '3', '2', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('44', '1256568158427201536', '4', '2', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('45', '1256569055395889152', '5', '2', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('46', '1256571983737307136', '6', '2', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('47', '1256572866260811777', '1', '3', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('48', '1256572765551378432', '2', '3', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('49', '1256570746774142976', '3', '3', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('50', '1256570389633351680', '4', '3', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('51', '1256575355232108544', '5', '3', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('52', '1256575330401828864', '6', '3', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('53', '1256575474111266816', '1', '4', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('54', '1256576738597453824', '2', '4', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('55', '1256576787712753664', '3', '4', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('56', '1256579884505808896', '4', '4', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('57', '1256579279494234112', '5', '4', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('58', '1256579164301869056', '6', '4', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('59', '1256692842384842752', '6', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('60', '1256695607790133248', '7', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('61', '1256623094850568192', '8', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('62', '1256626444941836288', '9', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('63', '1256623378670731264', '10', '1', null, null, null, null);
|
@ -1,35 +0,0 @@
|
||||
/*
|
||||
Navicat MySQL Data Transfer
|
||||
|
||||
Source Server : localhost
|
||||
Source Server Version : 50624
|
||||
Source Host : localhost:3306
|
||||
Source Database : novel_biz
|
||||
|
||||
Target Server Type : MYSQL
|
||||
Target Server Version : 50624
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 2020-05-02 12:40:12
|
||||
*/
|
||||
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for crawl_source
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `crawl_source`;
|
||||
CREATE TABLE `crawl_source` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`source_name` varchar(50) DEFAULT NULL COMMENT '源站名',
|
||||
`crawl_rule` varchar(2048) DEFAULT NULL COMMENT '爬取规则(json串)',
|
||||
`source_status` tinyint(1) DEFAULT '0' COMMENT '爬虫源状态,0:关闭,1:开启',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='爬虫源表';
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of crawl_source
|
||||
-- ----------------------------
|
||||
INSERT INTO `crawl_source` VALUES ('2', '百书斋', '{\r\n \"bookListUrl\": \"https://m.baishuzhai.com/blhb/{catId}/{page}.html\",\r\n \"catIdRule\": {\r\n \"catId1\": \"1\",\r\n \"catId2\": \"2\",\r\n \"catId3\": \"3\",\r\n \"catId4\": \"4\",\r\n \"catId5\": \"5\",\r\n \"catId6\": \"6\",\r\n \"catId7\": \"7\"\r\n },\r\n \"bookIdPatten\": \"href=\\\"/ibook/(\\\\d+/\\\\d+)/\\\"\",\r\n \"pagePatten\": \"value=\\\"(\\\\d+)/\\\\d+\\\"\",\r\n \"totalPagePatten\": \"value=\\\"\\\\d+/(\\\\d+)\\\"\",\r\n \"bookDetailUrl\": \"https://m.baishuzhai.com/ibook/{bookId}/\",\r\n \"bookNamePatten\": \"<span class=\\\"title\\\">([^/]+)</span>\",\r\n \"authorNamePatten\": \">作者:([^/]+)<\",\r\n \"picUrlPatten\": \"<img src=\\\"([^>]+)\\\"\\\\s+onerror=\\\"this.src=\",\r\n \"statusPatten\": \"状态:([^/]+)</li>\",\r\n \"bookStatusRule\": {\r\n \"连载\": 0,\r\n \"完成\": 1\r\n },\r\n \"scorePatten\": \"<div\\\\s+class=\\\"score\\\">(\\\\d+\\\\.\\\\d+)分</div>\",\r\n \"descStart\": \"<p class=\\\"review\\\">\",\r\n \"descEnd\": \"</p>\",\r\n \"upadateTimePatten\": \"更新:(\\\\d+-\\\\d+-\\\\d+)</li>\",\r\n \"upadateTimeFormatPatten\": \"yy-MM-dd\",\r\n \"bookIndexUrl\": \"https://m.baishuzhai.com/ibook/{bookId}/all.html\",\r\n \"indexIdPatten\": \"<a\\\\s+style=\\\"\\\"\\\\s+href=\\\"/ibook/\\\\d+/\\\\d+/(\\\\d+)\\\\.html\\\">[^/]+</a>\",\r\n \"indexNamePatten\": \"<a\\\\s+style=\\\"\\\"\\\\s+href=\\\"/ibook/\\\\d+/\\\\d+/\\\\d+\\\\.html\\\">([^/]+)</a>\",\r\n \"bookContentUrl\": \"https://baishuzhai.com/ibook/{bookId}/{indexId}.html\",\r\n \"contentStart\": \"id=\\\"content\\\">\",\r\n \"contentEnd\": \"<script>\"\r\n}', '1', '2020-05-01 14:22:50', '2020-05-01 14:22:50');
|
3417
sql/novel_plus.sql
3417
sql/novel_plus.sql
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user