mirror of
https://github.com/201206030/novel-plus.git
synced 2025-07-01 23:26:38 +00:00
Compare commits
64 Commits
release_v1
...
release_v2
Author | SHA1 | Date | |
---|---|---|---|
0e2e6229cd | |||
f8a669eb01 | |||
6d56399d0f | |||
1a0c1f864b | |||
b193aca288 | |||
7a6d7a4442 | |||
5505840b6e | |||
8eb3048b91 | |||
1b138c2aad | |||
f5e2dbaa6b | |||
b6cb9aaedc | |||
f9f1e474ec | |||
06bf848e99 | |||
6e171d20ed | |||
c62acc288e | |||
9975faed01 | |||
8fde3a3725 | |||
430504ee28 | |||
16447c60ec | |||
be7cbe2d6f | |||
8f1ed88b07 | |||
9b9851e7ab | |||
a55edf0408 | |||
856c4c0667 | |||
e4dd5bcb71 | |||
5dbddbdd96 | |||
73be43e1c5 | |||
ce2a3b4647 | |||
68abdeca93 | |||
0b505a3922 | |||
353cb8c536 | |||
e1e1310b9e | |||
4c42ac0d29 | |||
d025d3d514 | |||
a0fb8e481a | |||
80b933db8d | |||
87a060280a | |||
9c78f400dc | |||
c2cdf73893 | |||
a13ea78c3f | |||
0144b77983 | |||
07b9ffde96 | |||
002a0723f7 | |||
8a628f081f | |||
4aa6b82143 | |||
c80b02caf0 | |||
5e16119880 | |||
231b94f1da | |||
92ce982899 | |||
8c2e43c04f | |||
f553d23fb9 | |||
9773b73475 | |||
5543b905cd | |||
e273906441 | |||
83dc04c50b | |||
b4f5b18e93 | |||
fe80c21812 | |||
4c2a7f12c1 | |||
e24e87b546 | |||
b8b074d40a | |||
a662f42bcf | |||
0fa929f9de | |||
401d23871d | |||
4878f17de8 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -13,3 +13,6 @@
|
|||||||
/novel-admin/target
|
/novel-admin/target
|
||||||
/*.iml
|
/*.iml
|
||||||
/novel-admin/*.iml
|
/novel-admin/*.iml
|
||||||
|
.DS_Store
|
||||||
|
/novel-admin/cachedata
|
||||||
|
/novel-admin/logs
|
||||||
|
102
README.md
102
README.md
@ -1,7 +1,15 @@
|
|||||||
[](https://cloud.tencent.com/act/cps/redirect?redirect=1052&cps_key=736e609d66e0ac4e57813316cec6fd0b&from=console)
|
[]( https://www.eve.bz/cart.php?gid=11 )
|
||||||
|
|
||||||
# 小说精品屋-plus
|
# 小说精品屋-plus
|
||||||
|
|
||||||
|
#### 新项目:小说精品屋-微服务版
|
||||||
|
|
||||||
|
基于小说精品屋-plus构建的Spring Cloud 微服务小说门户平台,可用于学习和商用。
|
||||||
|
|
||||||
|
Gitee仓库地址: https://gitee.com/xiongxyang/novel-cloud
|
||||||
|
|
||||||
|
GitHub仓库地址: https://github.com/201206030/novel-cloud
|
||||||
|
|
||||||
#### 演示地址
|
#### 演示地址
|
||||||
|
|
||||||
[点击前往](http://www.java2nb.com)(前台门户)
|
[点击前往](http://www.java2nb.com)(前台门户)
|
||||||
@ -24,9 +32,9 @@
|
|||||||
- [x] 排行榜。
|
- [x] 排行榜。
|
||||||
- [x] 小说评论模块。
|
- [x] 小说评论模块。
|
||||||
- [x] 阅读主题模块。
|
- [x] 阅读主题模块。
|
||||||
- [ ] 作家专区。
|
- [x] 作家专区。
|
||||||
- [x] 充值。
|
- [x] 充值。
|
||||||
- [ ] 后台管理系统。
|
- [x] 后台管理系统。
|
||||||
- [x] 爬虫管理系统。
|
- [x] 爬虫管理系统。
|
||||||
|
|
||||||
#### 项目结构
|
#### 项目结构
|
||||||
@ -40,53 +48,109 @@ novel-plus -- 父工程
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### 技术选型
|
#### 技术选型
|
||||||
Springboot+Mybatis+Mysql+Ehcache+Thymeleaf+Layui
|
|
||||||
|
| 技术 | 说明
|
||||||
|
| -------------------- | ---------------------------
|
||||||
|
| SpringBoot | Spring应用快速开发脚手架
|
||||||
|
| MyBatis | 持久层ORM框架
|
||||||
|
| MyBatis Dynamic SQL | Mybatis动态sql
|
||||||
|
| PageHelper | MyBatis分页插件
|
||||||
|
| MyBatisGenerator | 持久层代码生成插件
|
||||||
|
| Sharding-Jdbc | 代码层分库分表中间件
|
||||||
|
| JJWT | JWT登录支持
|
||||||
|
| SpringSecurity | 安全框架
|
||||||
|
| Shiro | 安全框架
|
||||||
|
| Ehcache | Java进程内缓存框架(默认缓存)
|
||||||
|
| Redis | 分布式缓存(缓存替换方案,默认关闭,一行配置开启)
|
||||||
|
| ElasticSearch | 搜索引擎(搜索增强方案,默认关闭,一行配置开启)
|
||||||
|
| RabbitMq | 消息队列(流量削峰,默认关闭,一行配置开启)
|
||||||
|
| OSS | 阿里云对象存储服务(图片存储方式之一,一行配置即可切换)
|
||||||
|
| FastDfs |开源轻量级分布式文件系统(图片存储方式之一,一行配置即可切换)
|
||||||
|
| Redisson | 实现分布式锁
|
||||||
|
| Lombok | 简化对象封装工具
|
||||||
|
| Docker | 应用容器引擎
|
||||||
|
| Mysql | 数据库服务
|
||||||
|
| Thymeleaf | 模板引擎
|
||||||
|
| Layui | 前端UI
|
||||||
|
|
||||||
|
|
||||||
#### PC站截图
|
#### PC站截图
|
||||||
|
|
||||||
|
1. 首页
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||

|
2. 分类索引页
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
3. 搜索页
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
4. 排行榜
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
5. 详情页
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
6. 阅读页
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
7. 用户中心
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
8. 充值
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
9. 作家专区
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
10. 购买
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
#### 手机站截图
|
#### 手机站截图
|
||||||
|
|
||||||
1. 首页
|
1. 首页
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
2. 小说详情页
|
2. 小说详情页
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
3. 目录页
|
3. 目录页
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
4. 小说阅读页
|
4. 小说阅读页
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### 爬虫管理系统截图
|
#### 爬虫管理系统截图
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
#### 后台管理系统截图
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
#### 安装步骤
|
#### 安装步骤
|
||||||
|
|
||||||
@ -127,7 +191,7 @@ docker安装教程:[点击前往](https://my.oschina.net/java2nb/blog/4271989)
|
|||||||
|
|
||||||
#### QQ交流群
|
#### QQ交流群
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
#### 捐赠支持
|
#### 捐赠支持
|
||||||
|
|
||||||
|
BIN
assets/QQ20200520-215756.png
Normal file
BIN
assets/QQ20200520-215756.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 105 KiB |
Binary file not shown.
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 62 KiB |
82
es/index_create.txt
Normal file
82
es/index_create.txt
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
PUT /novel
|
||||||
|
{
|
||||||
|
"mappings" : {
|
||||||
|
"book" : {
|
||||||
|
"properties" : {
|
||||||
|
"id" : {
|
||||||
|
"type" : "long"
|
||||||
|
},
|
||||||
|
"authorId" : {
|
||||||
|
"type" : "long"
|
||||||
|
},
|
||||||
|
"authorName" : {
|
||||||
|
"type" : "text",
|
||||||
|
"analyzer": "ik_smart",
|
||||||
|
"boost": 1.9
|
||||||
|
},
|
||||||
|
|
||||||
|
"bookName" : {
|
||||||
|
"type" : "text",
|
||||||
|
"analyzer": "ik_smart",
|
||||||
|
"boost": 2
|
||||||
|
},
|
||||||
|
|
||||||
|
"bookDesc" : {
|
||||||
|
"type" : "text",
|
||||||
|
"analyzer": "ik_smart",
|
||||||
|
"boost": 0.1
|
||||||
|
},
|
||||||
|
|
||||||
|
"bookStatus" : {
|
||||||
|
"type" : "short"
|
||||||
|
},
|
||||||
|
|
||||||
|
"catId" : {
|
||||||
|
"type" : "integer"
|
||||||
|
},
|
||||||
|
|
||||||
|
"catName" : {
|
||||||
|
"type" : "text",
|
||||||
|
"analyzer": "ik_smart",
|
||||||
|
"boost": 1.0
|
||||||
|
},
|
||||||
|
|
||||||
|
"lastIndexId" : {
|
||||||
|
"type" : "long"
|
||||||
|
},
|
||||||
|
|
||||||
|
"lastIndexName" : {
|
||||||
|
"type" : "text",
|
||||||
|
"analyzer": "ik_smart",
|
||||||
|
"boost": 0.1
|
||||||
|
},
|
||||||
|
|
||||||
|
"lastIndexUpdateTime" : {
|
||||||
|
"type": "keyword"
|
||||||
|
},
|
||||||
|
|
||||||
|
"picUrl" : {
|
||||||
|
"type" : "keyword"
|
||||||
|
},
|
||||||
|
|
||||||
|
"score" : {
|
||||||
|
"type" : "float"
|
||||||
|
},
|
||||||
|
|
||||||
|
"wordCount" : {
|
||||||
|
"type" : "integer"
|
||||||
|
},
|
||||||
|
|
||||||
|
"workDirection" : {
|
||||||
|
"type" : "short"
|
||||||
|
},
|
||||||
|
|
||||||
|
"visitCount" : {
|
||||||
|
"type": "long"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
6
novel-admin/Dockerfile
Normal file
6
novel-admin/Dockerfile
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
FROM java:8
|
||||||
|
ADD novel-admin-1.0.0.jar /root
|
||||||
|
ENV dburl=""
|
||||||
|
ENV username=""
|
||||||
|
ENV password=""
|
||||||
|
ENTRYPOINT ["sh","-c","java -Dspring.datasource.url=${dburl} -Dspring.datasource.username=${username} -Dspring.datasource.password=${password} -jar /root/novel-admin-1.0.0.jar"]
|
8
novel-admin/logs/debug.log
Normal file
8
novel-admin/logs/debug.log
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
2020-05-13 21:52:00,972 INFO (StartupInfoLogger.java:50)- Starting TestDemo on USER-20180729KA with PID 3532 (started by Administrator in E:\baseprojectparent\novel-plus\novel-admin)
|
||||||
|
2020-05-13 21:52:01,113 DEBUG (StartupInfoLogger.java:53)- Running with Spring Boot v2.0.1.RELEASE, Spring v5.0.5.RELEASE
|
||||||
|
2020-05-13 21:52:01,131 INFO (SpringApplication.java:663)- The following profiles are active: dev
|
||||||
|
2020-05-13 21:52:54,469 DEBUG (ApplicationContextRegister.java:29)- ApplicationContext registed-->org.springframework.web.context.support.GenericWebApplicationContext@5b529706: startup date [Wed May 13 21:52:01 CST 2020]; root of context hierarchy
|
||||||
|
2020-05-13 21:53:49,622 INFO (StartupInfoLogger.java:59)- Started TestDemo in 114.268 seconds (JVM running for 124.957)
|
||||||
|
2020-05-18 09:48:03,219 INFO (StartupInfoLogger.java:50)- Starting TestDemo on DESKTOP-CPCLUI6 with PID 13172 (started by 11797 in D:\gitee\novel-plus\novel-admin)
|
||||||
|
2020-05-18 09:48:03,223 DEBUG (StartupInfoLogger.java:53)- Running with Spring Boot v2.0.1.RELEASE, Spring v5.0.5.RELEASE
|
||||||
|
2020-05-18 09:48:03,227 INFO (SpringApplication.java:663)- The following profiles are active: dev
|
@ -50,10 +50,10 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- NekoHTML 是一个简单地HTML扫描器和标签补偿器(tag balancer) ,使得程序能解析HTML文档并用标准的XML接口来访问其中的信息。
|
<!-- NekoHTML 是一个简单地HTML扫描器和标签补偿器(tag balancer) ,使得程序能解析HTML文档并用标准的XML接口来访问其中的信息。
|
||||||
这个解析器能投扫描HTML文件并“修正”许多作者(人或机器)在编写HTML文档过程中常犯的错误。
|
这个解析器能投扫描HTML文件并“修正”许多作者(人或机器)在编写HTML文档过程中常犯的错误。
|
||||||
NekoHTML 能增补缺失的父元素、自动用结束标签关闭相应的元素,以及不匹配的内嵌元素标签。
|
NekoHTML 能增补缺失的父元素、自动用结束标签关闭相应的元素,以及不匹配的内嵌元素标签。
|
||||||
NekoHTML 的开发使用了Xerces Native Interface (XNI),后者是Xerces2的实现基础。-->
|
NekoHTML 的开发使用了Xerces Native Interface (XNI),后者是Xerces2的实现基础。-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.sourceforge.nekohtml</groupId>
|
<groupId>net.sourceforge.nekohtml</groupId>
|
||||||
<artifactId>nekohtml</artifactId>
|
<artifactId>nekohtml</artifactId>
|
||||||
@ -147,13 +147,13 @@
|
|||||||
<!--</dependency>-->
|
<!--</dependency>-->
|
||||||
<!-- quartz -->
|
<!-- quartz -->
|
||||||
<!--<dependency>-->
|
<!--<dependency>-->
|
||||||
<!--<groupId>org.springframework.boot</groupId>-->
|
<!--<groupId>org.springframework.boot</groupId>-->
|
||||||
<!--<artifactId>spring-boot-starter-cache</artifactId>-->
|
<!--<artifactId>spring-boot-starter-cache</artifactId>-->
|
||||||
<!--</dependency>-->
|
<!--</dependency>-->
|
||||||
|
|
||||||
<!--<dependency>-->
|
<!--<dependency>-->
|
||||||
<!--<groupId>net.sf.ehcache</groupId>-->
|
<!--<groupId>net.sf.ehcache</groupId>-->
|
||||||
<!--<artifactId>ehcache</artifactId>-->
|
<!--<artifactId>ehcache</artifactId>-->
|
||||||
<!--</dependency>-->
|
<!--</dependency>-->
|
||||||
|
|
||||||
|
|
||||||
@ -188,7 +188,6 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
@ -239,18 +238,22 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
</plugin>-->
|
</plugin>-->
|
||||||
<!--SpringBoot项目默认使用spring-boot-maven-plugin,要打成被其他项目引用的jar包,需要更换此插件-->
|
<!--SpringBoot项目默认使用spring-boot-maven-plugin,要打成被其他项目引用的jar包,需要更换此插件-->
|
||||||
|
<!-- <plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
</configuration>
|
||||||
|
</plugin>-->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
<configuration>
|
|
||||||
<source>1.8</source>
|
|
||||||
<target>1.8</target>
|
|
||||||
<encoding>UTF-8</encoding>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<distributionManagement>
|
<!--<distributionManagement>
|
||||||
<repository>
|
<repository>
|
||||||
<id>nexus_release</id>
|
<id>nexus_release</id>
|
||||||
<name>release</name>
|
<name>release</name>
|
||||||
@ -261,5 +264,5 @@
|
|||||||
<name>snapshots</name>
|
<name>snapshots</name>
|
||||||
<url>http://47.106.243.172:8081/nexus/content/repositories/snapshots/</url>
|
<url>http://47.106.243.172:8081/nexus/content/repositories/snapshots/</url>
|
||||||
</snapshotRepository>
|
</snapshotRepository>
|
||||||
</distributionManagement>
|
</distributionManagement>-->
|
||||||
</project>
|
</project>
|
||||||
|
@ -0,0 +1,135 @@
|
|||||||
|
package com.java2nb.novel.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
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.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
|
||||||
|
|
||||||
|
import com.java2nb.novel.domain.AuthorCodeDO;
|
||||||
|
import com.java2nb.novel.service.AuthorCodeService;
|
||||||
|
import com.java2nb.common.utils.PageBean;
|
||||||
|
import com.java2nb.common.utils.Query;
|
||||||
|
import com.java2nb.common.utils.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 作家邀请码表
|
||||||
|
*
|
||||||
|
* @author xiongxy
|
||||||
|
* @email 1179705413@qq.com
|
||||||
|
* @date 2020-05-13 11:29:15
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/novel/authorCode")
|
||||||
|
public class AuthorCodeController {
|
||||||
|
@Autowired
|
||||||
|
private AuthorCodeService authorCodeService;
|
||||||
|
|
||||||
|
@GetMapping()
|
||||||
|
@RequiresPermissions("novel:authorCode:authorCode")
|
||||||
|
String AuthorCode() {
|
||||||
|
return "novel/authorCode/authorCode";
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取作家邀请码表列表", notes = "获取作家邀请码表列表")
|
||||||
|
@ResponseBody
|
||||||
|
@GetMapping("/list")
|
||||||
|
@RequiresPermissions("novel:authorCode:authorCode")
|
||||||
|
public R list(@RequestParam Map<String, Object> params) {
|
||||||
|
//查询列表数据
|
||||||
|
Query query = new Query(params);
|
||||||
|
List<AuthorCodeDO> authorCodeList = authorCodeService.list(query);
|
||||||
|
int total = authorCodeService.count(query);
|
||||||
|
PageBean pageBean = new PageBean(authorCodeList, total);
|
||||||
|
return R.ok().put("data", pageBean);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "新增作家邀请码表页面", notes = "新增作家邀请码表页面")
|
||||||
|
@GetMapping("/add")
|
||||||
|
@RequiresPermissions("novel:authorCode:add")
|
||||||
|
String add() {
|
||||||
|
return "novel/authorCode/add";
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改作家邀请码表页面", notes = "修改作家邀请码表页面")
|
||||||
|
@GetMapping("/edit/{id}")
|
||||||
|
@RequiresPermissions("novel:authorCode:edit")
|
||||||
|
String edit(@PathVariable("id") Long id, Model model) {
|
||||||
|
AuthorCodeDO authorCode = authorCodeService.get(id);
|
||||||
|
model.addAttribute("authorCode", authorCode);
|
||||||
|
return "novel/authorCode/edit";
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "查看作家邀请码表页面", notes = "查看作家邀请码表页面")
|
||||||
|
@GetMapping("/detail/{id}")
|
||||||
|
@RequiresPermissions("novel:authorCode:detail")
|
||||||
|
String detail(@PathVariable("id") Long id, Model model) {
|
||||||
|
AuthorCodeDO authorCode = authorCodeService.get(id);
|
||||||
|
model.addAttribute("authorCode", authorCode);
|
||||||
|
return "novel/authorCode/detail";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "新增作家邀请码表", notes = "新增作家邀请码表")
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/save")
|
||||||
|
@RequiresPermissions("novel:authorCode:add")
|
||||||
|
public R save( AuthorCodeDO authorCode) {
|
||||||
|
if (authorCodeService.save(authorCode) > 0) {
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
return R.error();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "修改作家邀请码表", notes = "修改作家邀请码表")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/update")
|
||||||
|
@RequiresPermissions("novel:authorCode:edit")
|
||||||
|
public R update( AuthorCodeDO authorCode) {
|
||||||
|
authorCodeService.update(authorCode);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "删除作家邀请码表", notes = "删除作家邀请码表")
|
||||||
|
@PostMapping("/remove")
|
||||||
|
@ResponseBody
|
||||||
|
@RequiresPermissions("novel:authorCode:remove")
|
||||||
|
public R remove( Long id) {
|
||||||
|
if (authorCodeService.remove(id) > 0) {
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
return R.error();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "批量删除作家邀请码表", notes = "批量删除作家邀请码表")
|
||||||
|
@PostMapping("/batchRemove")
|
||||||
|
@ResponseBody
|
||||||
|
@RequiresPermissions("novel:authorCode:batchRemove")
|
||||||
|
public R remove(@RequestParam("ids[]") Long[] ids) {
|
||||||
|
authorCodeService.batchRemove(ids);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,135 @@
|
|||||||
|
package com.java2nb.novel.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
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.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
|
||||||
|
|
||||||
|
import com.java2nb.novel.domain.AuthorDO;
|
||||||
|
import com.java2nb.novel.service.AuthorService;
|
||||||
|
import com.java2nb.common.utils.PageBean;
|
||||||
|
import com.java2nb.common.utils.Query;
|
||||||
|
import com.java2nb.common.utils.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 作者表
|
||||||
|
*
|
||||||
|
* @author xiongxy
|
||||||
|
* @email 1179705413@qq.com
|
||||||
|
* @date 2020-05-13 11:16:51
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/novel/author")
|
||||||
|
public class AuthorController {
|
||||||
|
@Autowired
|
||||||
|
private AuthorService authorService;
|
||||||
|
|
||||||
|
@GetMapping()
|
||||||
|
@RequiresPermissions("novel:author:author")
|
||||||
|
String Author() {
|
||||||
|
return "novel/author/author";
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取作者表列表", notes = "获取作者表列表")
|
||||||
|
@ResponseBody
|
||||||
|
@GetMapping("/list")
|
||||||
|
@RequiresPermissions("novel:author:author")
|
||||||
|
public R list(@RequestParam Map<String, Object> params) {
|
||||||
|
//查询列表数据
|
||||||
|
Query query = new Query(params);
|
||||||
|
List<AuthorDO> authorList = authorService.list(query);
|
||||||
|
int total = authorService.count(query);
|
||||||
|
PageBean pageBean = new PageBean(authorList, total);
|
||||||
|
return R.ok().put("data", pageBean);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "新增作者表页面", notes = "新增作者表页面")
|
||||||
|
@GetMapping("/add")
|
||||||
|
@RequiresPermissions("novel:author:add")
|
||||||
|
String add() {
|
||||||
|
return "novel/author/add";
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "修改作者表页面", notes = "修改作者表页面")
|
||||||
|
@GetMapping("/edit/{id}")
|
||||||
|
@RequiresPermissions("novel:author:edit")
|
||||||
|
String edit(@PathVariable("id") Long id, Model model) {
|
||||||
|
AuthorDO author = authorService.get(id);
|
||||||
|
model.addAttribute("author", author);
|
||||||
|
return "novel/author/edit";
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "查看作者表页面", notes = "查看作者表页面")
|
||||||
|
@GetMapping("/detail/{id}")
|
||||||
|
@RequiresPermissions("novel:author:detail")
|
||||||
|
String detail(@PathVariable("id") Long id, Model model) {
|
||||||
|
AuthorDO author = authorService.get(id);
|
||||||
|
model.addAttribute("author", author);
|
||||||
|
return "novel/author/detail";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "新增作者表", notes = "新增作者表")
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/save")
|
||||||
|
@RequiresPermissions("novel:author:add")
|
||||||
|
public R save( AuthorDO author) {
|
||||||
|
if (authorService.save(author) > 0) {
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
return R.error();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "修改作者表", notes = "修改作者表")
|
||||||
|
@ResponseBody
|
||||||
|
@RequestMapping("/update")
|
||||||
|
@RequiresPermissions("novel:author:edit")
|
||||||
|
public R update( AuthorDO author) {
|
||||||
|
authorService.update(author);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "删除作者表", notes = "删除作者表")
|
||||||
|
@PostMapping("/remove")
|
||||||
|
@ResponseBody
|
||||||
|
@RequiresPermissions("novel:author:remove")
|
||||||
|
public R remove( Long id) {
|
||||||
|
if (authorService.remove(id) > 0) {
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
return R.error();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "批量删除作者表", notes = "批量删除作者表")
|
||||||
|
@PostMapping("/batchRemove")
|
||||||
|
@ResponseBody
|
||||||
|
@RequiresPermissions("novel:author:batchRemove")
|
||||||
|
public R remove(@RequestParam("ids[]") Long[] ids) {
|
||||||
|
authorService.batchRemove(ids);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.java2nb.novel.dao;
|
||||||
|
|
||||||
|
import com.java2nb.novel.domain.AuthorCodeDO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 作家邀请码表
|
||||||
|
* @author xiongxy
|
||||||
|
* @email 1179705413@qq.com
|
||||||
|
* @date 2020-05-13 11:29:15
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface AuthorCodeDao {
|
||||||
|
|
||||||
|
AuthorCodeDO get(Long id);
|
||||||
|
|
||||||
|
List<AuthorCodeDO> list(Map<String,Object> map);
|
||||||
|
|
||||||
|
int count(Map<String,Object> map);
|
||||||
|
|
||||||
|
int save(AuthorCodeDO authorCode);
|
||||||
|
|
||||||
|
int update(AuthorCodeDO authorCode);
|
||||||
|
|
||||||
|
int remove(Long id);
|
||||||
|
|
||||||
|
int batchRemove(Long[] ids);
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package com.java2nb.novel.dao;
|
||||||
|
|
||||||
|
import com.java2nb.novel.domain.AuthorDO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 作者表
|
||||||
|
* @author xiongxy
|
||||||
|
* @email 1179705413@qq.com
|
||||||
|
* @date 2020-05-13 11:16:51
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface AuthorDao {
|
||||||
|
|
||||||
|
AuthorDO get(Long id);
|
||||||
|
|
||||||
|
List<AuthorDO> list(Map<String,Object> map);
|
||||||
|
|
||||||
|
int count(Map<String,Object> map);
|
||||||
|
|
||||||
|
int save(AuthorDO author);
|
||||||
|
|
||||||
|
int update(AuthorDO author);
|
||||||
|
|
||||||
|
int remove(Long id);
|
||||||
|
|
||||||
|
int batchRemove(Long[] ids);
|
||||||
|
}
|
@ -0,0 +1,121 @@
|
|||||||
|
package com.java2nb.novel.domain;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
import com.java2nb.common.jsonserializer.LongToStringSerializer;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 作家邀请码表
|
||||||
|
*
|
||||||
|
* @author xiongxy
|
||||||
|
* @email 1179705413@qq.com
|
||||||
|
* @date 2020-05-13 11:29:15
|
||||||
|
*/
|
||||||
|
public class AuthorCodeDO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
|
//主键
|
||||||
|
//java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值)
|
||||||
|
//所以通过序列化成字符串来解决
|
||||||
|
@JsonSerialize(using = LongToStringSerializer.class)
|
||||||
|
private Long id;
|
||||||
|
//邀请码
|
||||||
|
private String inviteCode;
|
||||||
|
//有效时间
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date validityTime;
|
||||||
|
//是否使用过,0:未使用,1:使用过
|
||||||
|
private Integer isUse;
|
||||||
|
//创建时间
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createTime;
|
||||||
|
//创建人ID
|
||||||
|
//java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值)
|
||||||
|
//所以通过序列化成字符串来解决
|
||||||
|
@JsonSerialize(using = LongToStringSerializer.class)
|
||||||
|
private Long createUserId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置:主键
|
||||||
|
*/
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取:主键
|
||||||
|
*/
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 设置:邀请码
|
||||||
|
*/
|
||||||
|
public void setInviteCode(String inviteCode) {
|
||||||
|
this.inviteCode = inviteCode;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取:邀请码
|
||||||
|
*/
|
||||||
|
public String getInviteCode() {
|
||||||
|
return inviteCode;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 设置:有效时间
|
||||||
|
*/
|
||||||
|
public void setValidityTime(Date validityTime) {
|
||||||
|
this.validityTime = validityTime;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取:有效时间
|
||||||
|
*/
|
||||||
|
public Date getValidityTime() {
|
||||||
|
return validityTime;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 设置:是否使用过,0:未使用,1:使用过
|
||||||
|
*/
|
||||||
|
public void setIsUse(Integer isUse) {
|
||||||
|
this.isUse = isUse;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取:是否使用过,0:未使用,1:使用过
|
||||||
|
*/
|
||||||
|
public Integer getIsUse() {
|
||||||
|
return isUse;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 设置:创建时间
|
||||||
|
*/
|
||||||
|
public void setCreateTime(Date createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取:创建时间
|
||||||
|
*/
|
||||||
|
public Date getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 设置:创建人ID
|
||||||
|
*/
|
||||||
|
public void setCreateUserId(Long createUserId) {
|
||||||
|
this.createUserId = createUserId;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取:创建人ID
|
||||||
|
*/
|
||||||
|
public Long getCreateUserId() {
|
||||||
|
return createUserId;
|
||||||
|
}
|
||||||
|
}
|
176
novel-admin/src/main/java/com/java2nb/novel/domain/AuthorDO.java
Normal file
176
novel-admin/src/main/java/com/java2nb/novel/domain/AuthorDO.java
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
package com.java2nb.novel.domain;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
import com.java2nb.common.jsonserializer.LongToStringSerializer;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 作者表
|
||||||
|
*
|
||||||
|
* @author xiongxy
|
||||||
|
* @email 1179705413@qq.com
|
||||||
|
* @date 2020-05-13 11:16:51
|
||||||
|
*/
|
||||||
|
public class AuthorDO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
|
//主键
|
||||||
|
//java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值)
|
||||||
|
//所以通过序列化成字符串来解决
|
||||||
|
@JsonSerialize(using = LongToStringSerializer.class)
|
||||||
|
private Long id;
|
||||||
|
//用户ID
|
||||||
|
//java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值)
|
||||||
|
//所以通过序列化成字符串来解决
|
||||||
|
@JsonSerialize(using = LongToStringSerializer.class)
|
||||||
|
private Long userId;
|
||||||
|
//邀请码
|
||||||
|
private String inviteCode;
|
||||||
|
//笔名
|
||||||
|
private String penName;
|
||||||
|
//手机号码
|
||||||
|
private String telPhone;
|
||||||
|
//QQ或微信账号
|
||||||
|
private String chatAccount;
|
||||||
|
//电子邮箱
|
||||||
|
private String email;
|
||||||
|
//作品方向,0:男频,1:女频
|
||||||
|
private Integer workDirection;
|
||||||
|
//创建时间
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createTime;
|
||||||
|
//0:正常,1:封禁
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置:主键
|
||||||
|
*/
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取:主键
|
||||||
|
*/
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 设置:用户ID
|
||||||
|
*/
|
||||||
|
public void setUserId(Long userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取:用户ID
|
||||||
|
*/
|
||||||
|
public Long getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 设置:邀请码
|
||||||
|
*/
|
||||||
|
public void setInviteCode(String inviteCode) {
|
||||||
|
this.inviteCode = inviteCode;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取:邀请码
|
||||||
|
*/
|
||||||
|
public String getInviteCode() {
|
||||||
|
return inviteCode;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 设置:笔名
|
||||||
|
*/
|
||||||
|
public void setPenName(String penName) {
|
||||||
|
this.penName = penName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取:笔名
|
||||||
|
*/
|
||||||
|
public String getPenName() {
|
||||||
|
return penName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 设置:手机号码
|
||||||
|
*/
|
||||||
|
public void setTelPhone(String telPhone) {
|
||||||
|
this.telPhone = telPhone;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取:手机号码
|
||||||
|
*/
|
||||||
|
public String getTelPhone() {
|
||||||
|
return telPhone;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 设置:QQ或微信账号
|
||||||
|
*/
|
||||||
|
public void setChatAccount(String chatAccount) {
|
||||||
|
this.chatAccount = chatAccount;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取:QQ或微信账号
|
||||||
|
*/
|
||||||
|
public String getChatAccount() {
|
||||||
|
return chatAccount;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 设置:电子邮箱
|
||||||
|
*/
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取:电子邮箱
|
||||||
|
*/
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 设置:作品方向,0:男频,1:女频
|
||||||
|
*/
|
||||||
|
public void setWorkDirection(Integer workDirection) {
|
||||||
|
this.workDirection = workDirection;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取:作品方向,0:男频,1:女频
|
||||||
|
*/
|
||||||
|
public Integer getWorkDirection() {
|
||||||
|
return workDirection;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 设置:创建时间
|
||||||
|
*/
|
||||||
|
public void setCreateTime(Date createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取:创建时间
|
||||||
|
*/
|
||||||
|
public Date getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 设置:0:正常,1:封禁
|
||||||
|
*/
|
||||||
|
public void setStatus(Integer status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取:0:正常,1:封禁
|
||||||
|
*/
|
||||||
|
public Integer getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.java2nb.novel.service;
|
||||||
|
|
||||||
|
import com.java2nb.novel.domain.AuthorCodeDO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 作家邀请码表
|
||||||
|
*
|
||||||
|
* @author xiongxy
|
||||||
|
* @email 1179705413@qq.com
|
||||||
|
* @date 2020-05-13 11:29:15
|
||||||
|
*/
|
||||||
|
public interface AuthorCodeService {
|
||||||
|
|
||||||
|
AuthorCodeDO get(Long id);
|
||||||
|
|
||||||
|
List<AuthorCodeDO> list(Map<String, Object> map);
|
||||||
|
|
||||||
|
int count(Map<String, Object> map);
|
||||||
|
|
||||||
|
int save(AuthorCodeDO authorCode);
|
||||||
|
|
||||||
|
int update(AuthorCodeDO authorCode);
|
||||||
|
|
||||||
|
int remove(Long id);
|
||||||
|
|
||||||
|
int batchRemove(Long[] ids);
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.java2nb.novel.service;
|
||||||
|
|
||||||
|
import com.java2nb.novel.domain.AuthorDO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 作者表
|
||||||
|
*
|
||||||
|
* @author xiongxy
|
||||||
|
* @email 1179705413@qq.com
|
||||||
|
* @date 2020-05-13 11:16:51
|
||||||
|
*/
|
||||||
|
public interface AuthorService {
|
||||||
|
|
||||||
|
AuthorDO get(Long id);
|
||||||
|
|
||||||
|
List<AuthorDO> list(Map<String, Object> map);
|
||||||
|
|
||||||
|
int count(Map<String, Object> map);
|
||||||
|
|
||||||
|
int save(AuthorDO author);
|
||||||
|
|
||||||
|
int update(AuthorDO author);
|
||||||
|
|
||||||
|
int remove(Long id);
|
||||||
|
|
||||||
|
int batchRemove(Long[] ids);
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
package com.java2nb.novel.service.impl;
|
||||||
|
|
||||||
|
import com.java2nb.common.utils.ShiroUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.java2nb.novel.dao.AuthorCodeDao;
|
||||||
|
import com.java2nb.novel.domain.AuthorCodeDO;
|
||||||
|
import com.java2nb.novel.service.AuthorCodeService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class AuthorCodeServiceImpl implements AuthorCodeService {
|
||||||
|
@Autowired
|
||||||
|
private AuthorCodeDao authorCodeDao;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AuthorCodeDO get(Long id){
|
||||||
|
return authorCodeDao.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AuthorCodeDO> list(Map<String, Object> map){
|
||||||
|
return authorCodeDao.list(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int count(Map<String, Object> map){
|
||||||
|
return authorCodeDao.count(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int save(AuthorCodeDO authorCode){
|
||||||
|
authorCode.setIsUse(0);
|
||||||
|
authorCode.setCreateTime(new Date());
|
||||||
|
authorCode.setCreateUserId(ShiroUtils.getUserId());
|
||||||
|
return authorCodeDao.save(authorCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int update(AuthorCodeDO authorCode){
|
||||||
|
return authorCodeDao.update(authorCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int remove(Long id){
|
||||||
|
return authorCodeDao.remove(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int batchRemove(Long[] ids){
|
||||||
|
return authorCodeDao.batchRemove(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
package com.java2nb.novel.service.impl;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.java2nb.novel.dao.AuthorDao;
|
||||||
|
import com.java2nb.novel.domain.AuthorDO;
|
||||||
|
import com.java2nb.novel.service.AuthorService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class AuthorServiceImpl implements AuthorService {
|
||||||
|
@Autowired
|
||||||
|
private AuthorDao authorDao;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AuthorDO get(Long id){
|
||||||
|
return authorDao.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AuthorDO> list(Map<String, Object> map){
|
||||||
|
return authorDao.list(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int count(Map<String, Object> map){
|
||||||
|
return authorDao.count(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int save(AuthorDO author){
|
||||||
|
return authorDao.save(author);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int update(AuthorDO author){
|
||||||
|
return authorDao.update(author);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int remove(Long id){
|
||||||
|
return authorDao.remove(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int batchRemove(Long[] ids){
|
||||||
|
return authorDao.batchRemove(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -10,9 +10,9 @@ spring:
|
|||||||
datasource:
|
datasource:
|
||||||
type: com.alibaba.druid.pool.DruidDataSource
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
driverClassName: com.mysql.jdbc.Driver
|
driverClassName: com.mysql.jdbc.Driver
|
||||||
url: jdbc:mysql://128.0.0.1:3306/novel_biz?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
|
url: jdbc:mysql://127.0.0.1:3306/novel_plus?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
|
||||||
username: root
|
username: root
|
||||||
password: test123456
|
password:
|
||||||
#password:
|
#password:
|
||||||
initialSize: 1
|
initialSize: 1
|
||||||
minIdle: 3
|
minIdle: 3
|
||||||
|
@ -3,7 +3,7 @@ server:
|
|||||||
# tomcat:
|
# tomcat:
|
||||||
# max-threads: 1000
|
# max-threads: 1000
|
||||||
# min-spare-threads: 30
|
# min-spare-threads: 30
|
||||||
port: 8082
|
port: 80
|
||||||
# uri-encoding: utf-8
|
# uri-encoding: utf-8
|
||||||
#security:
|
#security:
|
||||||
# basic:
|
# basic:
|
||||||
|
@ -0,0 +1,108 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
|
||||||
|
<mapper namespace="com.java2nb.novel.dao.AuthorCodeDao">
|
||||||
|
|
||||||
|
<select id="get" resultType="com.java2nb.novel.domain.AuthorCodeDO">
|
||||||
|
select `id`,`invite_code`,`validity_time`,`is_use`,`create_time`,`create_user_id` from author_code where id = #{value}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="list" resultType="com.java2nb.novel.domain.AuthorCodeDO">
|
||||||
|
select `id`,`invite_code`,`validity_time`,`is_use`,`create_time`,`create_user_id` from author_code
|
||||||
|
<where>
|
||||||
|
<if test="id != null and id != ''"> and id = #{id} </if>
|
||||||
|
<if test="inviteCode != null and inviteCode != ''"> and invite_code = #{inviteCode} </if>
|
||||||
|
<if test="validityTime != null and validityTime != ''"> and validity_time = #{validityTime} </if>
|
||||||
|
<if test="isUse != null and isUse != ''"> and is_use = #{isUse} </if>
|
||||||
|
<if test="createTime != null and createTime != ''"> and create_time = #{createTime} </if>
|
||||||
|
<if test="createUserId != null and createUserId != ''"> and create_user_id = #{createUserId} </if>
|
||||||
|
</where>
|
||||||
|
<choose>
|
||||||
|
<when test="sort != null and sort.trim() != ''">
|
||||||
|
order by ${sort} ${order}
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
order by create_time desc
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
<if test="offset != null and limit != null">
|
||||||
|
limit #{offset}, #{limit}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="count" resultType="int">
|
||||||
|
select count(*) from author_code
|
||||||
|
<where>
|
||||||
|
<if test="id != null and id != ''"> and id = #{id} </if>
|
||||||
|
<if test="inviteCode != null and inviteCode != ''"> and invite_code = #{inviteCode} </if>
|
||||||
|
<if test="validityTime != null and validityTime != ''"> and validity_time = #{validityTime} </if>
|
||||||
|
<if test="isUse != null and isUse != ''"> and is_use = #{isUse} </if>
|
||||||
|
<if test="createTime != null and createTime != ''"> and create_time = #{createTime} </if>
|
||||||
|
<if test="createUserId != null and createUserId != ''"> and create_user_id = #{createUserId} </if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="save" parameterType="com.java2nb.novel.domain.AuthorCodeDO" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into author_code
|
||||||
|
(
|
||||||
|
`invite_code`,
|
||||||
|
`validity_time`,
|
||||||
|
`is_use`,
|
||||||
|
`create_time`,
|
||||||
|
`create_user_id`
|
||||||
|
)
|
||||||
|
values
|
||||||
|
(
|
||||||
|
#{inviteCode},
|
||||||
|
#{validityTime},
|
||||||
|
#{isUse},
|
||||||
|
#{createTime},
|
||||||
|
#{createUserId}
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<insert id="saveSelective" parameterType="com.java2nb.novel.domain.AuthorCodeDO" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into author_code
|
||||||
|
(
|
||||||
|
<if test="id != null"> `id`, </if>
|
||||||
|
<if test="inviteCode != null"> `invite_code`, </if>
|
||||||
|
<if test="validityTime != null"> `validity_time`, </if>
|
||||||
|
<if test="isUse != null"> `is_use`, </if>
|
||||||
|
<if test="createTime != null"> `create_time`, </if>
|
||||||
|
<if test="createUserId != null"> `create_user_id` </if>
|
||||||
|
)
|
||||||
|
values
|
||||||
|
(
|
||||||
|
<if test="id != null"> #{id}, </if>
|
||||||
|
<if test="inviteCode != null"> #{inviteCode}, </if>
|
||||||
|
<if test="validityTime != null"> #{validityTime}, </if>
|
||||||
|
<if test="isUse != null"> #{isUse}, </if>
|
||||||
|
<if test="createTime != null"> #{createTime}, </if>
|
||||||
|
<if test="createUserId != null"> #{createUserId} </if>
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="update" parameterType="com.java2nb.novel.domain.AuthorCodeDO">
|
||||||
|
update author_code
|
||||||
|
<set>
|
||||||
|
<if test="inviteCode != null">`invite_code` = #{inviteCode}, </if>
|
||||||
|
<if test="validityTime != null">`validity_time` = #{validityTime}, </if>
|
||||||
|
<if test="isUse != null">`is_use` = #{isUse}, </if>
|
||||||
|
<if test="createTime != null">`create_time` = #{createTime}, </if>
|
||||||
|
<if test="createUserId != null">`create_user_id` = #{createUserId}</if>
|
||||||
|
</set>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="remove">
|
||||||
|
delete from author_code where id = #{value}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="batchRemove">
|
||||||
|
delete from author_code where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
</mapper>
|
136
novel-admin/src/main/resources/mybatis/novel/AuthorMapper.xml
Normal file
136
novel-admin/src/main/resources/mybatis/novel/AuthorMapper.xml
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
|
||||||
|
<mapper namespace="com.java2nb.novel.dao.AuthorDao">
|
||||||
|
|
||||||
|
<select id="get" resultType="com.java2nb.novel.domain.AuthorDO">
|
||||||
|
select `id`,`user_id`,`invite_code`,`pen_name`,`tel_phone`,`chat_account`,`email`,`work_direction`,`create_time`,`status` from author where id = #{value}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="list" resultType="com.java2nb.novel.domain.AuthorDO">
|
||||||
|
select `id`,`user_id`,`invite_code`,`pen_name`,`tel_phone`,`chat_account`,`email`,`work_direction`,`create_time`,`status` from author
|
||||||
|
<where>
|
||||||
|
<if test="id != null and id != ''"> and id = #{id} </if>
|
||||||
|
<if test="userId != null and userId != ''"> and user_id = #{userId} </if>
|
||||||
|
<if test="inviteCode != null and inviteCode != ''"> and invite_code = #{inviteCode} </if>
|
||||||
|
<if test="penName != null and penName != ''"> and pen_name = #{penName} </if>
|
||||||
|
<if test="telPhone != null and telPhone != ''"> and tel_phone = #{telPhone} </if>
|
||||||
|
<if test="chatAccount != null and chatAccount != ''"> and chat_account = #{chatAccount} </if>
|
||||||
|
<if test="email != null and email != ''"> and email = #{email} </if>
|
||||||
|
<if test="workDirection != null and workDirection != ''"> and work_direction = #{workDirection} </if>
|
||||||
|
<if test="createTime != null and createTime != ''"> and create_time = #{createTime} </if>
|
||||||
|
<if test="status != null and status != ''"> and status = #{status} </if>
|
||||||
|
</where>
|
||||||
|
<choose>
|
||||||
|
<when test="sort != null and sort.trim() != ''">
|
||||||
|
order by ${sort} ${order}
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
order by id desc
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
<if test="offset != null and limit != null">
|
||||||
|
limit #{offset}, #{limit}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="count" resultType="int">
|
||||||
|
select count(*) from author
|
||||||
|
<where>
|
||||||
|
<if test="id != null and id != ''"> and id = #{id} </if>
|
||||||
|
<if test="userId != null and userId != ''"> and user_id = #{userId} </if>
|
||||||
|
<if test="inviteCode != null and inviteCode != ''"> and invite_code = #{inviteCode} </if>
|
||||||
|
<if test="penName != null and penName != ''"> and pen_name = #{penName} </if>
|
||||||
|
<if test="telPhone != null and telPhone != ''"> and tel_phone = #{telPhone} </if>
|
||||||
|
<if test="chatAccount != null and chatAccount != ''"> and chat_account = #{chatAccount} </if>
|
||||||
|
<if test="email != null and email != ''"> and email = #{email} </if>
|
||||||
|
<if test="workDirection != null and workDirection != ''"> and work_direction = #{workDirection} </if>
|
||||||
|
<if test="createTime != null and createTime != ''"> and create_time = #{createTime} </if>
|
||||||
|
<if test="status != null and status != ''"> and status = #{status} </if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="save" parameterType="com.java2nb.novel.domain.AuthorDO" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into author
|
||||||
|
(
|
||||||
|
`user_id`,
|
||||||
|
`invite_code`,
|
||||||
|
`pen_name`,
|
||||||
|
`tel_phone`,
|
||||||
|
`chat_account`,
|
||||||
|
`email`,
|
||||||
|
`work_direction`,
|
||||||
|
`create_time`,
|
||||||
|
`status`
|
||||||
|
)
|
||||||
|
values
|
||||||
|
(
|
||||||
|
#{userId},
|
||||||
|
#{inviteCode},
|
||||||
|
#{penName},
|
||||||
|
#{telPhone},
|
||||||
|
#{chatAccount},
|
||||||
|
#{email},
|
||||||
|
#{workDirection},
|
||||||
|
#{createTime},
|
||||||
|
#{status}
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<insert id="saveSelective" parameterType="com.java2nb.novel.domain.AuthorDO" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into author
|
||||||
|
(
|
||||||
|
<if test="id != null"> `id`, </if>
|
||||||
|
<if test="userId != null"> `user_id`, </if>
|
||||||
|
<if test="inviteCode != null"> `invite_code`, </if>
|
||||||
|
<if test="penName != null"> `pen_name`, </if>
|
||||||
|
<if test="telPhone != null"> `tel_phone`, </if>
|
||||||
|
<if test="chatAccount != null"> `chat_account`, </if>
|
||||||
|
<if test="email != null"> `email`, </if>
|
||||||
|
<if test="workDirection != null"> `work_direction`, </if>
|
||||||
|
<if test="createTime != null"> `create_time`, </if>
|
||||||
|
<if test="status != null"> `status` </if>
|
||||||
|
)
|
||||||
|
values
|
||||||
|
(
|
||||||
|
<if test="id != null"> #{id}, </if>
|
||||||
|
<if test="userId != null"> #{userId}, </if>
|
||||||
|
<if test="inviteCode != null"> #{inviteCode}, </if>
|
||||||
|
<if test="penName != null"> #{penName}, </if>
|
||||||
|
<if test="telPhone != null"> #{telPhone}, </if>
|
||||||
|
<if test="chatAccount != null"> #{chatAccount}, </if>
|
||||||
|
<if test="email != null"> #{email}, </if>
|
||||||
|
<if test="workDirection != null"> #{workDirection}, </if>
|
||||||
|
<if test="createTime != null"> #{createTime}, </if>
|
||||||
|
<if test="status != null"> #{status} </if>
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="update" parameterType="com.java2nb.novel.domain.AuthorDO">
|
||||||
|
update author
|
||||||
|
<set>
|
||||||
|
<if test="userId != null">`user_id` = #{userId}, </if>
|
||||||
|
<if test="inviteCode != null">`invite_code` = #{inviteCode}, </if>
|
||||||
|
<if test="penName != null">`pen_name` = #{penName}, </if>
|
||||||
|
<if test="telPhone != null">`tel_phone` = #{telPhone}, </if>
|
||||||
|
<if test="chatAccount != null">`chat_account` = #{chatAccount}, </if>
|
||||||
|
<if test="email != null">`email` = #{email}, </if>
|
||||||
|
<if test="workDirection != null">`work_direction` = #{workDirection}, </if>
|
||||||
|
<if test="createTime != null">`create_time` = #{createTime}, </if>
|
||||||
|
<if test="status != null">`status` = #{status}</if>
|
||||||
|
</set>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="remove">
|
||||||
|
delete from author where id = #{value}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="batchRemove">
|
||||||
|
delete from author where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
</mapper>
|
@ -0,0 +1,107 @@
|
|||||||
|
var E = window.wangEditor;
|
||||||
|
$("[id^='contentEditor']").each(function (index, ele) {
|
||||||
|
var relName = $(ele).attr("id").substring(13);
|
||||||
|
var editor = new E('#contentEditor' + relName);
|
||||||
|
// 自定义菜单配置
|
||||||
|
editor.customConfig.menus = [
|
||||||
|
'head', // 标题
|
||||||
|
'bold', // 粗体
|
||||||
|
'fontSize', // 字号
|
||||||
|
'fontName', // 字体
|
||||||
|
'italic', // 斜体
|
||||||
|
'underline', // 下划线
|
||||||
|
'strikeThrough', // 删除线
|
||||||
|
'foreColor', // 文字颜色
|
||||||
|
//'backColor', // 背景颜色
|
||||||
|
//'link', // 插入链接
|
||||||
|
'list', // 列表
|
||||||
|
'justify', // 对齐方式
|
||||||
|
'quote', // 引用
|
||||||
|
'emoticon', // 表情
|
||||||
|
'image', // 插入图片
|
||||||
|
//'table', // 表格
|
||||||
|
//'video', // 插入视频
|
||||||
|
//'code', // 插入代码
|
||||||
|
'undo', // 撤销
|
||||||
|
'redo' // 重复
|
||||||
|
];
|
||||||
|
editor.customConfig.onchange = function (html) {
|
||||||
|
// html 即变化之后的内容
|
||||||
|
$("#" + relName).val(html);
|
||||||
|
}
|
||||||
|
editor.customConfig.uploadImgShowBase64 = true;
|
||||||
|
editor.create();
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
$("[id^='picImage']").each(function (index, ele) {
|
||||||
|
var relName = $(ele).attr("id").substring(8);
|
||||||
|
layui.use('upload', function () {
|
||||||
|
var upload = layui.upload;
|
||||||
|
//执行实例
|
||||||
|
var uploadInst = upload.render({
|
||||||
|
elem: '#picImage' + relName, //绑定元素
|
||||||
|
url: '/common/sysFile/upload', //上传接口
|
||||||
|
size: 1000,
|
||||||
|
accept: 'file',
|
||||||
|
done: function (r) {
|
||||||
|
$("#picImage" + relName).attr("src", r.fileName);
|
||||||
|
$("#" + relName).val(r.fileName);
|
||||||
|
},
|
||||||
|
error: function (r) {
|
||||||
|
layer.msg(r.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$().ready(function () {
|
||||||
|
validateRule();
|
||||||
|
});
|
||||||
|
|
||||||
|
$.validator.setDefaults({
|
||||||
|
submitHandler: function () {
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
function save() {
|
||||||
|
$.ajax({
|
||||||
|
cache: true,
|
||||||
|
type: "POST",
|
||||||
|
url: "/novel/author/save",
|
||||||
|
data: $('#signupForm').serialize(),// 你的formid
|
||||||
|
async: false,
|
||||||
|
error: function (request) {
|
||||||
|
parent.layer.alert("Connection error");
|
||||||
|
},
|
||||||
|
success: function (data) {
|
||||||
|
if (data.code == 0) {
|
||||||
|
parent.layer.msg("操作成功");
|
||||||
|
parent.reLoad();
|
||||||
|
var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
|
||||||
|
parent.layer.close(index);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
parent.layer.alert(data.msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
function validateRule() {
|
||||||
|
var icon = "<i class='fa fa-times-circle'></i> ";
|
||||||
|
$("#signupForm").validate({
|
||||||
|
ignore: "",
|
||||||
|
rules: {
|
||||||
|
},
|
||||||
|
messages: {
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
@ -0,0 +1,244 @@
|
|||||||
|
var prefix = "/novel/author"
|
||||||
|
$(function () {
|
||||||
|
load();
|
||||||
|
});
|
||||||
|
|
||||||
|
function load() {
|
||||||
|
$('#exampleTable')
|
||||||
|
.bootstrapTable(
|
||||||
|
{
|
||||||
|
method: 'get', // 服务器数据的请求方式 get or post
|
||||||
|
url: prefix + "/list", // 服务器数据的加载地址
|
||||||
|
// showRefresh : true,
|
||||||
|
// showToggle : true,
|
||||||
|
// showColumns : true,
|
||||||
|
iconSize: 'outline',
|
||||||
|
toolbar: '#exampleToolbar',
|
||||||
|
striped: true, // 设置为true会有隔行变色效果
|
||||||
|
dataType: "json", // 服务器返回的数据类型
|
||||||
|
pagination: true, // 设置为true会在底部显示分页条
|
||||||
|
// queryParamsType : "limit",
|
||||||
|
// //设置为limit则会发送符合RESTFull格式的参数
|
||||||
|
singleSelect: false, // 设置为true将禁止多选
|
||||||
|
// contentType : "application/x-www-form-urlencoded",
|
||||||
|
// //发送到服务器的数据编码类型
|
||||||
|
pageSize: 10, // 如果设置了分页,每页数据条数
|
||||||
|
pageNumber: 1, // 如果设置了分布,首页页码
|
||||||
|
//search : true, // 是否显示搜索框
|
||||||
|
showColumns: false, // 是否显示内容下拉框(选择显示的列)
|
||||||
|
sidePagination: "server", // 设置在哪里进行分页,可选值为"client" 或者 "server"
|
||||||
|
queryParams: function (params) {
|
||||||
|
//说明:传入后台的参数包括offset开始索引,limit步长,sort排序列,order:desc或者,以及所有列的键值对
|
||||||
|
var queryParams = getFormJson("searchForm");
|
||||||
|
queryParams.limit = params.limit;
|
||||||
|
queryParams.offset = params.offset;
|
||||||
|
return queryParams;
|
||||||
|
},
|
||||||
|
// //请求服务器数据时,你可以通过重写参数的方式添加一些额外的参数,例如 toolbar 中的参数 如果
|
||||||
|
// queryParamsType = 'limit' ,返回参数必须包含
|
||||||
|
// limit, offset, search, sort, order 否则, 需要包含:
|
||||||
|
// pageSize, pageNumber, searchText, sortName,
|
||||||
|
// sortOrder.
|
||||||
|
// 返回false将会终止请求
|
||||||
|
responseHandler: function (rs) {
|
||||||
|
|
||||||
|
if (rs.code == 0) {
|
||||||
|
return rs.data;
|
||||||
|
} else {
|
||||||
|
parent.layer.alert(rs.msg)
|
||||||
|
return {total: 0, rows: []};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
checkbox: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '序号',
|
||||||
|
formatter: function () {
|
||||||
|
return arguments[2] + 1;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'inviteCode',
|
||||||
|
title: '邀请码'
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'penName',
|
||||||
|
title: '笔名'
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'telPhone',
|
||||||
|
title: '手机号码'
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'chatAccount',
|
||||||
|
title: 'QQ或微信账号'
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'email',
|
||||||
|
title: '电子邮箱'
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'workDirection',
|
||||||
|
title: '作品方向',
|
||||||
|
formatter: function (value, row, index) {
|
||||||
|
return formatDict("work_direction", value);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'createTime',
|
||||||
|
title: '入驻时间'
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'status',
|
||||||
|
title: '状态',
|
||||||
|
formatter: function (value, row, index) {
|
||||||
|
return value == 1 ? '封禁' : '正常';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
field: 'id',
|
||||||
|
align: 'center',
|
||||||
|
formatter: function (value, row, index) {
|
||||||
|
if(row.status==1) {
|
||||||
|
var e = '<a class="btn btn-primary btn-sm ' + s_edit_h + '" href="#" mce_href="#" title="恢复正常" onclick="edit(\''
|
||||||
|
+ row.id
|
||||||
|
+ '\',0)"><i >恢复正常</i></a> ';
|
||||||
|
}else{
|
||||||
|
var e = '<a class="btn btn-primary btn-sm ' + s_edit_h + '" href="#" mce_href="#" title="封禁" onclick="edit(\''
|
||||||
|
+ row.id
|
||||||
|
+ '\',1)"><i >封禁</i></a> ';
|
||||||
|
}
|
||||||
|
return e ;
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function reLoad() {
|
||||||
|
$('#exampleTable').bootstrapTable('refresh');
|
||||||
|
}
|
||||||
|
|
||||||
|
function add() {
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: '增加',
|
||||||
|
maxmin: true,
|
||||||
|
shadeClose: false, // 点击遮罩关闭层
|
||||||
|
area: ['800px', '520px'],
|
||||||
|
content: prefix + '/add' // iframe的url
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function detail(id) {
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: '详情',
|
||||||
|
maxmin: true,
|
||||||
|
shadeClose: false, // 点击遮罩关闭层
|
||||||
|
area: ['800px', '520px'],
|
||||||
|
content: prefix + '/detail/' + id // iframe的url
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function edit(id,status) {
|
||||||
|
$.ajax({
|
||||||
|
cache: true,
|
||||||
|
type: "POST",
|
||||||
|
url: "/novel/author/update",
|
||||||
|
data: {'id':id,'status':status},// 你的formid
|
||||||
|
async: false,
|
||||||
|
error: function (request) {
|
||||||
|
parent.layer.alert("Connection error");
|
||||||
|
},
|
||||||
|
success: function (data) {
|
||||||
|
if (data.code == 0) {
|
||||||
|
parent.layer.msg("操作成功");
|
||||||
|
reLoad();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
parent.layer.alert(data.msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function remove(id) {
|
||||||
|
layer.confirm('确定要删除选中的记录?', {
|
||||||
|
btn: ['确定', '取消']
|
||||||
|
}, function () {
|
||||||
|
$.ajax({
|
||||||
|
url: prefix + "/remove",
|
||||||
|
type: "post",
|
||||||
|
data: {
|
||||||
|
'id': id
|
||||||
|
},
|
||||||
|
success: function (r) {
|
||||||
|
if (r.code == 0) {
|
||||||
|
layer.msg(r.msg);
|
||||||
|
reLoad();
|
||||||
|
} else {
|
||||||
|
layer.msg(r.msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetPwd(id) {
|
||||||
|
}
|
||||||
|
|
||||||
|
function batchRemove() {
|
||||||
|
var rows = $('#exampleTable').bootstrapTable('getSelections'); // 返回所有选择的行,当没有选择的记录时,返回一个空数组
|
||||||
|
if (rows.length == 0) {
|
||||||
|
layer.msg("请选择要删除的数据");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
layer.confirm("确认要删除选中的'" + rows.length + "'条数据吗?", {
|
||||||
|
btn: ['确定', '取消']
|
||||||
|
// 按钮
|
||||||
|
}, function () {
|
||||||
|
var ids = new Array();
|
||||||
|
// 遍历所有选择的行数据,取每条数据对应的ID
|
||||||
|
$.each(rows, function (i, row) {
|
||||||
|
ids[i] = row['id'];
|
||||||
|
});
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
data: {
|
||||||
|
"ids": ids
|
||||||
|
},
|
||||||
|
url: prefix + '/batchRemove',
|
||||||
|
success: function (r) {
|
||||||
|
if (r.code == 0) {
|
||||||
|
layer.msg(r.msg);
|
||||||
|
reLoad();
|
||||||
|
} else {
|
||||||
|
layer.msg(r.msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, function () {
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
@ -0,0 +1,103 @@
|
|||||||
|
var E = window.wangEditor;
|
||||||
|
$("[id^='contentEditor']").each(function (index, ele) {
|
||||||
|
var relName = $(ele).attr("id").substring(13);
|
||||||
|
var editor = new E('#contentEditor' + relName);
|
||||||
|
// 自定义菜单配置
|
||||||
|
editor.customConfig.menus = [
|
||||||
|
'head', // 标题
|
||||||
|
'bold', // 粗体
|
||||||
|
'fontSize', // 字号
|
||||||
|
'fontName', // 字体
|
||||||
|
'italic', // 斜体
|
||||||
|
'underline', // 下划线
|
||||||
|
'strikeThrough', // 删除线
|
||||||
|
'foreColor', // 文字颜色
|
||||||
|
//'backColor', // 背景颜色
|
||||||
|
//'link', // 插入链接
|
||||||
|
'list', // 列表
|
||||||
|
'justify', // 对齐方式
|
||||||
|
'quote', // 引用
|
||||||
|
'emoticon', // 表情
|
||||||
|
'image', // 插入图片
|
||||||
|
//'table', // 表格
|
||||||
|
//'video', // 插入视频
|
||||||
|
//'code', // 插入代码
|
||||||
|
'undo', // 撤销
|
||||||
|
'redo' // 重复
|
||||||
|
];
|
||||||
|
editor.customConfig.onchange = function (html) {
|
||||||
|
// html 即变化之后的内容
|
||||||
|
$("#" + relName).val(html);
|
||||||
|
}
|
||||||
|
editor.customConfig.uploadImgShowBase64 = true;
|
||||||
|
editor.create();
|
||||||
|
editor.txt.html($("#" + relName).val());
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
$("[id^='picImage']").each(function (index, ele) {
|
||||||
|
var relName = $(ele).attr("id").substring(8);
|
||||||
|
layui.use('upload', function () {
|
||||||
|
var upload = layui.upload;
|
||||||
|
//执行实例
|
||||||
|
var uploadInst = upload.render({
|
||||||
|
elem: '#picImage' + relName, //绑定元素
|
||||||
|
url: '/common/sysFile/upload', //上传接口
|
||||||
|
size: 1000,
|
||||||
|
accept: 'file',
|
||||||
|
done: function (r) {
|
||||||
|
$("#picImage" + relName).attr("src", r.fileName);
|
||||||
|
$("#" + relName).val(r.fileName);
|
||||||
|
},
|
||||||
|
error: function (r) {
|
||||||
|
layer.msg(r.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$().ready(function () {
|
||||||
|
validateRule();
|
||||||
|
});
|
||||||
|
|
||||||
|
$.validator.setDefaults({
|
||||||
|
submitHandler: function () {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
function update() {
|
||||||
|
$.ajax({
|
||||||
|
cache: true,
|
||||||
|
type: "POST",
|
||||||
|
url: "/novel/author/update",
|
||||||
|
data: $('#signupForm').serialize(),// 你的formid
|
||||||
|
async: false,
|
||||||
|
error: function (request) {
|
||||||
|
parent.layer.alert("Connection error");
|
||||||
|
},
|
||||||
|
success: function (data) {
|
||||||
|
if (data.code == 0) {
|
||||||
|
parent.layer.msg("操作成功");
|
||||||
|
parent.reLoad();
|
||||||
|
var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
|
||||||
|
parent.layer.close(index);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
parent.layer.alert(data.msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
function validateRule() {
|
||||||
|
var icon = "<i class='fa fa-times-circle'></i> ";
|
||||||
|
$("#signupForm").validate({
|
||||||
|
ignore: "",
|
||||||
|
rules: {
|
||||||
|
},
|
||||||
|
messages: {
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
@ -0,0 +1,115 @@
|
|||||||
|
var E = window.wangEditor;
|
||||||
|
$("[id^='contentEditor']").each(function (index, ele) {
|
||||||
|
var relName = $(ele).attr("id").substring(13);
|
||||||
|
var editor = new E('#contentEditor' + relName);
|
||||||
|
// 自定义菜单配置
|
||||||
|
editor.customConfig.menus = [
|
||||||
|
'head', // 标题
|
||||||
|
'bold', // 粗体
|
||||||
|
'fontSize', // 字号
|
||||||
|
'fontName', // 字体
|
||||||
|
'italic', // 斜体
|
||||||
|
'underline', // 下划线
|
||||||
|
'strikeThrough', // 删除线
|
||||||
|
'foreColor', // 文字颜色
|
||||||
|
//'backColor', // 背景颜色
|
||||||
|
//'link', // 插入链接
|
||||||
|
'list', // 列表
|
||||||
|
'justify', // 对齐方式
|
||||||
|
'quote', // 引用
|
||||||
|
'emoticon', // 表情
|
||||||
|
'image', // 插入图片
|
||||||
|
//'table', // 表格
|
||||||
|
//'video', // 插入视频
|
||||||
|
//'code', // 插入代码
|
||||||
|
'undo', // 撤销
|
||||||
|
'redo' // 重复
|
||||||
|
];
|
||||||
|
editor.customConfig.onchange = function (html) {
|
||||||
|
// html 即变化之后的内容
|
||||||
|
$("#" + relName).val(html);
|
||||||
|
}
|
||||||
|
editor.customConfig.uploadImgShowBase64 = true;
|
||||||
|
editor.create();
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
$("[id^='picImage']").each(function (index, ele) {
|
||||||
|
var relName = $(ele).attr("id").substring(8);
|
||||||
|
layui.use('upload', function () {
|
||||||
|
var upload = layui.upload;
|
||||||
|
//执行实例
|
||||||
|
var uploadInst = upload.render({
|
||||||
|
elem: '#picImage' + relName, //绑定元素
|
||||||
|
url: '/common/sysFile/upload', //上传接口
|
||||||
|
size: 1000,
|
||||||
|
accept: 'file',
|
||||||
|
done: function (r) {
|
||||||
|
$("#picImage" + relName).attr("src", r.fileName);
|
||||||
|
$("#" + relName).val(r.fileName);
|
||||||
|
},
|
||||||
|
error: function (r) {
|
||||||
|
layer.msg(r.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$().ready(function () {
|
||||||
|
validateRule();
|
||||||
|
});
|
||||||
|
|
||||||
|
$.validator.setDefaults({
|
||||||
|
submitHandler: function () {
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
function save() {
|
||||||
|
$.ajax({
|
||||||
|
cache: true,
|
||||||
|
type: "POST",
|
||||||
|
url: "/novel/authorCode/save",
|
||||||
|
data: $('#signupForm').serialize(),// 你的formid
|
||||||
|
async: false,
|
||||||
|
error: function (request) {
|
||||||
|
parent.layer.alert("Connection error");
|
||||||
|
},
|
||||||
|
success: function (data) {
|
||||||
|
if (data.code == 0) {
|
||||||
|
parent.layer.msg("操作成功");
|
||||||
|
parent.reLoad();
|
||||||
|
var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
|
||||||
|
parent.layer.close(index);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
parent.layer.alert(data.msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
function validateRule() {
|
||||||
|
var icon = "<i class='fa fa-times-circle'></i> ";
|
||||||
|
$("#signupForm").validate({
|
||||||
|
ignore: "",
|
||||||
|
rules: {
|
||||||
|
inviteCode: {
|
||||||
|
required: true
|
||||||
|
}, validityTime: {
|
||||||
|
required: true
|
||||||
|
}, },
|
||||||
|
messages: {
|
||||||
|
inviteCode: {
|
||||||
|
required: icon + "请选择邀请码"
|
||||||
|
}, validityTime: {
|
||||||
|
required: icon + "请选择有效时间"
|
||||||
|
}, }
|
||||||
|
})
|
||||||
|
}
|
@ -0,0 +1,212 @@
|
|||||||
|
var prefix = "/novel/authorCode"
|
||||||
|
$(function () {
|
||||||
|
load();
|
||||||
|
});
|
||||||
|
|
||||||
|
function load() {
|
||||||
|
$('#exampleTable')
|
||||||
|
.bootstrapTable(
|
||||||
|
{
|
||||||
|
method: 'get', // 服务器数据的请求方式 get or post
|
||||||
|
url: prefix + "/list", // 服务器数据的加载地址
|
||||||
|
// showRefresh : true,
|
||||||
|
// showToggle : true,
|
||||||
|
// showColumns : true,
|
||||||
|
iconSize: 'outline',
|
||||||
|
toolbar: '#exampleToolbar',
|
||||||
|
striped: true, // 设置为true会有隔行变色效果
|
||||||
|
dataType: "json", // 服务器返回的数据类型
|
||||||
|
pagination: true, // 设置为true会在底部显示分页条
|
||||||
|
// queryParamsType : "limit",
|
||||||
|
// //设置为limit则会发送符合RESTFull格式的参数
|
||||||
|
singleSelect: false, // 设置为true将禁止多选
|
||||||
|
// contentType : "application/x-www-form-urlencoded",
|
||||||
|
// //发送到服务器的数据编码类型
|
||||||
|
pageSize: 10, // 如果设置了分页,每页数据条数
|
||||||
|
pageNumber: 1, // 如果设置了分布,首页页码
|
||||||
|
//search : true, // 是否显示搜索框
|
||||||
|
showColumns: false, // 是否显示内容下拉框(选择显示的列)
|
||||||
|
sidePagination: "server", // 设置在哪里进行分页,可选值为"client" 或者 "server"
|
||||||
|
queryParams: function (params) {
|
||||||
|
//说明:传入后台的参数包括offset开始索引,limit步长,sort排序列,order:desc或者,以及所有列的键值对
|
||||||
|
var queryParams = getFormJson("searchForm");
|
||||||
|
queryParams.limit = params.limit;
|
||||||
|
queryParams.offset = params.offset;
|
||||||
|
return queryParams;
|
||||||
|
},
|
||||||
|
// //请求服务器数据时,你可以通过重写参数的方式添加一些额外的参数,例如 toolbar 中的参数 如果
|
||||||
|
// queryParamsType = 'limit' ,返回参数必须包含
|
||||||
|
// limit, offset, search, sort, order 否则, 需要包含:
|
||||||
|
// pageSize, pageNumber, searchText, sortName,
|
||||||
|
// sortOrder.
|
||||||
|
// 返回false将会终止请求
|
||||||
|
responseHandler: function (rs) {
|
||||||
|
|
||||||
|
if (rs.code == 0) {
|
||||||
|
return rs.data;
|
||||||
|
} else {
|
||||||
|
parent.layer.alert(rs.msg)
|
||||||
|
return {total: 0, rows: []};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
checkbox: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '序号',
|
||||||
|
formatter: function () {
|
||||||
|
return arguments[2] + 1;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'inviteCode',
|
||||||
|
title: '邀请码'
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'validityTime',
|
||||||
|
title: '有效时间'
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'isUse',
|
||||||
|
title: '是否使用过',
|
||||||
|
formatter: function (value, row, index) {
|
||||||
|
return value == 1 ? '使用过' : '未使用';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'createTime',
|
||||||
|
title: '创建时间'
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/* {
|
||||||
|
field: 'createUserId',
|
||||||
|
title: '创建人ID'
|
||||||
|
},*/
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
field: 'id',
|
||||||
|
align: 'center',
|
||||||
|
formatter: function (value, row, index) {
|
||||||
|
/* var d = '<a class="btn btn-primary btn-sm ' + s_detail_h + '" href="#" mce_href="#" title="详情" onclick="detail(\''
|
||||||
|
+ row.id
|
||||||
|
+ '\')"><i class="fa fa-file"></i></a> ';*/
|
||||||
|
/* var e = '<a class="btn btn-primary btn-sm ' + s_edit_h + '" href="#" mce_href="#" title="编辑" onclick="edit(\''
|
||||||
|
+ row.id
|
||||||
|
+ '\')"><i class="fa fa-edit"></i></a> ';*/
|
||||||
|
var r = '<a class="btn btn-warning btn-sm ' + s_remove_h + '" href="#" title="删除" mce_href="#" onclick="remove(\''
|
||||||
|
+ row.id
|
||||||
|
+ '\')"><i class="fa fa-remove"></i></a> ';
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function reLoad() {
|
||||||
|
$('#exampleTable').bootstrapTable('refresh');
|
||||||
|
}
|
||||||
|
|
||||||
|
function add() {
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: '增加',
|
||||||
|
maxmin: true,
|
||||||
|
shadeClose: false, // 点击遮罩关闭层
|
||||||
|
area: ['800px', '520px'],
|
||||||
|
content: prefix + '/add' // iframe的url
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function detail(id) {
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: '详情',
|
||||||
|
maxmin: true,
|
||||||
|
shadeClose: false, // 点击遮罩关闭层
|
||||||
|
area: ['800px', '520px'],
|
||||||
|
content: prefix + '/detail/' + id // iframe的url
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function edit(id) {
|
||||||
|
layer.open({
|
||||||
|
type: 2,
|
||||||
|
title: '编辑',
|
||||||
|
maxmin: true,
|
||||||
|
shadeClose: false, // 点击遮罩关闭层
|
||||||
|
area: ['800px', '520px'],
|
||||||
|
content: prefix + '/edit/' + id // iframe的url
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function remove(id) {
|
||||||
|
layer.confirm('确定要删除选中的记录?', {
|
||||||
|
btn: ['确定', '取消']
|
||||||
|
}, function () {
|
||||||
|
$.ajax({
|
||||||
|
url: prefix + "/remove",
|
||||||
|
type: "post",
|
||||||
|
data: {
|
||||||
|
'id': id
|
||||||
|
},
|
||||||
|
success: function (r) {
|
||||||
|
if (r.code == 0) {
|
||||||
|
layer.msg(r.msg);
|
||||||
|
reLoad();
|
||||||
|
} else {
|
||||||
|
layer.msg(r.msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetPwd(id) {
|
||||||
|
}
|
||||||
|
|
||||||
|
function batchRemove() {
|
||||||
|
var rows = $('#exampleTable').bootstrapTable('getSelections'); // 返回所有选择的行,当没有选择的记录时,返回一个空数组
|
||||||
|
if (rows.length == 0) {
|
||||||
|
layer.msg("请选择要删除的数据");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
layer.confirm("确认要删除选中的'" + rows.length + "'条数据吗?", {
|
||||||
|
btn: ['确定', '取消']
|
||||||
|
// 按钮
|
||||||
|
}, function () {
|
||||||
|
var ids = new Array();
|
||||||
|
// 遍历所有选择的行数据,取每条数据对应的ID
|
||||||
|
$.each(rows, function (i, row) {
|
||||||
|
ids[i] = row['id'];
|
||||||
|
});
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
data: {
|
||||||
|
"ids": ids
|
||||||
|
},
|
||||||
|
url: prefix + '/batchRemove',
|
||||||
|
success: function (r) {
|
||||||
|
if (r.code == 0) {
|
||||||
|
layer.msg(r.msg);
|
||||||
|
reLoad();
|
||||||
|
} else {
|
||||||
|
layer.msg(r.msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, function () {
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
@ -0,0 +1,115 @@
|
|||||||
|
var E = window.wangEditor;
|
||||||
|
$("[id^='contentEditor']").each(function (index, ele) {
|
||||||
|
var relName = $(ele).attr("id").substring(13);
|
||||||
|
var editor = new E('#contentEditor' + relName);
|
||||||
|
// 自定义菜单配置
|
||||||
|
editor.customConfig.menus = [
|
||||||
|
'head', // 标题
|
||||||
|
'bold', // 粗体
|
||||||
|
'fontSize', // 字号
|
||||||
|
'fontName', // 字体
|
||||||
|
'italic', // 斜体
|
||||||
|
'underline', // 下划线
|
||||||
|
'strikeThrough', // 删除线
|
||||||
|
'foreColor', // 文字颜色
|
||||||
|
//'backColor', // 背景颜色
|
||||||
|
//'link', // 插入链接
|
||||||
|
'list', // 列表
|
||||||
|
'justify', // 对齐方式
|
||||||
|
'quote', // 引用
|
||||||
|
'emoticon', // 表情
|
||||||
|
'image', // 插入图片
|
||||||
|
//'table', // 表格
|
||||||
|
//'video', // 插入视频
|
||||||
|
//'code', // 插入代码
|
||||||
|
'undo', // 撤销
|
||||||
|
'redo' // 重复
|
||||||
|
];
|
||||||
|
editor.customConfig.onchange = function (html) {
|
||||||
|
// html 即变化之后的内容
|
||||||
|
$("#" + relName).val(html);
|
||||||
|
}
|
||||||
|
editor.customConfig.uploadImgShowBase64 = true;
|
||||||
|
editor.create();
|
||||||
|
editor.txt.html($("#" + relName).val());
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
$("[id^='picImage']").each(function (index, ele) {
|
||||||
|
var relName = $(ele).attr("id").substring(8);
|
||||||
|
layui.use('upload', function () {
|
||||||
|
var upload = layui.upload;
|
||||||
|
//执行实例
|
||||||
|
var uploadInst = upload.render({
|
||||||
|
elem: '#picImage' + relName, //绑定元素
|
||||||
|
url: '/common/sysFile/upload', //上传接口
|
||||||
|
size: 1000,
|
||||||
|
accept: 'file',
|
||||||
|
done: function (r) {
|
||||||
|
$("#picImage" + relName).attr("src", r.fileName);
|
||||||
|
$("#" + relName).val(r.fileName);
|
||||||
|
},
|
||||||
|
error: function (r) {
|
||||||
|
layer.msg(r.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$().ready(function () {
|
||||||
|
validateRule();
|
||||||
|
});
|
||||||
|
|
||||||
|
$.validator.setDefaults({
|
||||||
|
submitHandler: function () {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
function update() {
|
||||||
|
$.ajax({
|
||||||
|
cache: true,
|
||||||
|
type: "POST",
|
||||||
|
url: "/novel/authorCode/update",
|
||||||
|
data: $('#signupForm').serialize(),// 你的formid
|
||||||
|
async: false,
|
||||||
|
error: function (request) {
|
||||||
|
parent.layer.alert("Connection error");
|
||||||
|
},
|
||||||
|
success: function (data) {
|
||||||
|
if (data.code == 0) {
|
||||||
|
parent.layer.msg("操作成功");
|
||||||
|
parent.reLoad();
|
||||||
|
var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
|
||||||
|
parent.layer.close(index);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
parent.layer.alert(data.msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
function validateRule() {
|
||||||
|
var icon = "<i class='fa fa-times-circle'></i> ";
|
||||||
|
$("#signupForm").validate({
|
||||||
|
ignore: "",
|
||||||
|
rules: {
|
||||||
|
inviteCode:
|
||||||
|
{
|
||||||
|
required: true
|
||||||
|
}, validityTime:
|
||||||
|
{
|
||||||
|
required: true
|
||||||
|
}, },
|
||||||
|
messages: {
|
||||||
|
inviteCode:
|
||||||
|
{
|
||||||
|
required: icon + "请选择邀请码"
|
||||||
|
}, validityTime:
|
||||||
|
{
|
||||||
|
required: icon + "请选择有效时间"
|
||||||
|
}, }
|
||||||
|
})
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,18 @@
|
|||||||
|
-- 菜单SQL
|
||||||
|
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
|
||||||
|
VALUES ('1', '作者表', 'novel/author', 'novel:author:author', '1', 'fa', '6');
|
||||||
|
|
||||||
|
-- 按钮父菜单ID
|
||||||
|
set @parentId = @@identity;
|
||||||
|
|
||||||
|
-- 菜单对应按钮SQL
|
||||||
|
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
|
||||||
|
SELECT @parentId, '查看', null, 'novel:author:detail', '2', null, '6';
|
||||||
|
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
|
||||||
|
SELECT @parentId, '新增', null, 'novel:author:add', '2', null, '6';
|
||||||
|
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
|
||||||
|
SELECT @parentId, '修改', null, 'novel:author:edit', '2', null, '6';
|
||||||
|
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
|
||||||
|
SELECT @parentId, '删除', null, 'novel:author:remove', '2', null, '6';
|
||||||
|
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
|
||||||
|
SELECT @parentId, '批量删除', null, 'novel:author:batchRemove', '2', null, '6';
|
@ -0,0 +1,18 @@
|
|||||||
|
-- 菜单SQL
|
||||||
|
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
|
||||||
|
VALUES ('1', '作家邀请码表', 'novel/authorCode', 'novel:authorCode:authorCode', '1', 'fa', '6');
|
||||||
|
|
||||||
|
-- 按钮父菜单ID
|
||||||
|
set @parentId = @@identity;
|
||||||
|
|
||||||
|
-- 菜单对应按钮SQL
|
||||||
|
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
|
||||||
|
SELECT @parentId, '查看', null, 'novel:authorCode:detail', '2', null, '6';
|
||||||
|
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
|
||||||
|
SELECT @parentId, '新增', null, 'novel:authorCode:add', '2', null, '6';
|
||||||
|
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
|
||||||
|
SELECT @parentId, '修改', null, 'novel:authorCode:edit', '2', null, '6';
|
||||||
|
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
|
||||||
|
SELECT @parentId, '删除', null, 'novel:authorCode:remove', '2', null, '6';
|
||||||
|
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
|
||||||
|
SELECT @parentId, '批量删除', null, 'novel:authorCode:batchRemove', '2', null, '6';
|
114
novel-admin/src/main/resources/templates/novel/author/add.html
Normal file
114
novel-admin/src/main/resources/templates/novel/author/add.html
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<head th:include="include :: header"></head>
|
||||||
|
<body class="gray-bg">
|
||||||
|
<div class="wrapper wrapper-content ">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div class="ibox float-e-margins">
|
||||||
|
<div class="ibox-content">
|
||||||
|
<form class="form-horizontal m-t" id="signupForm">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">用户ID:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="userId" name="userId"
|
||||||
|
class="form-control"
|
||||||
|
type="text">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">邀请码:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="inviteCode" name="inviteCode"
|
||||||
|
class="form-control"
|
||||||
|
type="text">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">笔名:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="penName" name="penName"
|
||||||
|
class="form-control"
|
||||||
|
type="text">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">手机号码:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="telPhone" name="telPhone"
|
||||||
|
class="form-control"
|
||||||
|
type="text">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">QQ或微信账号:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="chatAccount" name="chatAccount"
|
||||||
|
class="form-control"
|
||||||
|
type="text">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">电子邮箱:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="email" name="email"
|
||||||
|
class="form-control"
|
||||||
|
type="text">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">作品方向,0:男频,1:女频:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
|
||||||
|
<select data-placeholder="--选择--" id="workDirection"
|
||||||
|
name="workDirection"
|
||||||
|
class="form-control chosen-select" tabindex="2"
|
||||||
|
dict-type="work_direction">
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">入驻时间:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input type="text" class="laydate-icon layer-date form-control"
|
||||||
|
id="createTime"
|
||||||
|
name="createTime"
|
||||||
|
onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"
|
||||||
|
style="background-color: #fff;" readonly="readonly"/>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">0:正常,1:封禁:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="status" name="status"
|
||||||
|
class="form-control"
|
||||||
|
type="text">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-8 col-sm-offset-3">
|
||||||
|
<button type="submit" class="btn btn-primary">提交</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div th:include="include::footer"></div>
|
||||||
|
<script type="text/javascript" src="/wangEditor/release/wangEditor.js"></script>
|
||||||
|
<script type="text/javascript" src="/js/appjs/novel/author/add.js">
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,57 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<head th:include="include :: header"></head>
|
||||||
|
<body class="gray-bg">
|
||||||
|
<div class="wrapper wrapper-content ">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div class="ibox">
|
||||||
|
<div class="ibox-body">
|
||||||
|
<div class="fixed-table-toolbar">
|
||||||
|
<div class="columns pull-left">
|
||||||
|
</div>
|
||||||
|
<div class="columns pull-right">
|
||||||
|
<button class="btn btn-success" onclick="reLoad()">查询</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form id="searchForm">
|
||||||
|
<div class="columns pull-right col-md-2">
|
||||||
|
<input id="penName" name="penName" type="text" class="form-control"
|
||||||
|
placeholder="笔名">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<table id="exampleTable" data-mobile-responsive="true">
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--shiro控制bootstraptable行内按钮看见性 -->
|
||||||
|
<div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var s_detail_h = 'hidden';
|
||||||
|
var s_edit_h = 'hidden';
|
||||||
|
var s_remove_h = 'hidden';
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
<div shiro:hasPermission="test:order:detail">
|
||||||
|
<script type="text/javascript">
|
||||||
|
s_detail_h = '';
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
<div shiro:hasPermission="novel:author:edit">
|
||||||
|
<script type="text/javascript">
|
||||||
|
s_edit_h = '';
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
<div shiro:hasPermission="novel:author:remove">
|
||||||
|
<script type="text/javascript">
|
||||||
|
var s_remove_h = '';
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
<div th:include="include :: footer"></div>
|
||||||
|
<script type="text/javascript" src="/js/appjs/novel/author/author.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,111 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<head th:include="include :: header"></head>
|
||||||
|
<body class="gray-bg">
|
||||||
|
<div class="wrapper wrapper-content ">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div class="ibox float-e-margins">
|
||||||
|
<div class="ibox-content">
|
||||||
|
<form class="form-horizontal m-t" id="signupForm">
|
||||||
|
<input id="id" name="id" th:value="${author.id}"
|
||||||
|
type="hidden">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">用户ID:</label>
|
||||||
|
|
||||||
|
<div style="padding-top:8px" class="col-sm-8"
|
||||||
|
th:text="${author.userId}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">邀请码:</label>
|
||||||
|
|
||||||
|
<div style="padding-top:8px" class="col-sm-8"
|
||||||
|
th:text="${author.inviteCode}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">笔名:</label>
|
||||||
|
|
||||||
|
<div style="padding-top:8px" class="col-sm-8"
|
||||||
|
th:text="${author.penName}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">手机号码:</label>
|
||||||
|
|
||||||
|
<div style="padding-top:8px" class="col-sm-8"
|
||||||
|
th:text="${author.telPhone}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">QQ或微信账号:</label>
|
||||||
|
|
||||||
|
<div style="padding-top:8px" class="col-sm-8"
|
||||||
|
th:text="${author.chatAccount}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">电子邮箱:</label>
|
||||||
|
|
||||||
|
<div style="padding-top:8px" class="col-sm-8"
|
||||||
|
th:text="${author.email}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">作品方向,0:男频,1:女频:</label>
|
||||||
|
|
||||||
|
<div style="padding-top:8px" class="col-sm-8 dict-type" dict-type="work_direction"
|
||||||
|
th:attr="dict-value=${author.workDirection}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">入驻时间:</label>
|
||||||
|
|
||||||
|
<div style="padding-top:8px" class="col-sm-8"
|
||||||
|
th:text="${author.createTime}==null?null:${#dates.format(author.createTime,'yyyy-MM-dd HH:mm:ss')}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">0:正常,1:封禁:</label>
|
||||||
|
|
||||||
|
<div style="padding-top:8px" class="col-sm-8"
|
||||||
|
th:text="${author.status}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div th:include="include::footer"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
116
novel-admin/src/main/resources/templates/novel/author/edit.html
Normal file
116
novel-admin/src/main/resources/templates/novel/author/edit.html
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<head th:include="include :: header"></head>
|
||||||
|
<body class="gray-bg">
|
||||||
|
<div class="wrapper wrapper-content ">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div class="ibox float-e-margins">
|
||||||
|
<div class="ibox-content">
|
||||||
|
<form class="form-horizontal m-t" id="signupForm">
|
||||||
|
<input id="id" name="id" th:value="${author.id}"
|
||||||
|
type="hidden">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">用户ID:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="userId" name="userId"
|
||||||
|
th:value="${author.userId}"
|
||||||
|
class="form-control"
|
||||||
|
type="text">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">邀请码:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="inviteCode" name="inviteCode"
|
||||||
|
th:value="${author.inviteCode}"
|
||||||
|
class="form-control"
|
||||||
|
type="text">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">笔名:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="penName" name="penName"
|
||||||
|
th:value="${author.penName}"
|
||||||
|
class="form-control"
|
||||||
|
type="text">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">手机号码:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="telPhone" name="telPhone"
|
||||||
|
th:value="${author.telPhone}"
|
||||||
|
class="form-control"
|
||||||
|
type="text">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">QQ或微信账号:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="chatAccount" name="chatAccount"
|
||||||
|
th:value="${author.chatAccount}"
|
||||||
|
class="form-control"
|
||||||
|
type="text">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">电子邮箱:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="email" name="email"
|
||||||
|
th:value="${author.email}"
|
||||||
|
class="form-control"
|
||||||
|
type="text">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">作品方向,0:男频,1:女频:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
|
||||||
|
<select data-placeholder="--选择--" id="workDirection"
|
||||||
|
name="workDirection"
|
||||||
|
class="form-control chosen-select" tabindex="2"
|
||||||
|
dict-type="work_direction"
|
||||||
|
th:attr="dict-value=${author.workDirection}" >
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">入驻时间:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input type="text" class="laydate-icon layer-date form-control"
|
||||||
|
id="createTime"
|
||||||
|
name="createTime"
|
||||||
|
th:value="${author.createTime}==null?null:${#dates.format(author.createTime,'yyyy-MM-dd HH:mm:ss')}"
|
||||||
|
onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"
|
||||||
|
style="background-color: #fff;" readonly="readonly"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">0:正常,1:封禁:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="status" name="status"
|
||||||
|
th:value="${author.status}"
|
||||||
|
class="form-control"
|
||||||
|
type="text">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-8 col-sm-offset-3">
|
||||||
|
<button type="submit" class="btn btn-primary">提交</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div th:include="include::footer"></div>
|
||||||
|
<script type="text/javascript" src="/wangEditor/release/wangEditor.js"></script>
|
||||||
|
<script type="text/javascript" src="/js/appjs/novel/author/edit.js">
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,48 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<head th:include="include :: header"></head>
|
||||||
|
<body class="gray-bg">
|
||||||
|
<div class="wrapper wrapper-content ">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div class="ibox float-e-margins">
|
||||||
|
<div class="ibox-content">
|
||||||
|
<form class="form-horizontal m-t" id="signupForm">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">邀请码:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="inviteCode" name="inviteCode"
|
||||||
|
class="form-control"
|
||||||
|
type="text">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">有效时间:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input type="text" class="laydate-icon layer-date form-control"
|
||||||
|
id="validityTime"
|
||||||
|
name="validityTime"
|
||||||
|
onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"
|
||||||
|
style="background-color: #fff;" readonly="readonly"/>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-8 col-sm-offset-3">
|
||||||
|
<button type="submit" class="btn btn-primary">提交</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div th:include="include::footer"></div>
|
||||||
|
<script type="text/javascript" src="/wangEditor/release/wangEditor.js"></script>
|
||||||
|
<script type="text/javascript" src="/js/appjs/novel/authorCode/add.js">
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,66 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<head th:include="include :: header"></head>
|
||||||
|
<body class="gray-bg">
|
||||||
|
<div class="wrapper wrapper-content ">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div class="ibox">
|
||||||
|
<div class="ibox-body">
|
||||||
|
<div class="fixed-table-toolbar">
|
||||||
|
<div class="columns pull-left">
|
||||||
|
<button shiro:hasPermission="novel:authorCode:add" type="button"
|
||||||
|
class="btn btn-primary" onclick="add()">
|
||||||
|
<i class="fa fa-plus" aria-hidden="true"></i>添加
|
||||||
|
</button>
|
||||||
|
<button shiro:hasPermission="novel:authorCode:batchRemove" type="button"
|
||||||
|
class="btn btn-danger"
|
||||||
|
onclick="batchRemove()">
|
||||||
|
<i class="fa fa-trash" aria-hidden="true"></i>删除
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="columns pull-right">
|
||||||
|
<button class="btn btn-success" onclick="reLoad()">查询</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form id="searchForm">
|
||||||
|
<div class="columns pull-right col-md-2">
|
||||||
|
<input id="inviteCode" name="inviteCode" type="text" class="form-control"
|
||||||
|
placeholder="邀请码">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<table id="exampleTable" data-mobile-responsive="true">
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--shiro控制bootstraptable行内按钮看见性 -->
|
||||||
|
<div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var s_detail_h = 'hidden';
|
||||||
|
var s_edit_h = 'hidden';
|
||||||
|
var s_remove_h = 'hidden';
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
<div shiro:hasPermission="test:order:detail">
|
||||||
|
<script type="text/javascript">
|
||||||
|
s_detail_h = '';
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
<div shiro:hasPermission="novel:authorCode:edit">
|
||||||
|
<script type="text/javascript">
|
||||||
|
s_edit_h = '';
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
<div shiro:hasPermission="novel:authorCode:remove">
|
||||||
|
<script type="text/javascript">
|
||||||
|
var s_remove_h = '';
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
<div th:include="include :: footer"></div>
|
||||||
|
<script type="text/javascript" src="/js/appjs/novel/authorCode/authorCode.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,70 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<head th:include="include :: header"></head>
|
||||||
|
<body class="gray-bg">
|
||||||
|
<div class="wrapper wrapper-content ">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div class="ibox float-e-margins">
|
||||||
|
<div class="ibox-content">
|
||||||
|
<form class="form-horizontal m-t" id="signupForm">
|
||||||
|
<input id="id" name="id" th:value="${authorCode.id}"
|
||||||
|
type="hidden">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">邀请码:</label>
|
||||||
|
|
||||||
|
<div style="padding-top:8px" class="col-sm-8"
|
||||||
|
th:text="${authorCode.inviteCode}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">有效时间:</label>
|
||||||
|
|
||||||
|
<div style="padding-top:8px" class="col-sm-8"
|
||||||
|
th:text="${authorCode.validityTime}==null?null:${#dates.format(authorCode.validityTime,'yyyy-MM-dd HH:mm:ss')}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">是否使用过,0:未使用,1:使用过:</label>
|
||||||
|
|
||||||
|
<div style="padding-top:8px" class="col-sm-8"
|
||||||
|
th:text="${authorCode.isUse}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">创建时间:</label>
|
||||||
|
|
||||||
|
<div style="padding-top:8px" class="col-sm-8"
|
||||||
|
th:text="${authorCode.createTime}==null?null:${#dates.format(authorCode.createTime,'yyyy-MM-dd HH:mm:ss')}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">创建人ID:</label>
|
||||||
|
|
||||||
|
<div style="padding-top:8px" class="col-sm-8"
|
||||||
|
th:text="${authorCode.createUserId}">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div th:include="include::footer"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,79 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<head th:include="include :: header"></head>
|
||||||
|
<body class="gray-bg">
|
||||||
|
<div class="wrapper wrapper-content ">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div class="ibox float-e-margins">
|
||||||
|
<div class="ibox-content">
|
||||||
|
<form class="form-horizontal m-t" id="signupForm">
|
||||||
|
<input id="id" name="id" th:value="${authorCode.id}"
|
||||||
|
type="hidden">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">邀请码:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="inviteCode" name="inviteCode"
|
||||||
|
th:value="${authorCode.inviteCode}"
|
||||||
|
class="form-control"
|
||||||
|
type="text">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">有效时间:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input type="text" class="laydate-icon layer-date form-control"
|
||||||
|
id="validityTime"
|
||||||
|
name="validityTime"
|
||||||
|
th:value="${authorCode.validityTime}==null?null:${#dates.format(authorCode.validityTime,'yyyy-MM-dd HH:mm:ss')}"
|
||||||
|
onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"
|
||||||
|
style="background-color: #fff;" readonly="readonly"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">是否使用过,0:未使用,1:使用过:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="isUse" name="isUse"
|
||||||
|
th:value="${authorCode.isUse}"
|
||||||
|
class="form-control"
|
||||||
|
type="text">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">创建时间:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input type="text" class="laydate-icon layer-date form-control"
|
||||||
|
id="createTime"
|
||||||
|
name="createTime"
|
||||||
|
th:value="${authorCode.createTime}==null?null:${#dates.format(authorCode.createTime,'yyyy-MM-dd HH:mm:ss')}"
|
||||||
|
onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"
|
||||||
|
style="background-color: #fff;" readonly="readonly"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-3 control-label">创建人ID:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input id="createUserId" name="createUserId"
|
||||||
|
th:value="${authorCode.createUserId}"
|
||||||
|
class="form-control"
|
||||||
|
type="text">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-8 col-sm-offset-3">
|
||||||
|
<button type="submit" class="btn btn-primary">提交</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div th:include="include::footer"></div>
|
||||||
|
<script type="text/javascript" src="/wangEditor/release/wangEditor.js"></script>
|
||||||
|
<script type="text/javascript" src="/js/appjs/novel/authorCode/edit.js">
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>novel</artifactId>
|
<artifactId>novel</artifactId>
|
||||||
<groupId>com.java2nb</groupId>
|
<groupId>com.java2nb</groupId>
|
||||||
<version>1.1.1</version>
|
<version>2.5.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -31,11 +31,20 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-cache</artifactId>
|
<artifactId>spring-boot-starter-cache</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!--ehcache-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.sf.ehcache</groupId>
|
<groupId>net.sf.ehcache</groupId>
|
||||||
<artifactId>ehcache</artifactId>
|
<artifactId>ehcache</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!--集成redis-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-redis</artifactId>
|
||||||
|
<version>${redis.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!--mysql驱动-->
|
<!--mysql驱动-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
@ -48,6 +57,22 @@
|
|||||||
<version>${mybatis.version}</version>
|
<version>${mybatis.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 分库分表-->
|
||||||
|
<!-- sharding jdbc依赖 -->
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.shardingsphere</groupId>
|
||||||
|
<artifactId>sharding-jdbc-spring-boot-starter</artifactId>
|
||||||
|
<version>${sharding.jdbc.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.shardingsphere</groupId>
|
||||||
|
<artifactId>sharding-jdbc-spring-namespace</artifactId>
|
||||||
|
<version>${sharding.jdbc.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<!--分页助手启动器-->
|
<!--分页助手启动器-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.pagehelper</groupId>
|
<groupId>com.github.pagehelper</groupId>
|
||||||
|
@ -46,4 +46,23 @@ public interface CacheKey {
|
|||||||
* */
|
* */
|
||||||
String RUNNING_CRAWL_THREAD_KEY_PREFIX = "runningCrawlTreadDataKeyPrefix";
|
String RUNNING_CRAWL_THREAD_KEY_PREFIX = "runningCrawlTreadDataKeyPrefix";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上一次搜索引擎更新的时间
|
||||||
|
* */
|
||||||
|
String ES_LAST_UPDATE_TIME = "esLastUpdateTime";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索引擎转换锁
|
||||||
|
* */
|
||||||
|
String ES_TRANS_LOCK = "esTransLock";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上一次搜索引擎是否更新过小说点击量
|
||||||
|
* */
|
||||||
|
String ES_IS_UPDATE_VISIT = "esIsUpdateVisit";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 累积的小说点击量
|
||||||
|
* */
|
||||||
|
String BOOK_ADD_VISIT_COUNT = "bookAddVisitCount";
|
||||||
}
|
}
|
@ -51,9 +51,5 @@ public interface CacheService {
|
|||||||
* */
|
* */
|
||||||
void expire(String key, long timeout);
|
void expire(String key, long timeout);
|
||||||
|
|
||||||
/**
|
|
||||||
* 刷新缓存
|
|
||||||
* */
|
|
||||||
void refresh(String key);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,25 @@
|
|||||||
package com.java2nb.novel.core.cache.impl;
|
package com.java2nb.novel.core.cache.impl;
|
||||||
|
|
||||||
import com.java2nb.novel.core.cache.CacheService;
|
import com.java2nb.novel.core.cache.CacheService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import net.sf.ehcache.Cache;
|
import net.sf.ehcache.Cache;
|
||||||
import net.sf.ehcache.CacheManager;
|
import net.sf.ehcache.CacheManager;
|
||||||
import net.sf.ehcache.Element;
|
import net.sf.ehcache.Element;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xxy
|
* @author xxy
|
||||||
*/
|
*/
|
||||||
|
@ConditionalOnProperty(prefix = "cache", name = "type", havingValue = "ehcache")
|
||||||
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class EhCacheServiceImpl implements CacheService {
|
public class EhCacheServiceImpl implements CacheService {
|
||||||
|
|
||||||
@Autowired
|
private final CacheManager cacheManager ;
|
||||||
private CacheManager cacheManager ;
|
|
||||||
|
|
||||||
private static final String CACHE_NAME = "utilCache";
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得一个Cache,没有则创建一个。
|
* 获得一个Cache,没有则创建一个。
|
||||||
* @return
|
* @return
|
||||||
@ -30,14 +31,6 @@ public class EhCacheServiceImpl implements CacheService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public CacheManager getCacheManager() {
|
|
||||||
return cacheManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String get(String key) {
|
public String get(String key) {
|
||||||
Element element = getCache().get(key);
|
Element element = getCache().get(key);
|
||||||
@ -125,20 +118,6 @@ public class EhCacheServiceImpl implements CacheService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void refresh(String key) {
|
|
||||||
Element element = getCache().get(key);
|
|
||||||
if (element != null) {
|
|
||||||
Object value = element.getValue();
|
|
||||||
int timeToLive = element.getTimeToLive();
|
|
||||||
element = new Element(key, value);
|
|
||||||
element.setTimeToLive(timeToLive);
|
|
||||||
Cache cache = getCache();
|
|
||||||
cache.put(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
73
novel-common/src/main/java/com/java2nb/novel/core/cache/impl/RedisServiceImpl.java
vendored
Normal file
73
novel-common/src/main/java/com/java2nb/novel/core/cache/impl/RedisServiceImpl.java
vendored
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package com.java2nb.novel.core.cache.impl;
|
||||||
|
|
||||||
|
import com.java2nb.novel.core.cache.CacheService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xxy
|
||||||
|
*/
|
||||||
|
@ConditionalOnProperty(prefix = "cache", name = "type", havingValue = "redis")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Service
|
||||||
|
public class RedisServiceImpl implements CacheService {
|
||||||
|
|
||||||
|
private final StringRedisTemplate stringRedisTemplate;
|
||||||
|
|
||||||
|
private final RedisTemplate<Object, Object> redisTemplate;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String get(String key) {
|
||||||
|
return stringRedisTemplate.opsForValue().get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void set(String key, String value) {
|
||||||
|
stringRedisTemplate.opsForValue().set(key,value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void set(String key, String value, long timeout) {
|
||||||
|
stringRedisTemplate.opsForValue().set(key,value,timeout, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getObject(String key) {
|
||||||
|
return redisTemplate.opsForValue().get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setObject(String key, Object value) {
|
||||||
|
redisTemplate.opsForValue().set(key,value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setObject(String key, Object value, long timeout) {
|
||||||
|
redisTemplate.opsForValue().set(key,value,timeout, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void del(String key) {
|
||||||
|
redisTemplate.delete(key);
|
||||||
|
stringRedisTemplate.delete(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean contains(String key) {
|
||||||
|
return redisTemplate.hasKey(key) || stringRedisTemplate.hasKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void expire(String key, long timeout) {
|
||||||
|
redisTemplate.expire(key,timeout, TimeUnit.SECONDS);
|
||||||
|
stringRedisTemplate.expire(key,timeout, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -43,18 +43,31 @@ public enum ResponseStatus {
|
|||||||
USERNAME_PASS_ERROR(1004,"手机号或密码错误!"),
|
USERNAME_PASS_ERROR(1004,"手机号或密码错误!"),
|
||||||
TWO_PASSWORD_DIFF(1005, "两次输入的新密码不匹配!"),
|
TWO_PASSWORD_DIFF(1005, "两次输入的新密码不匹配!"),
|
||||||
OLD_PASSWORD_ERROR(1006, "旧密码不匹配!"),
|
OLD_PASSWORD_ERROR(1006, "旧密码不匹配!"),
|
||||||
|
USER_NO_BALANCE(1007, "用户余额不足"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 评论相关错误
|
* 评论相关错误
|
||||||
* */
|
* */
|
||||||
HAS_COMMENTS(3001, "已评价过该书籍!"),
|
HAS_COMMENTS(3001, "已评价过该书籍!"),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 作者相关错误
|
||||||
|
* */
|
||||||
|
INVITE_CODE_INVALID(4001, "邀请码无效!"),
|
||||||
|
AUTHOR_STATUS_FORBIDDEN(4002, "作者状态异常,暂不能管理小说!")
|
||||||
|
, BOOKNAME_EXISTS(4003,"已发布过同名小说!")
|
||||||
|
|
||||||
|
,
|
||||||
|
/**
|
||||||
|
* 搜索引擎相关错误
|
||||||
|
* */
|
||||||
|
ES_SEARCH_FAIL(9001,"密码错误!"),
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 其他通用错误
|
* 其他通用错误
|
||||||
* */
|
* */
|
||||||
PASSWORD_ERROR(88001,"密码错误!");
|
PASSWORD_ERROR(88001,"密码错误!");
|
||||||
|
|
||||||
private int code;
|
private int code;
|
||||||
private String msg;
|
private String msg;
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.java2nb.novel.core.utils;
|
package com.java2nb.novel.core.utils;
|
||||||
|
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.codec.Charsets;
|
import org.apache.commons.codec.Charsets;
|
||||||
import org.apache.http.client.utils.DateUtils;
|
import org.apache.http.client.utils.DateUtils;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
@ -9,6 +10,7 @@ import org.springframework.http.HttpHeaders;
|
|||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -17,34 +19,65 @@ import java.util.Objects;
|
|||||||
* 文件操作工具类
|
* 文件操作工具类
|
||||||
* @author 11797
|
* @author 11797
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class FileUtil {
|
public class FileUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 网络图片转本地
|
* 网络图片转本地
|
||||||
* */
|
* */
|
||||||
@SneakyThrows
|
|
||||||
public static String network2Local(String picSrc,String picSavePath,String visitPrefix) {
|
public static String network2Local(String picSrc,String picSavePath,String visitPrefix) {
|
||||||
//本地图片保存
|
InputStream input = null;
|
||||||
HttpHeaders headers = new HttpHeaders();
|
OutputStream out = null;
|
||||||
HttpEntity<String> requestEntity = new HttpEntity<>(null, headers);
|
try {
|
||||||
ResponseEntity<Resource> resEntity = RestTemplateUtil.getInstance(Charsets.ISO_8859_1.name()).exchange(picSrc, HttpMethod.GET, requestEntity, Resource.class);
|
//本地图片保存
|
||||||
InputStream input = Objects.requireNonNull(resEntity.getBody()).getInputStream();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
Date currentDate = new Date();
|
HttpEntity<String> requestEntity = new HttpEntity<>(null, headers);
|
||||||
picSrc = visitPrefix + DateUtils.formatDate(currentDate, "yyyy") + "/" + DateUtils.formatDate(currentDate, "MM") + "/" + DateUtils.formatDate(currentDate, "dd") + "/"
|
ResponseEntity<Resource> resEntity = RestTemplateUtil.getInstance(Charsets.ISO_8859_1.name()).exchange(picSrc, HttpMethod.GET, requestEntity, Resource.class);
|
||||||
+ UUIDUtil.getUUID32()
|
input = Objects.requireNonNull(resEntity.getBody()).getInputStream();
|
||||||
+ picSrc.substring(picSrc.lastIndexOf("."));
|
Date currentDate = new Date();
|
||||||
File picFile = new File(picSavePath + picSrc);
|
picSrc = visitPrefix + DateUtils.formatDate(currentDate, "yyyy") + "/" + DateUtils.formatDate(currentDate, "MM") + "/" + DateUtils.formatDate(currentDate, "dd") + "/"
|
||||||
File parentFile = picFile.getParentFile();
|
+ UUIDUtil.getUUID32()
|
||||||
if (!parentFile.exists()) {
|
+ picSrc.substring(picSrc.lastIndexOf("."));
|
||||||
parentFile.mkdirs();
|
File picFile = new File(picSavePath + picSrc);
|
||||||
|
File parentFile = picFile.getParentFile();
|
||||||
|
if (!parentFile.exists()) {
|
||||||
|
parentFile.mkdirs();
|
||||||
|
}
|
||||||
|
out = new FileOutputStream(picFile);
|
||||||
|
byte[] b = new byte[4096];
|
||||||
|
for (int n; (n = input.read(b)) != -1; ) {
|
||||||
|
out.write(b, 0, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
out.flush();
|
||||||
|
if( ImageIO.read(picFile) == null){
|
||||||
|
picSrc = "/images/default.gif";
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
|
||||||
|
picSrc = "/images/default.gif";
|
||||||
|
}finally {
|
||||||
|
if(input != null){
|
||||||
|
try {
|
||||||
|
input.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
}finally {
|
||||||
|
if(out != null){
|
||||||
|
try {
|
||||||
|
out.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
OutputStream out = new FileOutputStream(picFile);
|
|
||||||
byte[] b = new byte[4096];
|
|
||||||
for (int n; (n = input.read(b)) != -1; ) {
|
|
||||||
out.write(b, 0, n);
|
|
||||||
}
|
|
||||||
out.close();
|
|
||||||
input.close();
|
|
||||||
return picSrc;
|
return picSrc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public class RestTemplateUtil {
|
|||||||
requestFactory.setHttpClient(httpClient);
|
requestFactory.setHttpClient(httpClient);
|
||||||
requestFactory.setConnectionRequestTimeout(3000);
|
requestFactory.setConnectionRequestTimeout(3000);
|
||||||
requestFactory.setConnectTimeout(3000);
|
requestFactory.setConnectTimeout(3000);
|
||||||
requestFactory.setReadTimeout(10000);
|
requestFactory.setReadTimeout(30000);
|
||||||
RestTemplate restTemplate = new RestTemplate(requestFactory);
|
RestTemplate restTemplate = new RestTemplate(requestFactory);
|
||||||
List<HttpMessageConverter<?>> list = restTemplate.getMessageConverters();
|
List<HttpMessageConverter<?>> list = restTemplate.getMessageConverters();
|
||||||
for (HttpMessageConverter<?> httpMessageConverter : list) {
|
for (HttpMessageConverter<?> httpMessageConverter : list) {
|
||||||
|
@ -0,0 +1,73 @@
|
|||||||
|
package com.java2nb.novel.core.utils;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xiongxiaoyang
|
||||||
|
*/
|
||||||
|
public class StringUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将驼峰式命名的字符串转换为下划线大写方式。如果转换前的驼峰式命名的字符串为空,则返回空字符串。</br>
|
||||||
|
* 例如:HelloWorld->HELLO_WORLD
|
||||||
|
* @param name 转换前的驼峰式命名的字符串
|
||||||
|
* @return 转换后下划线大写方式命名的字符串
|
||||||
|
*/
|
||||||
|
public static String underscoreName(String name) {
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
if (name != null && name.length() > 0) {
|
||||||
|
// 将第一个字符处理成大写
|
||||||
|
result.append(name.substring(0, 1).toUpperCase());
|
||||||
|
// 循环处理其余字符
|
||||||
|
for (int i = 1; i < name.length(); i++) {
|
||||||
|
String s = name.substring(i, i + 1);
|
||||||
|
// 在大写字母前添加下划线
|
||||||
|
if (s.equals(s.toUpperCase()) && !Character.isDigit(s.charAt(0))) {
|
||||||
|
result.append("_");
|
||||||
|
}
|
||||||
|
// 其他字符直接转成大写
|
||||||
|
result.append(s.toUpperCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。</br>
|
||||||
|
* 例如:HELLO_WORLD->HelloWorld
|
||||||
|
* @param name 转换前的下划线大写方式命名的字符串
|
||||||
|
* @return 转换后的驼峰式命名的字符串
|
||||||
|
*/
|
||||||
|
public static String camelName(String name) {
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
// 快速检查
|
||||||
|
if (name == null || name.isEmpty()) {
|
||||||
|
// 没必要转换
|
||||||
|
return "";
|
||||||
|
} else if (!name.contains("_")) {
|
||||||
|
// 不含下划线,仅将首字母小写
|
||||||
|
return name.substring(0, 1).toLowerCase() + name.substring(1);
|
||||||
|
}
|
||||||
|
// 用下划线将原始字符串分割
|
||||||
|
String camels[] = name.split("_");
|
||||||
|
for (String camel : camels) {
|
||||||
|
// 跳过原始字符串中开头、结尾的下换线或双重下划线
|
||||||
|
if (camel.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 处理真正的驼峰片段
|
||||||
|
if (result.length() == 0) {
|
||||||
|
// 第一个驼峰片段,全部字母都小写
|
||||||
|
result.append(camel.toLowerCase());
|
||||||
|
} else {
|
||||||
|
// 其他的驼峰片段,首字母大写
|
||||||
|
result.append(camel.substring(0, 1).toUpperCase());
|
||||||
|
result.append(camel.substring(1).toLowerCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
136
novel-common/src/main/java/com/java2nb/novel/entity/Author.java
Normal file
136
novel-common/src/main/java/com/java2nb/novel/entity/Author.java
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
package com.java2nb.novel.entity;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
public class Author {
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private String inviteCode;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private String penName;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private String telPhone;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private String chatAccount;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private Byte workDirection;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private Byte status;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public Long getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setUserId(Long userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public String getInviteCode() {
|
||||||
|
return inviteCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setInviteCode(String inviteCode) {
|
||||||
|
this.inviteCode = inviteCode == null ? null : inviteCode.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public String getPenName() {
|
||||||
|
return penName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setPenName(String penName) {
|
||||||
|
this.penName = penName == null ? null : penName.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public String getTelPhone() {
|
||||||
|
return telPhone;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setTelPhone(String telPhone) {
|
||||||
|
this.telPhone = telPhone == null ? null : telPhone.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public String getChatAccount() {
|
||||||
|
return chatAccount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setChatAccount(String chatAccount) {
|
||||||
|
this.chatAccount = chatAccount == null ? null : chatAccount.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email == null ? null : email.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public Byte getWorkDirection() {
|
||||||
|
return workDirection;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setWorkDirection(Byte workDirection) {
|
||||||
|
this.workDirection = workDirection;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public Byte getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setStatus(Byte status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public Date getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setCreateTime(Date createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,84 @@
|
|||||||
|
package com.java2nb.novel.entity;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
public class AuthorCode {
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private String inviteCode;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private Date validityTime;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private Byte isUse;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private Long createUserId;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public String getInviteCode() {
|
||||||
|
return inviteCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setInviteCode(String inviteCode) {
|
||||||
|
this.inviteCode = inviteCode == null ? null : inviteCode.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public Date getValidityTime() {
|
||||||
|
return validityTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setValidityTime(Date validityTime) {
|
||||||
|
this.validityTime = validityTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public Byte getIsUse() {
|
||||||
|
return isUse;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setIsUse(Byte isUse) {
|
||||||
|
this.isUse = isUse;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public Date getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setCreateTime(Date createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public Long getCreateUserId() {
|
||||||
|
return createUserId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setCreateUserId(Long createUserId) {
|
||||||
|
this.createUserId = createUserId;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,110 @@
|
|||||||
|
package com.java2nb.novel.entity;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
|
||||||
|
public class UserBuyRecord {
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private Long bookId;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private String bookName;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private Long bookIndexId;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private String bookIndexName;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private Integer buyAmount;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public Long getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setUserId(Long userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public Long getBookId() {
|
||||||
|
return bookId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setBookId(Long bookId) {
|
||||||
|
this.bookId = bookId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public String getBookName() {
|
||||||
|
return bookName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setBookName(String bookName) {
|
||||||
|
this.bookName = bookName == null ? null : bookName.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public Long getBookIndexId() {
|
||||||
|
return bookIndexId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setBookIndexId(Long bookIndexId) {
|
||||||
|
this.bookIndexId = bookIndexId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public String getBookIndexName() {
|
||||||
|
return bookIndexName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setBookIndexName(String bookIndexName) {
|
||||||
|
this.bookIndexName = bookIndexName == null ? null : bookIndexName.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public Integer getBuyAmount() {
|
||||||
|
return buyAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setBuyAmount(Integer buyAmount) {
|
||||||
|
this.buyAmount = buyAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public Date getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public void setCreateTime(Date createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
package com.java2nb.novel.mapper;
|
||||||
|
|
||||||
|
import java.sql.JDBCType;
|
||||||
|
import java.util.Date;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
import org.mybatis.dynamic.sql.SqlColumn;
|
||||||
|
import org.mybatis.dynamic.sql.SqlTable;
|
||||||
|
|
||||||
|
public final class AuthorCodeDynamicSqlSupport {
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final AuthorCode authorCode = new AuthorCode();
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<Long> id = authorCode.id;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<String> inviteCode = authorCode.inviteCode;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<Date> validityTime = authorCode.validityTime;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<Byte> isUse = authorCode.isUse;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<Date> createTime = authorCode.createTime;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<Long> createUserId = authorCode.createUserId;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final class AuthorCode extends SqlTable {
|
||||||
|
public final SqlColumn<Long> id = column("id", JDBCType.BIGINT);
|
||||||
|
|
||||||
|
public final SqlColumn<String> inviteCode = column("invite_code", JDBCType.VARCHAR);
|
||||||
|
|
||||||
|
public final SqlColumn<Date> validityTime = column("validity_time", JDBCType.TIMESTAMP);
|
||||||
|
|
||||||
|
public final SqlColumn<Byte> isUse = column("is_use", JDBCType.TINYINT);
|
||||||
|
|
||||||
|
public final SqlColumn<Date> createTime = column("create_time", JDBCType.TIMESTAMP);
|
||||||
|
|
||||||
|
public final SqlColumn<Long> createUserId = column("create_user_id", JDBCType.BIGINT);
|
||||||
|
|
||||||
|
public AuthorCode() {
|
||||||
|
super("author_code");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,200 @@
|
|||||||
|
package com.java2nb.novel.mapper;
|
||||||
|
|
||||||
|
import static com.java2nb.novel.mapper.AuthorCodeDynamicSqlSupport.*;
|
||||||
|
import static org.mybatis.dynamic.sql.SqlBuilder.*;
|
||||||
|
|
||||||
|
import com.java2nb.novel.entity.AuthorCode;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
import org.apache.ibatis.annotations.DeleteProvider;
|
||||||
|
import org.apache.ibatis.annotations.InsertProvider;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Result;
|
||||||
|
import org.apache.ibatis.annotations.ResultMap;
|
||||||
|
import org.apache.ibatis.annotations.Results;
|
||||||
|
import org.apache.ibatis.annotations.SelectProvider;
|
||||||
|
import org.apache.ibatis.annotations.UpdateProvider;
|
||||||
|
import org.apache.ibatis.type.JdbcType;
|
||||||
|
import org.mybatis.dynamic.sql.BasicColumn;
|
||||||
|
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
|
||||||
|
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
|
||||||
|
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
|
||||||
|
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
|
||||||
|
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
|
||||||
|
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
|
||||||
|
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
|
||||||
|
import org.mybatis.dynamic.sql.update.UpdateDSL;
|
||||||
|
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
|
||||||
|
import org.mybatis.dynamic.sql.update.UpdateModel;
|
||||||
|
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
|
||||||
|
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
|
||||||
|
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface AuthorCodeMapper {
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
BasicColumn[] selectList = BasicColumn.columnList(id, inviteCode, validityTime, isUse, createTime, createUserId);
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||||
|
long count(SelectStatementProvider selectStatement);
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
@DeleteProvider(type=SqlProviderAdapter.class, method="delete")
|
||||||
|
int delete(DeleteStatementProvider deleteStatement);
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
@InsertProvider(type=SqlProviderAdapter.class, method="insert")
|
||||||
|
int insert(InsertStatementProvider<AuthorCode> insertStatement);
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
@InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
|
||||||
|
int insertMultiple(MultiRowInsertStatementProvider<AuthorCode> multipleInsertStatement);
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||||
|
@ResultMap("AuthorCodeResult")
|
||||||
|
Optional<AuthorCode> selectOne(SelectStatementProvider selectStatement);
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||||
|
@Results(id="AuthorCodeResult", value = {
|
||||||
|
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
|
||||||
|
@Result(column="invite_code", property="inviteCode", jdbcType=JdbcType.VARCHAR),
|
||||||
|
@Result(column="validity_time", property="validityTime", jdbcType=JdbcType.TIMESTAMP),
|
||||||
|
@Result(column="is_use", property="isUse", jdbcType=JdbcType.TINYINT),
|
||||||
|
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
|
||||||
|
@Result(column="create_user_id", property="createUserId", jdbcType=JdbcType.BIGINT)
|
||||||
|
})
|
||||||
|
List<AuthorCode> selectMany(SelectStatementProvider selectStatement);
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
@UpdateProvider(type=SqlProviderAdapter.class, method="update")
|
||||||
|
int update(UpdateStatementProvider updateStatement);
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default long count(CountDSLCompleter completer) {
|
||||||
|
return MyBatis3Utils.countFrom(this::count, authorCode, completer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default int delete(DeleteDSLCompleter completer) {
|
||||||
|
return MyBatis3Utils.deleteFrom(this::delete, authorCode, completer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default int deleteByPrimaryKey(Long id_) {
|
||||||
|
return delete(c ->
|
||||||
|
c.where(id, isEqualTo(id_))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default int insert(AuthorCode record) {
|
||||||
|
return MyBatis3Utils.insert(this::insert, record, authorCode, c ->
|
||||||
|
c.map(id).toProperty("id")
|
||||||
|
.map(inviteCode).toProperty("inviteCode")
|
||||||
|
.map(validityTime).toProperty("validityTime")
|
||||||
|
.map(isUse).toProperty("isUse")
|
||||||
|
.map(createTime).toProperty("createTime")
|
||||||
|
.map(createUserId).toProperty("createUserId")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default int insertMultiple(Collection<AuthorCode> records) {
|
||||||
|
return MyBatis3Utils.insertMultiple(this::insertMultiple, records, authorCode, c ->
|
||||||
|
c.map(id).toProperty("id")
|
||||||
|
.map(inviteCode).toProperty("inviteCode")
|
||||||
|
.map(validityTime).toProperty("validityTime")
|
||||||
|
.map(isUse).toProperty("isUse")
|
||||||
|
.map(createTime).toProperty("createTime")
|
||||||
|
.map(createUserId).toProperty("createUserId")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default int insertSelective(AuthorCode record) {
|
||||||
|
return MyBatis3Utils.insert(this::insert, record, authorCode, c ->
|
||||||
|
c.map(id).toPropertyWhenPresent("id", record::getId)
|
||||||
|
.map(inviteCode).toPropertyWhenPresent("inviteCode", record::getInviteCode)
|
||||||
|
.map(validityTime).toPropertyWhenPresent("validityTime", record::getValidityTime)
|
||||||
|
.map(isUse).toPropertyWhenPresent("isUse", record::getIsUse)
|
||||||
|
.map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
|
||||||
|
.map(createUserId).toPropertyWhenPresent("createUserId", record::getCreateUserId)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default Optional<AuthorCode> selectOne(SelectDSLCompleter completer) {
|
||||||
|
return MyBatis3Utils.selectOne(this::selectOne, selectList, authorCode, completer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default List<AuthorCode> select(SelectDSLCompleter completer) {
|
||||||
|
return MyBatis3Utils.selectList(this::selectMany, selectList, authorCode, completer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default List<AuthorCode> selectDistinct(SelectDSLCompleter completer) {
|
||||||
|
return MyBatis3Utils.selectDistinct(this::selectMany, selectList, authorCode, completer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default Optional<AuthorCode> selectByPrimaryKey(Long id_) {
|
||||||
|
return selectOne(c ->
|
||||||
|
c.where(id, isEqualTo(id_))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default int update(UpdateDSLCompleter completer) {
|
||||||
|
return MyBatis3Utils.update(this::update, authorCode, completer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
static UpdateDSL<UpdateModel> updateAllColumns(AuthorCode record, UpdateDSL<UpdateModel> dsl) {
|
||||||
|
return dsl.set(id).equalTo(record::getId)
|
||||||
|
.set(inviteCode).equalTo(record::getInviteCode)
|
||||||
|
.set(validityTime).equalTo(record::getValidityTime)
|
||||||
|
.set(isUse).equalTo(record::getIsUse)
|
||||||
|
.set(createTime).equalTo(record::getCreateTime)
|
||||||
|
.set(createUserId).equalTo(record::getCreateUserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
static UpdateDSL<UpdateModel> updateSelectiveColumns(AuthorCode record, UpdateDSL<UpdateModel> dsl) {
|
||||||
|
return dsl.set(id).equalToWhenPresent(record::getId)
|
||||||
|
.set(inviteCode).equalToWhenPresent(record::getInviteCode)
|
||||||
|
.set(validityTime).equalToWhenPresent(record::getValidityTime)
|
||||||
|
.set(isUse).equalToWhenPresent(record::getIsUse)
|
||||||
|
.set(createTime).equalToWhenPresent(record::getCreateTime)
|
||||||
|
.set(createUserId).equalToWhenPresent(record::getCreateUserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default int updateByPrimaryKey(AuthorCode record) {
|
||||||
|
return update(c ->
|
||||||
|
c.set(inviteCode).equalTo(record::getInviteCode)
|
||||||
|
.set(validityTime).equalTo(record::getValidityTime)
|
||||||
|
.set(isUse).equalTo(record::getIsUse)
|
||||||
|
.set(createTime).equalTo(record::getCreateTime)
|
||||||
|
.set(createUserId).equalTo(record::getCreateUserId)
|
||||||
|
.where(id, isEqualTo(record::getId))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default int updateByPrimaryKeySelective(AuthorCode record) {
|
||||||
|
return update(c ->
|
||||||
|
c.set(inviteCode).equalToWhenPresent(record::getInviteCode)
|
||||||
|
.set(validityTime).equalToWhenPresent(record::getValidityTime)
|
||||||
|
.set(isUse).equalToWhenPresent(record::getIsUse)
|
||||||
|
.set(createTime).equalToWhenPresent(record::getCreateTime)
|
||||||
|
.set(createUserId).equalToWhenPresent(record::getCreateUserId)
|
||||||
|
.where(id, isEqualTo(record::getId))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
package com.java2nb.novel.mapper;
|
||||||
|
|
||||||
|
import java.sql.JDBCType;
|
||||||
|
import java.util.Date;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
import org.mybatis.dynamic.sql.SqlColumn;
|
||||||
|
import org.mybatis.dynamic.sql.SqlTable;
|
||||||
|
|
||||||
|
public final class AuthorDynamicSqlSupport {
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final Author author = new Author();
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<Long> id = author.id;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<Long> userId = author.userId;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<String> inviteCode = author.inviteCode;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<String> penName = author.penName;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<String> telPhone = author.telPhone;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<String> chatAccount = author.chatAccount;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<String> email = author.email;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<Byte> workDirection = author.workDirection;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<Byte> status = author.status;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<Date> createTime = author.createTime;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final class Author extends SqlTable {
|
||||||
|
public final SqlColumn<Long> id = column("id", JDBCType.BIGINT);
|
||||||
|
|
||||||
|
public final SqlColumn<Long> userId = column("user_id", JDBCType.BIGINT);
|
||||||
|
|
||||||
|
public final SqlColumn<String> inviteCode = column("invite_code", JDBCType.VARCHAR);
|
||||||
|
|
||||||
|
public final SqlColumn<String> penName = column("pen_name", JDBCType.VARCHAR);
|
||||||
|
|
||||||
|
public final SqlColumn<String> telPhone = column("tel_phone", JDBCType.VARCHAR);
|
||||||
|
|
||||||
|
public final SqlColumn<String> chatAccount = column("chat_account", JDBCType.VARCHAR);
|
||||||
|
|
||||||
|
public final SqlColumn<String> email = column("email", JDBCType.VARCHAR);
|
||||||
|
|
||||||
|
public final SqlColumn<Byte> workDirection = column("work_direction", JDBCType.TINYINT);
|
||||||
|
|
||||||
|
public final SqlColumn<Byte> status = column("status", JDBCType.TINYINT);
|
||||||
|
|
||||||
|
public final SqlColumn<Date> createTime = column("create_time", JDBCType.TIMESTAMP);
|
||||||
|
|
||||||
|
public Author() {
|
||||||
|
super("author");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,232 @@
|
|||||||
|
package com.java2nb.novel.mapper;
|
||||||
|
|
||||||
|
import static com.java2nb.novel.mapper.AuthorDynamicSqlSupport.*;
|
||||||
|
import static org.mybatis.dynamic.sql.SqlBuilder.*;
|
||||||
|
|
||||||
|
import com.java2nb.novel.entity.Author;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
import org.apache.ibatis.annotations.DeleteProvider;
|
||||||
|
import org.apache.ibatis.annotations.InsertProvider;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Result;
|
||||||
|
import org.apache.ibatis.annotations.ResultMap;
|
||||||
|
import org.apache.ibatis.annotations.Results;
|
||||||
|
import org.apache.ibatis.annotations.SelectProvider;
|
||||||
|
import org.apache.ibatis.annotations.UpdateProvider;
|
||||||
|
import org.apache.ibatis.type.JdbcType;
|
||||||
|
import org.mybatis.dynamic.sql.BasicColumn;
|
||||||
|
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
|
||||||
|
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
|
||||||
|
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
|
||||||
|
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
|
||||||
|
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
|
||||||
|
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
|
||||||
|
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
|
||||||
|
import org.mybatis.dynamic.sql.update.UpdateDSL;
|
||||||
|
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
|
||||||
|
import org.mybatis.dynamic.sql.update.UpdateModel;
|
||||||
|
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
|
||||||
|
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
|
||||||
|
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface AuthorMapper {
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
BasicColumn[] selectList = BasicColumn.columnList(id, userId, inviteCode, penName, telPhone, chatAccount, email, workDirection, status, createTime);
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||||
|
long count(SelectStatementProvider selectStatement);
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
@DeleteProvider(type=SqlProviderAdapter.class, method="delete")
|
||||||
|
int delete(DeleteStatementProvider deleteStatement);
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
@InsertProvider(type=SqlProviderAdapter.class, method="insert")
|
||||||
|
int insert(InsertStatementProvider<Author> insertStatement);
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
@InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
|
||||||
|
int insertMultiple(MultiRowInsertStatementProvider<Author> multipleInsertStatement);
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||||
|
@ResultMap("AuthorResult")
|
||||||
|
Optional<Author> selectOne(SelectStatementProvider selectStatement);
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||||
|
@Results(id="AuthorResult", value = {
|
||||||
|
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
|
||||||
|
@Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT),
|
||||||
|
@Result(column="invite_code", property="inviteCode", jdbcType=JdbcType.VARCHAR),
|
||||||
|
@Result(column="pen_name", property="penName", jdbcType=JdbcType.VARCHAR),
|
||||||
|
@Result(column="tel_phone", property="telPhone", jdbcType=JdbcType.VARCHAR),
|
||||||
|
@Result(column="chat_account", property="chatAccount", jdbcType=JdbcType.VARCHAR),
|
||||||
|
@Result(column="email", property="email", jdbcType=JdbcType.VARCHAR),
|
||||||
|
@Result(column="work_direction", property="workDirection", jdbcType=JdbcType.TINYINT),
|
||||||
|
@Result(column="status", property="status", jdbcType=JdbcType.TINYINT),
|
||||||
|
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP)
|
||||||
|
})
|
||||||
|
List<Author> selectMany(SelectStatementProvider selectStatement);
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
@UpdateProvider(type=SqlProviderAdapter.class, method="update")
|
||||||
|
int update(UpdateStatementProvider updateStatement);
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default long count(CountDSLCompleter completer) {
|
||||||
|
return MyBatis3Utils.countFrom(this::count, author, completer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default int delete(DeleteDSLCompleter completer) {
|
||||||
|
return MyBatis3Utils.deleteFrom(this::delete, author, completer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default int deleteByPrimaryKey(Long id_) {
|
||||||
|
return delete(c ->
|
||||||
|
c.where(id, isEqualTo(id_))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default int insert(Author record) {
|
||||||
|
return MyBatis3Utils.insert(this::insert, record, author, c ->
|
||||||
|
c.map(id).toProperty("id")
|
||||||
|
.map(userId).toProperty("userId")
|
||||||
|
.map(inviteCode).toProperty("inviteCode")
|
||||||
|
.map(penName).toProperty("penName")
|
||||||
|
.map(telPhone).toProperty("telPhone")
|
||||||
|
.map(chatAccount).toProperty("chatAccount")
|
||||||
|
.map(email).toProperty("email")
|
||||||
|
.map(workDirection).toProperty("workDirection")
|
||||||
|
.map(status).toProperty("status")
|
||||||
|
.map(createTime).toProperty("createTime")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default int insertMultiple(Collection<Author> records) {
|
||||||
|
return MyBatis3Utils.insertMultiple(this::insertMultiple, records, author, c ->
|
||||||
|
c.map(id).toProperty("id")
|
||||||
|
.map(userId).toProperty("userId")
|
||||||
|
.map(inviteCode).toProperty("inviteCode")
|
||||||
|
.map(penName).toProperty("penName")
|
||||||
|
.map(telPhone).toProperty("telPhone")
|
||||||
|
.map(chatAccount).toProperty("chatAccount")
|
||||||
|
.map(email).toProperty("email")
|
||||||
|
.map(workDirection).toProperty("workDirection")
|
||||||
|
.map(status).toProperty("status")
|
||||||
|
.map(createTime).toProperty("createTime")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default int insertSelective(Author record) {
|
||||||
|
return MyBatis3Utils.insert(this::insert, record, author, c ->
|
||||||
|
c.map(id).toPropertyWhenPresent("id", record::getId)
|
||||||
|
.map(userId).toPropertyWhenPresent("userId", record::getUserId)
|
||||||
|
.map(inviteCode).toPropertyWhenPresent("inviteCode", record::getInviteCode)
|
||||||
|
.map(penName).toPropertyWhenPresent("penName", record::getPenName)
|
||||||
|
.map(telPhone).toPropertyWhenPresent("telPhone", record::getTelPhone)
|
||||||
|
.map(chatAccount).toPropertyWhenPresent("chatAccount", record::getChatAccount)
|
||||||
|
.map(email).toPropertyWhenPresent("email", record::getEmail)
|
||||||
|
.map(workDirection).toPropertyWhenPresent("workDirection", record::getWorkDirection)
|
||||||
|
.map(status).toPropertyWhenPresent("status", record::getStatus)
|
||||||
|
.map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default Optional<Author> selectOne(SelectDSLCompleter completer) {
|
||||||
|
return MyBatis3Utils.selectOne(this::selectOne, selectList, author, completer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default List<Author> select(SelectDSLCompleter completer) {
|
||||||
|
return MyBatis3Utils.selectList(this::selectMany, selectList, author, completer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default List<Author> selectDistinct(SelectDSLCompleter completer) {
|
||||||
|
return MyBatis3Utils.selectDistinct(this::selectMany, selectList, author, completer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default Optional<Author> selectByPrimaryKey(Long id_) {
|
||||||
|
return selectOne(c ->
|
||||||
|
c.where(id, isEqualTo(id_))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default int update(UpdateDSLCompleter completer) {
|
||||||
|
return MyBatis3Utils.update(this::update, author, completer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
static UpdateDSL<UpdateModel> updateAllColumns(Author record, UpdateDSL<UpdateModel> dsl) {
|
||||||
|
return dsl.set(id).equalTo(record::getId)
|
||||||
|
.set(userId).equalTo(record::getUserId)
|
||||||
|
.set(inviteCode).equalTo(record::getInviteCode)
|
||||||
|
.set(penName).equalTo(record::getPenName)
|
||||||
|
.set(telPhone).equalTo(record::getTelPhone)
|
||||||
|
.set(chatAccount).equalTo(record::getChatAccount)
|
||||||
|
.set(email).equalTo(record::getEmail)
|
||||||
|
.set(workDirection).equalTo(record::getWorkDirection)
|
||||||
|
.set(status).equalTo(record::getStatus)
|
||||||
|
.set(createTime).equalTo(record::getCreateTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
static UpdateDSL<UpdateModel> updateSelectiveColumns(Author record, UpdateDSL<UpdateModel> dsl) {
|
||||||
|
return dsl.set(id).equalToWhenPresent(record::getId)
|
||||||
|
.set(userId).equalToWhenPresent(record::getUserId)
|
||||||
|
.set(inviteCode).equalToWhenPresent(record::getInviteCode)
|
||||||
|
.set(penName).equalToWhenPresent(record::getPenName)
|
||||||
|
.set(telPhone).equalToWhenPresent(record::getTelPhone)
|
||||||
|
.set(chatAccount).equalToWhenPresent(record::getChatAccount)
|
||||||
|
.set(email).equalToWhenPresent(record::getEmail)
|
||||||
|
.set(workDirection).equalToWhenPresent(record::getWorkDirection)
|
||||||
|
.set(status).equalToWhenPresent(record::getStatus)
|
||||||
|
.set(createTime).equalToWhenPresent(record::getCreateTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default int updateByPrimaryKey(Author record) {
|
||||||
|
return update(c ->
|
||||||
|
c.set(userId).equalTo(record::getUserId)
|
||||||
|
.set(inviteCode).equalTo(record::getInviteCode)
|
||||||
|
.set(penName).equalTo(record::getPenName)
|
||||||
|
.set(telPhone).equalTo(record::getTelPhone)
|
||||||
|
.set(chatAccount).equalTo(record::getChatAccount)
|
||||||
|
.set(email).equalTo(record::getEmail)
|
||||||
|
.set(workDirection).equalTo(record::getWorkDirection)
|
||||||
|
.set(status).equalTo(record::getStatus)
|
||||||
|
.set(createTime).equalTo(record::getCreateTime)
|
||||||
|
.where(id, isEqualTo(record::getId))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default int updateByPrimaryKeySelective(Author record) {
|
||||||
|
return update(c ->
|
||||||
|
c.set(userId).equalToWhenPresent(record::getUserId)
|
||||||
|
.set(inviteCode).equalToWhenPresent(record::getInviteCode)
|
||||||
|
.set(penName).equalToWhenPresent(record::getPenName)
|
||||||
|
.set(telPhone).equalToWhenPresent(record::getTelPhone)
|
||||||
|
.set(chatAccount).equalToWhenPresent(record::getChatAccount)
|
||||||
|
.set(email).equalToWhenPresent(record::getEmail)
|
||||||
|
.set(workDirection).equalToWhenPresent(record::getWorkDirection)
|
||||||
|
.set(status).equalToWhenPresent(record::getStatus)
|
||||||
|
.set(createTime).equalToWhenPresent(record::getCreateTime)
|
||||||
|
.where(id, isEqualTo(record::getId))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -24,7 +24,7 @@ public final class BookContentDynamicSqlSupport {
|
|||||||
|
|
||||||
public final SqlColumn<Long> indexId = column("index_id", JDBCType.BIGINT);
|
public final SqlColumn<Long> indexId = column("index_id", JDBCType.BIGINT);
|
||||||
|
|
||||||
public final SqlColumn<String> content = column("content", JDBCType.LONGVARCHAR);
|
public final SqlColumn<String> content = column("content", JDBCType.VARCHAR);
|
||||||
|
|
||||||
public BookContent() {
|
public BookContent() {
|
||||||
super("book_content");
|
super("book_content");
|
||||||
|
@ -63,7 +63,7 @@ public interface BookContentMapper {
|
|||||||
@Results(id="BookContentResult", value = {
|
@Results(id="BookContentResult", value = {
|
||||||
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
|
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
|
||||||
@Result(column="index_id", property="indexId", jdbcType=JdbcType.BIGINT),
|
@Result(column="index_id", property="indexId", jdbcType=JdbcType.BIGINT),
|
||||||
@Result(column="content", property="content", jdbcType=JdbcType.LONGVARCHAR)
|
@Result(column="content", property="content", jdbcType=JdbcType.VARCHAR)
|
||||||
})
|
})
|
||||||
List<BookContent> selectMany(SelectStatementProvider selectStatement);
|
List<BookContent> selectMany(SelectStatementProvider selectStatement);
|
||||||
|
|
||||||
|
@ -0,0 +1,59 @@
|
|||||||
|
package com.java2nb.novel.mapper;
|
||||||
|
|
||||||
|
import java.sql.JDBCType;
|
||||||
|
import java.util.Date;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
import org.mybatis.dynamic.sql.SqlColumn;
|
||||||
|
import org.mybatis.dynamic.sql.SqlTable;
|
||||||
|
|
||||||
|
public final class UserBuyRecordDynamicSqlSupport {
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final UserBuyRecord userBuyRecord = new UserBuyRecord();
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<Long> id = userBuyRecord.id;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<Long> userId = userBuyRecord.userId;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<Long> bookId = userBuyRecord.bookId;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<String> bookName = userBuyRecord.bookName;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<Long> bookIndexId = userBuyRecord.bookIndexId;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<String> bookIndexName = userBuyRecord.bookIndexName;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<Integer> buyAmount = userBuyRecord.buyAmount;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final SqlColumn<Date> createTime = userBuyRecord.createTime;
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
public static final class UserBuyRecord extends SqlTable {
|
||||||
|
public final SqlColumn<Long> id = column("id", JDBCType.BIGINT);
|
||||||
|
|
||||||
|
public final SqlColumn<Long> userId = column("user_id", JDBCType.BIGINT);
|
||||||
|
|
||||||
|
public final SqlColumn<Long> bookId = column("book_id", JDBCType.BIGINT);
|
||||||
|
|
||||||
|
public final SqlColumn<String> bookName = column("book_name", JDBCType.VARCHAR);
|
||||||
|
|
||||||
|
public final SqlColumn<Long> bookIndexId = column("book_index_id", JDBCType.BIGINT);
|
||||||
|
|
||||||
|
public final SqlColumn<String> bookIndexName = column("book_index_name", JDBCType.VARCHAR);
|
||||||
|
|
||||||
|
public final SqlColumn<Integer> buyAmount = column("buy_amount", JDBCType.INTEGER);
|
||||||
|
|
||||||
|
public final SqlColumn<Date> createTime = column("create_time", JDBCType.TIMESTAMP);
|
||||||
|
|
||||||
|
public UserBuyRecord() {
|
||||||
|
super("user_buy_record");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,216 @@
|
|||||||
|
package com.java2nb.novel.mapper;
|
||||||
|
|
||||||
|
import static com.java2nb.novel.mapper.UserBuyRecordDynamicSqlSupport.*;
|
||||||
|
import static org.mybatis.dynamic.sql.SqlBuilder.*;
|
||||||
|
|
||||||
|
import com.java2nb.novel.entity.UserBuyRecord;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
import org.apache.ibatis.annotations.DeleteProvider;
|
||||||
|
import org.apache.ibatis.annotations.InsertProvider;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Result;
|
||||||
|
import org.apache.ibatis.annotations.ResultMap;
|
||||||
|
import org.apache.ibatis.annotations.Results;
|
||||||
|
import org.apache.ibatis.annotations.SelectProvider;
|
||||||
|
import org.apache.ibatis.annotations.UpdateProvider;
|
||||||
|
import org.apache.ibatis.type.JdbcType;
|
||||||
|
import org.mybatis.dynamic.sql.BasicColumn;
|
||||||
|
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
|
||||||
|
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
|
||||||
|
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
|
||||||
|
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
|
||||||
|
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
|
||||||
|
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
|
||||||
|
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
|
||||||
|
import org.mybatis.dynamic.sql.update.UpdateDSL;
|
||||||
|
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
|
||||||
|
import org.mybatis.dynamic.sql.update.UpdateModel;
|
||||||
|
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
|
||||||
|
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
|
||||||
|
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface UserBuyRecordMapper {
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
BasicColumn[] selectList = BasicColumn.columnList(id, userId, bookId, bookName, bookIndexId, bookIndexName, buyAmount, createTime);
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||||
|
long count(SelectStatementProvider selectStatement);
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
@DeleteProvider(type=SqlProviderAdapter.class, method="delete")
|
||||||
|
int delete(DeleteStatementProvider deleteStatement);
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
@InsertProvider(type=SqlProviderAdapter.class, method="insert")
|
||||||
|
int insert(InsertStatementProvider<UserBuyRecord> insertStatement);
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
@InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
|
||||||
|
int insertMultiple(MultiRowInsertStatementProvider<UserBuyRecord> multipleInsertStatement);
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||||
|
@ResultMap("UserBuyRecordResult")
|
||||||
|
Optional<UserBuyRecord> selectOne(SelectStatementProvider selectStatement);
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||||
|
@Results(id="UserBuyRecordResult", value = {
|
||||||
|
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
|
||||||
|
@Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT),
|
||||||
|
@Result(column="book_id", property="bookId", jdbcType=JdbcType.BIGINT),
|
||||||
|
@Result(column="book_name", property="bookName", jdbcType=JdbcType.VARCHAR),
|
||||||
|
@Result(column="book_index_id", property="bookIndexId", jdbcType=JdbcType.BIGINT),
|
||||||
|
@Result(column="book_index_name", property="bookIndexName", jdbcType=JdbcType.VARCHAR),
|
||||||
|
@Result(column="buy_amount", property="buyAmount", jdbcType=JdbcType.INTEGER),
|
||||||
|
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP)
|
||||||
|
})
|
||||||
|
List<UserBuyRecord> selectMany(SelectStatementProvider selectStatement);
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
@UpdateProvider(type=SqlProviderAdapter.class, method="update")
|
||||||
|
int update(UpdateStatementProvider updateStatement);
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default long count(CountDSLCompleter completer) {
|
||||||
|
return MyBatis3Utils.countFrom(this::count, userBuyRecord, completer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default int delete(DeleteDSLCompleter completer) {
|
||||||
|
return MyBatis3Utils.deleteFrom(this::delete, userBuyRecord, completer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default int deleteByPrimaryKey(Long id_) {
|
||||||
|
return delete(c ->
|
||||||
|
c.where(id, isEqualTo(id_))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default int insert(UserBuyRecord record) {
|
||||||
|
return MyBatis3Utils.insert(this::insert, record, userBuyRecord, c ->
|
||||||
|
c.map(id).toProperty("id")
|
||||||
|
.map(userId).toProperty("userId")
|
||||||
|
.map(bookId).toProperty("bookId")
|
||||||
|
.map(bookName).toProperty("bookName")
|
||||||
|
.map(bookIndexId).toProperty("bookIndexId")
|
||||||
|
.map(bookIndexName).toProperty("bookIndexName")
|
||||||
|
.map(buyAmount).toProperty("buyAmount")
|
||||||
|
.map(createTime).toProperty("createTime")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default int insertMultiple(Collection<UserBuyRecord> records) {
|
||||||
|
return MyBatis3Utils.insertMultiple(this::insertMultiple, records, userBuyRecord, c ->
|
||||||
|
c.map(id).toProperty("id")
|
||||||
|
.map(userId).toProperty("userId")
|
||||||
|
.map(bookId).toProperty("bookId")
|
||||||
|
.map(bookName).toProperty("bookName")
|
||||||
|
.map(bookIndexId).toProperty("bookIndexId")
|
||||||
|
.map(bookIndexName).toProperty("bookIndexName")
|
||||||
|
.map(buyAmount).toProperty("buyAmount")
|
||||||
|
.map(createTime).toProperty("createTime")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default int insertSelective(UserBuyRecord record) {
|
||||||
|
return MyBatis3Utils.insert(this::insert, record, userBuyRecord, c ->
|
||||||
|
c.map(id).toPropertyWhenPresent("id", record::getId)
|
||||||
|
.map(userId).toPropertyWhenPresent("userId", record::getUserId)
|
||||||
|
.map(bookId).toPropertyWhenPresent("bookId", record::getBookId)
|
||||||
|
.map(bookName).toPropertyWhenPresent("bookName", record::getBookName)
|
||||||
|
.map(bookIndexId).toPropertyWhenPresent("bookIndexId", record::getBookIndexId)
|
||||||
|
.map(bookIndexName).toPropertyWhenPresent("bookIndexName", record::getBookIndexName)
|
||||||
|
.map(buyAmount).toPropertyWhenPresent("buyAmount", record::getBuyAmount)
|
||||||
|
.map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default Optional<UserBuyRecord> selectOne(SelectDSLCompleter completer) {
|
||||||
|
return MyBatis3Utils.selectOne(this::selectOne, selectList, userBuyRecord, completer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default List<UserBuyRecord> select(SelectDSLCompleter completer) {
|
||||||
|
return MyBatis3Utils.selectList(this::selectMany, selectList, userBuyRecord, completer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default List<UserBuyRecord> selectDistinct(SelectDSLCompleter completer) {
|
||||||
|
return MyBatis3Utils.selectDistinct(this::selectMany, selectList, userBuyRecord, completer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default Optional<UserBuyRecord> selectByPrimaryKey(Long id_) {
|
||||||
|
return selectOne(c ->
|
||||||
|
c.where(id, isEqualTo(id_))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default int update(UpdateDSLCompleter completer) {
|
||||||
|
return MyBatis3Utils.update(this::update, userBuyRecord, completer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
static UpdateDSL<UpdateModel> updateAllColumns(UserBuyRecord record, UpdateDSL<UpdateModel> dsl) {
|
||||||
|
return dsl.set(id).equalTo(record::getId)
|
||||||
|
.set(userId).equalTo(record::getUserId)
|
||||||
|
.set(bookId).equalTo(record::getBookId)
|
||||||
|
.set(bookName).equalTo(record::getBookName)
|
||||||
|
.set(bookIndexId).equalTo(record::getBookIndexId)
|
||||||
|
.set(bookIndexName).equalTo(record::getBookIndexName)
|
||||||
|
.set(buyAmount).equalTo(record::getBuyAmount)
|
||||||
|
.set(createTime).equalTo(record::getCreateTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
static UpdateDSL<UpdateModel> updateSelectiveColumns(UserBuyRecord record, UpdateDSL<UpdateModel> dsl) {
|
||||||
|
return dsl.set(id).equalToWhenPresent(record::getId)
|
||||||
|
.set(userId).equalToWhenPresent(record::getUserId)
|
||||||
|
.set(bookId).equalToWhenPresent(record::getBookId)
|
||||||
|
.set(bookName).equalToWhenPresent(record::getBookName)
|
||||||
|
.set(bookIndexId).equalToWhenPresent(record::getBookIndexId)
|
||||||
|
.set(bookIndexName).equalToWhenPresent(record::getBookIndexName)
|
||||||
|
.set(buyAmount).equalToWhenPresent(record::getBuyAmount)
|
||||||
|
.set(createTime).equalToWhenPresent(record::getCreateTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default int updateByPrimaryKey(UserBuyRecord record) {
|
||||||
|
return update(c ->
|
||||||
|
c.set(userId).equalTo(record::getUserId)
|
||||||
|
.set(bookId).equalTo(record::getBookId)
|
||||||
|
.set(bookName).equalTo(record::getBookName)
|
||||||
|
.set(bookIndexId).equalTo(record::getBookIndexId)
|
||||||
|
.set(bookIndexName).equalTo(record::getBookIndexName)
|
||||||
|
.set(buyAmount).equalTo(record::getBuyAmount)
|
||||||
|
.set(createTime).equalTo(record::getCreateTime)
|
||||||
|
.where(id, isEqualTo(record::getId))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||||
|
default int updateByPrimaryKeySelective(UserBuyRecord record) {
|
||||||
|
return update(c ->
|
||||||
|
c.set(userId).equalToWhenPresent(record::getUserId)
|
||||||
|
.set(bookId).equalToWhenPresent(record::getBookId)
|
||||||
|
.set(bookName).equalToWhenPresent(record::getBookName)
|
||||||
|
.set(bookIndexId).equalToWhenPresent(record::getBookIndexId)
|
||||||
|
.set(bookIndexName).equalToWhenPresent(record::getBookIndexName)
|
||||||
|
.set(buyAmount).equalToWhenPresent(record::getBuyAmount)
|
||||||
|
.set(createTime).equalToWhenPresent(record::getCreateTime)
|
||||||
|
.where(id, isEqualTo(record::getId))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,79 @@
|
|||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
include: [common]
|
include: [common]
|
||||||
|
main:
|
||||||
|
allow-bean-definition-overriding: true
|
||||||
|
#Redis服务器IP
|
||||||
|
redis:
|
||||||
|
host: 127.0.0.1
|
||||||
|
#Redis服务器连接端口
|
||||||
|
port: 6379
|
||||||
|
#Redis服务器连接密码
|
||||||
|
password: test
|
||||||
|
jedis:
|
||||||
|
pool:
|
||||||
|
#连接池最大连接数(使用负值表示没有限制)
|
||||||
|
max-active: 8
|
||||||
|
#连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||||
|
max-wait: 1
|
||||||
|
#连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||||
|
max-idle: 8
|
||||||
|
#连接池中的最小空闲连接
|
||||||
|
min-idle: 0
|
||||||
|
#连接超时时间(毫秒)
|
||||||
|
timeout: 30000
|
||||||
datasource:
|
datasource:
|
||||||
url: jdbc:mysql://127.0.0.1:3306/novel_plus?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
|
url: jdbc:mysql://127.0.0.1:3306/novel_plus?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||||
username: root
|
username: root
|
||||||
password: test123456
|
password: test123456
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
|
||||||
|
####使用shardingJdbc时,
|
||||||
|
####所有的jdbcType都不能是LONGVARCHAR,否则会导致java.io.NotSerializableException: java.io.StringReader错误
|
||||||
|
##### 应该替换所有的 LONGVARCHAR 类型为VARCHAR
|
||||||
|
|
||||||
|
sharding:
|
||||||
|
jdbc:
|
||||||
|
datasource:
|
||||||
|
names: ds0 #,ds1
|
||||||
|
ds0:
|
||||||
|
type: com.zaxxer.hikari.HikariDataSource
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
jdbc-url: jdbc:mysql://localhost:3306/novel_plus?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
|
||||||
|
username: root
|
||||||
|
password: test123456
|
||||||
|
# ds1:
|
||||||
|
# type: com.alibaba.druid.pool.DruidDataSource
|
||||||
|
# driver-class-name: com.mysql.jdbc.Driver
|
||||||
|
# url: jdbc:mysql://localhost:3306/novel_plus2
|
||||||
|
# username: root
|
||||||
|
# password: test123456
|
||||||
|
config:
|
||||||
|
sharding:
|
||||||
|
props:
|
||||||
|
sql.show: true
|
||||||
|
tables:
|
||||||
|
book_content: #book_content表
|
||||||
|
key-generator-column-name: id #主键
|
||||||
|
actual-data-nodes: ds${0}.book_content${0..9} #数据节点
|
||||||
|
# database-strategy: #分库策略
|
||||||
|
# inline:
|
||||||
|
# sharding-column: book_id
|
||||||
|
# algorithm-expression: ds${book_id % 10}
|
||||||
|
table-strategy: #分表策略
|
||||||
|
inline:
|
||||||
|
shardingColumn: index_id
|
||||||
|
algorithm-expression: book_content${index_id % 10}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pic:
|
pic:
|
||||||
save:
|
save:
|
||||||
type: 2 #图片保存方式, 1不保存,使用网络图片 ,2本地保存
|
type: 2 #图片保存方式, 1不保存,使用爬取的网络图片 ,2保存在自己的存储介质
|
||||||
|
storage: local #存储介质,local:本地,OSS:阿里云对象存储,fastDfs:分布式文件系统
|
||||||
path: /var/pic #图片保存路径
|
path: /var/pic #图片保存路径
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,6 +11,9 @@ spring:
|
|||||||
generator:
|
generator:
|
||||||
write-numbers-as-strings: true
|
write-numbers-as-strings: true
|
||||||
|
|
||||||
|
#缓存类型,ehcache(默认)、redis
|
||||||
|
cache:
|
||||||
|
type: ehcache
|
||||||
|
|
||||||
mybatis:
|
mybatis:
|
||||||
configuration:
|
configuration:
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</commentGenerator>
|
</commentGenerator>
|
||||||
<jdbcConnection
|
<jdbcConnection
|
||||||
connectionURL="jdbc:mysql://127.0.0.1:3306/novel_plus?tinyInt1isBit=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true"
|
connectionURL="jdbc:mysql://127.0.0.1:3306/novel_plus?tinyInt1isBit=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true"
|
||||||
driverClass="com.mysql.jdbc.Driver" password="test123456"
|
driverClass="com.mysql.jdbc.Driver" password=""
|
||||||
userId="root" />
|
userId="root" />
|
||||||
|
|
||||||
<!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer, 为 true时把JDBC DECIMAL
|
<!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer, 为 true时把JDBC DECIMAL
|
||||||
@ -44,7 +44,7 @@
|
|||||||
</javaClientGenerator>
|
</javaClientGenerator>
|
||||||
|
|
||||||
<!--生成全部表tableName设为%-->
|
<!--生成全部表tableName设为%-->
|
||||||
<table tableName="order_pay" domainObjectName="OrderPay"/>
|
<table tableName="user_buy_record" domainObjectName="UserBuyRecord"/>
|
||||||
|
|
||||||
<!-- 指定数据库表 -->
|
<!-- 指定数据库表 -->
|
||||||
<!--<table schema="jly" tableName="job_position" domainObjectName="JobPositionTest"/>-->
|
<!--<table schema="jly" tableName="job_position" domainObjectName="JobPositionTest"/>-->
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>novel</artifactId>
|
<artifactId>novel</artifactId>
|
||||||
<groupId>com.java2nb</groupId>
|
<groupId>com.java2nb</groupId>
|
||||||
<version>1.1.1</version>
|
<version>2.5.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -25,6 +25,8 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-security</artifactId>
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -3,12 +3,17 @@ package com.java2nb.novel.core.crawl;
|
|||||||
import com.java2nb.novel.core.utils.HttpUtil;
|
import com.java2nb.novel.core.utils.HttpUtil;
|
||||||
import com.java2nb.novel.core.utils.IdWorker;
|
import com.java2nb.novel.core.utils.IdWorker;
|
||||||
import com.java2nb.novel.core.utils.RandomBookInfoUtil;
|
import com.java2nb.novel.core.utils.RandomBookInfoUtil;
|
||||||
|
import com.java2nb.novel.core.utils.RestTemplateUtil;
|
||||||
import com.java2nb.novel.entity.Book;
|
import com.java2nb.novel.entity.Book;
|
||||||
import com.java2nb.novel.entity.BookContent;
|
import com.java2nb.novel.entity.BookContent;
|
||||||
import com.java2nb.novel.entity.BookIndex;
|
import com.java2nb.novel.entity.BookIndex;
|
||||||
import com.java2nb.novel.utils.Constants;
|
import com.java2nb.novel.utils.Constants;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -22,17 +27,24 @@ import static java.util.regex.Pattern.compile;
|
|||||||
*
|
*
|
||||||
* @author Administrator
|
* @author Administrator
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class CrawlParser {
|
public class CrawlParser {
|
||||||
|
|
||||||
|
private static IdWorker idWorker = new IdWorker();
|
||||||
|
|
||||||
public static final Integer BOOK_INDEX_LIST_KEY = 1;
|
public static final Integer BOOK_INDEX_LIST_KEY = 1;
|
||||||
|
|
||||||
public static final Integer BOOK_CONTENT_LIST_KEY = 2;
|
public static final Integer BOOK_CONTENT_LIST_KEY = 2;
|
||||||
|
|
||||||
|
private static RestTemplate restTemplate = RestTemplateUtil.getInstance("utf-8");
|
||||||
|
|
||||||
|
private static ThreadLocal <Integer> retryCount = new ThreadLocal<>();
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public static Book parseBook(RuleBean ruleBean, String bookId) {
|
public static Book parseBook(RuleBean ruleBean, String bookId) {
|
||||||
Book book = new Book();
|
Book book = new Book();
|
||||||
String bookDetailUrl = ruleBean.getBookDetailUrl().replace("{bookId}", bookId);
|
String bookDetailUrl = ruleBean.getBookDetailUrl().replace("{bookId}", bookId);
|
||||||
String bookDetailHtml = HttpUtil.getByHttpClient(bookDetailUrl);
|
String bookDetailHtml = getByHttpClient(bookDetailUrl);
|
||||||
if (bookDetailHtml != null) {
|
if (bookDetailHtml != null) {
|
||||||
Pattern bookNamePatten = compile(ruleBean.getBookNamePatten());
|
Pattern bookNamePatten = compile(ruleBean.getBookNamePatten());
|
||||||
Matcher bookNameMatch = bookNamePatten.matcher(bookDetailHtml);
|
Matcher bookNameMatch = bookNamePatten.matcher(bookDetailHtml);
|
||||||
@ -54,6 +66,9 @@ public class CrawlParser {
|
|||||||
boolean isFindPicUrl = picUrlMatch.find();
|
boolean isFindPicUrl = picUrlMatch.find();
|
||||||
if (isFindPicUrl) {
|
if (isFindPicUrl) {
|
||||||
String picUrl = picUrlMatch.group(1);
|
String picUrl = picUrlMatch.group(1);
|
||||||
|
if(StringUtils.isNotBlank(picUrl) && StringUtils.isNotBlank(ruleBean.getPicUrlPrefix())) {
|
||||||
|
picUrl = ruleBean.getPicUrlPrefix() + picUrl;
|
||||||
|
}
|
||||||
//设置封面图片路径
|
//设置封面图片路径
|
||||||
book.setPicUrl(picUrl);
|
book.setPicUrl(picUrl);
|
||||||
}
|
}
|
||||||
@ -81,6 +96,12 @@ public class CrawlParser {
|
|||||||
|
|
||||||
String desc = bookDetailHtml.substring(bookDetailHtml.indexOf(ruleBean.getDescStart()) + ruleBean.getDescStart().length());
|
String desc = bookDetailHtml.substring(bookDetailHtml.indexOf(ruleBean.getDescStart()) + ruleBean.getDescStart().length());
|
||||||
desc = desc.substring(0, desc.indexOf(ruleBean.getDescEnd()));
|
desc = desc.substring(0, desc.indexOf(ruleBean.getDescEnd()));
|
||||||
|
//过滤掉简介中的特殊标签
|
||||||
|
desc = desc.replaceAll("<a[^<]+</a>","")
|
||||||
|
.replaceAll("<font[^<]+</font>","")
|
||||||
|
.replaceAll("<p>\\s*</p>","")
|
||||||
|
.replaceAll("<p>","")
|
||||||
|
.replaceAll("</p>","<br/>");
|
||||||
//设置书籍简介
|
//设置书籍简介
|
||||||
book.setBookDesc(desc);
|
book.setBookDesc(desc);
|
||||||
if (StringUtils.isNotBlank(ruleBean.getStatusPatten())) {
|
if (StringUtils.isNotBlank(ruleBean.getStatusPatten())) {
|
||||||
@ -136,8 +157,13 @@ public class CrawlParser {
|
|||||||
List<BookContent> contentList = new ArrayList<>();
|
List<BookContent> contentList = new ArrayList<>();
|
||||||
//读取目录
|
//读取目录
|
||||||
String indexListUrl = ruleBean.getBookIndexUrl().replace("{bookId}", sourceBookId);
|
String indexListUrl = ruleBean.getBookIndexUrl().replace("{bookId}", sourceBookId);
|
||||||
String indexListHtml = HttpUtil.getByHttpClient(indexListUrl);
|
String indexListHtml = getByHttpClient(indexListUrl);
|
||||||
|
|
||||||
if (indexListHtml != null) {
|
if (indexListHtml != null) {
|
||||||
|
if(StringUtils.isNotBlank(ruleBean.getBookIndexStart())){
|
||||||
|
indexListHtml = indexListHtml.substring(indexListHtml.indexOf(ruleBean.getBookIndexStart()) + ruleBean.getBookIndexStart().length());
|
||||||
|
}
|
||||||
|
|
||||||
Pattern indexIdPatten = compile(ruleBean.getIndexIdPatten());
|
Pattern indexIdPatten = compile(ruleBean.getIndexIdPatten());
|
||||||
Matcher indexIdMatch = indexIdPatten.matcher(indexListHtml);
|
Matcher indexIdMatch = indexIdPatten.matcher(indexListHtml);
|
||||||
|
|
||||||
@ -155,6 +181,7 @@ public class CrawlParser {
|
|||||||
String lastIndexName = null;
|
String lastIndexName = null;
|
||||||
|
|
||||||
while (isFindIndex) {
|
while (isFindIndex) {
|
||||||
|
|
||||||
BookIndex hasIndex = hasIndexs.get(indexNum);
|
BookIndex hasIndex = hasIndexs.get(indexNum);
|
||||||
String indexName = indexNameMatch.group(1);
|
String indexName = indexNameMatch.group(1);
|
||||||
|
|
||||||
@ -162,8 +189,8 @@ public class CrawlParser {
|
|||||||
String contentUrl = ruleBean.getBookContentUrl().replace("{bookId}", sourceBookId).replace("{indexId}", indexIdMatch.group(1));
|
String contentUrl = ruleBean.getBookContentUrl().replace("{bookId}", sourceBookId).replace("{indexId}", indexIdMatch.group(1));
|
||||||
|
|
||||||
//查询章节内容
|
//查询章节内容
|
||||||
String contentHtml = HttpUtil.getByHttpClient(contentUrl);
|
String contentHtml = getByHttpClient(contentUrl);
|
||||||
if (contentHtml != null) {
|
if (contentHtml != null && !contentHtml.contains("正在手打中")) {
|
||||||
String content = contentHtml.substring(contentHtml.indexOf(ruleBean.getContentStart()) + ruleBean.getContentStart().length());
|
String content = contentHtml.substring(contentHtml.indexOf(ruleBean.getContentStart()) + ruleBean.getContentStart().length());
|
||||||
content = content.substring(0, content.indexOf(ruleBean.getContentEnd()));
|
content = content.substring(0, content.indexOf(ruleBean.getContentEnd()));
|
||||||
//TODO插入章节目录和章节内容
|
//TODO插入章节目录和章节内容
|
||||||
@ -181,7 +208,7 @@ public class CrawlParser {
|
|||||||
if(hasIndexs.size() == 0){
|
if(hasIndexs.size() == 0){
|
||||||
//新书入库
|
//新书入库
|
||||||
//设置目录和章节内容
|
//设置目录和章节内容
|
||||||
Long indexId = new IdWorker().nextId();
|
Long indexId = idWorker.nextId();
|
||||||
lastIndexId = indexId;
|
lastIndexId = indexId;
|
||||||
lastIndexName = indexName;
|
lastIndexName = indexName;
|
||||||
bookIndex.setId(indexId);
|
bookIndex.setId(indexId);
|
||||||
@ -237,4 +264,37 @@ public class CrawlParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static String getByHttpClient(String url) {
|
||||||
|
try {
|
||||||
|
ResponseEntity<String> forEntity = restTemplate.getForEntity(url, String.class);
|
||||||
|
if (forEntity.getStatusCode() == HttpStatus.OK) {
|
||||||
|
String body = forEntity.getBody();
|
||||||
|
if(body.length() < Constants.INVALID_HTML_LENGTH){
|
||||||
|
return processErrorHttpResult(url);
|
||||||
|
}
|
||||||
|
//成功获得html内容
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return processErrorHttpResult(url);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
private static String processErrorHttpResult(String url){
|
||||||
|
Integer count = retryCount.get();
|
||||||
|
if(count == null){
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
if(count < Constants.HTTP_FAIL_RETRY_COUNT){
|
||||||
|
Thread.sleep( new Random().nextInt(10*1000));
|
||||||
|
retryCount.set(++count);
|
||||||
|
return getByHttpClient(url);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,14 @@ import java.util.Map;
|
|||||||
@Data
|
@Data
|
||||||
public class RuleBean {
|
public class RuleBean {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小说更新列表url
|
||||||
|
* */
|
||||||
|
private String updateBookListUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分类列表页URL规则
|
||||||
|
* */
|
||||||
private String bookListUrl;
|
private String bookListUrl;
|
||||||
|
|
||||||
private Map<String,String> catIdRule;
|
private Map<String,String> catIdRule;
|
||||||
@ -39,4 +47,9 @@ public class RuleBean {
|
|||||||
private String contentEnd;
|
private String contentEnd;
|
||||||
|
|
||||||
|
|
||||||
|
private String picUrlPrefix;
|
||||||
|
|
||||||
|
private String bookIndexStart;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ public class StarterListener implements ServletContextListener {
|
|||||||
Book book = CrawlParser.parseBook(ruleBean, needUpdateBook.getCrawlBookId());
|
Book book = CrawlParser.parseBook(ruleBean, needUpdateBook.getCrawlBookId());
|
||||||
//这里只做老书更新
|
//这里只做老书更新
|
||||||
book.setId(needUpdateBook.getId());
|
book.setId(needUpdateBook.getId());
|
||||||
if(needUpdateBook.getPicUrl()!=null && needUpdateBook.getPicUrl().startsWith(Constants.LOCAL_PIC_PREFIX)) {
|
if(needUpdateBook.getPicUrl()!=null && needUpdateBook.getPicUrl().contains(Constants.LOCAL_PIC_PREFIX)) {
|
||||||
//本地图片则不更新
|
//本地图片则不更新
|
||||||
book.setPicUrl(null);
|
book.setPicUrl(null);
|
||||||
}
|
}
|
||||||
|
@ -167,6 +167,11 @@ public class CrawlServiceImpl implements CrawlService {
|
|||||||
boolean isFindBookId = bookIdMatcher.find();
|
boolean isFindBookId = bookIdMatcher.find();
|
||||||
while (isFindBookId) {
|
while (isFindBookId) {
|
||||||
try {
|
try {
|
||||||
|
if(Thread.currentThread().isInterrupted()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
String bookId = bookIdMatcher.group(1);
|
String bookId = bookIdMatcher.group(1);
|
||||||
Book book = CrawlParser.parseBook(ruleBean, bookId);
|
Book book = CrawlParser.parseBook(ruleBean, bookId);
|
||||||
//这里只做新书入库,查询是否存在这本书
|
//这里只做新书入库,查询是否存在这本书
|
||||||
|
@ -14,4 +14,14 @@ public class Constants {
|
|||||||
* 访问量默认值
|
* 访问量默认值
|
||||||
*/
|
*/
|
||||||
public static final Long VISIT_COUNT_DEFAULT = 100L;
|
public static final Long VISIT_COUNT_DEFAULT = 100L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 爬取小说http请求中无效的内容长度
|
||||||
|
*/
|
||||||
|
public static final int INVALID_HTML_LENGTH = 1500;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 爬取小说http请求失败重试次数
|
||||||
|
*/
|
||||||
|
public static final Integer HTTP_FAIL_RETRY_COUNT = 5;
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,9 @@
|
|||||||
<li><span id="LabErr"></span></li>
|
<li><span id="LabErr"></span></li>
|
||||||
示例:<b>新顶点小说网</b>
|
示例:<b>新顶点小说网</b>
|
||||||
<li><input type="text" id="sourceName" class="s_input icon_name" placeholder="源站名"></li>
|
<li><input type="text" id="sourceName" class="s_input icon_name" placeholder="源站名"></li>
|
||||||
|
<!--示例:<b>https://m.xdingdiann.com/sort/0/1.html</b>
|
||||||
|
<li><input type="text" id="updateBookListUrl" class="s_input icon_key"
|
||||||
|
placeholder="小说更新列表url"></li>-->
|
||||||
示例:<b>http://m.xdingdiann.com/sort/{catId}/{page}.html</b> ({catId}代表分类ID,{page}代表分页页码)
|
示例:<b>http://m.xdingdiann.com/sort/{catId}/{page}.html</b> ({catId}代表分类ID,{page}代表分页页码)
|
||||||
<li><input type="text" id="bookListUrl" class="s_input icon_key"
|
<li><input type="text" id="bookListUrl" class="s_input icon_key"
|
||||||
placeholder="分类列表页URL规则"></li>
|
placeholder="分类列表页URL规则"></li>
|
||||||
@ -95,6 +98,9 @@
|
|||||||
示例:<b><img src="([^>]+)"\s+onerror="this.src=</b>
|
示例:<b><img src="([^>]+)"\s+onerror="this.src=</b>
|
||||||
<li><input type="text" id="picUrlPatten" class="s_input icon_key"
|
<li><input type="text" id="picUrlPatten" class="s_input icon_key"
|
||||||
placeholder="小说图片路径的正则表达式:"></li>
|
placeholder="小说图片路径的正则表达式:"></li>
|
||||||
|
<b>可空,适用于图片路径为相对路径的源站,加上小说图片路径,则为完整的可访问的图片路径</b>
|
||||||
|
<li><input type="text" id="picUrlPrefix" class="s_input icon_key"
|
||||||
|
placeholder="小说图片访问路径前缀:"></li>
|
||||||
示例:<b>状态:([^/]+)</li></b>
|
示例:<b>状态:([^/]+)</li></b>
|
||||||
<li><input type="text" id="statusPatten" class="s_input icon_key"
|
<li><input type="text" id="statusPatten" class="s_input icon_key"
|
||||||
placeholder="小说状态的正则表达式:"></li>
|
placeholder="小说状态的正则表达式:"></li>
|
||||||
@ -125,6 +131,9 @@
|
|||||||
示例:<b>http://m.xdingdiann.com/ddk{bookId}/all.html</b> (bookId代表小说ID)
|
示例:<b>http://m.xdingdiann.com/ddk{bookId}/all.html</b> (bookId代表小说ID)
|
||||||
<li><input type="text" id="bookIndexUrl" class="s_input icon_key"
|
<li><input type="text" id="bookIndexUrl" class="s_input icon_key"
|
||||||
placeholder="小说目录页的URL规则:"></li>
|
placeholder="小说目录页的URL规则:"></li>
|
||||||
|
<b>可空,适用于最新章节列表和全部章节列表在同一个页面的源站</b>
|
||||||
|
<li><input type="text" id="bookIndexStart" class="s_input icon_key"
|
||||||
|
placeholder="小说目录页内容开始截取字符串:"></li>
|
||||||
示例:<b><a\s+style=""\s+href="/ddk\d+/(\d+)\.html">[^/]+</a></b>
|
示例:<b><a\s+style=""\s+href="/ddk\d+/(\d+)\.html">[^/]+</a></b>
|
||||||
<li><input type="text" id="indexIdPatten" class="s_input icon_key"
|
<li><input type="text" id="indexIdPatten" class="s_input icon_key"
|
||||||
placeholder="目录页目录ID正则表达式:"></li>
|
placeholder="目录页目录ID正则表达式:"></li>
|
||||||
@ -278,6 +287,12 @@
|
|||||||
crawlRule.picUrlPatten = picUrlPatten;
|
crawlRule.picUrlPatten = picUrlPatten;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var picUrlPrefix = $("#picUrlPrefix").val();
|
||||||
|
|
||||||
|
if (picUrlPrefix.length > 0) {
|
||||||
|
crawlRule.picUrlPrefix = picUrlPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
var statusPatten = $("#statusPatten").val();
|
var statusPatten = $("#statusPatten").val();
|
||||||
if (statusPatten.length > 0) {
|
if (statusPatten.length > 0) {
|
||||||
crawlRule.statusPatten = statusPatten;
|
crawlRule.statusPatten = statusPatten;
|
||||||
@ -345,6 +360,13 @@
|
|||||||
|
|
||||||
crawlRule.bookIndexUrl = bookIndexUrl;
|
crawlRule.bookIndexUrl = bookIndexUrl;
|
||||||
|
|
||||||
|
|
||||||
|
var bookIndexStart = $("#bookIndexStart").val();
|
||||||
|
|
||||||
|
if (bookIndexStart.length > 0) {
|
||||||
|
crawlRule.bookIndexStart = bookIndexStart;
|
||||||
|
}
|
||||||
|
|
||||||
var indexIdPatten = $("#indexIdPatten").val();
|
var indexIdPatten = $("#indexIdPatten").val();
|
||||||
|
|
||||||
if (indexIdPatten.length == 0) {
|
if (indexIdPatten.length == 0) {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>novel</artifactId>
|
<artifactId>novel</artifactId>
|
||||||
<groupId>com.java2nb</groupId>
|
<groupId>com.java2nb</groupId>
|
||||||
<version>1.1.1</version>
|
<version>2.5.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -27,11 +27,57 @@
|
|||||||
<version>${jjwt.version}</version>
|
<version>${jjwt.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.searchbox</groupId>
|
||||||
|
<artifactId>jest</artifactId>
|
||||||
|
<version>${jest.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--aliyunOSS-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun.oss</groupId>
|
||||||
|
<artifactId>aliyun-sdk-oss</artifactId>
|
||||||
|
<version>${aliyun-sdk-oss.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-fileupload</groupId>
|
||||||
|
<artifactId>commons-fileupload</artifactId>
|
||||||
|
<version>${commons-fileupload.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--FastDfs-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.tobato</groupId>
|
||||||
|
<artifactId>fastdfs-client</artifactId>
|
||||||
|
<version>${fastdfs-client.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!--引入redisson分布式锁-->
|
||||||
|
<!-- <dependency>
|
||||||
|
<groupId>org.redisson</groupId>
|
||||||
|
<artifactId>redisson-spring-boot-starter</artifactId>
|
||||||
|
<version>${redisson.version}</version>
|
||||||
|
</dependency>-->
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alipay.sdk</groupId>
|
<groupId>com.alipay.sdk</groupId>
|
||||||
<artifactId>alipay-sdk-java</artifactId>
|
<artifactId>alipay-sdk-java</artifactId>
|
||||||
<version>4.9.153.ALL</version>
|
<version>${alipay-sdk-java.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
package com.java2nb.novel;
|
package com.java2nb.novel;
|
||||||
|
|
||||||
|
import com.github.tobato.fastdfs.FdfsClientConfig;
|
||||||
|
import io.shardingsphere.shardingjdbc.spring.boot.SpringBootConfiguration;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.cache.annotation.EnableCaching;
|
import org.springframework.cache.annotation.EnableCaching;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.scheduling.TaskScheduler;
|
import org.springframework.scheduling.TaskScheduler;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||||
@ -18,6 +21,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
@EnableCaching
|
@EnableCaching
|
||||||
@MapperScan(basePackages = {"com.java2nb.novel.mapper"})
|
@MapperScan(basePackages = {"com.java2nb.novel.mapper"})
|
||||||
|
@Import(FdfsClientConfig.class)
|
||||||
public class FrontNovelApplication {
|
public class FrontNovelApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -0,0 +1,127 @@
|
|||||||
|
package com.java2nb.novel.controller;
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.java2nb.novel.core.bean.ResultBean;
|
||||||
|
import com.java2nb.novel.core.enums.ResponseStatus;
|
||||||
|
import com.java2nb.novel.core.utils.BeanUtil;
|
||||||
|
import com.java2nb.novel.entity.Author;
|
||||||
|
import com.java2nb.novel.entity.Book;
|
||||||
|
import com.java2nb.novel.service.AuthorService;
|
||||||
|
import com.java2nb.novel.service.BookService;
|
||||||
|
import com.java2nb.novel.service.FriendLinkService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 11797
|
||||||
|
*/
|
||||||
|
@RequestMapping("author")
|
||||||
|
@RestController
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AuthorController extends BaseController{
|
||||||
|
|
||||||
|
private final AuthorService authorService;
|
||||||
|
|
||||||
|
private final BookService bookService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验笔名是否存在
|
||||||
|
* */
|
||||||
|
@PostMapping("checkPenName")
|
||||||
|
public ResultBean checkPenName(String penName){
|
||||||
|
|
||||||
|
return ResultBean.ok(authorService.checkPenName(penName));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 作家发布小说分页列表查询
|
||||||
|
* */
|
||||||
|
@PostMapping("listBookByPage")
|
||||||
|
public ResultBean listBookByPage(@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "10") int pageSize ,HttpServletRequest request){
|
||||||
|
|
||||||
|
return ResultBean.ok(new PageInfo<>(bookService.listBookPageByUserId(getUserDetails(request).getId(),page,pageSize)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发布小说
|
||||||
|
* */
|
||||||
|
@PostMapping("addBook")
|
||||||
|
public ResultBean addBook(@RequestParam("bookDesc") String bookDesc,Book book,HttpServletRequest request){
|
||||||
|
|
||||||
|
//查询作家信息
|
||||||
|
Author author = authorService.queryAuthor(getUserDetails(request).getId());
|
||||||
|
|
||||||
|
//判断作者状态是否正常
|
||||||
|
if(author.getStatus()==1){
|
||||||
|
//封禁状态,不能发布小说
|
||||||
|
return ResultBean.fail(ResponseStatus.AUTHOR_STATUS_FORBIDDEN);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//bookDesc不能使用book对象来接收,否则会自动去掉前面的空格
|
||||||
|
book.setBookDesc(bookDesc
|
||||||
|
.replaceAll("\\n","<br>")
|
||||||
|
.replaceAll("\\s"," "));
|
||||||
|
//发布小说
|
||||||
|
bookService.addBook(book,author.getId(),author.getPenName());
|
||||||
|
|
||||||
|
return ResultBean.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新小说状态,上架或下架
|
||||||
|
* */
|
||||||
|
@PostMapping("updateBookStatus")
|
||||||
|
public ResultBean updateBookStatus(Long bookId,Byte status,HttpServletRequest request){
|
||||||
|
//查询作家信息
|
||||||
|
Author author = authorService.queryAuthor(getUserDetails(request).getId());
|
||||||
|
|
||||||
|
//判断作者状态是否正常
|
||||||
|
if(author.getStatus()==1){
|
||||||
|
//封禁状态,不能发布小说
|
||||||
|
return ResultBean.fail(ResponseStatus.AUTHOR_STATUS_FORBIDDEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
//更新小说状态,上架或下架
|
||||||
|
bookService.updateBookStatus(bookId,status,author.getId());
|
||||||
|
|
||||||
|
return ResultBean.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发布章节内容
|
||||||
|
* */
|
||||||
|
@PostMapping("addBookContent")
|
||||||
|
public ResultBean addBookContent(Long bookId,String indexName,String content,HttpServletRequest request){
|
||||||
|
//查询作家信息
|
||||||
|
Author author = authorService.queryAuthor(getUserDetails(request).getId());
|
||||||
|
|
||||||
|
//判断作者状态是否正常
|
||||||
|
if(author.getStatus()==1){
|
||||||
|
//封禁状态,不能发布小说
|
||||||
|
return ResultBean.fail(ResponseStatus.AUTHOR_STATUS_FORBIDDEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
content = content.replaceAll("\\n","<br>")
|
||||||
|
.replaceAll("\\s"," ");
|
||||||
|
//发布章节内容
|
||||||
|
bookService.addBookContent(bookId,indexName,content,author.getId());
|
||||||
|
|
||||||
|
return ResultBean.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -4,14 +4,14 @@ import com.github.pagehelper.PageInfo;
|
|||||||
import com.java2nb.novel.core.bean.ResultBean;
|
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.Book;
|
|
||||||
import com.java2nb.novel.entity.BookComment;
|
import com.java2nb.novel.entity.BookComment;
|
||||||
import com.java2nb.novel.entity.BookIndex;
|
|
||||||
import com.java2nb.novel.search.BookSP;
|
import com.java2nb.novel.search.BookSP;
|
||||||
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;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
@ -19,7 +19,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,6 +32,11 @@ public class BookController extends BaseController{
|
|||||||
|
|
||||||
private final BookService bookService;
|
private final BookService bookService;
|
||||||
|
|
||||||
|
private final RabbitTemplate rabbitTemplate;
|
||||||
|
|
||||||
|
@Value("${spring.rabbitmq.enable}")
|
||||||
|
private Integer enableMq;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询首页小说设置列表数据
|
* 查询首页小说设置列表数据
|
||||||
@ -79,8 +83,8 @@ public class BookController extends BaseController{
|
|||||||
* */
|
* */
|
||||||
@PostMapping("searchByPage")
|
@PostMapping("searchByPage")
|
||||||
public ResultBean searchByPage(BookSP bookSP, @RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "20") int pageSize){
|
public ResultBean searchByPage(BookSP bookSP, @RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "20") int pageSize){
|
||||||
List<BookVO> books = bookService.searchByPage(bookSP,page,pageSize);
|
PageInfo<BookVO> pageInfo = bookService.searchByPage(bookSP,page,pageSize);
|
||||||
return ResultBean.ok(new PageInfo<>(books));
|
return ResultBean.ok(pageInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,7 +109,11 @@ public class BookController extends BaseController{
|
|||||||
* */
|
* */
|
||||||
@PostMapping("addVisitCount")
|
@PostMapping("addVisitCount")
|
||||||
public ResultBean addVisitCount(Long bookId){
|
public ResultBean addVisitCount(Long bookId){
|
||||||
bookService.addVisitCount(bookId);
|
if(enableMq == 1) {
|
||||||
|
rabbitTemplate.convertAndSend("ADD-BOOK-VISIT-EXCHANGE", null, bookId);
|
||||||
|
}else {
|
||||||
|
bookService.addVisitCount(bookId, 1);
|
||||||
|
}
|
||||||
return ResultBean.ok();
|
return ResultBean.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +124,11 @@ public class BookController extends BaseController{
|
|||||||
public ResultBean queryBookIndexAbout(Long bookId,Long lastBookIndexId) {
|
public ResultBean queryBookIndexAbout(Long bookId,Long lastBookIndexId) {
|
||||||
Map<String,Object> data = new HashMap<>(2);
|
Map<String,Object> data = new HashMap<>(2);
|
||||||
data.put("bookIndexCount",bookService.queryIndexCount(bookId));
|
data.put("bookIndexCount",bookService.queryIndexCount(bookId));
|
||||||
data.put("lastBookContent",bookService.queryBookContent(lastBookIndexId).getContent().substring(0,42));
|
String lastBookContent = bookService.queryBookContent(lastBookIndexId).getContent();
|
||||||
|
if(lastBookContent.length()>42){
|
||||||
|
lastBookContent=lastBookContent.substring(0,42);
|
||||||
|
}
|
||||||
|
data.put("lastBookContent",lastBookContent);
|
||||||
return ResultBean.ok(data);
|
return ResultBean.ok(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,4 +173,6 @@ public class BookController extends BaseController{
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,24 @@
|
|||||||
package com.java2nb.novel.controller;
|
package com.java2nb.novel.controller;
|
||||||
|
|
||||||
|
import com.java2nb.novel.core.bean.ResultBean;
|
||||||
|
import com.java2nb.novel.core.bean.UserDetails;
|
||||||
import com.java2nb.novel.core.utils.ThreadLocalUtil;
|
import com.java2nb.novel.core.utils.ThreadLocalUtil;
|
||||||
import com.java2nb.novel.entity.Book;
|
import com.java2nb.novel.entity.*;
|
||||||
import com.java2nb.novel.entity.BookContent;
|
import com.java2nb.novel.service.AuthorService;
|
||||||
import com.java2nb.novel.entity.BookIndex;
|
|
||||||
import com.java2nb.novel.entity.News;
|
|
||||||
import com.java2nb.novel.service.BookService;
|
import com.java2nb.novel.service.BookService;
|
||||||
import com.java2nb.novel.service.NewsService;
|
import com.java2nb.novel.service.NewsService;
|
||||||
|
import com.java2nb.novel.service.UserService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,12 +27,16 @@ import java.util.List;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Controller
|
@Controller
|
||||||
public class PageController{
|
public class PageController extends BaseController{
|
||||||
|
|
||||||
private final BookService bookService;
|
private final BookService bookService;
|
||||||
|
|
||||||
private final NewsService newsService;
|
private final NewsService newsService;
|
||||||
|
|
||||||
|
private final AuthorService authorService;
|
||||||
|
|
||||||
|
private final UserService userService;
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping("{url}.html")
|
@RequestMapping("{url}.html")
|
||||||
public String module(@PathVariable("url") String url) {
|
public String module(@PathVariable("url") String url) {
|
||||||
@ -35,7 +44,22 @@ public class PageController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("{module}/{url}.html")
|
@RequestMapping("{module}/{url}.html")
|
||||||
public String module2(@PathVariable("module") String module, @PathVariable("url") String url) {
|
public String module2(@PathVariable("module") String module, @PathVariable("url") String url,HttpServletRequest request) {
|
||||||
|
|
||||||
|
if(request.getRequestURI().startsWith("/author")) {
|
||||||
|
//访问作者专区
|
||||||
|
UserDetails user = getUserDetails(request);
|
||||||
|
if (user == null) {
|
||||||
|
//未登录
|
||||||
|
return "redirect:/user/login.html?originUrl=" + request.getRequestURI();
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isAuthor = authorService.isAuthor(user.getId());
|
||||||
|
if (!isAuthor) {
|
||||||
|
return "redirect:/author/register.html" ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return module + "/" + url;
|
return module + "/" + url;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +124,7 @@ public class PageController{
|
|||||||
* 内容页
|
* 内容页
|
||||||
* */
|
* */
|
||||||
@RequestMapping("/book/{bookId}/{bookIndexId}.html")
|
@RequestMapping("/book/{bookId}/{bookIndexId}.html")
|
||||||
public String indexList(@PathVariable("bookId") Long bookId,@PathVariable("bookIndexId") Long bookIndexId, Model model) {
|
public String indexList(@PathVariable("bookId") Long bookId,@PathVariable("bookIndexId") Long bookIndexId, HttpServletRequest request,Model model) {
|
||||||
//查询书籍
|
//查询书籍
|
||||||
Book book = bookService.queryBookDetail(bookId);
|
Book book = bookService.queryBookDetail(bookId);
|
||||||
model.addAttribute("book",book);
|
model.addAttribute("book",book);
|
||||||
@ -116,6 +140,23 @@ public class PageController{
|
|||||||
//查询内容
|
//查询内容
|
||||||
BookContent bookContent = bookService.queryBookContent(bookIndex.getId());
|
BookContent bookContent = bookService.queryBookContent(bookIndex.getId());
|
||||||
model.addAttribute("bookContent",bookContent);
|
model.addAttribute("bookContent",bookContent);
|
||||||
|
//判断该目录是否收费
|
||||||
|
if(bookIndex.getIsVip()!=null && bookIndex.getIsVip() == 1 ){
|
||||||
|
UserDetails user = getUserDetails(request);
|
||||||
|
if(user == null){
|
||||||
|
//未登录
|
||||||
|
return "redirect:/user/login.html?originUrl="+request.getRequestURI();
|
||||||
|
}
|
||||||
|
//收费,判断用户是否购买过该目录
|
||||||
|
boolean isBuy = userService.queryIsBuyBookIndex(user.getId(),bookIndexId);
|
||||||
|
if(!isBuy){
|
||||||
|
//没有购买过,需要购买
|
||||||
|
bookContent.setContent(null);
|
||||||
|
model.addAttribute("needBuy",true);
|
||||||
|
return "book/book_content";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
model.addAttribute("needBuy",false);
|
||||||
return ThreadLocalUtil.getTemplateDir()+"book/book_content";
|
return ThreadLocalUtil.getTemplateDir()+"book/book_content";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,4 +182,30 @@ public class PageController{
|
|||||||
return "about/news_info";
|
return "about/news_info";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 作者注册页面
|
||||||
|
* */
|
||||||
|
@RequestMapping("author/register.html")
|
||||||
|
public String authorRegister(Author author, HttpServletRequest request, Model model){
|
||||||
|
UserDetails user = getUserDetails(request);
|
||||||
|
if(user == null){
|
||||||
|
//未登录
|
||||||
|
return "redirect:/user/login.html?originUrl=/author/register.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(StringUtils.isNotBlank(author.getInviteCode())) {
|
||||||
|
//提交作者注册信息
|
||||||
|
String errorInfo = authorService.register(user.getId(), author);
|
||||||
|
if(StringUtils.isBlank(errorInfo)){
|
||||||
|
//注册成功
|
||||||
|
return "redirect:/author/index.html";
|
||||||
|
}
|
||||||
|
model.addAttribute("LabErr",errorInfo);
|
||||||
|
model.addAttribute("author",author);
|
||||||
|
}
|
||||||
|
return "author/register";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import com.java2nb.novel.core.cache.CacheService;
|
|||||||
import com.java2nb.novel.core.enums.ResponseStatus;
|
import com.java2nb.novel.core.enums.ResponseStatus;
|
||||||
import com.java2nb.novel.core.utils.RandomValidateCodeUtil;
|
import com.java2nb.novel.core.utils.RandomValidateCodeUtil;
|
||||||
import com.java2nb.novel.entity.User;
|
import com.java2nb.novel.entity.User;
|
||||||
|
import com.java2nb.novel.entity.UserBuyRecord;
|
||||||
import com.java2nb.novel.form.UserForm;
|
import com.java2nb.novel.form.UserForm;
|
||||||
import com.java2nb.novel.service.BookService;
|
import com.java2nb.novel.service.BookService;
|
||||||
import com.java2nb.novel.service.UserService;
|
import com.java2nb.novel.service.UserService;
|
||||||
@ -100,7 +101,9 @@ public class UserController extends BaseController {
|
|||||||
token = jwtTokenUtil.refreshToken(token);
|
token = jwtTokenUtil.refreshToken(token);
|
||||||
Map<String, Object> data = new HashMap<>(2);
|
Map<String, Object> data = new HashMap<>(2);
|
||||||
data.put("token", token);
|
data.put("token", token);
|
||||||
data.put("username", jwtTokenUtil.getUserDetailsFromToken(token).getUsername());
|
UserDetails userDetail = jwtTokenUtil.getUserDetailsFromToken(token);
|
||||||
|
data.put("username", userDetail.getUsername());
|
||||||
|
data.put("nickName", userDetail.getNickName());
|
||||||
return ResultBean.ok(data);
|
return ResultBean.ok(data);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -231,6 +234,12 @@ public class UserController extends BaseController {
|
|||||||
return ResultBean.fail(ResponseStatus.NO_LOGIN);
|
return ResultBean.fail(ResponseStatus.NO_LOGIN);
|
||||||
}
|
}
|
||||||
userService.updateUserInfo(userDetails.getId(),user);
|
userService.updateUserInfo(userDetails.getId(),user);
|
||||||
|
if(user.getNickName() != null){
|
||||||
|
userDetails.setNickName(user.getNickName());
|
||||||
|
Map<String, Object> data = new HashMap<>(1);
|
||||||
|
data.put("token", jwtTokenUtil.generateToken(userDetails));
|
||||||
|
return ResultBean.ok(data);
|
||||||
|
}
|
||||||
return ResultBean.ok();
|
return ResultBean.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,6 +273,21 @@ public class UserController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 购买小说章节
|
||||||
|
* */
|
||||||
|
@PostMapping("buyBookIndex")
|
||||||
|
public ResultBean buyBookIndex(UserBuyRecord buyRecord, HttpServletRequest request) {
|
||||||
|
UserDetails userDetails = getUserDetails(request);
|
||||||
|
if (userDetails == null) {
|
||||||
|
return ResultBean.fail(ResponseStatus.NO_LOGIN);
|
||||||
|
}
|
||||||
|
userService.buyBookIndex(userDetails.getId(),buyRecord);
|
||||||
|
return ResultBean.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,4 +11,6 @@ public class UserDetails {
|
|||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
|
private String nickName;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.java2nb.novel.core.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.EnableMBeanExport;
|
||||||
|
import org.springframework.jmx.support.RegistrationPolicy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 11797
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@EnableMBeanExport(registration= RegistrationPolicy.IGNORE_EXISTING)
|
||||||
|
public class FdfsConfiguration {
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.java2nb.novel.core.config;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 11797
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Component
|
||||||
|
@ConfigurationProperties(prefix="novel.file")
|
||||||
|
public class OssProperties{
|
||||||
|
|
||||||
|
private String endpoint;
|
||||||
|
|
||||||
|
private String keyId;
|
||||||
|
|
||||||
|
private String keySecret;
|
||||||
|
|
||||||
|
private String fileHost;
|
||||||
|
|
||||||
|
private String bucketName;
|
||||||
|
|
||||||
|
private String webUrl;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package com.java2nb.novel.core.config;
|
||||||
|
|
||||||
|
import org.springframework.amqp.core.*;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 11797
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@ConditionalOnProperty(prefix = "spring.rabbitmq", name = "enable", havingValue = "1")
|
||||||
|
public class RabbitConfig {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新数据库队列
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public Queue updateDbQueue() {
|
||||||
|
return new Queue("UPDATE-DB-QUEUE", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新数据库队列
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public Queue updateEsQueue() {
|
||||||
|
return new Queue("UPDATE-ES-QUEUE", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增加点击量交换机
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public FanoutExchange addVisitExchange() {
|
||||||
|
return new FanoutExchange("ADD-BOOK-VISIT-EXCHANGE");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新搜索引擎队列绑定到增加点击量交换机中
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public Binding updateEsBinding() {
|
||||||
|
|
||||||
|
return BindingBuilder.bind(updateEsQueue()).to(addVisitExchange());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新数据库绑定到增加点击量交换机中
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public Binding updateDbBinding() {
|
||||||
|
return BindingBuilder.bind(updateDbQueue()).to(addVisitExchange());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,107 @@
|
|||||||
|
package com.java2nb.novel.core.listener;
|
||||||
|
|
||||||
|
import com.java2nb.novel.core.cache.CacheKey;
|
||||||
|
import com.java2nb.novel.core.cache.CacheService;
|
||||||
|
import com.java2nb.novel.core.utils.Constants;
|
||||||
|
import com.java2nb.novel.entity.Book;
|
||||||
|
import com.java2nb.novel.service.BookService;
|
||||||
|
import com.java2nb.novel.service.SearchService;
|
||||||
|
import com.java2nb.novel.vo.EsBookVO;
|
||||||
|
import com.rabbitmq.client.Channel;
|
||||||
|
import io.searchbox.client.JestClient;
|
||||||
|
import io.searchbox.core.Index;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.amqp.core.Message;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
|
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 11797
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@ConditionalOnProperty(prefix = "spring.rabbitmq", name = "enable", havingValue = "1")
|
||||||
|
public class BookVisitAddListener {
|
||||||
|
|
||||||
|
private final BookService bookService;
|
||||||
|
|
||||||
|
private final CacheService cacheService;
|
||||||
|
|
||||||
|
private final SearchService searchService;
|
||||||
|
|
||||||
|
// private final RedissonClient redissonClient;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新数据库
|
||||||
|
* 流量削峰,每本小说累积10个点击更新一次
|
||||||
|
*/
|
||||||
|
@SneakyThrows
|
||||||
|
@RabbitListener(queues = {"UPDATE-DB-QUEUE"})
|
||||||
|
public void updateDb(Long bookId, Channel channel, Message message) {
|
||||||
|
|
||||||
|
log.debug("收到更新数据库消息:" + bookId);
|
||||||
|
Thread.sleep(1000 * 2);
|
||||||
|
//TODO 操作共享资源visitCount,集群环境下有线程安全问题,引入Redisson框架实现分布式锁
|
||||||
|
//RLock lock = redissonClient.getLock("visitCount");
|
||||||
|
//lock.lock();
|
||||||
|
|
||||||
|
|
||||||
|
//目前visitCount不重要,数据可丢失,暂不实现分布式锁
|
||||||
|
Integer visitCount = (Integer) cacheService.getObject(CacheKey.BOOK_ADD_VISIT_COUNT+bookId);
|
||||||
|
if(visitCount == null){
|
||||||
|
visitCount = 0 ;
|
||||||
|
}
|
||||||
|
cacheService.setObject(CacheKey.BOOK_ADD_VISIT_COUNT+bookId,++visitCount);
|
||||||
|
if(visitCount >= Constants.ADD_MAX_VISIT_COUNT) {
|
||||||
|
bookService.addVisitCount(bookId,visitCount);
|
||||||
|
cacheService.del(CacheKey.BOOK_ADD_VISIT_COUNT+bookId);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO 操作共享资源visitCount,集群环境下有线程安全问题,引入Redisson框架实现分布式锁
|
||||||
|
//lock.unlock();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新搜索引擎
|
||||||
|
* 流量削峰,每本小说1个小时更新一次
|
||||||
|
*/
|
||||||
|
@RabbitListener(queues = {"UPDATE-ES-QUEUE"})
|
||||||
|
public void updateEs(Long bookId, Channel channel, Message message) {
|
||||||
|
|
||||||
|
log.debug("收到更新搜索引擎消息:" + bookId);
|
||||||
|
if (cacheService.get(CacheKey.ES_IS_UPDATE_VISIT + bookId) == null) {
|
||||||
|
cacheService.set(CacheKey.ES_IS_UPDATE_VISIT + bookId, "1", 60 * 60);
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000 * 5);
|
||||||
|
Book book = bookService.queryBookDetail(bookId);
|
||||||
|
searchService.importToEs(book);
|
||||||
|
}catch (Exception e){
|
||||||
|
cacheService.del(CacheKey.ES_IS_UPDATE_VISIT + bookId);
|
||||||
|
log.error("更新搜索引擎失败"+bookId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,87 @@
|
|||||||
|
package com.java2nb.novel.core.schedule;
|
||||||
|
|
||||||
|
import com.java2nb.novel.core.cache.CacheKey;
|
||||||
|
import com.java2nb.novel.core.cache.CacheService;
|
||||||
|
import com.java2nb.novel.core.utils.BeanUtil;
|
||||||
|
import com.java2nb.novel.entity.Book;
|
||||||
|
import com.java2nb.novel.service.BookService;
|
||||||
|
import com.java2nb.novel.service.SearchService;
|
||||||
|
import com.java2nb.novel.vo.EsBookVO;
|
||||||
|
import io.searchbox.client.JestClient;
|
||||||
|
import io.searchbox.core.DocumentResult;
|
||||||
|
import io.searchbox.core.Index;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小说导入搜索引擎
|
||||||
|
*
|
||||||
|
* @author Administrator
|
||||||
|
*/
|
||||||
|
@ConditionalOnProperty(prefix = "spring.elasticsearch", name = "enable", havingValue = "1")
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class BookToEsSchedule {
|
||||||
|
|
||||||
|
private final BookService bookService;
|
||||||
|
|
||||||
|
private final CacheService cacheService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private final SearchService searchService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1分钟导入一次
|
||||||
|
*/
|
||||||
|
@Scheduled(fixedRate = 1000 * 60)
|
||||||
|
public void saveToEs() {
|
||||||
|
//TODO 引入Redisson框架实现分布式锁
|
||||||
|
//可以重复更新,只是效率可能略有降低,所以暂不实现分布式锁
|
||||||
|
if (cacheService.get(CacheKey.ES_TRANS_LOCK) == null) {
|
||||||
|
cacheService.set(CacheKey.ES_TRANS_LOCK, "1", 60 * 20);
|
||||||
|
try {
|
||||||
|
//查询需要更新的小说
|
||||||
|
Date lastDate = (Date) cacheService.getObject(CacheKey.ES_LAST_UPDATE_TIME);
|
||||||
|
if (lastDate == null) {
|
||||||
|
lastDate = new SimpleDateFormat("yyyy-MM-dd").parse("2020-01-01");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
List<Book> books = bookService.queryBookByUpdateTimeByPage(lastDate, 100);
|
||||||
|
for (Book book : books) {
|
||||||
|
searchService.importToEs(book);
|
||||||
|
lastDate = book.getUpdateTime();
|
||||||
|
Thread.sleep(5000);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cacheService.setObject(CacheKey.ES_LAST_UPDATE_TIME, lastDate);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
cacheService.del(CacheKey.ES_TRANS_LOCK);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,8 +1,10 @@
|
|||||||
package com.java2nb.novel.core.schedule;
|
package com.java2nb.novel.core.schedule;
|
||||||
|
|
||||||
|
import com.java2nb.novel.core.utils.Constants;
|
||||||
import com.java2nb.novel.entity.Book;
|
import com.java2nb.novel.entity.Book;
|
||||||
import com.java2nb.novel.service.BookService;
|
import com.java2nb.novel.service.BookService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
@ -12,14 +14,15 @@ import org.springframework.stereotype.Service;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 网络图片转存本地任务
|
* 将爬取的网络图片转存为自己的存储介质(本地、OSS、fastDfs)任务
|
||||||
|
*
|
||||||
* @author Administrator
|
* @author Administrator
|
||||||
*/
|
*/
|
||||||
@ConditionalOnProperty(prefix = "pic.save",name = "type",havingValue = "2")
|
@ConditionalOnProperty(prefix = "pic.save", name = "type", havingValue = "2")
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class Network2LocalPicSchedule {
|
public class CrawlPicTransSchedule {
|
||||||
|
|
||||||
private final BookService bookService;
|
private final BookService bookService;
|
||||||
|
|
||||||
@ -33,20 +36,18 @@ public class Network2LocalPicSchedule {
|
|||||||
* 10分钟转一次
|
* 10分钟转一次
|
||||||
*/
|
*/
|
||||||
@Scheduled(fixedRate = 1000 * 60 * 10)
|
@Scheduled(fixedRate = 1000 * 60 * 10)
|
||||||
|
@SneakyThrows
|
||||||
public void trans() {
|
public void trans() {
|
||||||
|
|
||||||
log.info("Network2LocalPicSchedule。。。。。。。。。。。。");
|
log.info("Network2LocalPicSchedule。。。。。。。。。。。。");
|
||||||
|
|
||||||
|
|
||||||
Integer offset = 0, limit = 100;
|
List<Book> networkPicBooks = bookService.queryNetworkPicBooks(Constants.LOCAL_PIC_PREFIX,100);
|
||||||
List<Book> networkPicBooks;
|
for (Book book : networkPicBooks) {
|
||||||
do {
|
bookService.updateBookPicToLocal(book.getPicUrl(), book.getId());
|
||||||
networkPicBooks = bookService.queryNetworkPicBooks(limit, offset);
|
//3秒钟转化一张图片,10分钟转化200张
|
||||||
for (Book book : networkPicBooks) {
|
Thread.sleep(3000);
|
||||||
bookService.updateBookPicToLocal(book.getPicUrl(), book.getId());
|
}
|
||||||
}
|
|
||||||
offset += limit;
|
|
||||||
} while (networkPicBooks.size() > 0);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -12,7 +12,7 @@ public class Constants {
|
|||||||
public static final String TEMPLATE_PATH_PREFIX_KEY = "templatePathPrefixKey";
|
public static final String TEMPLATE_PATH_PREFIX_KEY = "templatePathPrefixKey";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 本地图片保存前缀
|
* 保存图片到自己的存储介质路径前缀
|
||||||
* */
|
* */
|
||||||
public static final String LOCAL_PIC_PREFIX = "/localPic/";
|
public static final String LOCAL_PIC_PREFIX = "/localPic/";
|
||||||
|
|
||||||
@ -30,4 +30,9 @@ public class Constants {
|
|||||||
* 首页设置的小说数量
|
* 首页设置的小说数量
|
||||||
* */
|
* */
|
||||||
public static final int INDEX_BOOK_SETTING_NUM = 32;
|
public static final int INDEX_BOOK_SETTING_NUM = 32;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 累积的最大点击量
|
||||||
|
* */
|
||||||
|
public static final Integer ADD_MAX_VISIT_COUNT = 10;
|
||||||
}
|
}
|
||||||
|
@ -1,37 +1,42 @@
|
|||||||
package com.java2nb.novel.core.wrapper;
|
package com.java2nb.novel.core.wrapper;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletRequestWrapper;
|
import javax.servlet.http.HttpServletRequestWrapper;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* XSS过滤处理
|
* XSS过滤处理
|
||||||
|
*
|
||||||
* @author Administrator
|
* @author Administrator
|
||||||
*/
|
*/
|
||||||
public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper
|
public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
|
||||||
{
|
|
||||||
|
/**
|
||||||
|
* 假如有有html 代码是自己传来的 需要设定对应的name 不过滤
|
||||||
|
*/
|
||||||
|
private static final List<String> noFilterNames = Arrays.asList("content");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param request
|
* @param request
|
||||||
*/
|
*/
|
||||||
public XssHttpServletRequestWrapper(HttpServletRequest request)
|
public XssHttpServletRequestWrapper(HttpServletRequest request) {
|
||||||
{
|
|
||||||
super(request);
|
super(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getParameterValues(String name)
|
public String[] getParameterValues(String name) {
|
||||||
{
|
|
||||||
String[] values = super.getParameterValues(name);
|
String[] values = super.getParameterValues(name);
|
||||||
if (values != null)
|
if (!noFilterNames.contains(name) && values != null) {
|
||||||
{
|
|
||||||
int length = values.length;
|
int length = values.length;
|
||||||
String[] escapseValues = new String[length];
|
String[] escapseValues = new String[length];
|
||||||
for (int i = 0; i < length; i++)
|
for (int i = 0; i < length; i++) {
|
||||||
{
|
escapseValues[i] = values[i].replaceAll("<", "<").replaceAll(">", ">");
|
||||||
// 防xss攻击和过滤前后空格
|
|
||||||
escapseValues[i] = values[i].replaceAll("<","<").replaceAll(">",">");
|
|
||||||
}
|
}
|
||||||
return escapseValues;
|
return escapseValues;
|
||||||
}
|
}
|
||||||
return super.getParameterValues(name);
|
return values;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.java2nb.novel.search.BookSP;
|
|||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -15,13 +16,13 @@ public interface FrontBookMapper extends BookMapper {
|
|||||||
|
|
||||||
List<BookVO> searchByPage(BookSP params);
|
List<BookVO> searchByPage(BookSP params);
|
||||||
|
|
||||||
void addVisitCount(@Param("bookId") Long bookId);
|
void addVisitCount(@Param("bookId") Long bookId, @Param("visitCount") Integer visitCount);
|
||||||
|
|
||||||
List<Book> listRecBookByCatId(@Param("catId") Integer catId);
|
List<Book> listRecBookByCatId(@Param("catId") Integer catId);
|
||||||
|
|
||||||
void addCommentCount(@Param("bookId") Long bookId);
|
void addCommentCount(@Param("bookId") Long bookId);
|
||||||
|
|
||||||
List<Book> queryNetworkPicBooks(@Param("limit") Integer limit,@Param("offset") Integer offset);
|
List<Book> queryNetworkPicBooks(@Param("localPicPrefix") String localPicPrefix, @Param("limit") Integer limit);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按评分随机查询小说集合
|
* 按评分随机查询小说集合
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
package com.java2nb.novel.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.java2nb.novel.entity.Author;
|
||||||
|
import com.java2nb.novel.entity.FriendLink;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 11797
|
||||||
|
*/
|
||||||
|
public interface AuthorService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验笔名是否存在
|
||||||
|
* @param penName 校验的笔名
|
||||||
|
* @return true:存在该笔名,false: 不存在该笔名
|
||||||
|
* */
|
||||||
|
Boolean checkPenName(String penName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 作家注册
|
||||||
|
* @param userId 注册用户ID
|
||||||
|
*@param author 注册信息
|
||||||
|
* @return 返回错误信息
|
||||||
|
* */
|
||||||
|
String register(Long userId, Author author);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否是作家
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return true:是作家,false: 不是作家
|
||||||
|
* */
|
||||||
|
Boolean isAuthor(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询作家信息
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 作家对象
|
||||||
|
* */
|
||||||
|
Author queryAuthor(Long userId);
|
||||||
|
}
|
@ -1,12 +1,14 @@
|
|||||||
package com.java2nb.novel.service;
|
package com.java2nb.novel.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.java2nb.novel.search.BookSP;
|
import com.java2nb.novel.search.BookSP;
|
||||||
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.*;
|
||||||
import com.java2nb.novel.vo.BookVO;
|
import com.java2nb.novel.vo.BookVO;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -44,9 +46,9 @@ public interface BookService {
|
|||||||
* @param params 搜索参数
|
* @param params 搜索参数
|
||||||
* @param page 页码
|
* @param page 页码
|
||||||
* @param pageSize 分页大小
|
* @param pageSize 分页大小
|
||||||
* @return 小说集合
|
* @return 小说集合分页信息
|
||||||
* */
|
* */
|
||||||
List<BookVO> searchByPage(BookSP params, int page, int pageSize);
|
PageInfo searchByPage(BookSP params, int page, int pageSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询小说分类列表
|
* 查询小说分类列表
|
||||||
@ -110,8 +112,8 @@ public interface BookService {
|
|||||||
/**
|
/**
|
||||||
* 增加点击次数
|
* 增加点击次数
|
||||||
* @param bookId 书籍ID
|
* @param bookId 书籍ID
|
||||||
* */
|
* @param visitCount*/
|
||||||
void addVisitCount(Long bookId);
|
void addVisitCount(Long bookId, Integer visitCount);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询章节数
|
* 查询章节数
|
||||||
@ -178,17 +180,61 @@ public interface BookService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询网络图片的小说
|
* 查询网络图片的小说
|
||||||
|
*
|
||||||
|
* @param localPicPrefix
|
||||||
* @param limit 查询条数
|
* @param limit 查询条数
|
||||||
* @param offset 开始行数
|
|
||||||
* @return 返回小说集合
|
* @return 返回小说集合
|
||||||
* */
|
* */
|
||||||
List<Book> queryNetworkPicBooks(Integer limit, Integer offset);
|
List<Book> queryNetworkPicBooks(String localPicPrefix, Integer limit);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新小说网络图片到本地
|
* 更新爬取的小说网络图片到自己的存储介质(本地、OSS、fastDfs)
|
||||||
* @param picUrl 网络图片路径
|
* @param picUrl 爬取的网络图片路径
|
||||||
* @param bookId 小说ID
|
* @param bookId 小说ID
|
||||||
*/
|
*/
|
||||||
void updateBookPicToLocal(String picUrl, Long bookId);
|
void updateBookPicToLocal(String picUrl, Long bookId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过作者ID查询小说分页列表
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param page 页码
|
||||||
|
* @param pageSize 分页大小
|
||||||
|
* @return 小说集合
|
||||||
|
* */
|
||||||
|
List<Book> listBookPageByUserId(Long userId, int page, int pageSize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发布小说
|
||||||
|
* @param book 小说信息
|
||||||
|
* @param authorId 作家ID
|
||||||
|
* @param penName 作家笔名
|
||||||
|
* */
|
||||||
|
void addBook(Book book, Long authorId, String penName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新小说状态,上架或下架
|
||||||
|
* @param bookId 小说ID
|
||||||
|
* @param status 更新的状态
|
||||||
|
* @param authorId 作者ID
|
||||||
|
* */
|
||||||
|
void updateBookStatus(Long bookId, Byte status, Long authorId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发布章节内容
|
||||||
|
* @param bookId 小说ID
|
||||||
|
* @param indexName 章节名
|
||||||
|
* @param content 章节内容
|
||||||
|
* @param authorId 作者ID
|
||||||
|
* */
|
||||||
|
void addBookContent(Long bookId, String indexName, String content, Long authorId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据更新时间分页查询书籍列表
|
||||||
|
* @param startDate 开始时间,包括该时间
|
||||||
|
* @param limit 查询数量
|
||||||
|
* @return 书籍列表
|
||||||
|
* */
|
||||||
|
List<Book> queryBookByUpdateTimeByPage(Date startDate, int limit);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.java2nb.novel.service;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 11797
|
||||||
|
*/
|
||||||
|
public interface FileService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将爬取的网络图片转存为自己的存储介质(本地、OSS、fastDfs)
|
||||||
|
* @param picSrc 爬取的网络图片路径
|
||||||
|
* @param picSavePath 保存路径
|
||||||
|
* @return 新图片地址
|
||||||
|
* */
|
||||||
|
String transFile(String picSrc, String picSavePath);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.java2nb.novel.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.java2nb.novel.entity.Book;
|
||||||
|
import com.java2nb.novel.search.BookSP;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 11797
|
||||||
|
*/
|
||||||
|
public interface SearchService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入到es
|
||||||
|
* @param book 小说数据
|
||||||
|
*/
|
||||||
|
void importToEs(Book book);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索
|
||||||
|
* @param params 搜索参数
|
||||||
|
* @param page 当前页码
|
||||||
|
* @param pageSize 每页大小
|
||||||
|
* @return 分页信息
|
||||||
|
*/
|
||||||
|
PageInfo searchBook(BookSP params, int page, int pageSize);
|
||||||
|
}
|
@ -2,6 +2,7 @@ package com.java2nb.novel.service;
|
|||||||
|
|
||||||
|
|
||||||
import com.java2nb.novel.core.bean.UserDetails;
|
import com.java2nb.novel.core.bean.UserDetails;
|
||||||
|
import com.java2nb.novel.entity.UserBuyRecord;
|
||||||
import com.java2nb.novel.form.UserForm;
|
import com.java2nb.novel.form.UserForm;
|
||||||
import com.java2nb.novel.vo.BookReadHistoryVO;
|
import com.java2nb.novel.vo.BookReadHistoryVO;
|
||||||
import com.java2nb.novel.vo.BookShelfVO;
|
import com.java2nb.novel.vo.BookShelfVO;
|
||||||
@ -122,4 +123,19 @@ public interface UserService {
|
|||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @param amount 增加的余额 */
|
* @param amount 增加的余额 */
|
||||||
void addAmount(Long userId, int amount);
|
void addAmount(Long userId, int amount);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断用户是否购买过该小说章节
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param bookIndexId 章节目录ID
|
||||||
|
* @return true:购买过,false:没购买
|
||||||
|
* */
|
||||||
|
boolean queryIsBuyBookIndex(Long userId, Long bookIndexId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 购买小说章节
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param buyRecord 购买信息
|
||||||
|
* */
|
||||||
|
void buyBookIndex(Long userId, UserBuyRecord buyRecord);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,92 @@
|
|||||||
|
package com.java2nb.novel.service.impl;
|
||||||
|
|
||||||
|
import com.java2nb.novel.core.cache.CacheKey;
|
||||||
|
import com.java2nb.novel.core.cache.CacheService;
|
||||||
|
import com.java2nb.novel.core.enums.ResponseStatus;
|
||||||
|
import com.java2nb.novel.core.exception.BusinessException;
|
||||||
|
import com.java2nb.novel.entity.Author;
|
||||||
|
import com.java2nb.novel.entity.FriendLink;
|
||||||
|
import com.java2nb.novel.mapper.*;
|
||||||
|
import com.java2nb.novel.service.AuthorService;
|
||||||
|
import com.java2nb.novel.service.FriendLinkService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.mybatis.dynamic.sql.render.RenderingStrategies;
|
||||||
|
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
|
||||||
|
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.java2nb.novel.mapper.AuthorCodeDynamicSqlSupport.authorCode;
|
||||||
|
import static com.java2nb.novel.mapper.BookDynamicSqlSupport.book;
|
||||||
|
import static com.java2nb.novel.mapper.BookDynamicSqlSupport.id;
|
||||||
|
import static com.java2nb.novel.mapper.BookDynamicSqlSupport.updateTime;
|
||||||
|
import static com.java2nb.novel.mapper.FriendLinkDynamicSqlSupport.*;
|
||||||
|
import static org.mybatis.dynamic.sql.SqlBuilder.*;
|
||||||
|
import static org.mybatis.dynamic.sql.select.SelectDSL.select;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 11797
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class AuthorServiceImpl implements AuthorService {
|
||||||
|
|
||||||
|
private final AuthorMapper authorMapper;
|
||||||
|
|
||||||
|
private final AuthorCodeMapper authorCodeMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean checkPenName(String penName) {
|
||||||
|
return authorMapper.count(c ->
|
||||||
|
c.where(AuthorDynamicSqlSupport.penName, isEqualTo(penName))) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
@Override
|
||||||
|
public String register(Long userId, Author author) {
|
||||||
|
Date currentDate = new Date();
|
||||||
|
//判断邀请码是否有效
|
||||||
|
if (authorCodeMapper.count(c ->
|
||||||
|
c.where(AuthorCodeDynamicSqlSupport.inviteCode, isEqualTo(author.getInviteCode()))
|
||||||
|
.and(AuthorCodeDynamicSqlSupport.isUse, isEqualTo((byte) 0))
|
||||||
|
.and(AuthorCodeDynamicSqlSupport.validityTime, isGreaterThan(currentDate))) > 0) {
|
||||||
|
//邀请码有效
|
||||||
|
//保存作家信息
|
||||||
|
author.setUserId(userId);
|
||||||
|
author.setCreateTime(currentDate);
|
||||||
|
authorMapper.insertSelective(author);
|
||||||
|
//设置邀请码状态为已使用
|
||||||
|
authorCodeMapper.update(update(authorCode)
|
||||||
|
.set(AuthorCodeDynamicSqlSupport.isUse)
|
||||||
|
.equalTo((byte) 1)
|
||||||
|
.where(AuthorCodeDynamicSqlSupport.inviteCode,isEqualTo(author.getInviteCode()))
|
||||||
|
.build()
|
||||||
|
.render(RenderingStrategies.MYBATIS3));
|
||||||
|
return "";
|
||||||
|
} else {
|
||||||
|
//邀请码无效
|
||||||
|
return "邀请码无效!";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean isAuthor(Long userId) {
|
||||||
|
return authorMapper.count(c ->
|
||||||
|
c.where(AuthorDynamicSqlSupport.userId, isEqualTo(userId))) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Author queryAuthor(Long userId) {
|
||||||
|
return authorMapper.selectMany(
|
||||||
|
select(AuthorDynamicSqlSupport.id,AuthorDynamicSqlSupport.penName,AuthorDynamicSqlSupport.status)
|
||||||
|
.from(AuthorDynamicSqlSupport.author)
|
||||||
|
.where(AuthorDynamicSqlSupport.userId,isEqualTo(userId))
|
||||||
|
.build()
|
||||||
|
.render(RenderingStrategies.MYBATIS3)).get(0);
|
||||||
|
}
|
||||||
|
}
|
@ -2,24 +2,26 @@ package com.java2nb.novel.service.impl;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
|
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.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.BeanUtil;
|
import com.java2nb.novel.core.utils.*;
|
||||||
import com.java2nb.novel.core.utils.Constants;
|
|
||||||
import com.java2nb.novel.core.utils.FileUtil;
|
|
||||||
import com.java2nb.novel.core.utils.IdWorker;
|
|
||||||
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.search.BookSP;
|
||||||
|
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.SearchService;
|
||||||
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.vo.BookVO;
|
import com.java2nb.novel.vo.BookVO;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.mybatis.dynamic.sql.SortSpecification;
|
import org.mybatis.dynamic.sql.SortSpecification;
|
||||||
import org.mybatis.dynamic.sql.render.RenderingStrategies;
|
import org.mybatis.dynamic.sql.render.RenderingStrategies;
|
||||||
@ -49,14 +51,18 @@ import static org.mybatis.dynamic.sql.select.SelectDSL.select;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
public class BookServiceImpl implements BookService {
|
public class BookServiceImpl implements BookService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 本地图片保存路径
|
* 本地图片保存路径
|
||||||
* */
|
*/
|
||||||
@Value("${pic.save.path}")
|
@Value("${pic.save.path}")
|
||||||
private String picSavePath;
|
private String picSavePath;
|
||||||
|
|
||||||
|
@Value("${spring.elasticsearch.enable}")
|
||||||
|
private Integer esEnable;
|
||||||
|
|
||||||
private final FrontBookSettingMapper bookSettingMapper;
|
private final FrontBookSettingMapper bookSettingMapper;
|
||||||
|
|
||||||
private final FrontBookMapper bookMapper;
|
private final FrontBookMapper bookMapper;
|
||||||
@ -73,6 +79,12 @@ public class BookServiceImpl implements BookService {
|
|||||||
|
|
||||||
private final CacheService cacheService;
|
private final CacheService cacheService;
|
||||||
|
|
||||||
|
private final AuthorService authorService;
|
||||||
|
|
||||||
|
private final SearchService searchService;
|
||||||
|
|
||||||
|
private final FileService fileService;
|
||||||
|
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@Override
|
@Override
|
||||||
@ -80,24 +92,24 @@ public class BookServiceImpl implements BookService {
|
|||||||
String result = cacheService.get(CacheKey.INDEX_BOOK_SETTINGS_KEY);
|
String result = cacheService.get(CacheKey.INDEX_BOOK_SETTINGS_KEY);
|
||||||
if (result == null || result.length() < Constants.OBJECT_JSON_CACHE_EXIST_LENGTH) {
|
if (result == null || result.length() < Constants.OBJECT_JSON_CACHE_EXIST_LENGTH) {
|
||||||
List<BookSettingVO> list = bookSettingMapper.listVO();
|
List<BookSettingVO> list = bookSettingMapper.listVO();
|
||||||
if(list.size() == 0) {
|
if (list.size() == 0) {
|
||||||
//如果首页小说没有被设置,则初始化首页小说设置
|
//如果首页小说没有被设置,则初始化首页小说设置
|
||||||
list = initIndexBookSetting();
|
list = initIndexBookSetting();
|
||||||
}
|
}
|
||||||
result = new ObjectMapper().writeValueAsString(list.stream().collect(Collectors.groupingBy(BookSettingVO::getType)));
|
result = new ObjectMapper().writeValueAsString(list.stream().collect(Collectors.groupingBy(BookSettingVO::getType)));
|
||||||
cacheService.set(CacheKey.INDEX_BOOK_SETTINGS_KEY, result);
|
cacheService.set(CacheKey.INDEX_BOOK_SETTINGS_KEY, result);
|
||||||
}
|
}
|
||||||
return new ObjectMapper().readValue(result,Map.class);
|
return new ObjectMapper().readValue(result, Map.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化首页小说设置
|
* 初始化首页小说设置
|
||||||
* */
|
*/
|
||||||
private List<BookSettingVO> initIndexBookSetting() {
|
private List<BookSettingVO> initIndexBookSetting() {
|
||||||
Date currentDate = new Date();
|
Date currentDate = new Date();
|
||||||
List<Book> books = bookMapper.selectIdsByScoreAndRandom(Constants.INDEX_BOOK_SETTING_NUM);
|
List<Book> books = bookMapper.selectIdsByScoreAndRandom(Constants.INDEX_BOOK_SETTING_NUM);
|
||||||
if(books.size() == Constants.INDEX_BOOK_SETTING_NUM) {
|
if (books.size() == Constants.INDEX_BOOK_SETTING_NUM) {
|
||||||
List<BookSetting> bookSettingList = new ArrayList<>(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);
|
List<BookSettingVO> bookSettingVOList = new ArrayList<>(Constants.INDEX_BOOK_SETTING_NUM);
|
||||||
for (int i = 0; i < books.size(); i++) {
|
for (int i = 0; i < books.size(); i++) {
|
||||||
@ -111,7 +123,7 @@ public class BookServiceImpl implements BookService {
|
|||||||
type = 2;
|
type = 2;
|
||||||
} else if (i < 26) {
|
} else if (i < 26) {
|
||||||
type = 3;
|
type = 3;
|
||||||
}else{
|
} else {
|
||||||
type = 4;
|
type = 4;
|
||||||
}
|
}
|
||||||
BookSettingVO bookSettingVO = new BookSettingVO();
|
BookSettingVO bookSettingVO = new BookSettingVO();
|
||||||
@ -123,8 +135,8 @@ public class BookServiceImpl implements BookService {
|
|||||||
bookSetting.setUpdateTime(currentDate);
|
bookSetting.setUpdateTime(currentDate);
|
||||||
bookSettingList.add(bookSetting);
|
bookSettingList.add(bookSetting);
|
||||||
|
|
||||||
BeanUtils.copyProperties(book,bookSettingVO);
|
BeanUtils.copyProperties(book, bookSettingVO);
|
||||||
BeanUtils.copyProperties(bookSetting,bookSettingVO);
|
BeanUtils.copyProperties(bookSetting, bookSettingVO);
|
||||||
bookSettingVOList.add(bookSettingVO);
|
bookSettingVOList.add(bookSettingVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,25 +173,43 @@ public class BookServiceImpl implements BookService {
|
|||||||
List<BookVO> result = (List<BookVO>) cacheService.getObject(CacheKey.INDEX_UPDATE_BOOK_KEY);
|
List<BookVO> result = (List<BookVO>) cacheService.getObject(CacheKey.INDEX_UPDATE_BOOK_KEY);
|
||||||
if (result == null || result.size() == 0) {
|
if (result == null || result.size() == 0) {
|
||||||
List<Book> bookPOList = listRank((byte) 2, 23);
|
List<Book> bookPOList = listRank((byte) 2, 23);
|
||||||
result = BeanUtil.copyList(bookPOList,BookVO.class);
|
result = BeanUtil.copyList(bookPOList, BookVO.class);
|
||||||
cacheService.setObject(CacheKey.INDEX_UPDATE_BOOK_KEY, result, 60 * 10);
|
cacheService.setObject(CacheKey.INDEX_UPDATE_BOOK_KEY, result, 60 * 10);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BookVO> searchByPage(BookSP params, int page, int pageSize) {
|
public PageInfo searchByPage(BookSP params, int page, int pageSize) {
|
||||||
PageHelper.startPage(page, pageSize);
|
|
||||||
|
|
||||||
if (params.getUpdatePeriod() != null) {
|
if (params.getUpdatePeriod() != null) {
|
||||||
long cur = System.currentTimeMillis();
|
long cur = System.currentTimeMillis();
|
||||||
long period = params.getUpdatePeriod() * 24 * 3600 * 1000;
|
long period = params.getUpdatePeriod() * 24 * 3600 * 1000;
|
||||||
long time = cur - period;
|
long time = cur - period;
|
||||||
params.setUpdateTimeMin(new Date(time));
|
params.setUpdateTimeMin(new Date(time));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (esEnable == 1) {
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
return searchService.searchBook(params,page,pageSize);
|
||||||
|
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
PageHelper.startPage(page, pageSize);
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(params.getSort())) {
|
if (StringUtils.isNotBlank(params.getSort())) {
|
||||||
OrderByHelper.orderBy(params.getSort() + " desc");
|
OrderByHelper.orderBy(params.getSort() + " desc");
|
||||||
}
|
}
|
||||||
return bookMapper.searchByPage(params);
|
return new PageInfo<>(bookMapper.searchByPage(params));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -194,7 +224,7 @@ public class BookServiceImpl implements BookService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Book queryBookDetail(Long bookId) {
|
public Book queryBookDetail(Long bookId) {
|
||||||
SelectStatementProvider selectStatement = select(id, catName, catId, picUrl, bookName, authorId, authorName, bookDesc, bookStatus, visitCount, wordCount, lastIndexId, lastIndexName, lastIndexUpdateTime,score)
|
SelectStatementProvider selectStatement = select(book.allColumns())
|
||||||
.from(book)
|
.from(book)
|
||||||
.where(id, isEqualTo(bookId))
|
.where(id, isEqualTo(bookId))
|
||||||
.build()
|
.build()
|
||||||
@ -203,15 +233,15 @@ public class BookServiceImpl implements BookService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BookIndex> queryIndexList(Long bookId,String orderBy, Integer limit) {
|
public List<BookIndex> queryIndexList(Long bookId, String orderBy, Integer limit) {
|
||||||
if(StringUtils.isNotBlank(orderBy)){
|
if (StringUtils.isNotBlank(orderBy)) {
|
||||||
OrderByHelper.orderBy(orderBy);
|
OrderByHelper.orderBy(orderBy);
|
||||||
}
|
}
|
||||||
if(limit != null){
|
if (limit != null) {
|
||||||
PageHelper.startPage(1,limit);
|
PageHelper.startPage(1, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectStatementProvider selectStatement = select(BookIndexDynamicSqlSupport.id, BookIndexDynamicSqlSupport.bookId, BookIndexDynamicSqlSupport.indexNum, BookIndexDynamicSqlSupport.indexName, BookIndexDynamicSqlSupport.updateTime)
|
SelectStatementProvider selectStatement = select(BookIndexDynamicSqlSupport.id, BookIndexDynamicSqlSupport.bookId, BookIndexDynamicSqlSupport.indexNum, BookIndexDynamicSqlSupport.indexName, BookIndexDynamicSqlSupport.updateTime, BookIndexDynamicSqlSupport.isVip)
|
||||||
.from(bookIndex)
|
.from(bookIndex)
|
||||||
.where(BookIndexDynamicSqlSupport.bookId, isEqualTo(bookId))
|
.where(BookIndexDynamicSqlSupport.bookId, isEqualTo(bookId))
|
||||||
.build()
|
.build()
|
||||||
@ -222,7 +252,7 @@ public class BookServiceImpl implements BookService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BookIndex queryBookIndex(Long bookIndexId) {
|
public BookIndex queryBookIndex(Long bookIndexId) {
|
||||||
SelectStatementProvider selectStatement = select(BookIndexDynamicSqlSupport.id, BookIndexDynamicSqlSupport.bookId, BookIndexDynamicSqlSupport.indexNum, BookIndexDynamicSqlSupport.indexName, BookIndexDynamicSqlSupport.wordCount, BookIndexDynamicSqlSupport.updateTime)
|
SelectStatementProvider selectStatement = select(BookIndexDynamicSqlSupport.id, BookIndexDynamicSqlSupport.bookId, BookIndexDynamicSqlSupport.indexNum, BookIndexDynamicSqlSupport.indexName, BookIndexDynamicSqlSupport.wordCount, BookIndexDynamicSqlSupport.updateTime, BookIndexDynamicSqlSupport.isVip)
|
||||||
.from(bookIndex)
|
.from(bookIndex)
|
||||||
.where(BookIndexDynamicSqlSupport.id, isEqualTo(bookIndexId))
|
.where(BookIndexDynamicSqlSupport.id, isEqualTo(bookIndexId))
|
||||||
.build()
|
.build()
|
||||||
@ -268,7 +298,7 @@ public class BookServiceImpl implements BookService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BookContent queryBookContent(Long bookIndexId) {
|
public BookContent queryBookContent(Long bookIndexId) {
|
||||||
SelectStatementProvider selectStatement = select(BookContentDynamicSqlSupport.id,BookContentDynamicSqlSupport.content)
|
SelectStatementProvider selectStatement = select(BookContentDynamicSqlSupport.id, BookContentDynamicSqlSupport.content)
|
||||||
.from(bookContent)
|
.from(bookContent)
|
||||||
.where(BookContentDynamicSqlSupport.indexId, isEqualTo(bookIndexId))
|
.where(BookContentDynamicSqlSupport.indexId, isEqualTo(bookIndexId))
|
||||||
.limit(1)
|
.limit(1)
|
||||||
@ -302,6 +332,7 @@ public class BookServiceImpl implements BookService {
|
|||||||
}
|
}
|
||||||
SelectStatementProvider selectStatement = select(id, catId, catName, bookName, lastIndexId, lastIndexName, authorId, authorName, picUrl, bookDesc, wordCount, lastIndexUpdateTime)
|
SelectStatementProvider selectStatement = select(id, catId, catName, bookName, lastIndexId, lastIndexName, authorId, authorName, picUrl, bookDesc, wordCount, lastIndexUpdateTime)
|
||||||
.from(book)
|
.from(book)
|
||||||
|
.where(wordCount, isGreaterThan(0))
|
||||||
.orderBy(sortSpecification)
|
.orderBy(sortSpecification)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.build()
|
.build()
|
||||||
@ -311,9 +342,8 @@ public class BookServiceImpl implements BookService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addVisitCount(Long bookId) {
|
public void addVisitCount(Long bookId, Integer visitCount) {
|
||||||
bookMapper.addVisitCount(bookId);
|
bookMapper.addVisitCount(bookId,visitCount);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -345,10 +375,10 @@ public class BookServiceImpl implements BookService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BookCommentVO> listCommentByPage(Long userId,Long bookId, int page, int pageSize) {
|
public List<BookCommentVO> listCommentByPage(Long userId, Long bookId, int page, int pageSize) {
|
||||||
PageHelper.startPage(page, pageSize);
|
PageHelper.startPage(page, pageSize);
|
||||||
OrderByHelper.orderBy("t1.create_time desc");
|
OrderByHelper.orderBy("t1.create_time desc");
|
||||||
return bookCommentMapper.listCommentByPage(userId,bookId);
|
return bookCommentMapper.listCommentByPage(userId, bookId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@ -357,11 +387,11 @@ public class BookServiceImpl implements BookService {
|
|||||||
//判断该用户是否已评论过该书籍
|
//判断该用户是否已评论过该书籍
|
||||||
SelectStatementProvider selectStatement = select(count(BookCommentDynamicSqlSupport.id))
|
SelectStatementProvider selectStatement = select(count(BookCommentDynamicSqlSupport.id))
|
||||||
.from(bookComment)
|
.from(bookComment)
|
||||||
.where(BookCommentDynamicSqlSupport.createUserId,isEqualTo(userId))
|
.where(BookCommentDynamicSqlSupport.createUserId, isEqualTo(userId))
|
||||||
.and(BookCommentDynamicSqlSupport.bookId,isEqualTo(comment.getBookId()))
|
.and(BookCommentDynamicSqlSupport.bookId, isEqualTo(comment.getBookId()))
|
||||||
.build()
|
.build()
|
||||||
.render(RenderingStrategies.MYBATIS3);
|
.render(RenderingStrategies.MYBATIS3);
|
||||||
if(bookCommentMapper.count(selectStatement)>0){
|
if (bookCommentMapper.count(selectStatement) > 0) {
|
||||||
throw new BusinessException(ResponseStatus.HAS_COMMENTS);
|
throw new BusinessException(ResponseStatus.HAS_COMMENTS);
|
||||||
}
|
}
|
||||||
//增加评论
|
//增加评论
|
||||||
@ -370,7 +400,7 @@ public class BookServiceImpl implements BookService {
|
|||||||
bookCommentMapper.insertSelective(comment);
|
bookCommentMapper.insertSelective(comment);
|
||||||
//增加书籍评论数
|
//增加书籍评论数
|
||||||
bookMapper.addCommentCount(comment.getBookId());
|
bookMapper.addCommentCount(comment.getBookId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -378,14 +408,14 @@ public class BookServiceImpl implements BookService {
|
|||||||
Long authorId;
|
Long authorId;
|
||||||
SelectStatementProvider selectStatement = select(BookAuthorDynamicSqlSupport.id)
|
SelectStatementProvider selectStatement = select(BookAuthorDynamicSqlSupport.id)
|
||||||
.from(BookAuthorDynamicSqlSupport.bookAuthor)
|
.from(BookAuthorDynamicSqlSupport.bookAuthor)
|
||||||
.where(BookAuthorDynamicSqlSupport.penName,isEqualTo(authorName))
|
.where(BookAuthorDynamicSqlSupport.penName, isEqualTo(authorName))
|
||||||
.build()
|
.build()
|
||||||
.render(RenderingStrategies.MYBATIS3);
|
.render(RenderingStrategies.MYBATIS3);
|
||||||
List<BookAuthor> bookAuthors = bookAuthorMapper.selectMany(selectStatement);
|
List<BookAuthor> bookAuthors = bookAuthorMapper.selectMany(selectStatement);
|
||||||
if(bookAuthors.size()>0){
|
if (bookAuthors.size() > 0) {
|
||||||
//作者存在
|
//作者存在
|
||||||
authorId = bookAuthors.get(0).getId();
|
authorId = bookAuthors.get(0).getId();
|
||||||
}else{
|
} else {
|
||||||
//作者不存在,先创建作者
|
//作者不存在,先创建作者
|
||||||
Date currentDate = new Date();
|
Date currentDate = new Date();
|
||||||
authorId = new IdWorker().nextId();
|
authorId = new IdWorker().nextId();
|
||||||
@ -405,18 +435,17 @@ public class BookServiceImpl implements BookService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long queryIdByNameAndAuthor(String bookName, String author) {
|
public Long queryIdByNameAndAuthor(String bookName, String author) {
|
||||||
//查询小说ID
|
//查询小说ID
|
||||||
SelectStatementProvider selectStatement = select(id)
|
SelectStatementProvider selectStatement = select(id)
|
||||||
.from(book)
|
.from(book)
|
||||||
.where(BookDynamicSqlSupport.bookName,isEqualTo(bookName))
|
.where(BookDynamicSqlSupport.bookName, isEqualTo(bookName))
|
||||||
.and(BookDynamicSqlSupport.authorName,isEqualTo(authorName))
|
.and(BookDynamicSqlSupport.authorName, isEqualTo(authorName))
|
||||||
.build()
|
.build()
|
||||||
.render(RenderingStrategies.MYBATIS3);
|
.render(RenderingStrategies.MYBATIS3);
|
||||||
List<Book> books = bookMapper.selectMany(selectStatement);
|
List<Book> books = bookMapper.selectMany(selectStatement);
|
||||||
if(books.size()>0){
|
if (books.size() > 0) {
|
||||||
return books.get(0).getId();
|
return books.get(0).getId();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -426,7 +455,7 @@ public class BookServiceImpl implements BookService {
|
|||||||
public List<Integer> queryIndexNumByBookId(Long bookId) {
|
public List<Integer> queryIndexNumByBookId(Long bookId) {
|
||||||
SelectStatementProvider selectStatement = select(BookIndexDynamicSqlSupport.indexNum)
|
SelectStatementProvider selectStatement = select(BookIndexDynamicSqlSupport.indexNum)
|
||||||
.from(BookIndexDynamicSqlSupport.bookIndex)
|
.from(BookIndexDynamicSqlSupport.bookIndex)
|
||||||
.where(BookIndexDynamicSqlSupport.bookId,isEqualTo(bookId))
|
.where(BookIndexDynamicSqlSupport.bookId, isEqualTo(bookId))
|
||||||
.build()
|
.build()
|
||||||
.render(RenderingStrategies.MYBATIS3);
|
.render(RenderingStrategies.MYBATIS3);
|
||||||
|
|
||||||
@ -434,25 +463,136 @@ public class BookServiceImpl implements BookService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Book> queryNetworkPicBooks(Integer limit, Integer offset) {
|
public List<Book> queryNetworkPicBooks(String localPicPrefix, Integer limit) {
|
||||||
return bookMapper.queryNetworkPicBooks(limit,offset);
|
return bookMapper.queryNetworkPicBooks(localPicPrefix,limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateBookPicToLocal(String picUrl, Long bookId) {
|
public void updateBookPicToLocal(String picUrl, Long bookId) {
|
||||||
|
|
||||||
picUrl = FileUtil.network2Local(picUrl,picSavePath, Constants.LOCAL_PIC_PREFIX);
|
picUrl = fileService.transFile(picUrl, picSavePath);
|
||||||
|
|
||||||
bookMapper.update(update(book)
|
bookMapper.update(update(book)
|
||||||
.set(BookDynamicSqlSupport.picUrl)
|
.set(BookDynamicSqlSupport.picUrl)
|
||||||
.equalTo(picUrl)
|
.equalTo(picUrl)
|
||||||
.set(updateTime)
|
.set(updateTime)
|
||||||
.equalTo(new Date())
|
.equalTo(new Date())
|
||||||
.where(id,isEqualTo(bookId))
|
.where(id, isEqualTo(bookId))
|
||||||
.build()
|
.build()
|
||||||
.render(RenderingStrategies.MYBATIS3));
|
.render(RenderingStrategies.MYBATIS3));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Book> listBookPageByUserId(Long userId, int page, int pageSize) {
|
||||||
|
|
||||||
|
PageHelper.startPage(page, pageSize);
|
||||||
|
|
||||||
|
SelectStatementProvider selectStatement = select(id, bookName, visitCount, lastIndexName, status)
|
||||||
|
.from(book)
|
||||||
|
.where(authorId, isEqualTo(authorService.queryAuthor(userId).getId()))
|
||||||
|
.orderBy(BookDynamicSqlSupport.createTime.descending())
|
||||||
|
.build()
|
||||||
|
.render(RenderingStrategies.MYBATIS3);
|
||||||
|
return bookMapper.selectMany(selectStatement);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addBook(Book book, Long authorId, String penName) {
|
||||||
|
//判断小说名是否存在
|
||||||
|
if (queryIdByNameAndAuthor(book.getBookName(), penName) != null) {
|
||||||
|
//该作者发布过此书名的小说
|
||||||
|
throw new BusinessException(ResponseStatus.BOOKNAME_EXISTS);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
book.setAuthorName(penName);
|
||||||
|
book.setAuthorId(authorId);
|
||||||
|
book.setVisitCount(0L);
|
||||||
|
book.setWordCount(0);
|
||||||
|
book.setScore(6.5f);
|
||||||
|
book.setLastIndexName("");
|
||||||
|
book.setCreateTime(new Date());
|
||||||
|
book.setUpdateTime(book.getCreateTime());
|
||||||
|
bookMapper.insertSelective(book);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateBookStatus(Long bookId, Byte status, Long authorId) {
|
||||||
|
bookMapper.update(update(book)
|
||||||
|
.set(BookDynamicSqlSupport.status)
|
||||||
|
.equalTo(status)
|
||||||
|
.where(id, isEqualTo(bookId))
|
||||||
|
.and(BookDynamicSqlSupport.authorId, isEqualTo(authorId))
|
||||||
|
.build()
|
||||||
|
.render(RenderingStrategies.MYBATIS3));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
@Override
|
||||||
|
public void addBookContent(Long bookId, String indexName, String content, Long authorId) {
|
||||||
|
|
||||||
|
Book book = queryBookDetail(bookId);
|
||||||
|
if (!authorId.equals(book.getAuthorId())) {
|
||||||
|
//并不是更新自己的小说
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Long lastIndexId = new IdWorker().nextId();
|
||||||
|
Date currentDate = new Date();
|
||||||
|
int wordCount = content.length();
|
||||||
|
|
||||||
|
//更新小说主表信息
|
||||||
|
bookMapper.update(update(BookDynamicSqlSupport.book)
|
||||||
|
.set(BookDynamicSqlSupport.lastIndexId)
|
||||||
|
.equalTo(lastIndexId)
|
||||||
|
.set(BookDynamicSqlSupport.lastIndexName)
|
||||||
|
.equalTo(indexName)
|
||||||
|
.set(BookDynamicSqlSupport.lastIndexUpdateTime)
|
||||||
|
.equalTo(currentDate)
|
||||||
|
.set(BookDynamicSqlSupport.wordCount)
|
||||||
|
.equalTo(book.getWordCount() + wordCount)
|
||||||
|
.where(id, isEqualTo(bookId))
|
||||||
|
.and(BookDynamicSqlSupport.authorId, isEqualTo(authorId))
|
||||||
|
.build()
|
||||||
|
.render(RenderingStrategies.MYBATIS3));
|
||||||
|
//更新小说目录表
|
||||||
|
int indexNum = 0;
|
||||||
|
if (book.getLastIndexId() != null) {
|
||||||
|
indexNum = queryBookIndex(book.getLastIndexId()).getIndexNum() + 1;
|
||||||
|
}
|
||||||
|
BookIndex lastBookIndex = new BookIndex();
|
||||||
|
lastBookIndex.setId(lastIndexId);
|
||||||
|
lastBookIndex.setWordCount(wordCount);
|
||||||
|
lastBookIndex.setIndexName(indexName);
|
||||||
|
lastBookIndex.setIndexNum(indexNum);
|
||||||
|
lastBookIndex.setBookId(bookId);
|
||||||
|
lastBookIndex.setIsVip(book.getStatus());
|
||||||
|
lastBookIndex.setCreateTime(currentDate);
|
||||||
|
lastBookIndex.setUpdateTime(currentDate);
|
||||||
|
bookIndexMapper.insertSelective(lastBookIndex);
|
||||||
|
|
||||||
|
//更新小说内容表
|
||||||
|
BookContent bookContent = new BookContent();
|
||||||
|
bookContent.setIndexId(lastIndexId);
|
||||||
|
bookContent.setContent(content);
|
||||||
|
bookContentMapper.insertSelective(bookContent);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Book> queryBookByUpdateTimeByPage(Date startDate, int limit) {
|
||||||
|
|
||||||
|
|
||||||
|
return bookMapper.selectMany(select(book.allColumns())
|
||||||
|
.from(book)
|
||||||
|
.where(updateTime, isGreaterThan(startDate))
|
||||||
|
.orderBy(updateTime)
|
||||||
|
.limit(limit)
|
||||||
|
.build()
|
||||||
|
.render(RenderingStrategies.MYBATIS3));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
package com.java2nb.novel.service.impl;
|
||||||
|
|
||||||
|
import com.github.tobato.fastdfs.domain.StorePath;
|
||||||
|
import com.github.tobato.fastdfs.service.FastFileStorageClient;
|
||||||
|
import com.java2nb.novel.core.utils.Constants;
|
||||||
|
import com.java2nb.novel.core.utils.FileUtil;
|
||||||
|
import com.java2nb.novel.service.FileService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 11797
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
@ConditionalOnProperty(prefix = "pic.save", name = "storage", havingValue = "fastDfs")
|
||||||
|
public class FastDfsFileServiceImpl implements FileService {
|
||||||
|
|
||||||
|
private final FastFileStorageClient storageClient;
|
||||||
|
|
||||||
|
@Value("${fdfs.webUrl}")
|
||||||
|
private String webUrl;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String transFile(String picSrc, String picSavePath) {
|
||||||
|
|
||||||
|
File file;
|
||||||
|
String filePath = FileUtil.network2Local(picSrc, picSavePath, Constants.LOCAL_PIC_PREFIX);
|
||||||
|
if (filePath.contains(Constants.LOCAL_PIC_PREFIX)) {
|
||||||
|
file = new File(picSavePath + filePath);
|
||||||
|
} else {
|
||||||
|
//默认图片不存储
|
||||||
|
return filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
FileInputStream inputStream = new FileInputStream(file);
|
||||||
|
StorePath storePath = storageClient.uploadFile(inputStream, file.length(),
|
||||||
|
FilenameUtils.getExtension(file.getName()), null);
|
||||||
|
//这里额外加上LOCAL_PIC_PREFIX路径,表明该图片是个人资源,而不是爬虫爬取的网络资源,不需要再次进行转换,
|
||||||
|
// 实际访问时,再通过nginx的rewite指令来重写路径,去掉LOCAL_PIC_PREFIX
|
||||||
|
return webUrl+Constants.LOCAL_PIC_PREFIX+storePath.getFullPath();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
} finally {
|
||||||
|
//删除
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
return "/images/default.gif";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.java2nb.novel.service.impl;
|
||||||
|
|
||||||
|
import com.java2nb.novel.core.utils.Constants;
|
||||||
|
import com.java2nb.novel.core.utils.FileUtil;
|
||||||
|
import com.java2nb.novel.service.FileService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 11797
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@ConditionalOnProperty(prefix = "pic.save", name = "storage", havingValue = "local")
|
||||||
|
public class LocalFileServiceImpl implements FileService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String transFile(String picSrc, String picSavePath){
|
||||||
|
|
||||||
|
return FileUtil.network2Local(picSrc, picSavePath, Constants.LOCAL_PIC_PREFIX);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,76 @@
|
|||||||
|
package com.java2nb.novel.service.impl;
|
||||||
|
|
||||||
|
import com.aliyun.oss.OSSClient;
|
||||||
|
import com.aliyun.oss.model.CannedAccessControlList;
|
||||||
|
import com.aliyun.oss.model.CreateBucketRequest;
|
||||||
|
import com.aliyun.oss.model.PutObjectRequest;
|
||||||
|
import com.aliyun.oss.model.PutObjectResult;
|
||||||
|
import com.java2nb.novel.core.config.OssProperties;
|
||||||
|
import com.java2nb.novel.core.utils.Constants;
|
||||||
|
import com.java2nb.novel.core.utils.FileUtil;
|
||||||
|
import com.java2nb.novel.service.FileService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 11797
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@ConditionalOnProperty(prefix = "pic.save", name = "storage", havingValue = "OSS")
|
||||||
|
@Slf4j
|
||||||
|
public class OssFileServiceImpl implements FileService {
|
||||||
|
|
||||||
|
private final OssProperties ossProperties;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String transFile(String picSrc, String picSavePath) {
|
||||||
|
|
||||||
|
File file;
|
||||||
|
String filePath = FileUtil.network2Local(picSrc, picSavePath, Constants.LOCAL_PIC_PREFIX);
|
||||||
|
if (filePath.contains(Constants.LOCAL_PIC_PREFIX)) {
|
||||||
|
file = new File(picSavePath+filePath);
|
||||||
|
} else {
|
||||||
|
//默认图片不存储
|
||||||
|
return filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
filePath = filePath.replaceFirst(picSavePath,"");
|
||||||
|
|
||||||
|
filePath = filePath.startsWith("/") ? filePath.replaceFirst("/","") : filePath;
|
||||||
|
|
||||||
|
|
||||||
|
OSSClient ossClient = new OSSClient(ossProperties.getEndpoint(), ossProperties.getKeyId(), ossProperties.getKeySecret());
|
||||||
|
try {
|
||||||
|
//容器不存在,就创建
|
||||||
|
if (!ossClient.doesBucketExist(ossProperties.getBucketName())) {
|
||||||
|
ossClient.createBucket(ossProperties.getBucketName());
|
||||||
|
CreateBucketRequest createBucketRequest = new CreateBucketRequest(ossProperties.getBucketName());
|
||||||
|
createBucketRequest.setCannedACL(CannedAccessControlList.PublicRead);
|
||||||
|
ossClient.createBucket(createBucketRequest);
|
||||||
|
}
|
||||||
|
//上传文件
|
||||||
|
PutObjectResult result = ossClient.putObject(new PutObjectRequest(ossProperties.getBucketName(), filePath, file));
|
||||||
|
//设置权限 这里是公开读
|
||||||
|
ossClient.setBucketAcl(ossProperties.getBucketName(), CannedAccessControlList.PublicRead);
|
||||||
|
|
||||||
|
if(result != null) {
|
||||||
|
return ossProperties.getWebUrl() + "/" + filePath;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
} finally {
|
||||||
|
//关闭
|
||||||
|
ossClient.shutdown();
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
return "/images/default.gif";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,199 @@
|
|||||||
|
package com.java2nb.novel.service.impl;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.JavaType;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
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.service.SearchService;
|
||||||
|
import com.java2nb.novel.vo.EsBookVO;
|
||||||
|
import io.searchbox.client.JestClient;
|
||||||
|
import io.searchbox.core.*;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||||
|
import org.elasticsearch.index.query.QueryBuilders;
|
||||||
|
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||||
|
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
|
||||||
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 11797
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class SearchServiceImpl implements SearchService {
|
||||||
|
|
||||||
|
private final String INDEX = "novel";
|
||||||
|
|
||||||
|
private final String TYPE = "book";
|
||||||
|
|
||||||
|
private final JestClient jestClient;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SneakyThrows
|
||||||
|
public void importToEs(Book book) {
|
||||||
|
//导入到ES
|
||||||
|
EsBookVO esBookVO = new EsBookVO();
|
||||||
|
BeanUtils.copyProperties(book, esBookVO, "lastIndexUpdateTime");
|
||||||
|
esBookVO.setLastIndexUpdateTime(new SimpleDateFormat("yyyy/MM/dd HH:mm").format(book.getLastIndexUpdateTime()));
|
||||||
|
Index action = new Index.Builder(esBookVO).index(INDEX).type(TYPE).id(book.getId().toString()).build();
|
||||||
|
|
||||||
|
jestClient.execute(action);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
@Override
|
||||||
|
public PageInfo searchBook(BookSP params, int page, int pageSize) {
|
||||||
|
List<EsBookVO> bookList = new ArrayList<>(0);
|
||||||
|
|
||||||
|
//使用搜索引擎搜索
|
||||||
|
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||||
|
// 构造查询哪个字段
|
||||||
|
if (StringUtils.isNoneBlank(params.getKeyword())) {
|
||||||
|
boolQueryBuilder = boolQueryBuilder.must(QueryBuilders.queryStringQuery(params.getKeyword()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 作品方向
|
||||||
|
if (params.getWorkDirection() != null) {
|
||||||
|
boolQueryBuilder.filter(QueryBuilders.termQuery("workDirection", params.getWorkDirection()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分类
|
||||||
|
if (params.getCatId() != null) {
|
||||||
|
boolQueryBuilder.filter(QueryBuilders.termQuery("catId", params.getCatId()));
|
||||||
|
}
|
||||||
|
if (params.getBookStatus() != null) {
|
||||||
|
boolQueryBuilder.filter(QueryBuilders.termQuery("bookStatus", params.getBookStatus()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.getWordCountMin() == null) {
|
||||||
|
params.setWordCountMin(0);
|
||||||
|
}
|
||||||
|
if (params.getWordCountMax() == null) {
|
||||||
|
params.setWordCountMax(Integer.MAX_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolQueryBuilder.filter(QueryBuilders.rangeQuery("wordCount").gte(params.getWordCountMin()).lte(params.getWordCountMax()));
|
||||||
|
|
||||||
|
if (params.getUpdateTimeMin() != null) {
|
||||||
|
boolQueryBuilder.filter(QueryBuilders.rangeQuery("lastIndexUpdateTime").gte(params.getUpdateTimeMin()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
||||||
|
searchSourceBuilder.query(boolQueryBuilder);
|
||||||
|
|
||||||
|
|
||||||
|
Count count = new Count.Builder().addIndex(INDEX).addType(TYPE)
|
||||||
|
.query(searchSourceBuilder.toString()).build();
|
||||||
|
CountResult results = jestClient.execute(count);
|
||||||
|
Double total = results.getCount();
|
||||||
|
|
||||||
|
|
||||||
|
// 高亮字段
|
||||||
|
HighlightBuilder highlightBuilder = new HighlightBuilder();
|
||||||
|
highlightBuilder.field("authorName");
|
||||||
|
highlightBuilder.field("bookName");
|
||||||
|
highlightBuilder.field("bookDesc");
|
||||||
|
highlightBuilder.field("lastIndexName");
|
||||||
|
highlightBuilder.field("catName");
|
||||||
|
highlightBuilder.preTags("<span style='color:red'>").postTags("</span>");
|
||||||
|
highlightBuilder.fragmentSize(20000);
|
||||||
|
searchSourceBuilder.highlighter(highlightBuilder);
|
||||||
|
|
||||||
|
|
||||||
|
//设置排序
|
||||||
|
if (params.getSort() != null) {
|
||||||
|
searchSourceBuilder.sort(StringUtil.camelName(params.getSort()), SortOrder.DESC);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置分页
|
||||||
|
searchSourceBuilder.from((page - 1) * pageSize);
|
||||||
|
searchSourceBuilder.size(pageSize);
|
||||||
|
|
||||||
|
// 构建Search对象
|
||||||
|
Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(INDEX).addType(TYPE).build();
|
||||||
|
log.debug(search.toString());
|
||||||
|
SearchResult result;
|
||||||
|
result = jestClient.execute(search);
|
||||||
|
if (result.isSucceeded()) {
|
||||||
|
log.debug(result.getJsonString());
|
||||||
|
|
||||||
|
Map resultMap = new ObjectMapper().readValue(result.getJsonString(), Map.class);
|
||||||
|
if (resultMap.get("hits") != null) {
|
||||||
|
Map hitsMap = (Map) resultMap.get("hits");
|
||||||
|
if (hitsMap.size() > 0 && hitsMap.get("hits") != null) {
|
||||||
|
List hitsList = (List) hitsMap.get("hits");
|
||||||
|
if (hitsList.size() > 0 && result.getSourceAsString() != null) {
|
||||||
|
|
||||||
|
JavaType jt = new ObjectMapper().getTypeFactory().constructParametricType(ArrayList.class, EsBookVO.class);
|
||||||
|
bookList = new ObjectMapper().readValue("[" + result.getSourceAsString() + "]", jt);
|
||||||
|
|
||||||
|
if (bookList != null) {
|
||||||
|
for (int i = 0; i < bookList.size(); i++) {
|
||||||
|
hitsMap = (Map) hitsList.get(i);
|
||||||
|
Map highlightMap = (Map) hitsMap.get("highlight");
|
||||||
|
if (highlightMap != null && highlightMap.size() > 0) {
|
||||||
|
|
||||||
|
List<String> authorNameList = (List<String>) highlightMap.get("authorName");
|
||||||
|
if (authorNameList != null && authorNameList.size() > 0) {
|
||||||
|
bookList.get(i).setAuthorName(authorNameList.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> bookNameList = (List<String>) highlightMap.get("bookName");
|
||||||
|
if (bookNameList != null && bookNameList.size() > 0) {
|
||||||
|
bookList.get(i).setBookName(bookNameList.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> bookDescList = (List<String>) highlightMap.get("bookDesc");
|
||||||
|
if (bookDescList != null && bookDescList.size() > 0) {
|
||||||
|
bookList.get(i).setBookDesc(bookDescList.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> lastIndexNameList = (List<String>) highlightMap.get("lastIndexName");
|
||||||
|
if (lastIndexNameList != null && lastIndexNameList.size() > 0) {
|
||||||
|
bookList.get(i).setLastIndexName(lastIndexNameList.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> catNameList = (List<String>) highlightMap.get("catName");
|
||||||
|
if (catNameList != null && catNameList.size() > 0) {
|
||||||
|
bookList.get(i).setCatName(catNameList.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PageInfo<EsBookVO> pageInfo = new PageInfo<>(bookList);
|
||||||
|
pageInfo.setTotal(total.longValue());
|
||||||
|
pageInfo.setPageNum(page);
|
||||||
|
pageInfo.setPageSize(pageSize);
|
||||||
|
return pageInfo;
|
||||||
|
}
|
||||||
|
throw new BusinessException(ResponseStatus.ES_SEARCH_FAIL);
|
||||||
|
}
|
||||||
|
}
|
@ -3,14 +3,12 @@ package com.java2nb.novel.service.impl;
|
|||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.java2nb.novel.core.bean.UserDetails;
|
import com.java2nb.novel.core.bean.UserDetails;
|
||||||
import com.java2nb.novel.core.utils.BeanUtil;
|
import com.java2nb.novel.core.utils.BeanUtil;
|
||||||
|
import com.java2nb.novel.entity.*;
|
||||||
|
import com.java2nb.novel.entity.User;
|
||||||
import com.java2nb.novel.form.UserForm;
|
import com.java2nb.novel.form.UserForm;
|
||||||
import com.java2nb.novel.service.UserService;
|
import com.java2nb.novel.service.UserService;
|
||||||
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.entity.User;
|
|
||||||
import com.java2nb.novel.entity.UserBookshelf;
|
|
||||||
import com.java2nb.novel.entity.UserFeedback;
|
|
||||||
import com.java2nb.novel.entity.UserReadHistory;
|
|
||||||
import com.java2nb.novel.mapper.*;
|
import com.java2nb.novel.mapper.*;
|
||||||
import com.java2nb.novel.vo.BookReadHistoryVO;
|
import com.java2nb.novel.vo.BookReadHistoryVO;
|
||||||
import com.java2nb.novel.vo.BookShelfVO;
|
import com.java2nb.novel.vo.BookShelfVO;
|
||||||
@ -31,6 +29,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.java2nb.novel.mapper.BookDynamicSqlSupport.book;
|
||||||
|
import static com.java2nb.novel.mapper.BookDynamicSqlSupport.id;
|
||||||
import static com.java2nb.novel.mapper.UserBookshelfDynamicSqlSupport.userBookshelf;
|
import static com.java2nb.novel.mapper.UserBookshelfDynamicSqlSupport.userBookshelf;
|
||||||
import static com.java2nb.novel.mapper.UserDynamicSqlSupport.*;
|
import static com.java2nb.novel.mapper.UserDynamicSqlSupport.*;
|
||||||
import static com.java2nb.novel.mapper.UserFeedbackDynamicSqlSupport.userFeedback;
|
import static com.java2nb.novel.mapper.UserFeedbackDynamicSqlSupport.userFeedback;
|
||||||
@ -54,6 +54,8 @@ public class UserServiceImpl implements UserService {
|
|||||||
|
|
||||||
private final UserFeedbackMapper userFeedbackMapper;
|
private final UserFeedbackMapper userFeedbackMapper;
|
||||||
|
|
||||||
|
private final UserBuyRecordMapper userBuyRecordMapper;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -84,13 +86,14 @@ public class UserServiceImpl implements UserService {
|
|||||||
UserDetails userDetails = new UserDetails();
|
UserDetails userDetails = new UserDetails();
|
||||||
userDetails.setId(id);
|
userDetails.setId(id);
|
||||||
userDetails.setUsername(entity.getUsername());
|
userDetails.setUsername(entity.getUsername());
|
||||||
|
userDetails.setNickName(entity.getNickName());
|
||||||
return userDetails;
|
return userDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserDetails login(UserForm form) {
|
public UserDetails login(UserForm form) {
|
||||||
//根据用户名密码查询记录
|
//根据用户名密码查询记录
|
||||||
SelectStatementProvider selectStatement = select(id, username)
|
SelectStatementProvider selectStatement = select(id, username,nickName)
|
||||||
.from(user)
|
.from(user)
|
||||||
.where(username, isEqualTo(form.getUsername()))
|
.where(username, isEqualTo(form.getUsername()))
|
||||||
.and(password, isEqualTo(MD5Util.MD5Encode(form.getPassword(), Charsets.UTF_8.name())))
|
.and(password, isEqualTo(MD5Util.MD5Encode(form.getPassword(), Charsets.UTF_8.name())))
|
||||||
@ -102,7 +105,9 @@ public class UserServiceImpl implements UserService {
|
|||||||
}
|
}
|
||||||
//生成UserDetail对象并返回
|
//生成UserDetail对象并返回
|
||||||
UserDetails userDetails = new UserDetails();
|
UserDetails userDetails = new UserDetails();
|
||||||
userDetails.setId(users.get(0).getId());
|
User user = users.get(0);
|
||||||
|
userDetails.setId(user.getId());
|
||||||
|
userDetails.setNickName(user.getNickName());
|
||||||
userDetails.setUsername(form.getUsername());
|
userDetails.setUsername(form.getUsername());
|
||||||
return userDetails;
|
return userDetails;
|
||||||
}
|
}
|
||||||
@ -266,5 +271,40 @@ public class UserServiceImpl implements UserService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean queryIsBuyBookIndex(Long userId, Long bookIndexId) {
|
||||||
|
|
||||||
|
return userBuyRecordMapper.count(c ->
|
||||||
|
c.where(UserBuyRecordDynamicSqlSupport.userId, isEqualTo(userId))
|
||||||
|
.and(UserBuyRecordDynamicSqlSupport.bookIndexId,isEqualTo(bookIndexId))) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
@Override
|
||||||
|
public void buyBookIndex(Long userId, UserBuyRecord buyRecord) {
|
||||||
|
//查询用户余额
|
||||||
|
long balance = userInfo(userId).getAccountBalance();
|
||||||
|
if(balance<10){
|
||||||
|
//余额不足
|
||||||
|
throw new BusinessException(ResponseStatus.USER_NO_BALANCE);
|
||||||
|
}
|
||||||
|
buyRecord.setUserId(userId);
|
||||||
|
buyRecord.setCreateTime(new Date());
|
||||||
|
buyRecord.setBuyAmount(10);
|
||||||
|
//生成购买记录
|
||||||
|
userBuyRecordMapper.insertSelective(buyRecord);
|
||||||
|
|
||||||
|
//减少用户余额
|
||||||
|
userMapper.update(update(user)
|
||||||
|
.set(UserDynamicSqlSupport.accountBalance)
|
||||||
|
.equalTo(balance-10)
|
||||||
|
.where(id,isEqualTo(userId))
|
||||||
|
.build()
|
||||||
|
.render(RenderingStrategies.MYBATIS3));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
85
novel-front/src/main/java/com/java2nb/novel/vo/EsBookVO.java
Normal file
85
novel-front/src/main/java/com/java2nb/novel/vo/EsBookVO.java
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
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
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class EsBookVO {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
|
||||||
|
private Byte workDirection;
|
||||||
|
|
||||||
|
|
||||||
|
private Integer catId;
|
||||||
|
|
||||||
|
|
||||||
|
private String catName;
|
||||||
|
|
||||||
|
|
||||||
|
private String picUrl;
|
||||||
|
|
||||||
|
|
||||||
|
private String bookName;
|
||||||
|
|
||||||
|
|
||||||
|
private Long authorId;
|
||||||
|
|
||||||
|
|
||||||
|
private String authorName;
|
||||||
|
|
||||||
|
|
||||||
|
private String bookDesc;
|
||||||
|
|
||||||
|
|
||||||
|
private Float score;
|
||||||
|
|
||||||
|
|
||||||
|
private Byte bookStatus;
|
||||||
|
|
||||||
|
|
||||||
|
private Long visitCount;
|
||||||
|
|
||||||
|
|
||||||
|
private Integer wordCount;
|
||||||
|
|
||||||
|
|
||||||
|
private Integer commentCount;
|
||||||
|
|
||||||
|
|
||||||
|
private Long lastIndexId;
|
||||||
|
|
||||||
|
|
||||||
|
private String lastIndexName;
|
||||||
|
|
||||||
|
private String lastIndexUpdateTime;
|
||||||
|
|
||||||
|
|
||||||
|
private Byte isVip;
|
||||||
|
|
||||||
|
|
||||||
|
private Byte status;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private Integer crawlSourceId;
|
||||||
|
|
||||||
|
|
||||||
|
private String crawlBookId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private Byte crawlIsStop;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
16
novel-front/src/main/resources/application-fastdfs.yml
Normal file
16
novel-front/src/main/resources/application-fastdfs.yml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#FastDfs的配置 ====================================
|
||||||
|
#读取inputsream阻塞时间
|
||||||
|
fdfs:
|
||||||
|
connect-timeout: 600
|
||||||
|
so-timeout: 1500
|
||||||
|
#tracker地址
|
||||||
|
trackerList: 127.0.0.1:22122
|
||||||
|
#缩略图配置
|
||||||
|
thumbImage:
|
||||||
|
height: 150
|
||||||
|
width: 150
|
||||||
|
#通过nginx 访问地址
|
||||||
|
webUrl: http://127.0.0.1/
|
||||||
|
#获取连接池最大数量
|
||||||
|
pool.max-total: 200
|
||||||
|
|
9
novel-front/src/main/resources/application-oss.yml
Normal file
9
novel-front/src/main/resources/application-oss.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#OSS
|
||||||
|
novel:
|
||||||
|
file:
|
||||||
|
endpoint: oss-cn-shenzhen.aliyuncs.com #不同的服务器,地址不同
|
||||||
|
key-id: dhjjrue6767778878 #去OSS控制台获取
|
||||||
|
key-secret: dssdkkrkelrkellk44554 #去OSS控制台获取
|
||||||
|
bucket-name: novel #这个自己创建bucket时的命名,控制台创建也行,代码创建也行
|
||||||
|
file-host: pic #文件路径
|
||||||
|
web-url: https://xxyimg.oss-cn-hangzhou.aliyuncs.com #OSS文件的web访问地址
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user