|
|
@@ -16,19 +16,20 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollStreamUtil;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import vip.xiaonuo.auth.core.pojo.SaBaseLoginUser;
|
|
|
import vip.xiaonuo.auth.core.util.StpLoginUserUtil;
|
|
|
-import vip.xiaonuo.common.enums.CommonSortOrderEnum;
|
|
|
import vip.xiaonuo.common.exception.CommonException;
|
|
|
import vip.xiaonuo.common.page.CommonPageRequest;
|
|
|
import vip.xiaonuo.common.pojo.CommonResult;
|
|
|
+import vip.xiaonuo.forum.modular.chapterDiscussion.entity.ForumChapterDiscussion;
|
|
|
+import vip.xiaonuo.forum.modular.chapterDiscussion.mapper.ForumChapterDiscussionMapper;
|
|
|
import vip.xiaonuo.forum.modular.postinfo.entity.ForumPostInfo;
|
|
|
import vip.xiaonuo.forum.modular.postinfo.mapper.ForumPostInfoMapper;
|
|
|
import vip.xiaonuo.forum.modular.postlike.entity.ForumPostLike;
|
|
|
@@ -47,7 +48,6 @@ import vip.xiaonuo.forum.modular.sensitivityrecord.mapper.ForumSensitivityRecord
|
|
|
import vip.xiaonuo.sys.api.SysUserApi;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.time.LocalDate;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
@@ -75,6 +75,12 @@ public class ForumPostReplyServiceImpl extends ServiceImpl<ForumPostReplyMapper,
|
|
|
@Resource
|
|
|
private ForumPostLikeMapper forumPostLikeMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ForumPostReplyMapper forumPostReplyMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ForumChapterDiscussionMapper forumChapterDiscussionMapper;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public Page<ForumPostReply> page(ForumPostReplyPageParam forumPostReplyPageParam) {
|
|
|
@@ -249,21 +255,53 @@ public class ForumPostReplyServiceImpl extends ServiceImpl<ForumPostReplyMapper,
|
|
|
/**
|
|
|
* 查询两个时间段的发帖数
|
|
|
*/
|
|
|
- public long getPostCountByDateAndType(String startTime, String endTime, Integer postType) {
|
|
|
- QueryWrapper<ForumPostReply> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.lambda().eq(ForumPostReply::getPostType, 3);
|
|
|
- queryWrapper.lambda().between(ForumPostReply::getCreateTime, startTime, endTime);
|
|
|
- queryWrapper.lambda().eq(ForumPostReply::getParentId, "-1");
|
|
|
- return this.count(queryWrapper);
|
|
|
+ public long getPostCountByDateAndType(String courseId, String startTime, String endTime, Integer postType) {
|
|
|
+ if (StringUtils.isNotBlank(courseId)) {
|
|
|
+ QueryWrapper<ForumChapterDiscussion> queryWrapper1 = new QueryWrapper<>();
|
|
|
+ queryWrapper1.lambda().eq(ForumChapterDiscussion::getCourseId, courseId);
|
|
|
+ List<ForumChapterDiscussion> forumChapterDiscussions = forumChapterDiscussionMapper.selectList(queryWrapper1);
|
|
|
+ if (forumChapterDiscussions.size() > 0) {
|
|
|
+ QueryWrapper<ForumPostReply> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda().eq(ForumPostReply::getPostType, postType);
|
|
|
+ queryWrapper.lambda().between(ForumPostReply::getCreateTime, startTime, endTime);
|
|
|
+ queryWrapper.lambda().in(ForumPostReply::getPostId, CollStreamUtil.toList(forumChapterDiscussions, ForumChapterDiscussion::getPostId));
|
|
|
+ queryWrapper.lambda().eq(ForumPostReply::getParentId, "-1");
|
|
|
+ return this.count(queryWrapper);
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ QueryWrapper<ForumPostReply> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda().eq(ForumPostReply::getPostType, postType);
|
|
|
+ queryWrapper.lambda().between(ForumPostReply::getCreateTime, startTime, endTime);
|
|
|
+ queryWrapper.lambda().eq(ForumPostReply::getParentId, "-1");
|
|
|
+ return this.count(queryWrapper);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public long getReplyCountByDateAndType(String startTime, String endTime, Integer postType) {
|
|
|
- QueryWrapper<ForumPostReply> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.lambda().eq(ForumPostReply::getPostType, 3);
|
|
|
- queryWrapper.lambda().between(ForumPostReply::getCreateTime, startTime, endTime);
|
|
|
- queryWrapper.lambda().notIn(ForumPostReply::getParentId, "-1");
|
|
|
- return this.count(queryWrapper);
|
|
|
+ public long getReplyCountByDateAndType(String courseId, String startTime, String endTime, Integer postType) {
|
|
|
+ if (StringUtils.isNotBlank(courseId)) {
|
|
|
+ QueryWrapper<ForumChapterDiscussion> queryWrapper1 = new QueryWrapper<>();
|
|
|
+ queryWrapper1.lambda().eq(ForumChapterDiscussion::getCourseId, courseId);
|
|
|
+ List<ForumChapterDiscussion> forumChapterDiscussions = forumChapterDiscussionMapper.selectList(queryWrapper1);
|
|
|
+ if (forumChapterDiscussions.size() > 0) {
|
|
|
+ QueryWrapper<ForumPostReply> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda().eq(ForumPostReply::getPostType, postType);
|
|
|
+ queryWrapper.lambda().notIn(ForumPostReply::getParentId, "-1");
|
|
|
+ queryWrapper.lambda().between(ForumPostReply::getCreateTime, startTime, endTime);
|
|
|
+ queryWrapper.lambda().in(ForumPostReply::getPostId, CollStreamUtil.toList(forumChapterDiscussions, ForumChapterDiscussion::getPostId));
|
|
|
+ return this.count(queryWrapper);
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ QueryWrapper<ForumPostReply> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda().eq(ForumPostReply::getPostType, postType);
|
|
|
+ queryWrapper.lambda().notIn(ForumPostReply::getParentId, "-1");
|
|
|
+ queryWrapper.lambda().between(ForumPostReply::getCreateTime, startTime, endTime);
|
|
|
+ return this.count(queryWrapper);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|