mirror of
https://github.com/201206030/novel-plus.git
synced 2025-07-01 07:16:39 +00:00
Compare commits
11 Commits
release_v2
...
release_v2
Author | SHA1 | Date | |
---|---|---|---|
68a1ece57c | |||
77645da2bd | |||
36376aa623 | |||
9e98665cca | |||
9a19a33406 | |||
a4f7042b87 | |||
31aa3192fd | |||
cd11854eff | |||
85f5048fd9 | |||
f625ee38e1 | |||
2c3e346ea7 |
@ -44,6 +44,7 @@ GitHub仓库地址: https://github.com/201206030/novel-cloud
|
||||
- [x] 阅读主题模块。
|
||||
- [x] 作家专区。
|
||||
- [x] 充值。
|
||||
- [x] 订阅。
|
||||
- [x] 后台管理系统。
|
||||
- [x] 爬虫管理系统。
|
||||
|
||||
@ -126,7 +127,7 @@ novel-plus -- 父工程
|
||||
|
||||

|
||||
|
||||

|
||||

|
||||
|
||||

|
||||
|
||||
@ -219,10 +220,10 @@ docker安装教程:[点击前往](https://my.oschina.net/java2nb/blog/4271989)
|
||||
|
||||

|
||||
|
||||
#### 联系作者
|
||||
### 免责声明
|
||||
|
||||
精力有限有问题可以扫一扫添加作者微信(避免伸手党,只限赞赏用户,谢谢,其他不回复)
|
||||

|
||||
本项目提供的爬虫工具仅用于采集项目初期的测试数据,请勿用于商业盈利。
|
||||
用户使用本系统从事任何违法违规的事情,一切后果由用户自行承担,作者不承担任何责任。
|
||||
|
||||
#### 备注
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>novel</artifactId>
|
||||
<groupId>com.java2nb</groupId>
|
||||
<version>2.7.1</version>
|
||||
<version>2.9.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -3,6 +3,10 @@ package com.java2nb.novel.core.utils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static java.util.regex.Pattern.*;
|
||||
|
||||
/**
|
||||
* @author xiongxiaoyang
|
||||
@ -70,4 +74,83 @@ public class StringUtil {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字符串有效汉字
|
||||
* */
|
||||
public static String getChineseValidWord(String origStr){
|
||||
|
||||
//可以替换大部分空白字符, 不限于空格 . 说明:\s 可以匹配空格、制表符、换页符等空白字符的其中任意一个
|
||||
origStr = origStr.replaceAll("\\s*","");
|
||||
|
||||
/* //完全清除标点
|
||||
origStr = origStr.replaceAll("\\pP","");*/
|
||||
|
||||
//清除所有符号,只留下字母 数字 汉字 共3类.
|
||||
origStr = origStr.replaceAll("[\\pP\\p{Punct}]","");
|
||||
|
||||
//去除字母和数字
|
||||
origStr = origStr.replaceAll("[A-Za-z0-9]*","");
|
||||
|
||||
return origStr;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字符串英文单词数量
|
||||
* */
|
||||
public static int getEnglishWordCount(String origStr){
|
||||
Pattern pattern = compile("\\b\\w+\\b");
|
||||
Matcher matcher = pattern.matcher(origStr);
|
||||
int count = 0;
|
||||
while (matcher.find()) {
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字符串中文汉字数量
|
||||
* */
|
||||
public static int getChineseWordCount(String origStr){
|
||||
Pattern pattern = compile("[\u4e00-\u9fa5]");
|
||||
Matcher matcher = pattern.matcher(origStr);
|
||||
int count = 0;
|
||||
while (matcher.find()) {
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字符串有效数字数量
|
||||
* */
|
||||
public static int getNumberWordCount(String origStr){
|
||||
Pattern pattern = compile("\\d+");
|
||||
Matcher matcher = pattern.matcher(origStr);
|
||||
int count = 0;
|
||||
while (matcher.find()) {
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字符串有效字数
|
||||
* */
|
||||
public static int getStrValidWordCount(String origStr){
|
||||
return getChineseWordCount(origStr) + getEnglishWordCount(origStr) + getNumberWordCount(origStr);
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String str = "Welcome to China. 你好呀!中国人,我是1123号程序员, 来给你服务23天. Hello Word";
|
||||
System.out.println(getChineseWordCount(str));
|
||||
System.out.println(getEnglishWordCount(str));
|
||||
System.out.println(getNumberWordCount(str));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -22,6 +22,9 @@ public class BookIndex {
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private Byte isVip;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private Integer bookPrice;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
private Date createTime;
|
||||
|
||||
@ -88,6 +91,16 @@ public class BookIndex {
|
||||
this.isVip = isVip;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public Integer getBookPrice() {
|
||||
return bookPrice;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public void setBookPrice(Integer bookPrice) {
|
||||
this.bookPrice = bookPrice;
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
|
@ -28,6 +28,9 @@ public final class BookIndexDynamicSqlSupport {
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<Byte> isVip = bookIndex.isVip;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<Integer> bookPrice = bookIndex.bookPrice;
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
public static final SqlColumn<Date> createTime = bookIndex.createTime;
|
||||
|
||||
@ -48,6 +51,8 @@ public final class BookIndexDynamicSqlSupport {
|
||||
|
||||
public final SqlColumn<Byte> isVip = column("is_vip", JDBCType.TINYINT);
|
||||
|
||||
public final SqlColumn<Integer> bookPrice = column("book_price", JDBCType.INTEGER);
|
||||
|
||||
public final SqlColumn<Date> createTime = column("create_time", JDBCType.TIMESTAMP);
|
||||
|
||||
public final SqlColumn<Date> updateTime = column("update_time", JDBCType.TIMESTAMP);
|
||||
|
@ -4,10 +4,12 @@ import static com.java2nb.novel.mapper.BookIndexDynamicSqlSupport.*;
|
||||
import static org.mybatis.dynamic.sql.SqlBuilder.*;
|
||||
|
||||
import com.java2nb.novel.entity.BookIndex;
|
||||
|
||||
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;
|
||||
@ -35,45 +37,46 @@ import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;
|
||||
@Mapper
|
||||
public interface BookIndexMapper {
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
BasicColumn[] selectList = BasicColumn.columnList(id, bookId, indexNum, indexName, wordCount, isVip, createTime, updateTime);
|
||||
BasicColumn[] selectList = BasicColumn.columnList(id, bookId, indexNum, indexName, wordCount, isVip, bookPrice, createTime, updateTime);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||
@SelectProvider(type = SqlProviderAdapter.class, method = "select")
|
||||
long count(SelectStatementProvider selectStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@DeleteProvider(type=SqlProviderAdapter.class, method="delete")
|
||||
@DeleteProvider(type = SqlProviderAdapter.class, method = "delete")
|
||||
int delete(DeleteStatementProvider deleteStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@InsertProvider(type=SqlProviderAdapter.class, method="insert")
|
||||
@InsertProvider(type = SqlProviderAdapter.class, method = "insert")
|
||||
int insert(InsertStatementProvider<BookIndex> insertStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
|
||||
@InsertProvider(type = SqlProviderAdapter.class, method = "insertMultiple")
|
||||
int insertMultiple(MultiRowInsertStatementProvider<BookIndex> multipleInsertStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||
@SelectProvider(type = SqlProviderAdapter.class, method = "select")
|
||||
@ResultMap("BookIndexResult")
|
||||
Optional<BookIndex> selectOne(SelectStatementProvider selectStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@SelectProvider(type=SqlProviderAdapter.class, method="select")
|
||||
@Results(id="BookIndexResult", value = {
|
||||
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
|
||||
@Result(column="book_id", property="bookId", jdbcType=JdbcType.BIGINT),
|
||||
@Result(column="index_num", property="indexNum", jdbcType=JdbcType.INTEGER),
|
||||
@Result(column="index_name", property="indexName", jdbcType=JdbcType.VARCHAR),
|
||||
@Result(column="word_count", property="wordCount", jdbcType=JdbcType.INTEGER),
|
||||
@Result(column="is_vip", property="isVip", jdbcType=JdbcType.TINYINT),
|
||||
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
|
||||
@Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP)
|
||||
@SelectProvider(type = SqlProviderAdapter.class, method = "select")
|
||||
@Results(id = "BookIndexResult", value = {
|
||||
@Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
|
||||
@Result(column = "book_id", property = "bookId", jdbcType = JdbcType.BIGINT),
|
||||
@Result(column = "index_num", property = "indexNum", jdbcType = JdbcType.INTEGER),
|
||||
@Result(column = "index_name", property = "indexName", jdbcType = JdbcType.VARCHAR),
|
||||
@Result(column = "word_count", property = "wordCount", jdbcType = JdbcType.INTEGER),
|
||||
@Result(column = "is_vip", property = "isVip", jdbcType = JdbcType.TINYINT),
|
||||
@Result(column = "book_price", property = "bookPrice", jdbcType = JdbcType.INTEGER),
|
||||
@Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP),
|
||||
@Result(column = "update_time", property = "updateTime", jdbcType = JdbcType.TIMESTAMP)
|
||||
})
|
||||
List<BookIndex> selectMany(SelectStatementProvider selectStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@UpdateProvider(type=SqlProviderAdapter.class, method="update")
|
||||
@UpdateProvider(type = SqlProviderAdapter.class, method = "update")
|
||||
int update(UpdateStatementProvider updateStatement);
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
@ -88,50 +91,53 @@ public interface BookIndexMapper {
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int deleteByPrimaryKey(Long id_) {
|
||||
return delete(c ->
|
||||
c.where(id, isEqualTo(id_))
|
||||
return delete(c ->
|
||||
c.where(id, isEqualTo(id_))
|
||||
);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int insert(BookIndex record) {
|
||||
return MyBatis3Utils.insert(this::insert, record, bookIndex, c ->
|
||||
c.map(id).toProperty("id")
|
||||
.map(bookId).toProperty("bookId")
|
||||
.map(indexNum).toProperty("indexNum")
|
||||
.map(indexName).toProperty("indexName")
|
||||
.map(wordCount).toProperty("wordCount")
|
||||
.map(isVip).toProperty("isVip")
|
||||
.map(createTime).toProperty("createTime")
|
||||
.map(updateTime).toProperty("updateTime")
|
||||
c.map(id).toProperty("id")
|
||||
.map(bookId).toProperty("bookId")
|
||||
.map(indexNum).toProperty("indexNum")
|
||||
.map(indexName).toProperty("indexName")
|
||||
.map(wordCount).toProperty("wordCount")
|
||||
.map(isVip).toProperty("isVip")
|
||||
.map(bookPrice).toProperty("bookPrice")
|
||||
.map(createTime).toProperty("createTime")
|
||||
.map(updateTime).toProperty("updateTime")
|
||||
);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int insertMultiple(Collection<BookIndex> records) {
|
||||
return MyBatis3Utils.insertMultiple(this::insertMultiple, records, bookIndex, c ->
|
||||
c.map(id).toProperty("id")
|
||||
.map(bookId).toProperty("bookId")
|
||||
.map(indexNum).toProperty("indexNum")
|
||||
.map(indexName).toProperty("indexName")
|
||||
.map(wordCount).toProperty("wordCount")
|
||||
.map(isVip).toProperty("isVip")
|
||||
.map(createTime).toProperty("createTime")
|
||||
.map(updateTime).toProperty("updateTime")
|
||||
c.map(id).toProperty("id")
|
||||
.map(bookId).toProperty("bookId")
|
||||
.map(indexNum).toProperty("indexNum")
|
||||
.map(indexName).toProperty("indexName")
|
||||
.map(wordCount).toProperty("wordCount")
|
||||
.map(isVip).toProperty("isVip")
|
||||
.map(bookPrice).toProperty("bookPrice")
|
||||
.map(createTime).toProperty("createTime")
|
||||
.map(updateTime).toProperty("updateTime")
|
||||
);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int insertSelective(BookIndex record) {
|
||||
return MyBatis3Utils.insert(this::insert, record, bookIndex, c ->
|
||||
c.map(id).toPropertyWhenPresent("id", record::getId)
|
||||
.map(bookId).toPropertyWhenPresent("bookId", record::getBookId)
|
||||
.map(indexNum).toPropertyWhenPresent("indexNum", record::getIndexNum)
|
||||
.map(indexName).toPropertyWhenPresent("indexName", record::getIndexName)
|
||||
.map(wordCount).toPropertyWhenPresent("wordCount", record::getWordCount)
|
||||
.map(isVip).toPropertyWhenPresent("isVip", record::getIsVip)
|
||||
.map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
|
||||
.map(updateTime).toPropertyWhenPresent("updateTime", record::getUpdateTime)
|
||||
c.map(id).toPropertyWhenPresent("id", record::getId)
|
||||
.map(bookId).toPropertyWhenPresent("bookId", record::getBookId)
|
||||
.map(indexNum).toPropertyWhenPresent("indexNum", record::getIndexNum)
|
||||
.map(indexName).toPropertyWhenPresent("indexName", record::getIndexName)
|
||||
.map(wordCount).toPropertyWhenPresent("wordCount", record::getWordCount)
|
||||
.map(isVip).toPropertyWhenPresent("isVip", record::getIsVip)
|
||||
.map(bookPrice).toPropertyWhenPresent("bookPrice", record::getBookPrice)
|
||||
.map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
|
||||
.map(updateTime).toPropertyWhenPresent("updateTime", record::getUpdateTime)
|
||||
);
|
||||
}
|
||||
|
||||
@ -153,7 +159,7 @@ public interface BookIndexMapper {
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default Optional<BookIndex> selectByPrimaryKey(Long id_) {
|
||||
return selectOne(c ->
|
||||
c.where(id, isEqualTo(id_))
|
||||
c.where(id, isEqualTo(id_))
|
||||
);
|
||||
}
|
||||
|
||||
@ -170,6 +176,7 @@ public interface BookIndexMapper {
|
||||
.set(indexName).equalTo(record::getIndexName)
|
||||
.set(wordCount).equalTo(record::getWordCount)
|
||||
.set(isVip).equalTo(record::getIsVip)
|
||||
.set(bookPrice).equalTo(record::getBookPrice)
|
||||
.set(createTime).equalTo(record::getCreateTime)
|
||||
.set(updateTime).equalTo(record::getUpdateTime);
|
||||
}
|
||||
@ -182,6 +189,7 @@ public interface BookIndexMapper {
|
||||
.set(indexName).equalToWhenPresent(record::getIndexName)
|
||||
.set(wordCount).equalToWhenPresent(record::getWordCount)
|
||||
.set(isVip).equalToWhenPresent(record::getIsVip)
|
||||
.set(bookPrice).equalToWhenPresent(record::getBookPrice)
|
||||
.set(createTime).equalToWhenPresent(record::getCreateTime)
|
||||
.set(updateTime).equalToWhenPresent(record::getUpdateTime);
|
||||
}
|
||||
@ -189,28 +197,30 @@ public interface BookIndexMapper {
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int updateByPrimaryKey(BookIndex record) {
|
||||
return update(c ->
|
||||
c.set(bookId).equalTo(record::getBookId)
|
||||
.set(indexNum).equalTo(record::getIndexNum)
|
||||
.set(indexName).equalTo(record::getIndexName)
|
||||
.set(wordCount).equalTo(record::getWordCount)
|
||||
.set(isVip).equalTo(record::getIsVip)
|
||||
.set(createTime).equalTo(record::getCreateTime)
|
||||
.set(updateTime).equalTo(record::getUpdateTime)
|
||||
.where(id, isEqualTo(record::getId))
|
||||
c.set(bookId).equalTo(record::getBookId)
|
||||
.set(indexNum).equalTo(record::getIndexNum)
|
||||
.set(indexName).equalTo(record::getIndexName)
|
||||
.set(wordCount).equalTo(record::getWordCount)
|
||||
.set(isVip).equalTo(record::getIsVip)
|
||||
.set(bookPrice).equalTo(record::getBookPrice)
|
||||
.set(createTime).equalTo(record::getCreateTime)
|
||||
.set(updateTime).equalTo(record::getUpdateTime)
|
||||
.where(id, isEqualTo(record::getId))
|
||||
);
|
||||
}
|
||||
|
||||
@Generated("org.mybatis.generator.api.MyBatisGenerator")
|
||||
default int updateByPrimaryKeySelective(BookIndex record) {
|
||||
return update(c ->
|
||||
c.set(bookId).equalToWhenPresent(record::getBookId)
|
||||
.set(indexNum).equalToWhenPresent(record::getIndexNum)
|
||||
.set(indexName).equalToWhenPresent(record::getIndexName)
|
||||
.set(wordCount).equalToWhenPresent(record::getWordCount)
|
||||
.set(isVip).equalToWhenPresent(record::getIsVip)
|
||||
.set(createTime).equalToWhenPresent(record::getCreateTime)
|
||||
.set(updateTime).equalToWhenPresent(record::getUpdateTime)
|
||||
.where(id, isEqualTo(record::getId))
|
||||
c.set(bookId).equalToWhenPresent(record::getBookId)
|
||||
.set(indexNum).equalToWhenPresent(record::getIndexNum)
|
||||
.set(indexName).equalToWhenPresent(record::getIndexName)
|
||||
.set(wordCount).equalToWhenPresent(record::getWordCount)
|
||||
.set(isVip).equalToWhenPresent(record::getIsVip)
|
||||
.set(bookPrice).equalToWhenPresent(record::getBookPrice)
|
||||
.set(createTime).equalToWhenPresent(record::getCreateTime)
|
||||
.set(updateTime).equalToWhenPresent(record::getUpdateTime)
|
||||
.where(id, isEqualTo(record::getId))
|
||||
);
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>novel</artifactId>
|
||||
<groupId>com.java2nb</groupId>
|
||||
<version>2.7.1</version>
|
||||
<version>2.9.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -224,6 +224,9 @@ public class CrawlServiceImpl implements CrawlService {
|
||||
boolean isFindBookId = bookIdMatcher.find();
|
||||
while (isFindBookId) {
|
||||
try {
|
||||
//1.阻塞过程(使用了 sleep,同步锁的 wait,socket 中的 receiver,accept 等方法时)
|
||||
//捕获中断异常InterruptedException来退出线程。
|
||||
//2.非阻塞过程中通过判断中断标志来退出线程。
|
||||
if(Thread.currentThread().isInterrupted()){
|
||||
return;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>novel</artifactId>
|
||||
<groupId>com.java2nb</groupId>
|
||||
<version>2.7.1</version>
|
||||
<version>2.9.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -2,7 +2,9 @@ package com.java2nb.novel.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.java2nb.novel.core.bean.ResultBean;
|
||||
import com.java2nb.novel.core.bean.UserDetails;
|
||||
import com.java2nb.novel.core.enums.ResponseStatus;
|
||||
import com.java2nb.novel.core.exception.BusinessException;
|
||||
import com.java2nb.novel.core.utils.BeanUtil;
|
||||
import com.java2nb.novel.entity.Author;
|
||||
import com.java2nb.novel.entity.Book;
|
||||
@ -58,15 +60,7 @@ public class AuthorController extends BaseController{
|
||||
@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);
|
||||
|
||||
}
|
||||
Author author = checkAuthor(request);
|
||||
|
||||
//bookDesc不能使用book对象来接收,否则会自动去掉前面的空格
|
||||
book.setBookDesc(bookDesc
|
||||
@ -83,14 +77,7 @@ public class AuthorController extends BaseController{
|
||||
* */
|
||||
@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);
|
||||
}
|
||||
Author author = checkAuthor(request);
|
||||
|
||||
//更新小说状态,上架或下架
|
||||
bookService.updateBookStatus(bookId,status,author.getId());
|
||||
@ -100,24 +87,79 @@ public class AuthorController extends BaseController{
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 删除章节
|
||||
*/
|
||||
@PostMapping("deleteIndex")
|
||||
public ResultBean deleteIndex(Long indexId, HttpServletRequest request) {
|
||||
|
||||
Author author = checkAuthor(request);
|
||||
|
||||
//删除章节
|
||||
bookService.deleteIndex(indexId, author.getId());
|
||||
|
||||
return ResultBean.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新章节名
|
||||
*/
|
||||
@PostMapping("updateIndexName")
|
||||
public ResultBean updateIndexName(Long indexId, String indexName, HttpServletRequest request) {
|
||||
|
||||
Author author = checkAuthor(request);
|
||||
|
||||
//更新章节名
|
||||
bookService.updateIndexName(indexId, indexName, author.getId());
|
||||
|
||||
return ResultBean.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 发布章节内容
|
||||
* */
|
||||
*/
|
||||
@PostMapping("addBookContent")
|
||||
public ResultBean addBookContent(Long bookId,String indexName,String content,Byte isVip,HttpServletRequest request){
|
||||
//查询作家信息
|
||||
Author author = authorService.queryAuthor(getUserDetails(request).getId());
|
||||
public ResultBean addBookContent(Long bookId, String indexName, String content,Byte isVip, HttpServletRequest request) {
|
||||
Author author = checkAuthor(request);
|
||||
|
||||
//判断作者状态是否正常
|
||||
if(author.getStatus()==1){
|
||||
//封禁状态,不能发布小说
|
||||
return ResultBean.fail(ResponseStatus.AUTHOR_STATUS_FORBIDDEN);
|
||||
}
|
||||
|
||||
content = content.replaceAll("\\n","<br>")
|
||||
.replaceAll("\\s"," ");
|
||||
content = content.replaceAll("\\n", "<br>")
|
||||
.replaceAll("\\s", " ");
|
||||
//发布章节内容
|
||||
bookService.addBookContent(bookId,indexName,content,isVip,author.getId());
|
||||
bookService.addBookContent(bookId, indexName, content,isVip, author.getId());
|
||||
|
||||
return ResultBean.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询章节内容
|
||||
*/
|
||||
@PostMapping("queryIndexContent")
|
||||
public ResultBean queryIndexContent(Long indexId, HttpServletRequest request) {
|
||||
|
||||
Author author = checkAuthor(request);
|
||||
|
||||
String content = bookService.queryIndexContent(indexId, author.getId());
|
||||
|
||||
content = content.replaceAll("<br>", "\n")
|
||||
.replaceAll(" ", " ");
|
||||
|
||||
return ResultBean.ok(content);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新章节内容
|
||||
*/
|
||||
@PostMapping("updateBookContent")
|
||||
public ResultBean updateBookContent(Long indexId, String indexName, String content, HttpServletRequest request) {
|
||||
Author author = checkAuthor(request);
|
||||
|
||||
content = content.replaceAll("\\n", "<br>")
|
||||
.replaceAll("\\s", " ");
|
||||
//更新章节内容
|
||||
bookService.updateBookContent(indexId, indexName, content, author.getId());
|
||||
|
||||
return ResultBean.ok();
|
||||
}
|
||||
@ -151,6 +193,28 @@ public class AuthorController extends BaseController{
|
||||
));
|
||||
}
|
||||
|
||||
private Author checkAuthor(HttpServletRequest request) {
|
||||
|
||||
UserDetails userDetails = getUserDetails(request);
|
||||
if (userDetails == null) {
|
||||
throw new BusinessException(ResponseStatus.NO_LOGIN);
|
||||
}
|
||||
|
||||
//查询作家信息
|
||||
Author author = authorService.queryAuthor(userDetails.getId());
|
||||
|
||||
//判断作者状态是否正常
|
||||
if (author.getStatus() == 1) {
|
||||
//封禁状态,不能发布小说
|
||||
throw new BusinessException(ResponseStatus.AUTHOR_STATUS_FORBIDDEN);
|
||||
}
|
||||
|
||||
|
||||
return author;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -167,7 +167,15 @@ public class BookController extends BaseController{
|
||||
* */
|
||||
@PostMapping("queryNewIndexList")
|
||||
public ResultBean queryNewIndexList(Long bookId){
|
||||
return ResultBean.ok(bookService.queryIndexList(bookId,"index_num desc",10));
|
||||
return ResultBean.ok(bookService.queryIndexList(bookId,"index_num desc",1,10));
|
||||
}
|
||||
|
||||
/**
|
||||
* 目录页
|
||||
* */
|
||||
@PostMapping("/queryIndexList")
|
||||
public ResultBean indexList(Long bookId,@RequestParam(value = "curr", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "5") int pageSize,@RequestParam(value = "orderBy") String orderBy) {
|
||||
return ResultBean.ok(new PageInfo<>(bookService.queryIndexList(bookId,orderBy,page,pageSize)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -101,9 +101,11 @@ public class PageController extends BaseController{
|
||||
public String bookDetail(@PathVariable("bookId") Long bookId, Model model) {
|
||||
Book book = bookService.queryBookDetail(bookId);
|
||||
model.addAttribute("book",book);
|
||||
//查询首章目录ID
|
||||
Long firstBookIndexId = bookService.queryFirstBookIndexId(bookId);
|
||||
model.addAttribute("firstBookIndexId",firstBookIndexId);
|
||||
if(book.getLastIndexId() != null) {
|
||||
//查询首章目录ID
|
||||
Long firstBookIndexId = bookService.queryFirstBookIndexId(bookId);
|
||||
model.addAttribute("firstBookIndexId", firstBookIndexId);
|
||||
}
|
||||
return ThreadLocalUtil.getTemplateDir()+"book/book_detail";
|
||||
}
|
||||
|
||||
@ -114,7 +116,7 @@ public class PageController extends BaseController{
|
||||
public String indexList(@PathVariable("bookId") Long bookId, Model model) {
|
||||
Book book = bookService.queryBookDetail(bookId);
|
||||
model.addAttribute("book",book);
|
||||
List<BookIndex> bookIndexList = bookService.queryIndexList(bookId,null,null);
|
||||
List<BookIndex> bookIndexList = bookService.queryIndexList(bookId,null,1,null);
|
||||
model.addAttribute("bookIndexList",bookIndexList);
|
||||
model.addAttribute("bookIndexCount",bookIndexList.size());
|
||||
return ThreadLocalUtil.getTemplateDir()+"book/book_index";
|
||||
|
@ -282,6 +282,7 @@ public class UserController extends BaseController {
|
||||
if (userDetails == null) {
|
||||
return ResultBean.fail(ResponseStatus.NO_LOGIN);
|
||||
}
|
||||
buyRecord.setBuyAmount(bookService.queryBookIndex(buyRecord.getBookIndexId()).getBookPrice());
|
||||
userService.buyBookIndex(userDetails.getId(),buyRecord);
|
||||
return ResultBean.ok();
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package com.java2nb.novel.core.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 章节费用配置
|
||||
* @author cd
|
||||
*/
|
||||
@Component
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "book.price")
|
||||
public class BookPriceConfig {
|
||||
|
||||
private BigDecimal wordCount;
|
||||
|
||||
private BigDecimal value;
|
||||
|
||||
|
||||
}
|
@ -66,10 +66,12 @@ public interface BookService {
|
||||
* 查询目录列表
|
||||
* @param bookId 书籍ID
|
||||
* @param orderBy 排序
|
||||
*@param limit 查询条数
|
||||
* @param page 查询页码
|
||||
*@param pageSize 分页大小
|
||||
*@return 目录集合
|
||||
* */
|
||||
List<BookIndex> queryIndexList(Long bookId, String orderBy, Integer limit);
|
||||
List<BookIndex> queryIndexList(Long bookId, String orderBy, Integer page, Integer pageSize);
|
||||
|
||||
|
||||
/**
|
||||
* 查询目录
|
||||
@ -244,4 +246,36 @@ public interface BookService {
|
||||
* @return 作品列表
|
||||
*/
|
||||
List<Book> queryBookList(Long authorId);
|
||||
|
||||
/**
|
||||
* 删除章节
|
||||
* @param indexId
|
||||
* @param authorId 作家ID
|
||||
*/
|
||||
void deleteIndex(Long indexId, Long authorId);
|
||||
|
||||
/**
|
||||
* 更新章节名
|
||||
* @param indexId
|
||||
* @param indexName
|
||||
* @param authorId
|
||||
*/
|
||||
void updateIndexName(Long indexId, String indexName, Long authorId);
|
||||
|
||||
/**
|
||||
* 查询章节内容
|
||||
* @param indexId
|
||||
* @param authorId
|
||||
* @return
|
||||
*/
|
||||
String queryIndexContent(Long indexId, Long authorId);
|
||||
|
||||
/**
|
||||
* 更新章节内容
|
||||
* @param indexId
|
||||
* @param indexName
|
||||
* @param content
|
||||
* @param authorId
|
||||
*/
|
||||
void updateBookContent( Long indexId, String indexName, String content, Long authorId);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.java2nb.novel.core.cache.CacheKey;
|
||||
import com.java2nb.novel.core.cache.CacheService;
|
||||
import com.java2nb.novel.core.config.BookPriceConfig;
|
||||
import com.java2nb.novel.core.enums.ResponseStatus;
|
||||
import com.java2nb.novel.core.exception.BusinessException;
|
||||
import com.java2nb.novel.core.utils.*;
|
||||
@ -25,6 +26,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.mybatis.dynamic.sql.SortSpecification;
|
||||
import org.mybatis.dynamic.sql.render.RenderingStrategies;
|
||||
import org.mybatis.dynamic.sql.render.RenderingStrategy;
|
||||
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@ -32,6 +34,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import tk.mybatis.orderbyhelper.OrderByHelper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@ -41,6 +44,7 @@ import java.util.stream.Collectors;
|
||||
import static com.java2nb.novel.mapper.BookCategoryDynamicSqlSupport.bookCategory;
|
||||
import static com.java2nb.novel.mapper.BookCommentDynamicSqlSupport.bookComment;
|
||||
import static com.java2nb.novel.mapper.BookContentDynamicSqlSupport.bookContent;
|
||||
import static com.java2nb.novel.mapper.BookContentDynamicSqlSupport.content;
|
||||
import static com.java2nb.novel.mapper.BookDynamicSqlSupport.*;
|
||||
import static com.java2nb.novel.mapper.BookIndexDynamicSqlSupport.bookIndex;
|
||||
import static org.mybatis.dynamic.sql.SqlBuilder.*;
|
||||
@ -85,6 +89,8 @@ public class BookServiceImpl implements BookService {
|
||||
|
||||
private final FileService fileService;
|
||||
|
||||
private final BookPriceConfig bookPriceConfig;
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
@ -233,12 +239,12 @@ public class BookServiceImpl implements BookService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookIndex> queryIndexList(Long bookId, String orderBy, Integer limit) {
|
||||
public List<BookIndex> queryIndexList(Long bookId, String orderBy, Integer page, Integer pageSize) {
|
||||
if (StringUtils.isNotBlank(orderBy)) {
|
||||
OrderByHelper.orderBy(orderBy);
|
||||
}
|
||||
if (limit != null) {
|
||||
PageHelper.startPage(1, limit);
|
||||
if (page != null && pageSize != null) {
|
||||
PageHelper.startPage(page, pageSize);
|
||||
}
|
||||
|
||||
SelectStatementProvider selectStatement = select(BookIndexDynamicSqlSupport.id, BookIndexDynamicSqlSupport.bookId, BookIndexDynamicSqlSupport.indexNum, BookIndexDynamicSqlSupport.indexName, BookIndexDynamicSqlSupport.updateTime, BookIndexDynamicSqlSupport.isVip)
|
||||
@ -250,9 +256,10 @@ public class BookServiceImpl implements BookService {
|
||||
return bookIndexMapper.selectMany(selectStatement);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BookIndex queryBookIndex(Long bookIndexId) {
|
||||
SelectStatementProvider selectStatement = select(BookIndexDynamicSqlSupport.id, BookIndexDynamicSqlSupport.bookId, BookIndexDynamicSqlSupport.indexNum, BookIndexDynamicSqlSupport.indexName, BookIndexDynamicSqlSupport.wordCount, BookIndexDynamicSqlSupport.updateTime, BookIndexDynamicSqlSupport.isVip)
|
||||
SelectStatementProvider selectStatement = select(BookIndexDynamicSqlSupport.id, BookIndexDynamicSqlSupport.bookId, BookIndexDynamicSqlSupport.indexNum, BookIndexDynamicSqlSupport.indexName, BookIndexDynamicSqlSupport.wordCount,BookIndexDynamicSqlSupport.bookPrice, BookIndexDynamicSqlSupport.updateTime, BookIndexDynamicSqlSupport.isVip)
|
||||
.from(bookIndex)
|
||||
.where(BookIndexDynamicSqlSupport.id, isEqualTo(bookIndexId))
|
||||
.build()
|
||||
@ -488,7 +495,7 @@ public class BookServiceImpl implements BookService {
|
||||
|
||||
PageHelper.startPage(page, pageSize);
|
||||
|
||||
SelectStatementProvider selectStatement = select(id, bookName, visitCount, yesterdayBuy,lastIndexName, status)
|
||||
SelectStatementProvider selectStatement = select(id, bookName, picUrl, catName, visitCount, yesterdayBuy, lastIndexUpdateTime, updateTime, wordCount, lastIndexName, status)
|
||||
.from(book)
|
||||
.where(authorId, isEqualTo(authorService.queryAuthor(userId).getId()))
|
||||
.orderBy(BookDynamicSqlSupport.createTime.descending())
|
||||
@ -538,13 +545,9 @@ public class BookServiceImpl implements BookService {
|
||||
//并不是更新自己的小说
|
||||
return;
|
||||
}
|
||||
if(book.getStatus() != 1){
|
||||
//小说未上架,不能设置VIP
|
||||
isVip = 0;
|
||||
}
|
||||
Long lastIndexId = new IdWorker().nextId();
|
||||
Date currentDate = new Date();
|
||||
int wordCount = content.length();
|
||||
int wordCount = StringUtil.getStrValidWordCount(content);
|
||||
|
||||
//更新小说主表信息
|
||||
bookMapper.update(update(BookDynamicSqlSupport.book)
|
||||
@ -560,6 +563,10 @@ public class BookServiceImpl implements BookService {
|
||||
.and(BookDynamicSqlSupport.authorId, isEqualTo(authorId))
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3));
|
||||
|
||||
//计算价格
|
||||
int bookPrice = new BigDecimal(wordCount).divide(bookPriceConfig.getWordCount()).multiply(bookPriceConfig.getValue()).intValue();
|
||||
|
||||
//更新小说目录表
|
||||
int indexNum = 0;
|
||||
if (book.getLastIndexId() != null) {
|
||||
@ -572,6 +579,7 @@ public class BookServiceImpl implements BookService {
|
||||
lastBookIndex.setIndexNum(indexNum);
|
||||
lastBookIndex.setBookId(bookId);
|
||||
lastBookIndex.setIsVip(isVip);
|
||||
lastBookIndex.setBookPrice(bookPrice);
|
||||
lastBookIndex.setCreateTime(currentDate);
|
||||
lastBookIndex.setUpdateTime(currentDate);
|
||||
bookIndexMapper.insertSelective(lastBookIndex);
|
||||
@ -608,5 +616,217 @@ public class BookServiceImpl implements BookService {
|
||||
.render(RenderingStrategies.MYBATIS3));
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void deleteIndex(Long indexId, Long authorId) {
|
||||
|
||||
//查询小说章节表信息
|
||||
List<BookIndex> bookIndices = bookIndexMapper.selectMany(
|
||||
select(BookIndexDynamicSqlSupport.bookId, BookIndexDynamicSqlSupport.wordCount)
|
||||
.from(bookIndex)
|
||||
.where(BookIndexDynamicSqlSupport.id, isEqualTo(indexId)).build().render(RenderingStrategy.MYBATIS3));
|
||||
if (bookIndices.size() > 0) {
|
||||
BookIndex bookIndex = bookIndices.get(0);
|
||||
//获取小说ID
|
||||
Long bookId = bookIndex.getBookId();
|
||||
//查询小说表信息
|
||||
List<Book> books = bookMapper.selectMany(
|
||||
select(wordCount, BookDynamicSqlSupport.authorId)
|
||||
.from(book)
|
||||
.where(id, isEqualTo(bookId))
|
||||
.build()
|
||||
.render(RenderingStrategy.MYBATIS3));
|
||||
if (books.size() > 0) {
|
||||
Book book = books.get(0);
|
||||
int wordCount = book.getWordCount();
|
||||
//作者ID相同,表明该小说是登录用户发布,可以删除
|
||||
if (book.getAuthorId().equals(authorId)) {
|
||||
//删除目录表和内容表记录
|
||||
bookIndexMapper.deleteByPrimaryKey(indexId);
|
||||
bookContentMapper.delete(deleteFrom(bookContent).where(BookContentDynamicSqlSupport.indexId, isEqualTo(indexId)).build()
|
||||
.render(RenderingStrategies.MYBATIS3));
|
||||
//更新总字数
|
||||
wordCount = wordCount - bookIndex.getWordCount();
|
||||
//更新最新章节
|
||||
Long lastIndexId = null;
|
||||
String lastIndexName = null;
|
||||
Date lastIndexUpdateTime = null;
|
||||
List<BookIndex> lastBookIndices = bookIndexMapper.selectMany(
|
||||
select(BookIndexDynamicSqlSupport.id, BookIndexDynamicSqlSupport.indexName, BookIndexDynamicSqlSupport.createTime)
|
||||
.from(BookIndexDynamicSqlSupport.bookIndex)
|
||||
.where(BookIndexDynamicSqlSupport.bookId, isEqualTo(bookId))
|
||||
.orderBy(BookIndexDynamicSqlSupport.indexNum.descending())
|
||||
.limit(1)
|
||||
.build()
|
||||
.render(RenderingStrategy.MYBATIS3));
|
||||
if (lastBookIndices.size() > 0) {
|
||||
BookIndex lastBookIndex = lastBookIndices.get(0);
|
||||
lastIndexId = lastBookIndex.getId();
|
||||
lastIndexName = lastBookIndex.getIndexName();
|
||||
lastIndexUpdateTime = lastBookIndex.getCreateTime();
|
||||
|
||||
}
|
||||
//更新小说主表信息
|
||||
bookMapper.update(update(BookDynamicSqlSupport.book)
|
||||
.set(BookDynamicSqlSupport.wordCount)
|
||||
.equalTo(wordCount)
|
||||
.set(updateTime)
|
||||
.equalTo(new Date())
|
||||
.set(BookDynamicSqlSupport.lastIndexId)
|
||||
.equalTo(lastIndexId)
|
||||
.set(BookDynamicSqlSupport.lastIndexName)
|
||||
.equalTo(lastIndexName)
|
||||
.set(BookDynamicSqlSupport.lastIndexUpdateTime)
|
||||
.equalTo(lastIndexUpdateTime)
|
||||
.where(id, isEqualTo(bookId))
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateIndexName(Long indexId, String indexName, Long authorId) {
|
||||
//查询小说章节表信息
|
||||
List<BookIndex> bookIndices = bookIndexMapper.selectMany(
|
||||
select(BookIndexDynamicSqlSupport.bookId, BookIndexDynamicSqlSupport.wordCount)
|
||||
.from(bookIndex)
|
||||
.where(BookIndexDynamicSqlSupport.id, isEqualTo(indexId)).build().render(RenderingStrategy.MYBATIS3));
|
||||
if (bookIndices.size() > 0) {
|
||||
BookIndex bookIndex = bookIndices.get(0);
|
||||
//获取小说ID
|
||||
Long bookId = bookIndex.getBookId();
|
||||
//查询小说表信息
|
||||
List<Book> books = bookMapper.selectMany(
|
||||
select(wordCount, BookDynamicSqlSupport.authorId)
|
||||
.from(book)
|
||||
.where(id, isEqualTo(bookId))
|
||||
.build()
|
||||
.render(RenderingStrategy.MYBATIS3));
|
||||
if (books.size() > 0) {
|
||||
Book book = books.get(0);
|
||||
//作者ID相同,表明该小说是登录用户发布,可以修改
|
||||
if (book.getAuthorId().equals(authorId)) {
|
||||
|
||||
bookIndexMapper.update(
|
||||
update(BookIndexDynamicSqlSupport.bookIndex)
|
||||
.set(BookIndexDynamicSqlSupport.indexName)
|
||||
.equalTo(indexName)
|
||||
.set(BookIndexDynamicSqlSupport.updateTime)
|
||||
.equalTo(new Date())
|
||||
.where(BookIndexDynamicSqlSupport.id, isEqualTo(indexId))
|
||||
.build()
|
||||
.render(RenderingStrategy.MYBATIS3));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String queryIndexContent(Long indexId, Long authorId) {
|
||||
//查询小说章节表信息
|
||||
List<BookIndex> bookIndices = bookIndexMapper.selectMany(
|
||||
select(BookIndexDynamicSqlSupport.bookId, BookIndexDynamicSqlSupport.wordCount)
|
||||
.from(bookIndex)
|
||||
.where(BookIndexDynamicSqlSupport.id, isEqualTo(indexId)).build().render(RenderingStrategy.MYBATIS3));
|
||||
if (bookIndices.size() > 0) {
|
||||
BookIndex bookIndex = bookIndices.get(0);
|
||||
//获取小说ID
|
||||
Long bookId = bookIndex.getBookId();
|
||||
//查询小说表信息
|
||||
List<Book> books = bookMapper.selectMany(
|
||||
select(wordCount, BookDynamicSqlSupport.authorId)
|
||||
.from(book)
|
||||
.where(id, isEqualTo(bookId))
|
||||
.build()
|
||||
.render(RenderingStrategy.MYBATIS3));
|
||||
if (books.size() > 0) {
|
||||
Book book = books.get(0);
|
||||
//作者ID相同,表明该小说是登录用户发布
|
||||
if (book.getAuthorId().equals(authorId)) {
|
||||
return bookContentMapper.selectMany(
|
||||
select(content)
|
||||
.from(bookContent)
|
||||
.where(BookContentDynamicSqlSupport.indexId, isEqualTo(indexId))
|
||||
.limit(1)
|
||||
.build().render(RenderingStrategy.MYBATIS3))
|
||||
.get(0).getContent();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void updateBookContent(Long indexId, String indexName, String content, Long authorId) {
|
||||
|
||||
//查询小说章节表信息
|
||||
List<BookIndex> bookIndices = bookIndexMapper.selectMany(
|
||||
select(BookIndexDynamicSqlSupport.bookId, BookIndexDynamicSqlSupport.wordCount)
|
||||
.from(bookIndex)
|
||||
.where(BookIndexDynamicSqlSupport.id, isEqualTo(indexId)).build().render(RenderingStrategy.MYBATIS3));
|
||||
if (bookIndices.size() > 0) {
|
||||
BookIndex bookIndex = bookIndices.get(0);
|
||||
//获取小说ID
|
||||
Long bookId = bookIndex.getBookId();
|
||||
//查询小说表信息
|
||||
List<Book> books = bookMapper.selectMany(
|
||||
select(wordCount, BookDynamicSqlSupport.authorId)
|
||||
.from(book)
|
||||
.where(id, isEqualTo(bookId))
|
||||
.build()
|
||||
.render(RenderingStrategy.MYBATIS3));
|
||||
if (books.size() > 0) {
|
||||
Book book = books.get(0);
|
||||
//作者ID相同,表明该小说是登录用户发布,可以修改
|
||||
if (book.getAuthorId().equals(authorId)) {
|
||||
Date currentDate = new Date();
|
||||
int wordCount = StringUtil.getStrValidWordCount(content);
|
||||
|
||||
//计算价格
|
||||
int bookPrice = new BigDecimal(wordCount).divide(bookPriceConfig.getWordCount()).multiply(bookPriceConfig.getValue()).intValue();
|
||||
|
||||
|
||||
//更新小说目录表
|
||||
int update = bookIndexMapper.update(
|
||||
update(BookIndexDynamicSqlSupport.bookIndex)
|
||||
.set(BookIndexDynamicSqlSupport.indexName)
|
||||
.equalTo(indexName)
|
||||
.set(BookIndexDynamicSqlSupport.wordCount)
|
||||
.equalTo(wordCount)
|
||||
.set(BookIndexDynamicSqlSupport.bookPrice)
|
||||
.equalTo(bookPrice)
|
||||
.set(BookIndexDynamicSqlSupport.updateTime)
|
||||
.equalTo(currentDate)
|
||||
.where(BookIndexDynamicSqlSupport.id, isEqualTo(indexId))
|
||||
.build().render(RenderingStrategy.MYBATIS3));
|
||||
|
||||
//更新小说内容表
|
||||
bookContentMapper.update(
|
||||
update(BookContentDynamicSqlSupport.bookContent)
|
||||
.set(BookContentDynamicSqlSupport.content)
|
||||
.equalTo(content)
|
||||
.where(BookContentDynamicSqlSupport.indexId, isEqualTo(indexId))
|
||||
.build().render(RenderingStrategy.MYBATIS3));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -284,20 +284,19 @@ public class UserServiceImpl implements UserService {
|
||||
public void buyBookIndex(Long userId, UserBuyRecord buyRecord) {
|
||||
//查询用户余额
|
||||
long balance = userInfo(userId).getAccountBalance();
|
||||
if(balance<10){
|
||||
if(balance<buyRecord.getBuyAmount()){
|
||||
//余额不足
|
||||
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)
|
||||
.equalTo(balance-buyRecord.getBuyAmount())
|
||||
.where(id,isEqualTo(userId))
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3));
|
||||
|
@ -57,3 +57,11 @@ author:
|
||||
share-proportion: 0.7
|
||||
#兑换比率(人民币)
|
||||
exchange-proportion: 0.01
|
||||
|
||||
#小说章节定价规则
|
||||
book:
|
||||
price:
|
||||
#字数
|
||||
word-count: 1000
|
||||
#价值(屋币)
|
||||
value: 5
|
@ -238,17 +238,17 @@
|
||||
if (preId > 0) {
|
||||
location.href = '/book/' + bid + '/' + preId + '.html';
|
||||
} else {
|
||||
location.href = '/book/chapterlist-' + bid + '.html';
|
||||
location.href = '/book/indexList-' + bid + '.html';
|
||||
}
|
||||
} else if (e.keyCode == 39) {
|
||||
if (nextId > 0) {
|
||||
location.href = '/book/' + bid + '/' + nextId + '.html';
|
||||
} else {
|
||||
location.href = '/book/chapterlist-' + bid + '.html';
|
||||
location.href = '/book/indexList-' + bid + '.html';
|
||||
}
|
||||
}
|
||||
});
|
||||
BookDetail.SetReadHistory(bid, cid, crank);
|
||||
//BookDetail.SetReadHistory(bid, cid, crank);
|
||||
},
|
||||
SetReadHistory: function (bid, cid, crank) {
|
||||
var strHistory = jQuery.cookie("wapviewhistory");
|
||||
|
16
novel-front/src/main/resources/static/javascript/date.js
Normal file
16
novel-front/src/main/resources/static/javascript/date.js
Normal file
@ -0,0 +1,16 @@
|
||||
//格式化时间函数
|
||||
Date.prototype.Format = function (fmt) {
|
||||
var o = {
|
||||
"M+": this.getMonth() + 1, //月份
|
||||
"d+": this.getDate(), //日
|
||||
"h+": this.getHours(), //小时
|
||||
"m+": this.getMinutes(), //分
|
||||
"s+": this.getSeconds(), //秒
|
||||
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
|
||||
"S": this.getMilliseconds() //毫秒
|
||||
};
|
||||
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
|
||||
for (var k in o)
|
||||
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
|
||||
return fmt;
|
||||
};
|
@ -109,16 +109,24 @@
|
||||
<script src="/layui/layui.all.js" type="text/javascript"></script>
|
||||
<script src="/javascript/header.js" type="text/javascript"></script>
|
||||
<script src="/javascript/user.js" type="text/javascript"></script>
|
||||
<script src="/javascript/common.js" type="text/javascript"></script>
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
var bookId = getSearchString("bookId");
|
||||
search(1, 10);
|
||||
|
||||
function search(curr, limit) {
|
||||
|
||||
var data = {'curr':curr,'limit':limit};
|
||||
|
||||
if(bookId){
|
||||
data.bookId = bookId;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/author/listIncomeDailyByPage",
|
||||
data: {'curr':curr,'limit':limit},
|
||||
data: data,
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.code == 200) {
|
||||
|
@ -60,7 +60,11 @@
|
||||
<li><input type="text" id="bookIndex" name="bookIndex" class="s_input" ></li>
|
||||
<b>章节内容:</b><li id="contentLi">
|
||||
<textarea name="bookContent" rows="30" cols="80" id="bookContent"
|
||||
class="textarea"></textarea></li>
|
||||
class="textarea"></textarea></li><br/>
|
||||
|
||||
<b>是否收费:</b>
|
||||
<li><input type="radio" name="isVip" value="0" checked >免费
|
||||
<input type="radio" name="isVip" value="1" >收费</li>
|
||||
|
||||
|
||||
<li style="margin-top: 10px"><input type="button" onclick="addBookContent()" name="btnRegister" value="提交"
|
||||
@ -118,13 +122,6 @@
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
|
||||
var bookStatus = getSearchString("bookStatus");
|
||||
if(bookStatus == 1){
|
||||
$("#contentLi").after("<b>是否收费:</b>\n" +
|
||||
" <li><input type=\"radio\" name=\"isVip\" value=\"0\" checked >免费\n" +
|
||||
" <input type=\"radio\" name=\"isVip\" value=\"1\" >收费</li><br/>");
|
||||
}
|
||||
|
||||
|
||||
var lock = false;
|
||||
function addBookContent() {
|
||||
@ -153,11 +150,7 @@
|
||||
}
|
||||
|
||||
|
||||
var isVip = 0;
|
||||
if(bookStatus == 1){
|
||||
|
||||
isVip = $("input:checked[name=isVip]").val();
|
||||
}
|
||||
var isVip = $("input:checked[name=isVip]").val();
|
||||
|
||||
|
||||
|
||||
@ -170,7 +163,7 @@
|
||||
success: function (data) {
|
||||
if (data.code == 200) {
|
||||
|
||||
window.location.href = '/author/index.html';
|
||||
window.location.href = '/author/index_list.html?bookId='+bookId;
|
||||
|
||||
|
||||
} else {
|
||||
|
@ -0,0 +1,220 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
|
||||
<title>作家管理系统-小说精品屋</title>
|
||||
<link rel="stylesheet" href="/css/base.css?v=1"/>
|
||||
<link rel="stylesheet" href="/css/user.css"/>
|
||||
</head>
|
||||
</head>
|
||||
<body class="">
|
||||
|
||||
<div class="header">
|
||||
<div class="mainNav" id="mainNav">
|
||||
<div class="box_center cf"
|
||||
style="text-align: center;height: 44px;line-height: 48px;color: #fff;font-size: 16px;">
|
||||
|
||||
小说精品屋作家管理
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="main box_center cf">
|
||||
<div class="userBox cf">
|
||||
<div class="my_l">
|
||||
|
||||
<ul class="log_list">
|
||||
<li><a class="link_4 on" href="/author/index.html">作品管理</a></li>
|
||||
<li><a class="link_2 " href="/author/author_income_detail.html">稿费收入</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="my_r">
|
||||
<div class="my_bookshelf">
|
||||
|
||||
<div class="userBox cf">
|
||||
<form method="post" action="./register.html" id="form2">
|
||||
<div class="aspNetHidden">
|
||||
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
|
||||
value="/wEPDwUKLTIzNjMxNDQxNw9kFgJmD2QWAmYPFgIeBFRleHQFqAE8YSBocmVmPSIvc2VhcmNoLmFzcHg/c2VhcmNoS2V5PeWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqyIgdGFyZ2V0PSJfYmxhbmsiPuWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqzwvYT5kZOquoASBvnvPbc/TYIQiLhSPJ8GKnYQrmk7jGhb5AC5Q">
|
||||
</div>
|
||||
|
||||
<div class="aspNetHidden">
|
||||
|
||||
<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="23AA6834">
|
||||
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION"
|
||||
value="/wEdAAVece19BIZ9HiByRfHz3pfnqKSXUE1UN51mNFrIuw38c3Y2+Mc6SrnAqio3oCKbxYZZ1lS+gZUZKpbsAea8j7ASAv40DHFcQ/NE7tJUnABeyQ3d9sFDIcFCYNqlVtprfLoh4JFy0U+R/CcMuyAiWTz7">
|
||||
</div>
|
||||
<div class="user_l">
|
||||
<div></div>
|
||||
<h3>小说章节内容填写</h3>
|
||||
<ul class="log_list">
|
||||
<li><span id="LabErr"></span></li>
|
||||
<b>章节名:</b>
|
||||
<li><input type="text" id="bookIndex" name="bookIndex" class="s_input" ></li>
|
||||
<b>章节内容:</b>
|
||||
<li id="contentLi">
|
||||
<textarea name="bookContent" rows="30" cols="80" id="bookContent"
|
||||
class="textarea"></textarea>
|
||||
</li>
|
||||
<li style="margin-top: 10px"><input type="button" onclick="addBookContent()" name="btnRegister" value="提交"
|
||||
id="btnRegister" class="btn_red">
|
||||
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<!--<div id="divData" class="updateTable">
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th class="name">
|
||||
爬虫源(已开启的爬虫源)
|
||||
</th>
|
||||
<th class="chapter">
|
||||
成功爬取数量(websocket实现)
|
||||
</th>
|
||||
<th class="time">
|
||||
目标爬取数量
|
||||
</th>
|
||||
<th class="goread">
|
||||
状态(正在运行,已停止)(一次只能运行一个爬虫源)
|
||||
</th>
|
||||
<th class="goread">
|
||||
操作(启动,停止)
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="bookShelfList">
|
||||
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="pageBox cf" id="shellPage">
|
||||
</div>
|
||||
</div>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
<script src="/javascript/jquery-1.8.0.min.js" type="text/javascript"></script>
|
||||
<script src="/layui/layui.all.js" type="text/javascript"></script>
|
||||
<script src="/javascript/header.js" type="text/javascript"></script>
|
||||
<script src="/javascript/user.js" type="text/javascript"></script>
|
||||
<script src="/javascript/common.js" type="text/javascript"></script>
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
|
||||
var bookId = getSearchString("bookId");
|
||||
var indexId = getSearchString("indexId");
|
||||
var indexName = decodeURI(decodeURI(getSearchString("indexName")));
|
||||
var isVip = getSearchString("isVip");
|
||||
|
||||
$("#bookIndex").val(indexName);
|
||||
if(isVip == 1){
|
||||
$("#contentLi").after("<b>是否收费:</b>\n" +
|
||||
" <li><input type=\"radio\" disabled name=\"isVip\" value=\"0\" >免费\n" +
|
||||
" <input type=\"radio\" disabled name=\"isVip\" value=\"1\" checked >收费</li><br/>");
|
||||
}else{
|
||||
$("#contentLi").after("<b>是否收费:</b>\n" +
|
||||
" <li><input type=\"radio\" disabled name=\"isVip\" value=\"0\" checked >免费\n" +
|
||||
" <input type=\"radio\" disabled name=\"isVip\" value=\"1\" >收费</li><br/>");
|
||||
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/author/queryIndexContent",
|
||||
data: {'indexId':indexId},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.code == 200) {
|
||||
|
||||
$("#bookContent").html(data.data);
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
layer.alert(data.msg);
|
||||
}
|
||||
|
||||
},
|
||||
error: function () {
|
||||
lock = false;
|
||||
layer.alert('网络异常');
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var lock = false;
|
||||
function addBookContent() {
|
||||
|
||||
if(lock){
|
||||
return;
|
||||
}
|
||||
lock = true;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var indexName = $("#bookIndex").val();
|
||||
if(!indexName){
|
||||
$("#LabErr").html("章节名不能为空!");
|
||||
lock = false;
|
||||
return;
|
||||
}
|
||||
|
||||
var content = $("#bookContent").val();
|
||||
if(!content){
|
||||
$("#LabErr").html("章节内容不能为空!");
|
||||
lock = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/author/updateBookContent",
|
||||
data: {'indexId':indexId,'indexName':indexName,'content':content},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.code == 200) {
|
||||
|
||||
window.location.href = '/author/index_list.html?bookId='+bookId;
|
||||
|
||||
|
||||
} else {
|
||||
lock = false;
|
||||
$("#LabErr").html(data.msg);
|
||||
}
|
||||
|
||||
},
|
||||
error: function () {
|
||||
lock = false;
|
||||
layer.alert('网络异常');
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
</html>
|
@ -8,6 +8,19 @@
|
||||
<title>作家管理系统-小说精品屋</title>
|
||||
<link rel="stylesheet" href="/css/base.css?v=1"/>
|
||||
<link rel="stylesheet" href="/css/user.css" />
|
||||
<style type="text/css">
|
||||
.redBtn{
|
||||
padding: 5px;
|
||||
border-radius: 20px;
|
||||
border: 1px solid #f80;
|
||||
background: #f80;
|
||||
color: #fff;
|
||||
}
|
||||
a.redBtn:hover{
|
||||
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
</head>
|
||||
<body class="">
|
||||
@ -35,7 +48,11 @@
|
||||
|
||||
</div>
|
||||
<div class="my_r">
|
||||
<div class="my_bookshelf">
|
||||
<div id="noContentDiv" >
|
||||
<div class="tc" style="margin-top: 200px"><a href="/author/book_add.html" class="btn_red">创建作品</a></div>
|
||||
|
||||
</div>
|
||||
<div class="my_bookshelf" id="hasContentDiv" style="display: none">
|
||||
<div class="title cf">
|
||||
<h2 class="fl">小说列表</h2>
|
||||
<div class="fr"><a href="/author/book_add.html" class="btn_red">发布小说</a></div>
|
||||
@ -45,23 +62,23 @@
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="style">
|
||||
序号
|
||||
<th class="goread">
|
||||
书名
|
||||
</th>
|
||||
<th class="name">
|
||||
小说名
|
||||
<th class="goread">
|
||||
分类
|
||||
</th>
|
||||
<th class="goread">
|
||||
点击量
|
||||
</th>
|
||||
<th class="goread">
|
||||
昨日订阅量
|
||||
</th>
|
||||
<th class="name">
|
||||
最新章节
|
||||
昨日订阅数
|
||||
</th>
|
||||
<th class="goread">
|
||||
状态
|
||||
更新时间
|
||||
</th>
|
||||
<th class="goread">
|
||||
总字数
|
||||
</th>
|
||||
<th class="goread">
|
||||
操作
|
||||
@ -119,6 +136,7 @@
|
||||
<script src="/layui/layui.all.js" type="text/javascript"></script>
|
||||
<script src="/javascript/header.js" type="text/javascript"></script>
|
||||
<script src="/javascript/user.js" type="text/javascript"></script>
|
||||
<script src="/javascript/date.js" type="text/javascript"></script>
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
search(1, 5);
|
||||
@ -134,28 +152,41 @@
|
||||
if (data.code == 200) {
|
||||
var bookList = data.data.list;
|
||||
if (bookList.length > 0) {
|
||||
$("#hasContentDiv").css("display","block");
|
||||
$("#noContentDiv").css("display","none");
|
||||
var bookListHtml = "";
|
||||
for(var i=0;i<bookList.length;i++){
|
||||
var book = bookList[i];
|
||||
bookListHtml+=(" <tr class=\"book_list\" vals=\"291\">\n" +
|
||||
" <td class=\"style bookclass\">\n" +
|
||||
" ["+(i+1)+"]\n" +
|
||||
" </td>\n" +
|
||||
" <td class=\"name\">\n" +
|
||||
/* " <td class=\"style bookclass\">\n" +
|
||||
" ["+(i+1)+"]\n" +
|
||||
" </td>\n" +*/
|
||||
|
||||
" <td class=\"goread\">\n" +
|
||||
"<img width='50' height='70' src='"+book.picUrl+"'/><br/>" +
|
||||
" "+book.bookName+"</td>\n" +
|
||||
|
||||
|
||||
" <td class=\"goread\" >"
|
||||
+book.catName+"</td>\n" +
|
||||
|
||||
" <td class=\"goread\" valsc=\"291|2037554|1\">"
|
||||
+book.visitCount+"</td>\n" +
|
||||
|
||||
" <td class=\"goread\" valsc=\"291|2037554|1\">"
|
||||
+book.yesterdayBuy+"</td>\n" +
|
||||
" <td class=\"name\">\n" +
|
||||
" "+book.lastIndexName+"\n" +
|
||||
" </td>\n" +
|
||||
" <td class=\"goread\" id='bookStatus"+book.id+"'>"+(book.status==0?'免费':'上架')+
|
||||
|
||||
" <td class=\"goread\">\n" +
|
||||
" "+new Date(Date.parse(book.lastIndexUpdateTime?book.lastIndexUpdateTime:book.updateTime)).Format("yyyy-MM-dd hh:mm")+"更新\n" +
|
||||
" </td>\n" +
|
||||
|
||||
" <td class=\"goread\" valsc=\"291|2037554|1\">"
|
||||
+book.wordCount+"</td>\n" +
|
||||
|
||||
" <td class=\"goread\" id='opt"+book.id+"'>" +
|
||||
"<a href='javascript:updateBookStatus(\""+book.id+"\","+book.status+")'>"+(book.status==0?'上架':'下架')+" </a><br/>" +
|
||||
"<a href='/author/content_add.html?bookStatus="+book.status+"&bookId="+book.id+"'>发布章节 </a>" +
|
||||
"<a target='_blank' class='redBtn' href='/author/index_list.html?bookId="+book.id+"'>章节管理 </a><br/>" +
|
||||
"<a target='_blank' href='/author/author_income_detail.html?bookId="+book.id+"'>薪酬查询 </a><br/>"+
|
||||
"<a target='_blank' href='/book/"+book.id+".html'>作品信息</a>"+
|
||||
"</td> </tr>");
|
||||
}
|
||||
$("#bookList").html(bookListHtml);
|
||||
|
330
novel-front/src/main/resources/templates/author/index_list.html
Normal file
330
novel-front/src/main/resources/templates/author/index_list.html
Normal file
@ -0,0 +1,330 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
|
||||
<title>作家管理系统-小说精品屋</title>
|
||||
<link rel="stylesheet" href="/css/base.css?v=1"/>
|
||||
<link rel="stylesheet" href="/css/user.css"/>
|
||||
<style type="text/css">
|
||||
.redBtn {
|
||||
padding: 5px;
|
||||
border-radius: 20px;
|
||||
border: 1px solid #f80;
|
||||
background: #f80;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
a.redBtn:hover {
|
||||
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
</head>
|
||||
<body class="">
|
||||
|
||||
<div class="header">
|
||||
<div class="mainNav" id="mainNav">
|
||||
<div class="box_center cf"
|
||||
style="text-align: center;height: 44px;line-height: 48px;color: #fff;font-size: 16px;">
|
||||
|
||||
小说精品屋作家管理
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="main box_center cf">
|
||||
<div class="userBox cf">
|
||||
<div class="my_l">
|
||||
|
||||
<ul class="log_list">
|
||||
<li><a class="link_4 on" href="/author/index.html">作品管理</a></li>
|
||||
<li><a class="link_2 " href="/author/author_income_detail.html">稿费收入</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="my_r">
|
||||
<div id="noContentDiv">
|
||||
<div class="tc" style="margin-top: 200px"><a href="javascript:addContent()" class="btn_red">新建章节</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="my_bookshelf" id="hasContentDiv" style="display: none">
|
||||
<div class="title cf">
|
||||
<h2 class="fl">章节列表</h2>
|
||||
<div class="fr"><a href="javascript:addContent()" class="btn_red">新建章节</a></div>
|
||||
</div>
|
||||
|
||||
<div id="divData" class="updateTable">
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<!-- <th class="style">
|
||||
序号
|
||||
</th>-->
|
||||
<th class="name">
|
||||
章节名
|
||||
</th>
|
||||
<th class="goread">
|
||||
更新时间
|
||||
</th>
|
||||
<th class="goread">
|
||||
是否收费
|
||||
</th>
|
||||
<th class="goread">
|
||||
操作
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="bookList">
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="pageBox cf" id="shellPage">
|
||||
</div>
|
||||
</div>
|
||||
<!--<div id="divData" class="updateTable">
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th class="name">
|
||||
爬虫源(已开启的爬虫源)
|
||||
</th>
|
||||
<th class="chapter">
|
||||
成功爬取数量(websocket实现)
|
||||
</th>
|
||||
<th class="time">
|
||||
目标爬取数量
|
||||
</th>
|
||||
<th class="goread">
|
||||
状态(正在运行,已停止)(一次只能运行一个爬虫源)
|
||||
</th>
|
||||
<th class="goread">
|
||||
操作(启动,停止)
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="bookShelfList">
|
||||
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="pageBox cf" id="shellPage">
|
||||
</div>
|
||||
</div>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
<script src="/javascript/jquery-1.8.0.min.js" type="text/javascript"></script>
|
||||
<script src="/layui/layui.all.js" type="text/javascript"></script>
|
||||
<script src="/javascript/header.js" type="text/javascript"></script>
|
||||
<script src="/javascript/user.js" type="text/javascript"></script>
|
||||
<script src="/javascript/date.js" type="text/javascript"></script>
|
||||
<script src="/javascript/common.js" type="text/javascript"></script>
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
|
||||
var bookId = getSearchString("bookId");
|
||||
|
||||
var indexCount = 0;
|
||||
|
||||
search(1, 5);
|
||||
|
||||
function search(curr, limit) {
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/book/queryIndexList",
|
||||
data: {'bookId': bookId, 'curr': curr, 'limit': limit, 'orderBy': 'index_num desc'},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.code == 200) {
|
||||
var bookList = data.data.list;
|
||||
if (bookList.length > 0) {
|
||||
indexCount = bookList.length;
|
||||
$("#hasContentDiv").css("display", "block");
|
||||
$("#noContentDiv").css("display", "none");
|
||||
var bookListHtml = "";
|
||||
for (var i = 0; i < bookList.length; i++) {
|
||||
var book = bookList[i];
|
||||
bookListHtml += (" <tr class=\"book_list\" vals=\"291\">\n" +
|
||||
/* " <td class=\"style bookclass\">\n" +
|
||||
" ["+(i+1)+"]\n" +
|
||||
" </td>\n" +*/
|
||||
|
||||
" <td id='name" + book.id + "' class=\"name\">\n" +
|
||||
" " + book.indexName + "</td>\n" +
|
||||
|
||||
|
||||
" <td class=\"goread\">\n" +
|
||||
" " + new Date(Date.parse(book.updateTime)).Format("yyyy-MM-dd hh:mm") + "<br/>更新\n" +
|
||||
" </td>\n" +
|
||||
|
||||
" <td class=\"goread\" valsc=\"291|2037554|1\">"
|
||||
+ (book.isVip == 1 ? '收费' : '免费') + "</td>\n" +
|
||||
|
||||
" <td class=\"goread\" id='opt" + book.id + "'>" +
|
||||
"<a class='redBtn' href='javascript:updateIndex(\"" + book.id + "\"," + book.isVip + ")'>修改 </a><br/>" +
|
||||
"<a href='javascript:deleteIndex(\"" + book.id + "\")'>删除 </a><br/>" +
|
||||
"</td> </tr>");
|
||||
}
|
||||
$("#bookList").html(bookListHtml);
|
||||
|
||||
layui.use('laypage', function () {
|
||||
var laypage = layui.laypage;
|
||||
|
||||
//执行一个laypage实例
|
||||
laypage.render({
|
||||
elem: 'shellPage' //注意,这里的 test1 是 ID,不用加 # 号
|
||||
, count: data.data.total //数据总数,从服务端得到,
|
||||
, curr: data.data.pageNum
|
||||
, limit: data.data.pageSize
|
||||
, jump: function (obj, first) {
|
||||
|
||||
|
||||
//obj包含了当前分页的所有参数,比如:
|
||||
console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。
|
||||
console.log(obj.limit); //得到每页显示的条数
|
||||
|
||||
|
||||
//首次不执行
|
||||
if (!first) {
|
||||
search(obj.curr, obj.limit);
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else if (data.code == 1001) {
|
||||
//未登录
|
||||
location.href = '/user/login.html?originUrl=' + decodeURIComponent(location.href);
|
||||
|
||||
} else {
|
||||
layer.alert(data.msg);
|
||||
}
|
||||
|
||||
},
|
||||
error: function () {
|
||||
layer.alert('网络异常');
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
function addContent() {
|
||||
location.href = "/author/content_add.html?indexCount=" + indexCount + "&bookId=" + bookId;
|
||||
|
||||
}
|
||||
|
||||
function updateIndex(indexId, isVip) {
|
||||
|
||||
var indexName = $.trim($("#name" + indexId).text());
|
||||
|
||||
|
||||
location.href = "/author/content_update.html?bookId=" + bookId
|
||||
+ "&indexId=" + indexId
|
||||
+ "&indexName=" + encodeURI(encodeURI(indexName))
|
||||
+ "&isVip=" + isVip;
|
||||
|
||||
|
||||
/*
|
||||
var indexName = $("#name"+indexId).text();
|
||||
|
||||
var htmlStr = "<input type=\"text\" value=\""+$.trim(indexName)+"\">";
|
||||
|
||||
$("#name"+indexId).html(htmlStr);
|
||||
$("#name"+indexId).find("input").focus();
|
||||
$("#name"+indexId).find("input").select();
|
||||
|
||||
$("#name"+indexId).find("input").keyup(function(event){
|
||||
if(event.keyCode ==13){
|
||||
$(this).blur();
|
||||
}
|
||||
});
|
||||
|
||||
$("#name"+indexId).find("input").blur(function () {
|
||||
var indexName = $(this).val();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/author/updateIndexName",
|
||||
data: {'indexId':indexId,'indexName':indexName},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.code == 200) {
|
||||
|
||||
$("#name"+indexId).html(indexName);
|
||||
|
||||
|
||||
} else if (data.code == 1001) {
|
||||
//未登录
|
||||
location.href = '/user/login.html?originUrl=' + decodeURIComponent(location.href);
|
||||
|
||||
}else {
|
||||
layer.alert(data.msg);
|
||||
}
|
||||
|
||||
},
|
||||
error: function () {
|
||||
layer.alert('网络异常');
|
||||
}
|
||||
})
|
||||
|
||||
});*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function deleteIndex(indexId) {
|
||||
|
||||
layer.confirm('确认要删除吗?删除后数据无法找回!', {
|
||||
btn: ['确定', '取消']//按钮
|
||||
}, function (index) {
|
||||
|
||||
layer.close(index);
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/author/deleteIndex",
|
||||
data: {'indexId': indexId},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.code == 200) {
|
||||
|
||||
location.reload();
|
||||
|
||||
|
||||
} else if (data.code == 1001) {
|
||||
//未登录
|
||||
location.href = '/user/login.html?originUrl=' + decodeURIComponent(location.href);
|
||||
|
||||
} else {
|
||||
layer.alert(data.msg);
|
||||
}
|
||||
|
||||
},
|
||||
error: function () {
|
||||
layer.alert('网络异常');
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
</script>
|
||||
</html>
|
@ -40,6 +40,8 @@
|
||||
<input type="hidden" id="preIndexName" th:value="${bookIndex.indexName}"/>
|
||||
|
||||
<input type="hidden" id="preContentId" th:value="${bookIndex.id}"/>
|
||||
<input type="hidden" id="preIndexId" th:value="${preBookIndexId}"/>
|
||||
<input type="hidden" id="nextIndexId" th:value="${nextBookIndexId}"/>
|
||||
|
||||
<div th:replace="common/top :: top('10')">
|
||||
</div>
|
||||
@ -114,7 +116,7 @@
|
||||
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEdAAX4WEeZOhVYVmRzc9paH9JSy/08L4LdXX0bnEtd0tA2crFh4MPja1O/9L0Y0B5Q7Mkw2OnJlkYmOh3/iyqfPkkn99UiP/cCDJ38/2cPKg8P57VHEmkKJr8/tJbwExBtkfhGxxoA1kMIQUaw59BH5iPe">
|
||||
</div>
|
||||
<ul class="order_list">
|
||||
<li>价格:<span class="red">10屋币(1元=100屋币)</span></li>
|
||||
<li>价格:<span class="red" th:text="${bookIndex.bookPrice}+'屋币(1元=100屋币)'"></span></li>
|
||||
<li id="panelPay" class="btns"><a class="btn_red" href="javascript:buyBookIndex()" >购买</a></li>
|
||||
|
||||
</ul>
|
||||
@ -269,11 +271,12 @@
|
||||
})
|
||||
|
||||
|
||||
var currentBId =37, usfltotal = 0, spmymoney = 0;
|
||||
var bookId = $("#bookId").val();
|
||||
var indexId = $("#preContentId").val();
|
||||
var preIndexId = $("#preIndexId").val();
|
||||
var nextIndexId = $("#nextIndexId").val();
|
||||
$(function () {
|
||||
BookDetail.GetReadSet(37,1959973,0,1959974,1);
|
||||
BookDetail.ClickChapter(37,1959973,0);
|
||||
BookDetail.GetFavorites(37);
|
||||
BookDetail.GetReadSet(bookId,indexId,preIndexId,nextIndexId,1);
|
||||
$(".ico_setup").click(function () {
|
||||
|
||||
$(".maskBox,.setupBox").show();
|
||||
@ -318,7 +321,7 @@
|
||||
if(bookIndexId != 0){
|
||||
window.location.href = '/book/'+bookId+'/'+bookIndexId+".html";
|
||||
}else{
|
||||
layer.alert("已经是第一章了!");
|
||||
window.location.href = '/book/indexList-' + bookId + '.html';
|
||||
}
|
||||
|
||||
}
|
||||
@ -326,7 +329,7 @@
|
||||
if(bookIndexId != 0){
|
||||
window.location.href = '/book/'+bookId+'/'+bookIndexId+".html";
|
||||
}else{
|
||||
layer.alert("已经是最新章节了!");
|
||||
window.location.href = '/book/indexList-' + bookId + '.html';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,7 +45,7 @@
|
||||
<a class="icon_hide" href="javascript:void(0)" onclick=""><i></i>收起</a>
|
||||
<a class="icon_show" href="javascript:void(0)" onclick=""><i></i>展开</a>
|
||||
</div>
|
||||
<div class="btns">
|
||||
<div class="btns" id="optBtn">
|
||||
<a th:href="'/book/'+${book.id}+'/'+${firstBookIndexId}+'.html'" class="btn_ora">点击阅读</a>
|
||||
<span id="cFavs"><a href="javascript:void(0);" class="btn_ora_white btn_addsj"
|
||||
onclick="javascript:BookDetail.AddFavorites(37,0,0);">加入书架</a>
|
||||
@ -196,27 +196,32 @@
|
||||
var pathname = window.location.pathname;
|
||||
var bookId = pathname.substring(pathname.lastIndexOf("/") + 1, pathname.lastIndexOf("."))
|
||||
//查询章节信息
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/book/queryBookIndexAbout",
|
||||
data: {'bookId': bookId, 'lastBookIndexId': $("#lastBookIndexId").val()},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.code == 200) {
|
||||
var bookIndexData = data.data;
|
||||
$("#bookIndexCount").html("(" + bookIndexData.bookIndexCount + "章)");
|
||||
$("#lastBookContent").html(bookIndexData.lastBookContent + "...");
|
||||
var lastBookIndexId = $("#lastBookIndexId").val();
|
||||
if(lastBookIndexId){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/book/queryBookIndexAbout",
|
||||
data: {'bookId': bookId, 'lastBookIndexId': lastBookIndexId},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.code == 200) {
|
||||
var bookIndexData = data.data;
|
||||
$("#bookIndexCount").html("(" + bookIndexData.bookIndexCount + "章)");
|
||||
$("#lastBookContent").html(bookIndexData.lastBookContent + "...");
|
||||
|
||||
|
||||
} else {
|
||||
layer.alert(data.msg);
|
||||
} else {
|
||||
layer.alert(data.msg);
|
||||
}
|
||||
|
||||
},
|
||||
error: function () {
|
||||
layer.alert('网络异常');
|
||||
}
|
||||
|
||||
},
|
||||
error: function () {
|
||||
layer.alert('网络异常');
|
||||
}
|
||||
})
|
||||
})
|
||||
}else{
|
||||
$("#optBtn").remove();
|
||||
}
|
||||
</script>
|
||||
<script language="javascript" type="text/javascript">
|
||||
//查询是否在书架
|
||||
|
@ -238,7 +238,7 @@
|
||||
<div class="Readarea ReadAjax_content screen_container"
|
||||
style="color: rgb(0, 0, 0); font-size: 10px;background-color: #fff" th:if="${needBuy}">
|
||||
<h5>此章为VIP章节,需要订阅后才能继续阅读</h5>
|
||||
价格:<span style="color: red">10屋币(1元=100屋币)</span><br/>
|
||||
价格:<span style="color: red" th:text="${bookIndex.bookPrice}+'屋币(1元=100屋币)'"></span><br/>
|
||||
<a href="javascript:buyBookIndex()" type="button" class="layui-btn layui-btn-sm layui-btn-radius">购买</a>
|
||||
|
||||
</div>
|
||||
|
2
pom.xml
2
pom.xml
@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>com.java2nb</groupId>
|
||||
<artifactId>novel</artifactId>
|
||||
<version>2.7.1</version>
|
||||
<version>2.9.0</version>
|
||||
<modules>
|
||||
<module>novel-common</module>
|
||||
<module>novel-front</module>
|
||||
|
1
sql/20201122.sql
Normal file
1
sql/20201122.sql
Normal file
@ -0,0 +1 @@
|
||||
alter table book_index add column `book_price` int(3) DEFAULT 0 COMMENT '章节费用(屋币)' after `is_vip`;
|
@ -1868,3 +1868,5 @@ CREATE TABLE `author_income` (
|
||||
|
||||
|
||||
alter table book add column `yesterday_buy` int(11) DEFAULT '0' COMMENT '昨日订阅数' after comment_count;
|
||||
|
||||
alter table book_index add column `book_price` int(3) DEFAULT 0 COMMENT '章节费用(屋币)' after `is_vip`;
|
Reference in New Issue
Block a user