From 1c38c12ef967b754dcbcfed69c8d7739003a69ca Mon Sep 17 00:00:00 2001 From: Administrator <2863138610@qq.com> Date: 星期三, 14 十二月 2022 11:13:36 +0800 Subject: [PATCH] 修复讨论区长期有效的话题不显示发布时间的问题 --- src/main/java/com/qxueyou/scc/operation/topic/service/impl/TopicService.java | 183 +++++++++++++++++++++++---------------------- 1 files changed, 93 insertions(+), 90 deletions(-) diff --git a/src/main/java/com/qxueyou/scc/operation/topic/service/impl/TopicService.java b/src/main/java/com/qxueyou/scc/operation/topic/service/impl/TopicService.java index 8daafa1..6273da7 100644 --- a/src/main/java/com/qxueyou/scc/operation/topic/service/impl/TopicService.java +++ b/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"); } @@ -680,7 +683,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", @@ -689,14 +692,14 @@ @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 +709,7 @@ topicInfo.setDeleteFlag(false); TraceUtils.setUpdateTrace(topicInfo); save(topicInfo); - + if(StringUtils.isNotEmpty(topicInfo.getClassId())){ String[] classIds = topicInfo.getClassId().split(","); TopicClassRe topicClassRe = null; @@ -715,7 +718,7 @@ topicClassRe.setClassId(classIds[i]); topicClassRe.setTopicId(editTopicInfo.getTopicId()); TraceUtils.setCreateTrace(topicClassRe); - save(topicClassRe);// 保存到中间表 + save(topicClassRe);// 淇濆瓨鍒颁腑闂磋〃 } } return new Result(true, "success"); @@ -751,17 +754,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 +772,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 +787,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 +806,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 +825,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 +849,8 @@ map.put("commentPraiseCount", tuple.get(qCommentObject).getCommentPraiseCount()); map.put("className", tuple.get(qClsClass).getName()); return map; - }).collect(Collectors.toList())); - + }).collect(Collectors.toList())); + } } -- Gitblit v1.8.0