From 068fc7f2e81178e55fa191a13709af64b1a163f6 Mon Sep 17 00:00:00 2001 From: EricsHu <hrr145632> Date: 星期一, 05 十二月 2022 14:27:43 +0800 Subject: [PATCH] 处理编码 --- src/main/java/com/qxueyou/scc/operation/topic/service/impl/TopicService.java | 88 ++++++++++++++++++++++---------------------- 1 files changed, 44 insertions(+), 44 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..e7827ed 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,7 +136,7 @@ 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); @@ -154,7 +154,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();// 鍙備笌浜烘暟 return new Result(true, "success", CollectionUtils.newObjectMap("topicId", topicId,"topicType", topic.getTopicType(), "createTime", topic.getCreateTime(), "topicName", topic.getTopicName(), "issuer", @@ -168,7 +168,7 @@ 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); @@ -185,7 +185,7 @@ topicClassRe.setClassId(classIds[i]); topicClassRe.setTopicId(topicInfo.getTopicId()); TraceUtils.setCreateTrace(topicClassRe); - save(topicClassRe);// 保存到中间表 + save(topicClassRe);// 淇濆瓨鍒颁腑闂磋〃 } } @@ -199,7 +199,7 @@ commentObject.setCommentCount(initParam); commentObject.setCommentPraiseCount(initParam); commentObject.setViewCount(initParam); - save(commentObject);// 创建评论对象 + save(commentObject);// 鍒涘缓璇勮瀵硅薄 return new Result(true, "add success"); } @@ -267,23 +267,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 +305,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 +317,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, @@ -448,14 +448,14 @@ 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 +512,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(); @@ -543,13 +543,13 @@ @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); @@ -564,7 +564,7 @@ commentPraise.setCommentterId(ClientUtils.getUserId()); commentPraise.setCommentter(ClientUtils.getUserName()); TraceUtils.setCreateTrace(commentPraise); - save(commentPraise);// 保存到点赞表 + save(commentPraise);// 淇濆瓨鍒扮偣璧炶〃 return new Result(true, "success"); } @@ -574,51 +574,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 +645,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 +680,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", @@ -692,11 +692,11 @@ // 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()); @@ -715,7 +715,7 @@ topicClassRe.setClassId(classIds[i]); topicClassRe.setTopicId(editTopicInfo.getTopicId()); TraceUtils.setCreateTrace(topicClassRe); - save(topicClassRe);// 保存到中间表 + save(topicClassRe);// 淇濆瓨鍒颁腑闂磋〃 } } return new Result(true, "success"); @@ -751,7 +751,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", @@ -760,7 +760,7 @@ } /** - * 获取班级讨论数量 + * 鑾峰彇鐝骇璁ㄨ鏁伴噺 * * @param classId * @return @@ -789,10 +789,10 @@ } /** - * 获取热门话题列表 + * 鑾峰彇鐑棬璇濋鍒楄〃 * - * type 1热门,2最近 - * scope 1班级,2机构 + * type 1鐑棬锛�2鏈�杩� + * scope 1鐝骇锛�2鏈烘瀯 * */ @CachePut(value = "topic_list", key = "#classId+#keyword+#limit+#pageNum+#type+#scope") @@ -803,14 +803,14 @@ 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); -- Gitblit v1.8.0