mirror of
https://github.com/201206030/novel-plus.git
synced 2025-04-27 01:30:51 +00:00
perf: 后台评论管理
This commit is contained in:
parent
8ddc6cc434
commit
3ffa75dc10
@ -1,15 +1,15 @@
|
|||||||
package com.java2nb.novel.dao;
|
package com.java2nb.novel.dao;
|
||||||
|
|
||||||
import com.java2nb.novel.domain.BookDO;
|
import com.java2nb.novel.domain.BookDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 小说表
|
* 小说表
|
||||||
|
*
|
||||||
* @author xiongxy
|
* @author xiongxy
|
||||||
* @email 1179705413@qq.com
|
* @email 1179705413@qq.com
|
||||||
* @date 2020-12-01 03:49:46
|
* @date 2020-12-01 03:49:46
|
||||||
@ -19,9 +19,9 @@ public interface BookDao {
|
|||||||
|
|
||||||
BookDO get(Long id);
|
BookDO get(Long id);
|
||||||
|
|
||||||
List<BookDO> list(Map<String,Object> map);
|
List<BookDO> list(Map<String, Object> map);
|
||||||
|
|
||||||
int count(Map<String,Object> map);
|
int count(Map<String, Object> map);
|
||||||
|
|
||||||
int save(BookDO book);
|
int save(BookDO book);
|
||||||
|
|
||||||
@ -32,4 +32,7 @@ public interface BookDao {
|
|||||||
int batchRemove(Long[] ids);
|
int batchRemove(Long[] ids);
|
||||||
|
|
||||||
List<Map<Object, Object>> tableSta(Date minDate);
|
List<Map<Object, Object>> tableSta(Date minDate);
|
||||||
|
|
||||||
|
List<BookDO> batchGet(List<Long> ids);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package com.java2nb.novel.dao;
|
package com.java2nb.novel.dao;
|
||||||
|
|
||||||
import com.java2nb.novel.domain.UserDO;
|
import com.java2nb.novel.domain.UserDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author xiongxy
|
* @author xiongxy
|
||||||
* @email 1179705413@qq.com
|
* @email 1179705413@qq.com
|
||||||
* @date 2020-12-01 03:49:08
|
* @date 2020-12-01 03:49:08
|
||||||
@ -19,9 +17,9 @@ public interface UserDao {
|
|||||||
|
|
||||||
UserDO get(Long id);
|
UserDO get(Long id);
|
||||||
|
|
||||||
List<UserDO> list(Map<String,Object> map);
|
List<UserDO> list(Map<String, Object> map);
|
||||||
|
|
||||||
int count(Map<String,Object> map);
|
int count(Map<String, Object> map);
|
||||||
|
|
||||||
int save(UserDO user);
|
int save(UserDO user);
|
||||||
|
|
||||||
@ -32,4 +30,6 @@ public interface UserDao {
|
|||||||
int batchRemove(Long[] ids);
|
int batchRemove(Long[] ids);
|
||||||
|
|
||||||
List<Map<Object, Object>> tableSta(Date minDate);
|
List<Map<Object, Object>> tableSta(Date minDate);
|
||||||
|
|
||||||
|
List<UserDO> batchGet(List<Long> userIds);
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,11 @@
|
|||||||
package com.java2nb.novel.domain;
|
package com.java2nb.novel.domain;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
import com.java2nb.common.jsonserializer.LongToStringSerializer;
|
import com.java2nb.common.jsonserializer.LongToStringSerializer;
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,6 +16,7 @@ import java.util.Date;
|
|||||||
* @date 2023-04-14 21:59:28
|
* @date 2023-04-14 21:59:28
|
||||||
*/
|
*/
|
||||||
public class BookCommentDO implements Serializable {
|
public class BookCommentDO implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
@ -50,84 +45,117 @@ public class BookCommentDO implements Serializable {
|
|||||||
@JsonSerialize(using = LongToStringSerializer.class)
|
@JsonSerialize(using = LongToStringSerializer.class)
|
||||||
private Long createUserId;
|
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) {
|
public void setId(Long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取:主键
|
* 获取:主键
|
||||||
*/
|
*/
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置:小说ID
|
* 设置:小说ID
|
||||||
*/
|
*/
|
||||||
public void setBookId(Long bookId) {
|
public void setBookId(Long bookId) {
|
||||||
this.bookId = bookId;
|
this.bookId = bookId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取:小说ID
|
* 获取:小说ID
|
||||||
*/
|
*/
|
||||||
public Long getBookId() {
|
public Long getBookId() {
|
||||||
return bookId;
|
return bookId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置:评价内容
|
* 设置:评价内容
|
||||||
*/
|
*/
|
||||||
public void setCommentContent(String commentContent) {
|
public void setCommentContent(String commentContent) {
|
||||||
this.commentContent = commentContent;
|
this.commentContent = commentContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取:评价内容
|
* 获取:评价内容
|
||||||
*/
|
*/
|
||||||
public String getCommentContent() {
|
public String getCommentContent() {
|
||||||
return commentContent;
|
return commentContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置:回复数量
|
* 设置:回复数量
|
||||||
*/
|
*/
|
||||||
public void setReplyCount(Integer replyCount) {
|
public void setReplyCount(Integer replyCount) {
|
||||||
this.replyCount = replyCount;
|
this.replyCount = replyCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取:回复数量
|
* 获取:回复数量
|
||||||
*/
|
*/
|
||||||
public Integer getReplyCount() {
|
public Integer getReplyCount() {
|
||||||
return replyCount;
|
return replyCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置:审核状态,0:待审核,1:审核通过,2:审核不通过
|
* 设置:审核状态,0:待审核,1:审核通过,2:审核不通过
|
||||||
*/
|
*/
|
||||||
public void setAuditStatus(Integer auditStatus) {
|
public void setAuditStatus(Integer auditStatus) {
|
||||||
this.auditStatus = auditStatus;
|
this.auditStatus = auditStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取:审核状态,0:待审核,1:审核通过,2:审核不通过
|
* 获取:审核状态,0:待审核,1:审核通过,2:审核不通过
|
||||||
*/
|
*/
|
||||||
public Integer getAuditStatus() {
|
public Integer getAuditStatus() {
|
||||||
return auditStatus;
|
return auditStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置:评价时间
|
* 设置:评价时间
|
||||||
*/
|
*/
|
||||||
public void setCreateTime(Date createTime) {
|
public void setCreateTime(Date createTime) {
|
||||||
this.createTime = createTime;
|
this.createTime = createTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取:评价时间
|
* 获取:评价时间
|
||||||
*/
|
*/
|
||||||
public Date getCreateTime() {
|
public Date getCreateTime() {
|
||||||
return createTime;
|
return createTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置:评价人
|
* 设置:评价人
|
||||||
*/
|
*/
|
||||||
public void setCreateUserId(Long createUserId) {
|
public void setCreateUserId(Long createUserId) {
|
||||||
this.createUserId = createUserId;
|
this.createUserId = createUserId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取:评价人
|
* 获取:评价人
|
||||||
*/
|
*/
|
||||||
|
@ -1,54 +1,76 @@
|
|||||||
package com.java2nb.novel.service.impl;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import com.java2nb.novel.dao.BookCommentDao;
|
|
||||||
import com.java2nb.novel.domain.BookCommentDO;
|
|
||||||
import com.java2nb.novel.service.BookCommentService;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class BookCommentServiceImpl implements BookCommentService {
|
public class BookCommentServiceImpl implements BookCommentService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private BookCommentDao bookCommentDao;
|
private BookCommentDao bookCommentDao;
|
||||||
|
@Autowired
|
||||||
|
private BookDao bookDao;
|
||||||
|
@Autowired
|
||||||
|
private UserDao userDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BookCommentDO get(Long id){
|
public BookCommentDO get(Long id) {
|
||||||
return bookCommentDao.get(id);
|
return bookCommentDao.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BookCommentDO> list(Map<String, Object> map){
|
public List<BookCommentDO> list(Map<String, Object> map) {
|
||||||
return bookCommentDao.list(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
|
@Override
|
||||||
public int count(Map<String, Object> map){
|
public int count(Map<String, Object> map) {
|
||||||
return bookCommentDao.count(map);
|
return bookCommentDao.count(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int save(BookCommentDO bookComment){
|
public int save(BookCommentDO bookComment) {
|
||||||
return bookCommentDao.save(bookComment);
|
return bookCommentDao.save(bookComment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int update(BookCommentDO bookComment){
|
public int update(BookCommentDO bookComment) {
|
||||||
return bookCommentDao.update(bookComment);
|
return bookCommentDao.update(bookComment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int remove(Long id){
|
public int remove(Long id) {
|
||||||
return bookCommentDao.remove(id);
|
return bookCommentDao.remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int batchRemove(Long[] ids){
|
public int batchRemove(Long[] ids) {
|
||||||
return bookCommentDao.batchRemove(ids);
|
return bookCommentDao.batchRemove(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,5 +285,13 @@
|
|||||||
GROUP BY DATE_FORMAT(create_time, "%Y-%m-%d")
|
GROUP BY DATE_FORMAT(create_time, "%Y-%m-%d")
|
||||||
ORDER BY staDate
|
ORDER BY staDate
|
||||||
</select>
|
</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>
|
</mapper>
|
@ -4,7 +4,18 @@
|
|||||||
<mapper namespace="com.java2nb.novel.dao.UserDao">
|
<mapper namespace="com.java2nb.novel.dao.UserDao">
|
||||||
|
|
||||||
<select id="get" resultType="com.java2nb.novel.domain.UserDO">
|
<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 `id`,
|
||||||
|
`username`,
|
||||||
|
`password`,
|
||||||
|
`nick_name`,
|
||||||
|
`user_photo`,
|
||||||
|
`user_sex`,
|
||||||
|
`account_balance`,
|
||||||
|
`status`,
|
||||||
|
`create_time`,
|
||||||
|
`update_time`
|
||||||
|
from user
|
||||||
|
where id = #{value}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="list" resultType="com.java2nb.novel.domain.UserDO">
|
<select id="list" resultType="com.java2nb.novel.domain.UserDO">
|
||||||
@ -54,8 +65,7 @@
|
|||||||
|
|
||||||
<insert id="save" parameterType="com.java2nb.novel.domain.UserDO">
|
<insert id="save" parameterType="com.java2nb.novel.domain.UserDO">
|
||||||
insert into user
|
insert into user
|
||||||
(
|
(`id`,
|
||||||
`id`,
|
|
||||||
`username`,
|
`username`,
|
||||||
`password`,
|
`password`,
|
||||||
`nick_name`,
|
`nick_name`,
|
||||||
@ -64,11 +74,8 @@
|
|||||||
`account_balance`,
|
`account_balance`,
|
||||||
`status`,
|
`status`,
|
||||||
`create_time`,
|
`create_time`,
|
||||||
`update_time`
|
`update_time`)
|
||||||
)
|
values (#{id},
|
||||||
values
|
|
||||||
(
|
|
||||||
#{id},
|
|
||||||
#{username},
|
#{username},
|
||||||
#{password},
|
#{password},
|
||||||
#{nickName},
|
#{nickName},
|
||||||
@ -77,8 +84,7 @@
|
|||||||
#{accountBalance},
|
#{accountBalance},
|
||||||
#{status},
|
#{status},
|
||||||
#{createTime},
|
#{createTime},
|
||||||
#{updateTime}
|
#{updateTime})
|
||||||
)
|
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<insert id="saveSelective" parameterType="com.java2nb.novel.domain.UserDO">
|
<insert id="saveSelective" parameterType="com.java2nb.novel.domain.UserDO">
|
||||||
@ -127,7 +133,9 @@
|
|||||||
</update>
|
</update>
|
||||||
|
|
||||||
<delete id="remove">
|
<delete id="remove">
|
||||||
delete from user where id = #{value}
|
delete
|
||||||
|
from user
|
||||||
|
where id = #{value}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<delete id="batchRemove">
|
<delete id="batchRemove">
|
||||||
@ -138,17 +146,20 @@
|
|||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<select id="tableSta" resultType="map">
|
<select id="tableSta" resultType="map">
|
||||||
SELECT
|
SELECT DATE_FORMAT(create_time, "%Y-%m-%d") AS staDate,
|
||||||
DATE_FORMAT( create_time, "%Y-%m-%d" ) AS staDate,
|
COUNT(1) userCount
|
||||||
COUNT( 1 ) userCount
|
FROM user
|
||||||
FROM
|
WHERE create_time >= #{minDate}
|
||||||
user
|
GROUP BY DATE_FORMAT(create_time, "%Y-%m-%d")
|
||||||
WHERE
|
ORDER BY staDate
|
||||||
create_time >= #{minDate}
|
</select>
|
||||||
GROUP BY
|
<select id="batchGet" resultType="com.java2nb.novel.domain.UserDO">
|
||||||
DATE_FORMAT( create_time, "%Y-%m-%d" )
|
select
|
||||||
ORDER BY
|
`id`,`username`,`password`,`nick_name`,`user_photo`,`user_sex`,`account_balance`,`status`,`create_time`,`update_time`
|
||||||
staDate
|
from user where id in
|
||||||
|
<foreach item="id" collection="list" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
@ -61,25 +61,25 @@ function load() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'bookId',
|
field: 'bookName',
|
||||||
title: '小说ID'
|
title: '评论小说'
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'commentContent',
|
field: 'commentContent',
|
||||||
title: '评价内容'
|
title: '评论内容'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'createTime',
|
field: 'createTime',
|
||||||
title: '评价时间'
|
title: '评论时间'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'createUserId',
|
field: 'userName',
|
||||||
title: '评价人ID'
|
title: '评论人'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user