| | |
| | | import com.qxueyou.scc.user.service.IUserService; |
| | | |
| | | /** |
| | | * 话题服务层 |
| | | * 话题服务层 |
| | | * |
| | | * @author chenjunliang |
| | | */ |
| | |
| | | + " 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", |
| | |
| | | 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); |
| | |
| | | + " 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", |
| | |
| | | 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); |
| | |
| | | topicClassRe.setClassId(classIds[i]); |
| | | topicClassRe.setTopicId(topicInfo.getTopicId()); |
| | | TraceUtils.setCreateTrace(topicClassRe); |
| | | save(topicClassRe);// 保存到中间表 |
| | | save(topicClassRe);// 保存到中间表 |
| | | } |
| | | } |
| | | |
| | |
| | | commentObject.setCommentCount(initParam); |
| | | commentObject.setCommentPraiseCount(initParam); |
| | | commentObject.setViewCount(initParam); |
| | | save(commentObject);// 创建评论对象 |
| | | save(commentObject);// 创建评论对象 |
| | | return new Result(true, "add success"); |
| | | } |
| | | |
| | |
| | | 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)); |
| | |
| | | + " 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)); |
| | |
| | | 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, |
| | |
| | | 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"); |
| | | } |
| | |
| | | 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(); |
| | |
| | | |
| | | @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); |
| | | |
| | |
| | | commentPraise.setCommentterId(ClientUtils.getUserId()); |
| | | commentPraise.setCommentter(ClientUtils.getUserName()); |
| | | TraceUtils.setCreateTrace(commentPraise); |
| | | save(commentPraise);// 保存到点赞表 |
| | | save(commentPraise);// 保存到点赞表 |
| | | |
| | | return new Result(true, "success"); |
| | | } |
| | |
| | | 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()) |
| | |
| | | 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"); |
| | | } |
| | |
| | | + " 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", |
| | |
| | | |
| | | // 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()); |
| | |
| | | topicClassRe.setClassId(classIds[i]); |
| | | topicClassRe.setTopicId(editTopicInfo.getTopicId()); |
| | | TraceUtils.setCreateTrace(topicClassRe); |
| | | save(topicClassRe);// 保存到中间表 |
| | | save(topicClassRe);// 保存到中间表 |
| | | } |
| | | } |
| | | return new Result(true, "success"); |
| | |
| | | + " 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", |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取班级讨论数量 |
| | | * 获取班级讨论数量 |
| | | * |
| | | * @param classId |
| | | * @return |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取热门话题列表 |
| | | * 获取热门话题列表 |
| | | * |
| | | * type 1热门,2最近 |
| | | * scope 1班级,2机构 |
| | | * type 1热门,2最近 |
| | | * scope 1班级,2机构 |
| | | * |
| | | */ |
| | | @CachePut(value = "topic_list", key = "#classId+#keyword+#limit+#pageNum+#type+#scope") |
| | |
| | | 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); |
| | | |