派生自 projectDept/qhighschool

EricsHu
2023-06-19 bc3b37b1622091def1f6ee4c3eb3ff79499b3466
src/main/java/com/qxueyou/scc/operation/topic/service/impl/TopicService.java
@@ -50,7 +50,7 @@
import com.qxueyou.scc.user.service.IUserService;
/**
 * 话题服务层
 * 话题服务层
 *
 * @author chenjunliang
 */
@@ -92,7 +92,7 @@
                    + " c.commentObjectId =o.commentObjectId and o.commentObjectType = 5";
            List<Map<String, Object>> commentIdLst = findListWithMapByHql(findPeopleCountByHql,
                    CollectionUtils.newObjectMap("topicId", topicId));
            int peopleCount = commentIdLst.size();// 参与人数
            int peopleCount = commentIdLst.size();// 参与人数
            map.put("peopleCount", peopleCount);
        }
        return new Result(true, "success",
@@ -136,14 +136,14 @@
        String hql = "from CommentObject where deleteFlag is false and commentObjectUid = ? and commentObjectType = 5";
        CommentObject commentObject = findUnique(hql, CollectionUtils.newList(topicId), CommentObject.class);
        BigInteger viewCount = commentObject.getViewCount();
        commentObject.setViewCount(viewCount.add(new BigInteger("1")));// 查看条数+1
        commentObject.setViewCount(viewCount.add(new BigInteger("1")));// 查看条数+1
        BigInteger viewCount2Json = commentObject.getViewCount();
        BigInteger commentPraiseCount = commentObject.getCommentPraiseCount();
        TraceUtils.setUpdateTrace(commentObject);
        save(commentObject);
        TopicInfo topic = this.read(TopicInfo.class, topicId);
        String[] classIds = topic.getClassId().split(",");
        Map<String, Object> argsMap = new HashMap<String, Object>(1);
        argsMap.put("classIds", classIds);
        List<Map<String, Object>> classMapLst = findListWithMapByHql(
@@ -154,8 +154,8 @@
                + " c.commentObjectId =o.commentObjectId and o.commentObjectType = 5";
        List<Map<String, Object>> commentIdLst = findListWithMapByHql(findPeopleCountByHql,CollectionUtils.newObjectMap("topicId", topicId));
        int peopleCount = commentIdLst.size();// 参与人数
        int peopleCount = commentIdLst.size();// 参与人数
        return new Result(true, "success",
                CollectionUtils.newObjectMap("topicId", topicId,"topicType", topic.getTopicType(), "createTime", topic.getCreateTime(), "topicName", topic.getTopicName(), "issuer",
                        topic.getCreator(), "issuerId", topic.getCreateId(), "deadline", topic.getEndTime(),
@@ -168,15 +168,18 @@
    public Result addTopicInfo(TopicInfo topicInfo) {
//       if(topicInfo.getTopicType()==TopicInfo.TOPIC_TYPE_CLS && StringUtils.isEmpty(topicInfo.getClassId())) {
       if(StringUtils.isEmpty(topicInfo.getClassId())) {
          return new Result(false, "请选择关联班级!");
          return new Result(false, "请选择关联班级!");
       }
       String classId = topicInfo.getClassId();
       topicInfo.setTopicId(null);
        topicInfo.setDeleteFlag(false);
        topicInfo.setOrgId(ClientUtils.getOrgId());
        TraceUtils.setCreateTrace(topicInfo);
        if(topicInfo.getStartTime() == null){
            topicInfo.setStartTime(new Date());
        }
        save(topicInfo);
        if(StringUtils.isNotEmpty(classId)){
           String[] classIds = classId.split(",");
            TopicClassRe topicClassRe = null;
@@ -185,10 +188,10 @@
                topicClassRe.setClassId(classIds[i]);
                topicClassRe.setTopicId(topicInfo.getTopicId());
                TraceUtils.setCreateTrace(topicClassRe);
                save(topicClassRe);// 保存到中间表
                save(topicClassRe);// 保存到中间表
            }
        }
        CommentObject commentObject = new CommentObject();
        commentObject.setCommentObjectUid(topicInfo.getTopicId());
        commentObject.setCommentObjectName(topicInfo.getTopicName());
@@ -199,7 +202,7 @@
        commentObject.setCommentCount(initParam);
        commentObject.setCommentPraiseCount(initParam);
        commentObject.setViewCount(initParam);
        save(commentObject);// 创建评论对象
        save(commentObject);// 创建评论对象
        return new Result(true, "add success");
    }
@@ -267,23 +270,23 @@
        Map<String, Object> mapJson = new HashMap<String, Object>();
        String name = clsClass.getName();
        String imgPath = clsClass.getImgPath();
        int topicCount = findCountByComplexHql(// 获取话题条数
        int topicCount = findCountByComplexHql(// 获取话题条数
                "select count(1) from TopicClassRe r  where deleteFlag is false and classId =:classId",
                CollectionUtils.newObjectMap("classId", classId));
        String findTopicIdLst = "select topicId as topicId from TopicClassRe where deleteFlag is false and classId=:classId";
        List<Map<String, Object>> topicIdLst = findListWithMapByHql(findTopicIdLst, // 获取班级所有话题的id
        List<Map<String, Object>> topicIdLst = findListWithMapByHql(findTopicIdLst, // 获取班级所有话题的id
                CollectionUtils.newObjectMap("classId", classId));
        int commentCount = 0;
        int studentCommentCount = 0;
        for (Map<String, Object> map : topicIdLst) {
            String topicId = (String) map.get("topicId");
            CommentObject commentObject = findUnique(// 获取话题的评论条数
            CommentObject commentObject = findUnique(// 获取话题的评论条数
                    "from CommentObject where deleteFlag is false and commentObjectUid = ? and commentObjectType = 5",
                    CollectionUtils.newList(topicId), CommentObject.class);
            BigInteger BigcommentCount = commentObject.getCommentCount();
            int count = BigcommentCount.intValue();
            commentCount += count;
            List<Map<String, Object>> lstCommentId = findListWithMapByHql(// 获取回复话题的评论人数
            List<Map<String, Object>> lstCommentId = findListWithMapByHql(// 获取回复话题的评论人数
                    "select distinct c.commentterId as  commentterId from CommentObject o,Comment c where o.deleteFlag is false and o.commentObjectUid =:topicId and"
                            + " c.commentObjectId =o.commentObjectId and o.commentObjectType = 5",
                    CollectionUtils.newObjectMap("topicId", topicId));
@@ -305,7 +308,7 @@
                + " and c.commentObjectId=o.commentObjectId and o.commentObjectUid =:topicId order by c.createTime desc";
        List<Map<String, Object>> commentLst = findListWithMapByHql(hql,
                CollectionUtils.newObjectMap("topicId", topicId), new Pager(pageSize, pageNum));
        int commentCount = findCountByComplexHql(// 获取总条数
        int commentCount = findCountByComplexHql(// 获取总条数
                "select count(1) from Comment c ,CommentObject o where c.deleteFlag is false and o.deleteFlag is false"
                + "  and c.commentObjectId=o.commentObjectId and o.commentObjectUid =:topicId and o.commentObjectType = 5",
                CollectionUtils.newObjectMap("topicId", topicId));
@@ -317,14 +320,14 @@
            User user = read(User.class, userId);
            String imgPath = user.getImgPath();
            map.put("imgPath", imgPath);
            // 获取每条评论的点赞数 ;
            // 获取每条评论的点赞数 ;
            String findPraiseCountByHql = "select count(1) from CommentPraise where deleteFlag is false and commentId =:commentId";
            int praiseCount = findCountByComplexHql(findPraiseCountByHql,
                    CollectionUtils.newObjectMap("commentId", commentId));
            map.put("praiseCount", praiseCount);
            map.put("commentCount", findCountByComplexHql("select count(1) from Comment where deleteFlag is false and commentParentId =:commentId",
                    CollectionUtils.newObjectMap("commentId", commentId)));
            // 获取回复这个评论的自评论内容
            // 获取回复这个评论的自评论内容
            String findSubCommentDetailByhql = "select commentter as commentter ,content as commentContent ,createTime as commentTime from  Comment "
                    + " where deleteFlag is false and  commentId =:commentParentId ";
            List<Map<String, Object>> subCommentDetail = findListWithMapByHql(findSubCommentDetailByhql,
@@ -378,51 +381,51 @@
        return new Result(true, "success",
                CollectionUtils.newObjectMap("commentLst", commentLst, "commentCount", commentCount));
    }
    @Override
    public Result appMyComment(String userId, Pager pager) {
       QSnsMyComment qSnsMyComment = QSnsMyComment.snsMyComment;
       JPAQuery<SnsMyComment> query = this.getQueryFactory().
             selectFrom(qSnsMyComment).where(qSnsMyComment.createId.eq(userId));
       List<SnsMyComment> lstSnsMyComment = query.orderBy(qSnsMyComment.commentTime.desc())
             .offset(pager.getOffset()).limit(pager.getPageSize()).fetch();
       long commentCount = query.fetchCount();
        return new Result(true, "success",
                CollectionUtils.newObjectMap("dataList", lstSnsMyComment, "count", commentCount));
    }
    @Override
    public Result commentToMe(String userId, Pager pager) {
       QSnsCommentToMe qSnsCommentToMe = QSnsCommentToMe.snsCommentToMe;
      JPAQuery<SnsCommentToMe> query = this.getQueryFactory().
            selectFrom(qSnsCommentToMe).where(qSnsCommentToMe.createId.eq(userId));
      List<SnsCommentToMe> lstSnsMyComment = query.orderBy(qSnsCommentToMe.commentTime.desc())
            .offset(pager.getOffset()).limit(pager.getPageSize()).fetch();
      long commentCount = query.fetchCount();
       return new Result(true, "success",
               CollectionUtils.newObjectMap("dataList", lstSnsMyComment, "count", commentCount));
    }
    @Override
    public Result praiseToMe(String userId, Pager pager) {
       QSnsPraiseToMe qSnsPraiseToMe = QSnsPraiseToMe.snsPraiseToMe;
       JPAQuery<SnsPraiseToMe> query = this.getQueryFactory().
             selectFrom(qSnsPraiseToMe).where(qSnsPraiseToMe.createId.eq(userId));
       List<SnsPraiseToMe> lstSnsMyComment = query.orderBy(qSnsPraiseToMe.praiseTime.desc())
             .offset(pager.getOffset()).limit(pager.getPageSize()).fetch();
       long commentCount = query.fetchCount();
        return new Result(true, "success",
                CollectionUtils.newObjectMap("dataList", lstSnsMyComment, "count", commentCount));
    }
@@ -431,31 +434,31 @@
    @Override
    public Result appMyPraise(String userId, Pager pager) {
       QSnsMyPraise qSnsMyPraise = QSnsMyPraise.snsMyPraise;
       JPAQuery<SnsMyPraise> query = this.getQueryFactory().
             selectFrom(qSnsMyPraise).where(qSnsMyPraise.createId.eq(userId));
       List<SnsMyPraise> lstSnsMyComment = query.orderBy(qSnsMyPraise.praiseTime.desc())
             .offset(pager.getOffset()).limit(pager.getPageSize()).fetch();
       long commentCount = query.fetchCount();
        return new Result(true, "success",
                CollectionUtils.newObjectMap("dataList", lstSnsMyComment, "count", commentCount));
    }
    @Override
    public Result deleteMycomment(String commentId) {
        Comment comment = read(Comment.class, commentId);
        if(!comment.getCreateId().equals(ClientUtils.getUserId())) {
           return new Result(false, "只能删除自己发布的信息");
           return new Result(false, "只能删除自己发布的信息");
        }
        comment.setDeleteFlag(true);
        TraceUtils.setCreateTrace(comment);
        save(comment);// 删除评论表的
        save(comment);// 删除评论表的
        String[] commentIds = commentId.split(",");
        this.bulkUpdateInLoop("update CommentPraise set deleteFlag = true where commentId = ?", commentIds);// 删除对应的点赞
        this.bulkUpdateInLoop("update CommentPraise set deleteFlag = true where commentId = ?", commentIds);// 删除对应的点赞
        return new Result(true, "success");
    }
@@ -512,7 +515,7 @@
        String hql = "from CommentObject where commentObjectUid=? and deleteFlag is false and commentObjectType = 5";
        CommentObject commentObject = findUnique(hql, CollectionUtils.newList(commentObjectId), CommentObject.class);
        BigInteger commentCount = commentObject.getCommentCount();
        commentObject.setCommentCount(commentCount.add(new BigInteger("1")));// 评论+1;
        commentObject.setCommentCount(commentCount.add(new BigInteger("1")));// 评论+1;
        TraceUtils.setUpdateTrace(commentObject);
        save(commentObject);
        Comment comment = new Comment();
@@ -534,7 +537,7 @@
            save(topicInfo);
        } else {
            comment.setCommentParentId(commentParentId);
            this.bulkUpdate("update Comment set commentCount = commentCount + 1 where commentId = ?", new Object[] {commentParentId});
        }
        save(comment);
@@ -543,20 +546,20 @@
    @Override
    public Result addPraise(String commentId, String commentObjectId) {
        if (StringUtils.isBlank(commentId)) {// 点赞话题
        if (StringUtils.isBlank(commentId)) {// 点赞话题
            String hql = "from CommentObject where deleteFlag is false and commentObjectUid = ? and commentObjectType = 5";
            CommentObject commentObject = findUnique(hql, CollectionUtils.newList(commentObjectId),
                    CommentObject.class);
            BigInteger commentPraiseCount = commentObject.getCommentPraiseCount();
            BigInteger one = new BigInteger("1");
            commentObject.setCommentPraiseCount(commentPraiseCount.add(one));// 点赞数+1
            commentObject.setCommentPraiseCount(commentPraiseCount.add(one));// 点赞数+1
            TraceUtils.setCreateTrace(commentObject);
            save(commentObject);
        }else {
           this.bulkUpdate("update Comment set commentPraiseCount = commentPraiseCount + 1 where commentId = ?", new Object[] {commentId});
        }
        CommentPraise commentPraise = new CommentPraise();
        commentPraise.setCommentId(commentId);
        commentPraise.setCommentObjectId(commentObjectId);
@@ -564,8 +567,8 @@
        commentPraise.setCommentterId(ClientUtils.getUserId());
        commentPraise.setCommentter(ClientUtils.getUserName());
        TraceUtils.setCreateTrace(commentPraise);
        save(commentPraise);// 保存到点赞表
        save(commentPraise);// 保存到点赞表
        return new Result(true, "success");
    }
@@ -574,51 +577,51 @@
        QCommentObject qCommentObject = QCommentObject.commentObject;
        QComment qComment = QComment.comment;
        QCommentPraise qCommentPraise = QCommentPraise.commentPraise;
        //我发的讨论数量
        //我发的讨论数量
        long topicCount = this.getQueryFactory().selectFrom(qTopicInfo).where(qTopicInfo.deleteFlag.isFalse().and(qTopicInfo.createId.eq(userId))).fetchCount();
        //我发的讨论的评论数
        //我发的讨论的评论数
      long topicCommentToMeCount = this.getQueryFactory().select(qCommentObject.commentCount.sum()).from(qCommentObject)
            .where(qCommentObject.deleteFlag.isFalse().and(qCommentObject.createId.eq(userId))
                  .and(qCommentObject.commentObjectType.eq(CommentObject.COMMENT_TYPE_INTERACT)))
            .fetchCount();
      //我发的评论的评论数
      //我发的评论的评论数
      long commentToMeCount = this.getQueryFactory().selectDistinct(qComment.commentId).from(qCommentObject, qComment)
            .where(qComment.deleteFlag.isFalse().and(qCommentObject.deleteFlag.isFalse())
                  .and(qCommentObject.createId.eq(userId)).and(qCommentObject.commentObjectUid.eq(qComment.commentObjectId))
                  .and(qCommentObject.commentObjectType.eq(CommentObject.COMMENT_TYPE_INTERACT)).and(qComment.commentParentId.isNotNull()))
            .fetchCount();
      //我评论的讨论的评论数
      //我评论的讨论的评论数
      long topicCommentCount = this.getQueryFactory().selectDistinct(qComment.commentId).from(qCommentObject, qComment)
            .where(qComment.deleteFlag.isFalse().and(qCommentObject.deleteFlag.isFalse())
                  .and(qComment.createId.eq(userId)).and(qCommentObject.commentObjectUid.eq(qComment.commentObjectId))
                  .and(qCommentObject.commentObjectType.eq(CommentObject.COMMENT_TYPE_INTERACT)).and(qComment.commentParentId.isNotNull()))
            .fetchCount();
      //我评论的数
      //我评论的数
      long commentCount = this.getQueryFactory().selectDistinct(qComment.commentId).from(qCommentObject, qComment)
            .where(qComment.deleteFlag.isFalse().and(qCommentObject.deleteFlag.isFalse())
                  .and(qComment.createId.eq(userId)).and(qCommentObject.commentObjectUid.eq(qComment.commentObjectId))
                  .and(qCommentObject.commentObjectType.eq(CommentObject.COMMENT_TYPE_INTERACT)).and(qComment.commentParentId.isNotNull()))
            .fetchCount();
      //我对讨论的点赞数
      //我对讨论的点赞数
      long topicPraise = this.getQueryFactory().selectDistinct(qCommentPraise.commentPraiseId).from(qCommentObject, qCommentPraise)
            .where(qCommentObject.deleteFlag.isFalse().and(qCommentPraise.createId.eq(userId))
                  .and(qCommentPraise.commentObjectId.eq(qCommentObject.commentObjectId)).and(qCommentPraise.deleteFlag.isFalse())
                  .and(qCommentObject.commentObjectType.eq(CommentObject.COMMENT_TYPE_INTERACT)))
            .fetchCount();
        //我对评论的点赞数
        //我对评论的点赞数
        long commentPraise = this.getQueryFactory().selectDistinct(qCommentPraise.commentPraiseId).from(qCommentObject, qComment, qCommentPraise)
            .where(qComment.deleteFlag.isFalse().and(qCommentObject.deleteFlag.isFalse()).and(qCommentPraise.commentId.eq(qComment.commentId))
                  .and(qCommentPraise.createId.eq(userId)).and(qCommentObject.commentObjectUid.eq(qComment.commentObjectId)).and(qCommentPraise.deleteFlag.isFalse())
                  .and(qCommentObject.commentObjectType.eq(CommentObject.COMMENT_TYPE_INTERACT)))
            .fetchCount();
        //我的讨论的点赞数
        //我的讨论的点赞数
        long topicPraiseToMe = this.getQueryFactory().select(qCommentObject.commentPraiseCount.sum()).from(qCommentObject)
            .where(qCommentObject.deleteFlag.isFalse().and(qCommentObject.createId.eq(userId))
                  .and(qCommentObject.commentObjectType.eq(CommentObject.COMMENT_TYPE_INTERACT)))
            .fetchCount();
        //我的讨论的点赞数
        //我的讨论的点赞数
        long commentPraiseToMe = this.getQueryFactory().selectDistinct(qCommentPraise.commentPraiseId).from(qCommentObject, qComment, qCommentPraise)
            .where(qComment.deleteFlag.isFalse().and(qCommentObject.deleteFlag.isFalse()).and(qCommentPraise.commentId.eq(qComment.commentId))
                  .and(qComment.createId.eq(userId)).and(qCommentObject.commentObjectUid.eq(qComment.commentObjectId)).and(qCommentPraise.deleteFlag.isFalse())
@@ -645,9 +648,9 @@
            save(topicInfo);
        }
        bulkUpdateInLoop("update Comment set deleteFlag = true where commentId = ?", topicIds);// 删除话题对应的评论;
        bulkUpdateInLoop("update Comment set deleteFlag = true where commentId = ?", topicIds);// 删除话题对应的评论;
        bulkUpdateInLoop("update TopicClassRe set deleteFlag = true where topicId = ?", topicIds);// 删除话题对应的班级;
        bulkUpdateInLoop("update TopicClassRe set deleteFlag = true where topicId = ?", topicIds);// 删除话题对应的班级;
        return new Result(true, "success");
    }
@@ -674,29 +677,30 @@
        List<Map<String, Object>> topicLst = findListWithMapByHql(hql, hqlMap, new Pager(pageSize, pageNum));
        int sunCount=0;
        for (Map<String, Object> map : topicLst) {
            String topicId = (String) map.get("topicId");
            String findPeopleCountByHql = "select distinct c.commentterId as commentterId from CommentObject o,Comment c where o.deleteFlag is false and o.commentObjectUid =:topicId and"
                    + " c.commentObjectId =o.commentObjectId and o.commentObjectType = 5";
            List<Map<String, Object>> commentIdLst = findListWithMapByHql(findPeopleCountByHql,
                    CollectionUtils.newObjectMap("topicId", topicId));
            int peopleCount = commentIdLst.size();// 参与人数
            int peopleCount = commentIdLst.size();// 参与人数
            sunCount+=peopleCount;
            map.put("peopleCount", peopleCount);
        }
        return new Result(true, "success",
                CollectionUtils.newObjectMap("topicLst", topicLst, "topicCount", topicCount));
        return new Result(true, "success",CollectionUtils.newObjectMap("topicLst", topicLst, "topicCount", topicCount,"sunCount",sunCount));
    }
    @Override
    public Result updateTopicInfo(TopicInfo editTopicInfo) {
//       if(editTopicInfo.getTopicType()==TopicInfo.TOPIC_TYPE_CLS && StringUtils.isEmpty(editTopicInfo.getClassId())) {
       if(StringUtils.isEmpty(editTopicInfo.getClassId())) {
          return new Result(false, "请选择关联班级!");
          return new Result(false, "请选择关联班级!");
       }
        TopicInfo topicInfo = read(TopicInfo.class, editTopicInfo.getTopicId());
        this.bulkUpdate("update TopicClassRe set deleteFlag = true where topicId = ?", new Object[] {topicInfo.getTopicId()});// 删除对应的中间表数据
        this.bulkUpdate("update TopicClassRe set deleteFlag = true where topicId = ?", new Object[] {topicInfo.getTopicId()});// 删除对应的中间表数据
        topicInfo.setTopicName(editTopicInfo.getTopicName());
        topicInfo.setTopicType(editTopicInfo.getTopicType());
        topicInfo.setTopicDesc(editTopicInfo.getTopicDesc());
@@ -706,7 +710,7 @@
        topicInfo.setDeleteFlag(false);
        TraceUtils.setUpdateTrace(topicInfo);
        save(topicInfo);
        if(StringUtils.isNotEmpty(topicInfo.getClassId())){
           String[] classIds = topicInfo.getClassId().split(",");
            TopicClassRe topicClassRe = null;
@@ -715,7 +719,7 @@
                topicClassRe.setClassId(classIds[i]);
                topicClassRe.setTopicId(editTopicInfo.getTopicId());
                TraceUtils.setCreateTrace(topicClassRe);
                save(topicClassRe);// 保存到中间表
                save(topicClassRe);// 保存到中间表
            }
        }
        return new Result(true, "success");
@@ -751,17 +755,17 @@
                    + " c.commentObjectId =o.commentObjectId and o.commentObjectType = 5";
            List<Map<String, Object>> commentIdLst = findListWithMapByHql(findPeopleCountByHql,
                    CollectionUtils.newObjectMap("topicId", topicId));
            int peopleCount = commentIdLst.size();// 参与人数
            int peopleCount = commentIdLst.size();// 参与人数
            map.put("peopleCount", peopleCount);
        }
        return new Result(true, "success",
                CollectionUtils.newObjectMap("topicLst", topicLst, "topicCount", topicCount));
    }
    /**
     * 获取班级讨论数量
     *
     * 获取班级讨论数量
     *
     * @param classId
     * @return
     */
@@ -769,13 +773,13 @@
       if(StringUtils.isEmpty(classId)){
          return 0L;
       }
       QTopicInfo qTopicInfo = QTopicInfo.topicInfo;
      QTopicClassRe qTopicClassRe = QTopicClassRe.topicClassRe;
      QCommentObject qCommentObject = QCommentObject.commentObject;
      QClsClass qClsClass = QClsClass.clsClass;
      QUser qUser = QUser.user;
       JPAQuery<Long> query = this.getQueryFactory().select(qTopicInfo.topicId.countDistinct()).from(qTopicInfo, qTopicClassRe, qCommentObject, qClsClass, qUser )
            .where(qTopicInfo.deleteFlag.isFalse().and(qTopicClassRe.deleteFlag.isFalse()).and(qUser.userId.eq(qTopicInfo.createId))
                  .and(qCommentObject.deleteFlag.isFalse()).and(qTopicClassRe.topicId.eq(qTopicInfo.topicId))
@@ -784,16 +788,16 @@
                  .and(qCommentObject.commentObjectUid.eq(qTopicInfo.topicId)).and(
                        qTopicInfo.createTime.after(new Date(new Date().getTime() - 1000L * 60 * 60 * 24 * 30 * 12)))
                  .and(qCommentObject.commentObjectType.eq(CommentObject.COMMENT_TYPE_INTERACT))).groupBy(qTopicInfo.topicId);
       return query.fetchCount();
    }
    /**
     * 获取热门话题列表
     *
     * type 1热门,2最近
     * scope 1班级,2机构
     *
     * 获取热门话题列表
     *
     * type 1热门,2最近
     * scope 1班级,2机构
     *
     */
    @CachePut(value = "topic_list", key = "#classId+#keyword+#limit+#pageNum+#type+#scope")
   public Map<String, Object> getHotTopicLst(String classId, String keyword, Integer limit, Integer pageNum, int type, int scope){
@@ -803,17 +807,17 @@
      QClsClass qClsClass = QClsClass.clsClass;
      QUser qUser = QUser.user;
      //热门取最近30天内,否则取1年内
      //热门取最近30天内,否则取1年内
      long time = type == 1 ? 1000L * 60 * 60 * 24 * 30 : 1000L * 60 * 60 * 24 * 30 * 12;
      //讨论的范围
      //讨论的范围
      Predicate scopeRight = scope == 1?qClsClass.classId.eq(classId):qClsClass.orgId.eq(ClientUtils.getOrgId());
      @SuppressWarnings("rawtypes")
      //排序方式
      //排序方式
      OrderSpecifier order = type == 1?new OrderSpecifier<BigInteger>(Order.DESC, qCommentObject.commentCount.add(qCommentObject.commentPraiseCount)):
         new OrderSpecifier<Date>(Order.DESC, qTopicInfo.createTime);
      JPAQuery<Tuple> query = this.getQueryFactory().select(qTopicInfo, qCommentObject, qClsClass, qUser).from(qTopicInfo, qTopicClassRe, qCommentObject, qClsClass, qUser )
            .where(qTopicInfo.deleteFlag.isFalse().and(qTopicClassRe.deleteFlag.isFalse()).and(qUser.userId.eq(qTopicInfo.createId))
                  .and(qCommentObject.deleteFlag.isFalse()).and(qTopicClassRe.topicId.eq(qTopicInfo.topicId)).and(qClsClass.deleteFlag.isFalse())
@@ -822,9 +826,9 @@
                  .and(qCommentObject.commentObjectUid.eq(qTopicInfo.topicId).and(
                        qTopicInfo.createTime.after(new Date(new Date().getTime() - time))))
                  .and(qCommentObject.commentObjectType.eq(CommentObject.COMMENT_TYPE_INTERACT))).groupBy(qTopicInfo.topicId);
      long count = query.fetchCount();
      return CollectionUtils.newObjectMap("count", count, "listData", query.offset(pageNum).limit(limit)
            .orderBy(order, qTopicInfo.createTime.desc()).fetch().stream()
            .map(tuple -> {
@@ -846,8 +850,8 @@
               map.put("commentPraiseCount", tuple.get(qCommentObject).getCommentPraiseCount());
               map.put("className", tuple.get(qClsClass).getName());
               return map;
            }).collect(Collectors.toList()));
            }).collect(Collectors.toList()));
   }
}