mirror of
https://github.com/201206030/novel-plus.git
synced 2025-04-26 17:20:52 +00:00
perf: 后台评论管理
This commit is contained in:
parent
8ddc6cc434
commit
3ffa75dc10
@ -1,15 +1,15 @@
|
||||
package com.java2nb.novel.dao;
|
||||
|
||||
import com.java2nb.novel.domain.BookDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 小说表
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2020-12-01 03:49:46
|
||||
@ -17,19 +17,22 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
@Mapper
|
||||
public interface BookDao {
|
||||
|
||||
BookDO get(Long id);
|
||||
|
||||
List<BookDO> list(Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
int save(BookDO book);
|
||||
|
||||
int update(BookDO book);
|
||||
|
||||
int remove(Long id);
|
||||
|
||||
int batchRemove(Long[] ids);
|
||||
BookDO get(Long id);
|
||||
|
||||
List<BookDO> list(Map<String, Object> map);
|
||||
|
||||
int count(Map<String, Object> map);
|
||||
|
||||
int save(BookDO book);
|
||||
|
||||
int update(BookDO book);
|
||||
|
||||
int remove(Long id);
|
||||
|
||||
int batchRemove(Long[] ids);
|
||||
|
||||
List<Map<Object, Object>> tableSta(Date minDate);
|
||||
|
||||
List<BookDO> batchGet(List<Long> ids);
|
||||
|
||||
}
|
||||
|
@ -1,15 +1,13 @@
|
||||
package com.java2nb.novel.dao;
|
||||
|
||||
import com.java2nb.novel.domain.UserDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2020-12-01 03:49:08
|
||||
@ -17,19 +15,21 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
@Mapper
|
||||
public interface UserDao {
|
||||
|
||||
UserDO get(Long id);
|
||||
|
||||
List<UserDO> list(Map<String,Object> map);
|
||||
|
||||
int count(Map<String,Object> map);
|
||||
|
||||
int save(UserDO user);
|
||||
|
||||
int update(UserDO user);
|
||||
|
||||
int remove(Long id);
|
||||
|
||||
int batchRemove(Long[] ids);
|
||||
UserDO get(Long id);
|
||||
|
||||
List<UserDO> list(Map<String, Object> map);
|
||||
|
||||
int count(Map<String, Object> map);
|
||||
|
||||
int save(UserDO user);
|
||||
|
||||
int update(UserDO user);
|
||||
|
||||
int remove(Long id);
|
||||
|
||||
int batchRemove(Long[] ids);
|
||||
|
||||
List<Map<Object, Object>> tableSta(Date minDate);
|
||||
|
||||
List<UserDO> batchGet(List<Long> userIds);
|
||||
}
|
||||
|
@ -1,137 +1,165 @@
|
||||
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;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 小说评论表
|
||||
*
|
||||
*
|
||||
* @author xiongxy
|
||||
* @email 1179705413@qq.com
|
||||
* @date 2023-04-14 21:59:28
|
||||
*/
|
||||
public class BookCommentDO 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 bookId;
|
||||
//评价内容
|
||||
private String commentContent;
|
||||
//回复数量
|
||||
private Integer replyCount;
|
||||
//审核状态,0:待审核,1:审核通过,2:审核不通过
|
||||
private Integer auditStatus;
|
||||
//评价时间
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
//评价人
|
||||
//java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值)
|
||||
//所以通过序列化成字符串来解决
|
||||
@JsonSerialize(using = LongToStringSerializer.class)
|
||||
private Long createUserId;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 设置:主键
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
/**
|
||||
* 获取:主键
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
/**
|
||||
* 设置:小说ID
|
||||
*/
|
||||
public void setBookId(Long bookId) {
|
||||
this.bookId = bookId;
|
||||
}
|
||||
/**
|
||||
* 获取:小说ID
|
||||
*/
|
||||
public Long getBookId() {
|
||||
return bookId;
|
||||
}
|
||||
/**
|
||||
* 设置:评价内容
|
||||
*/
|
||||
public void setCommentContent(String commentContent) {
|
||||
this.commentContent = commentContent;
|
||||
}
|
||||
/**
|
||||
* 获取:评价内容
|
||||
*/
|
||||
public String getCommentContent() {
|
||||
return commentContent;
|
||||
}
|
||||
/**
|
||||
* 设置:回复数量
|
||||
*/
|
||||
public void setReplyCount(Integer replyCount) {
|
||||
this.replyCount = replyCount;
|
||||
}
|
||||
/**
|
||||
* 获取:回复数量
|
||||
*/
|
||||
public Integer getReplyCount() {
|
||||
return replyCount;
|
||||
}
|
||||
/**
|
||||
* 设置:审核状态,0:待审核,1:审核通过,2:审核不通过
|
||||
*/
|
||||
public void setAuditStatus(Integer auditStatus) {
|
||||
this.auditStatus = auditStatus;
|
||||
}
|
||||
/**
|
||||
* 获取:审核状态,0:待审核,1:审核通过,2:审核不通过
|
||||
*/
|
||||
public Integer getAuditStatus() {
|
||||
return auditStatus;
|
||||
}
|
||||
/**
|
||||
* 设置:评价时间
|
||||
*/
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
/**
|
||||
* 获取:评价时间
|
||||
*/
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
/**
|
||||
* 设置:评价人
|
||||
*/
|
||||
public void setCreateUserId(Long createUserId) {
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
/**
|
||||
* 获取:评价人
|
||||
*/
|
||||
public Long getCreateUserId() {
|
||||
return createUserId;
|
||||
}
|
||||
|
||||
//主键
|
||||
//java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值)
|
||||
//所以通过序列化成字符串来解决
|
||||
@JsonSerialize(using = LongToStringSerializer.class)
|
||||
private Long id;
|
||||
//小说ID
|
||||
//java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值)
|
||||
//所以通过序列化成字符串来解决
|
||||
@JsonSerialize(using = LongToStringSerializer.class)
|
||||
private Long bookId;
|
||||
//评价内容
|
||||
private String commentContent;
|
||||
//回复数量
|
||||
private Integer replyCount;
|
||||
//审核状态,0:待审核,1:审核通过,2:审核不通过
|
||||
private Integer auditStatus;
|
||||
//评价时间
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
//评价人
|
||||
//java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值)
|
||||
//所以通过序列化成字符串来解决
|
||||
@JsonSerialize(using = LongToStringSerializer.class)
|
||||
private Long createUserId;
|
||||
|
||||
private String bookName;
|
||||
|
||||
private String userName;
|
||||
|
||||
public String getBookName() {
|
||||
return bookName;
|
||||
}
|
||||
|
||||
public void setBookName(String bookName) {
|
||||
this.bookName = bookName;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置:主键
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:主键
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置:小说ID
|
||||
*/
|
||||
public void setBookId(Long bookId) {
|
||||
this.bookId = bookId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:小说ID
|
||||
*/
|
||||
public Long getBookId() {
|
||||
return bookId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置:评价内容
|
||||
*/
|
||||
public void setCommentContent(String commentContent) {
|
||||
this.commentContent = commentContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:评价内容
|
||||
*/
|
||||
public String getCommentContent() {
|
||||
return commentContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置:回复数量
|
||||
*/
|
||||
public void setReplyCount(Integer replyCount) {
|
||||
this.replyCount = replyCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:回复数量
|
||||
*/
|
||||
public Integer getReplyCount() {
|
||||
return replyCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置:审核状态,0:待审核,1:审核通过,2:审核不通过
|
||||
*/
|
||||
public void setAuditStatus(Integer auditStatus) {
|
||||
this.auditStatus = auditStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:审核状态,0:待审核,1:审核通过,2:审核不通过
|
||||
*/
|
||||
public Integer getAuditStatus() {
|
||||
return auditStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置:评价时间
|
||||
*/
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:评价时间
|
||||
*/
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置:评价人
|
||||
*/
|
||||
public void setCreateUserId(Long createUserId) {
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取:评价人
|
||||
*/
|
||||
public Long getCreateUserId() {
|
||||
return createUserId;
|
||||
}
|
||||
}
|
||||
|
@ -1,55 +1,77 @@
|
||||
package com.java2nb.novel.service.impl;
|
||||
|
||||
import com.java2nb.novel.dao.BookCommentDao;
|
||||
import com.java2nb.novel.dao.BookDao;
|
||||
import com.java2nb.novel.dao.UserDao;
|
||||
import com.java2nb.novel.domain.BookCommentDO;
|
||||
import com.java2nb.novel.domain.BookDO;
|
||||
import com.java2nb.novel.domain.UserDO;
|
||||
import com.java2nb.novel.service.BookCommentService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.java2nb.novel.dao.BookCommentDao;
|
||||
import com.java2nb.novel.domain.BookCommentDO;
|
||||
import com.java2nb.novel.service.BookCommentService;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service
|
||||
public class BookCommentServiceImpl implements BookCommentService {
|
||||
@Autowired
|
||||
private BookCommentDao bookCommentDao;
|
||||
|
||||
@Override
|
||||
public BookCommentDO get(Long id){
|
||||
return bookCommentDao.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookCommentDO> list(Map<String, Object> map){
|
||||
return bookCommentDao.list(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(Map<String, Object> map){
|
||||
return bookCommentDao.count(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int save(BookCommentDO bookComment){
|
||||
return bookCommentDao.save(bookComment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(BookCommentDO bookComment){
|
||||
return bookCommentDao.update(bookComment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int remove(Long id){
|
||||
return bookCommentDao.remove(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchRemove(Long[] ids){
|
||||
return bookCommentDao.batchRemove(ids);
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
private BookCommentDao bookCommentDao;
|
||||
@Autowired
|
||||
private BookDao bookDao;
|
||||
@Autowired
|
||||
private UserDao userDao;
|
||||
|
||||
@Override
|
||||
public BookCommentDO get(Long id) {
|
||||
return bookCommentDao.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BookCommentDO> list(Map<String, Object> map) {
|
||||
List<BookCommentDO> list = bookCommentDao.list(map);
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
List<Long> bookIds = list.stream().map(BookCommentDO::getBookId).collect(Collectors.toList());
|
||||
Map<Long, String> bookNameMap = bookDao.batchGet(bookIds).stream()
|
||||
.collect(Collectors.toMap(BookDO::getId, BookDO::getBookName));
|
||||
List<Long> userIds = list.stream().map(BookCommentDO::getCreateUserId).collect(Collectors.toList());
|
||||
Map<Long, String> userNameMap = userDao.batchGet(userIds).stream()
|
||||
.collect(Collectors.toMap(UserDO::getId, UserDO::getUsername));
|
||||
list.forEach(v -> {
|
||||
v.setBookName(bookNameMap.get(v.getBookId()));
|
||||
v.setUserName(userNameMap.get(v.getCreateUserId()));
|
||||
});
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(Map<String, Object> map) {
|
||||
return bookCommentDao.count(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int save(BookCommentDO bookComment) {
|
||||
return bookCommentDao.save(bookComment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(BookCommentDO bookComment) {
|
||||
return bookCommentDao.update(bookComment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int remove(Long id) {
|
||||
return bookCommentDao.remove(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchRemove(Long[] ids) {
|
||||
return bookCommentDao.batchRemove(ids);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -285,5 +285,13 @@
|
||||
GROUP BY DATE_FORMAT(create_time, "%Y-%m-%d")
|
||||
ORDER BY staDate
|
||||
</select>
|
||||
<select id="batchGet" resultType="com.java2nb.novel.domain.BookDO">
|
||||
select
|
||||
`id`,`work_direction`,`cat_id`,`cat_name`,`pic_url`,`book_name`,`author_id`,`author_name`,`book_desc`,`score`,`book_status`,`visit_count`,`word_count`,`comment_count`,`yesterday_buy`,`last_index_id`,`last_index_name`,`last_index_update_time`,`is_vip`,`status`,`update_time`,`create_time`,`crawl_source_id`,`crawl_book_id`,`crawl_last_time`,`crawl_is_stop`
|
||||
from book where id in
|
||||
<foreach item="id" collection="list" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -4,8 +4,19 @@
|
||||
<mapper namespace="com.java2nb.novel.dao.UserDao">
|
||||
|
||||
<select id="get" resultType="com.java2nb.novel.domain.UserDO">
|
||||
select `id`,`username`,`password`,`nick_name`,`user_photo`,`user_sex`,`account_balance`,`status`,`create_time`,`update_time` from user where id = #{value}
|
||||
</select>
|
||||
select `id`,
|
||||
`username`,
|
||||
`password`,
|
||||
`nick_name`,
|
||||
`user_photo`,
|
||||
`user_sex`,
|
||||
`account_balance`,
|
||||
`status`,
|
||||
`create_time`,
|
||||
`update_time`
|
||||
from user
|
||||
where id = #{value}
|
||||
</select>
|
||||
|
||||
<select id="list" resultType="com.java2nb.novel.domain.UserDO">
|
||||
select
|
||||
@ -53,33 +64,28 @@
|
||||
</select>
|
||||
|
||||
<insert id="save" parameterType="com.java2nb.novel.domain.UserDO">
|
||||
insert into user
|
||||
(
|
||||
`id`,
|
||||
`username`,
|
||||
`password`,
|
||||
`nick_name`,
|
||||
`user_photo`,
|
||||
`user_sex`,
|
||||
`account_balance`,
|
||||
`status`,
|
||||
`create_time`,
|
||||
`update_time`
|
||||
)
|
||||
values
|
||||
(
|
||||
#{id},
|
||||
#{username},
|
||||
#{password},
|
||||
#{nickName},
|
||||
#{userPhoto},
|
||||
#{userSex},
|
||||
#{accountBalance},
|
||||
#{status},
|
||||
#{createTime},
|
||||
#{updateTime}
|
||||
)
|
||||
</insert>
|
||||
insert into user
|
||||
(`id`,
|
||||
`username`,
|
||||
`password`,
|
||||
`nick_name`,
|
||||
`user_photo`,
|
||||
`user_sex`,
|
||||
`account_balance`,
|
||||
`status`,
|
||||
`create_time`,
|
||||
`update_time`)
|
||||
values (#{id},
|
||||
#{username},
|
||||
#{password},
|
||||
#{nickName},
|
||||
#{userPhoto},
|
||||
#{userSex},
|
||||
#{accountBalance},
|
||||
#{status},
|
||||
#{createTime},
|
||||
#{updateTime})
|
||||
</insert>
|
||||
|
||||
<insert id="saveSelective" parameterType="com.java2nb.novel.domain.UserDO">
|
||||
insert into user
|
||||
@ -127,8 +133,10 @@
|
||||
</update>
|
||||
|
||||
<delete id="remove">
|
||||
delete from user where id = #{value}
|
||||
</delete>
|
||||
delete
|
||||
from user
|
||||
where id = #{value}
|
||||
</delete>
|
||||
|
||||
<delete id="batchRemove">
|
||||
delete from user where id in
|
||||
@ -138,17 +146,20 @@
|
||||
</delete>
|
||||
|
||||
<select id="tableSta" resultType="map">
|
||||
SELECT
|
||||
DATE_FORMAT( create_time, "%Y-%m-%d" ) AS staDate,
|
||||
COUNT( 1 ) userCount
|
||||
FROM
|
||||
user
|
||||
WHERE
|
||||
create_time >= #{minDate}
|
||||
GROUP BY
|
||||
DATE_FORMAT( create_time, "%Y-%m-%d" )
|
||||
ORDER BY
|
||||
staDate
|
||||
</select>
|
||||
SELECT DATE_FORMAT(create_time, "%Y-%m-%d") AS staDate,
|
||||
COUNT(1) userCount
|
||||
FROM user
|
||||
WHERE create_time >= #{minDate}
|
||||
GROUP BY DATE_FORMAT(create_time, "%Y-%m-%d")
|
||||
ORDER BY staDate
|
||||
</select>
|
||||
<select id="batchGet" resultType="com.java2nb.novel.domain.UserDO">
|
||||
select
|
||||
`id`,`username`,`password`,`nick_name`,`user_photo`,`user_sex`,`account_balance`,`status`,`create_time`,`update_time`
|
||||
from user where id in
|
||||
<foreach item="id" collection="list" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -61,25 +61,25 @@ function load() {
|
||||
},
|
||||
|
||||
{
|
||||
field: 'bookId',
|
||||
title: '小说ID'
|
||||
field: 'bookName',
|
||||
title: '评论小说'
|
||||
},
|
||||
|
||||
{
|
||||
field: 'commentContent',
|
||||
title: '评价内容'
|
||||
title: '评论内容'
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '评价时间'
|
||||
title: '评论时间'
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
field: 'createUserId',
|
||||
title: '评价人ID'
|
||||
field: 'userName',
|
||||
title: '评论人'
|
||||
},
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user