| | |
| | | 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( |
| | |
| | | |
| | | List<Map<String, Object>> commentIdLst = findListWithMapByHql(findPeopleCountByHql,CollectionUtils.newObjectMap("topicId", topicId)); |
| | | 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(), |
| | |
| | | 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; |
| | |
| | | save(topicClassRe);// 保存到中间表 |
| | | } |
| | | } |
| | | |
| | | |
| | | CommentObject commentObject = new CommentObject(); |
| | | commentObject.setCommentObjectUid(topicInfo.getTopicId()); |
| | | commentObject.setCommentObjectName(topicInfo.getTopicName()); |
| | |
| | | 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)); |
| | | } |
| | |
| | | @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); |
| | |
| | | save(topicInfo); |
| | | } else { |
| | | comment.setCommentParentId(commentParentId); |
| | | |
| | | |
| | | this.bulkUpdate("update Comment set commentCount = commentCount + 1 where commentId = ?", new Object[] {commentParentId}); |
| | | } |
| | | save(comment); |
| | |
| | | }else { |
| | | this.bulkUpdate("update Comment set commentPraiseCount = commentPraiseCount + 1 where commentId = ?", new Object[] {commentId}); |
| | | } |
| | | |
| | | |
| | | CommentPraise commentPraise = new CommentPraise(); |
| | | commentPraise.setCommentId(commentId); |
| | | commentPraise.setCommentObjectId(commentObjectId); |
| | |
| | | commentPraise.setCommentter(ClientUtils.getUserName()); |
| | | TraceUtils.setCreateTrace(commentPraise); |
| | | save(commentPraise);// 保存到点赞表 |
| | | |
| | | |
| | | return new Result(true, "success"); |
| | | } |
| | | |
| | |
| | | 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.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()) |
| | |
| | | |
| | | @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, "请选择关联班级!"); |
| | |
| | | topicInfo.setDeleteFlag(false); |
| | | TraceUtils.setUpdateTrace(topicInfo); |
| | | save(topicInfo); |
| | | |
| | | |
| | | if(StringUtils.isNotEmpty(topicInfo.getClassId())){ |
| | | String[] classIds = topicInfo.getClassId().split(","); |
| | | TopicClassRe topicClassRe = null; |
| | |
| | | CollectionUtils.newObjectMap("topicLst", topicLst, "topicCount", topicCount)); |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取班级讨论数量 |
| | | * |
| | | * |
| | | * @param classId |
| | | * @return |
| | | */ |
| | |
| | | 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)) |
| | |
| | | .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机构 |
| | | * |
| | | * |
| | | */ |
| | | @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){ |
| | |
| | | |
| | | //热门取最近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()) |
| | |
| | | .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 -> { |
| | |
| | | map.put("commentPraiseCount", tuple.get(qCommentObject).getCommentPraiseCount()); |
| | | map.put("className", tuple.get(qClsClass).getName()); |
| | | return map; |
| | | }).collect(Collectors.toList())); |
| | | |
| | | }).collect(Collectors.toList())); |
| | | |
| | | } |
| | | |
| | | } |