|
|
|
|
@ -3,6 +3,7 @@ package com.hpjpw.idoapp.service;
|
|
|
|
|
import com.hpjpw.ido.domain.CheerComment;
|
|
|
|
|
import com.hpjpw.ido.domain.CheerMoment;
|
|
|
|
|
import com.hpjpw.ido.domain.CheerThumb;
|
|
|
|
|
import com.hpjpw.ido.domain.Topic;
|
|
|
|
|
import com.hpjpw.ido.service.ICheerCommentService;
|
|
|
|
|
import com.hpjpw.ido.service.ICheerMomentService;
|
|
|
|
|
import com.hpjpw.ido.service.ICheerThumbService;
|
|
|
|
|
@ -12,7 +13,10 @@ import com.ruoyi.system.service.ISysUserService;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class IDoCheerService {
|
|
|
|
|
@ -27,73 +31,70 @@ public class IDoCheerService {
|
|
|
|
|
@Autowired
|
|
|
|
|
ITopicService topicService;
|
|
|
|
|
|
|
|
|
|
/* 将所有返回动态相关信息存到map中 */
|
|
|
|
|
public Map<String, Object> momentMap(CheerMoment item){
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
/* 返回动态id,动态发布者id/姓名/头像,动态主题内容,动态内容及图片,动态发布时间 */
|
|
|
|
|
map.put("id", item.getId());
|
|
|
|
|
map.put("reportId", item.getReportId());
|
|
|
|
|
map.put("reportName", sysUserService.selectUserById(item.getReportId()).getNickName());
|
|
|
|
|
map.put("reportAvatar", sysUserService.selectUserById(item.getReportId()).getAvatar());
|
|
|
|
|
/* 没有主题则传null值 */
|
|
|
|
|
Long topicId = item.getTopicId();
|
|
|
|
|
if (StringUtils.isNotNull(topicId)) {
|
|
|
|
|
Topic topic = topicService.selectTopicById(topicId);
|
|
|
|
|
if (StringUtils.isNotNull(topic)) {
|
|
|
|
|
map.put("topic", topic.getContent());
|
|
|
|
|
} else {
|
|
|
|
|
map.put("topic", null);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
map.put("topic", null);
|
|
|
|
|
}
|
|
|
|
|
map.put("content", item.getContent());
|
|
|
|
|
map.put("picture1", item.getPicture1());
|
|
|
|
|
map.put("picture2", item.getPicture2());
|
|
|
|
|
map.put("picture3", item.getPicture3());
|
|
|
|
|
map.put("time", item.getTime());
|
|
|
|
|
/* 返回所有点赞id,点赞者id和姓名,以及点赞总数量 */
|
|
|
|
|
List<Map<String, String>> thumbList = new ArrayList<>();
|
|
|
|
|
CheerThumb cheerThumb = new CheerThumb();
|
|
|
|
|
cheerThumb.setMomentId(item.getId());
|
|
|
|
|
List<CheerThumb> cheerThumbList = cheerThumbService.selectCheerThumbList(cheerThumb);
|
|
|
|
|
for (CheerThumb thumb : cheerThumbList) {
|
|
|
|
|
Map<String, String> mapOfThumb = new HashMap<>();
|
|
|
|
|
mapOfThumb.put("thumbId", thumb.getId());
|
|
|
|
|
mapOfThumb.put("thumbedId", thumb.getThumbedId().toString());
|
|
|
|
|
mapOfThumb.put("thumbedName", thumb.getThumbedName());
|
|
|
|
|
thumbList.add(mapOfThumb);
|
|
|
|
|
}
|
|
|
|
|
map.put("thumbNum", cheerThumbList.size());
|
|
|
|
|
map.put("thumbs", thumbList);
|
|
|
|
|
/* 返回所有评论,具体评论id、评论者id、名称、头像、评论内容以及总评论数 */
|
|
|
|
|
List<Map<String, String>> commentList = new ArrayList<>();
|
|
|
|
|
CheerComment cheerComment = new CheerComment();
|
|
|
|
|
cheerComment.setMomentId(item.getId());
|
|
|
|
|
List<CheerComment> cheerCommentList = cheerCommentService.selectCheerCommentList(cheerComment);
|
|
|
|
|
for (int i = 0; i < cheerCommentList.size(); i++) {
|
|
|
|
|
IDoPersonalMomentService.getCheerComment(commentList, cheerCommentList, i, sysUserService);
|
|
|
|
|
}
|
|
|
|
|
map.put("commentNum", cheerCommentList.size());
|
|
|
|
|
map.put("comments", commentList);
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 针对前端的加油站动态请求服务,一次性返回相关数据 */
|
|
|
|
|
public List<Map<String,Object>> momentListReSponse(){
|
|
|
|
|
public List<Map<String, Object>> momentListResponse() {
|
|
|
|
|
/* 实际返回的列表 */
|
|
|
|
|
List<Map<String,Object>> listReturn = new ArrayList<>();
|
|
|
|
|
List<Map<String, Object>> listReturn = new ArrayList<>();
|
|
|
|
|
/* 获取所有动态 */
|
|
|
|
|
List<CheerMoment> cheerMomentList = cheerMomentService.selectCheerMomentList(new CheerMoment());
|
|
|
|
|
System.out.println("cheerMomentList=>"+cheerMomentList);
|
|
|
|
|
CheerMoment cheerMoment = new CheerMoment();
|
|
|
|
|
cheerMoment.setStatus("1");
|
|
|
|
|
List<CheerMoment> cheerMomentList = cheerMomentService.selectCheerMomentList(cheerMoment);
|
|
|
|
|
System.out.println("cheerMomentList=>" + cheerMomentList);
|
|
|
|
|
/* 对每一条加油站动态插入map数据 */
|
|
|
|
|
for (CheerMoment item :cheerMomentList) {
|
|
|
|
|
/* 审核通过 */
|
|
|
|
|
if (item.getStatus().equals("1")){
|
|
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
|
|
/* 返回动态id,动态发布者id/姓名/头像,动态主题内容,动态内容及图片,动态发布时间 */
|
|
|
|
|
map.put("id",item.getId());
|
|
|
|
|
map.put("reportId",item.getReportId());
|
|
|
|
|
map.put("reportName",sysUserService.selectUserById(item.getReportId()).getNickName());
|
|
|
|
|
map.put("reportAvatar",sysUserService.selectUserById(item.getReportId()).getAvatar());
|
|
|
|
|
/* 没有主题则传null值 */
|
|
|
|
|
if (StringUtils.isNotNull(item.getTopicId())){
|
|
|
|
|
map.put("topic",topicService.selectTopicById(item.getTopicId()).getContent());
|
|
|
|
|
}else {
|
|
|
|
|
map.put("topic",null);
|
|
|
|
|
}
|
|
|
|
|
map.put("content",item.getContent());
|
|
|
|
|
map.put("picture1",item.getPicture1());
|
|
|
|
|
map.put("picture2",item.getPicture2());
|
|
|
|
|
map.put("picture3",item.getPicture3());
|
|
|
|
|
map.put("time",item.getTime());
|
|
|
|
|
/* 返回所有点赞id,点赞者id和姓名,以及点赞总数量 */
|
|
|
|
|
List<Map<String,String>> thumbList = new ArrayList<>();
|
|
|
|
|
CheerThumb cheerThumb = new CheerThumb();
|
|
|
|
|
cheerThumb.setMomentId(item.getId());
|
|
|
|
|
List<CheerThumb> cheerThumbList = cheerThumbService.selectCheerThumbList(cheerThumb);
|
|
|
|
|
for (CheerThumb thumb :cheerThumbList) {
|
|
|
|
|
Map<String,String> mapOfThumb = new HashMap<>();
|
|
|
|
|
mapOfThumb.put("thumbId",thumb.getId());
|
|
|
|
|
mapOfThumb.put("thumbedId",thumb.getThumbedId().toString());
|
|
|
|
|
mapOfThumb.put("thumbedName", thumb.getThumbedName());
|
|
|
|
|
thumbList.add(mapOfThumb);
|
|
|
|
|
}
|
|
|
|
|
map.put("thumbNum",cheerThumbList.size());
|
|
|
|
|
map.put("thumbs",thumbList);
|
|
|
|
|
/* 默认返回最多3条评论,返回具体评论id、评论者id、名称、头像、评论内容以及总评论数 */
|
|
|
|
|
/* 修改>>返回所有评论数据 */
|
|
|
|
|
List<Map<String,String>> commentList = new ArrayList<>();
|
|
|
|
|
CheerComment cheerComment = new CheerComment();
|
|
|
|
|
cheerComment.setMomentId(item.getId());
|
|
|
|
|
List<CheerComment> cheerCommentList = cheerCommentService.selectCheerCommentList(cheerComment);
|
|
|
|
|
int defaultComment = cheerCommentList.size();
|
|
|
|
|
for (int i = 0; i < defaultComment; i++) {
|
|
|
|
|
/* 如果当前评论为空则直接退出 */
|
|
|
|
|
/*if (i>=cheerCommentList.size()){
|
|
|
|
|
break;
|
|
|
|
|
}*/
|
|
|
|
|
CheerComment comment = cheerCommentList.get(i);
|
|
|
|
|
Map<String,String> mapOfComment = new HashMap<>();
|
|
|
|
|
mapOfComment.put("commentId",comment.getId().toString());
|
|
|
|
|
mapOfComment.put("commentatorId",comment.getFromId().toString());
|
|
|
|
|
mapOfComment.put("commentatorName",sysUserService.selectUserById(comment.getFromId()).getNickName());
|
|
|
|
|
mapOfComment.put("commentatorAvatar",sysUserService.selectUserById(comment.getFromId()).getAvatar());
|
|
|
|
|
mapOfComment.put("content", comment.getContent());
|
|
|
|
|
commentList.add(mapOfComment);
|
|
|
|
|
}
|
|
|
|
|
map.put("commentNum",cheerCommentList.size());
|
|
|
|
|
map.put("comments",commentList);
|
|
|
|
|
listReturn.add(map);
|
|
|
|
|
}
|
|
|
|
|
for (CheerMoment item : cheerMomentList) {
|
|
|
|
|
listReturn.add(momentMap(item));
|
|
|
|
|
}
|
|
|
|
|
/* 对结果做一次反转,即按照最近的时间排序,并将此结果返回 */
|
|
|
|
|
/*Collections.reverse(listReturn);*/
|
|
|
|
|
@ -101,78 +102,32 @@ public class IDoCheerService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 针对前端的撕逼墙具体动态的评论请求服务 */
|
|
|
|
|
public List<Map<String,String>> commentListResponse(Long momentId){
|
|
|
|
|
public List<Map<String, String>> commentListResponse(Long momentId) {
|
|
|
|
|
CheerComment cheerComment = new CheerComment();
|
|
|
|
|
cheerComment.setMomentId(momentId);
|
|
|
|
|
List<CheerComment> cheerCommentList = cheerCommentService.selectCheerCommentList(cheerComment);
|
|
|
|
|
List<Map<String,String>> listReturn = new ArrayList<>();
|
|
|
|
|
List<Map<String, String>> listReturn = new ArrayList<>();
|
|
|
|
|
/* 返回每一条评论的动态id,评论id,评论内容,评论者id,评论者姓名,评论者头像 */
|
|
|
|
|
for (CheerComment item :cheerCommentList) {
|
|
|
|
|
Map<String,String> map = new HashMap<>();
|
|
|
|
|
map.put("momentId",item.getMomentId().toString());
|
|
|
|
|
map.put("commentId",item.getId().toString());
|
|
|
|
|
map.put("content",item.getContent());
|
|
|
|
|
map.put("commentatorId",item.getFromId().toString());
|
|
|
|
|
map.put("commentatorName",sysUserService.selectUserById(item.getFromId()).getNickName());
|
|
|
|
|
map.put("commentatorAvatar",sysUserService.selectUserById(item.getFromId()).getAvatar());
|
|
|
|
|
for (CheerComment item : cheerCommentList) {
|
|
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
|
|
map.put("momentId", item.getMomentId().toString());
|
|
|
|
|
map.put("commentId", item.getId().toString());
|
|
|
|
|
map.put("content", item.getContent());
|
|
|
|
|
map.put("commentatorId", item.getFromId().toString());
|
|
|
|
|
map.put("commentatorName", sysUserService.selectUserById(item.getFromId()).getNickName());
|
|
|
|
|
map.put("commentatorAvatar", sysUserService.selectUserById(item.getFromId()).getAvatar());
|
|
|
|
|
listReturn.add(map);
|
|
|
|
|
}
|
|
|
|
|
return listReturn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 针对某一动态id(此处确定存在此动态,controller中添加安全校验),返回该动态所有内容 */
|
|
|
|
|
public Map<String,Object> momentResponse(Long momentId){
|
|
|
|
|
public Map<String, Object> momentResponse(Long momentId) {
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
CheerMoment item = cheerMomentService.selectCheerMomentById(momentId);
|
|
|
|
|
/* 审核通过 */
|
|
|
|
|
if (item.getStatus().equals("1")) {
|
|
|
|
|
/* 返回动态id,动态发布者id/姓名/头像,动态主题内容,动态内容及图片,动态发布时间 */
|
|
|
|
|
map.put("id", item.getId());
|
|
|
|
|
map.put("reportId", item.getReportId());
|
|
|
|
|
map.put("reportName", sysUserService.selectUserById(item.getReportId()).getNickName());
|
|
|
|
|
map.put("reportAvatar", sysUserService.selectUserById(item.getReportId()).getAvatar());
|
|
|
|
|
/* 没有主题则传null值 */
|
|
|
|
|
if (StringUtils.isNotNull(item.getTopicId())) {
|
|
|
|
|
map.put("topic", topicService.selectTopicById(item.getTopicId()).getContent());
|
|
|
|
|
} else {
|
|
|
|
|
map.put("topic", null);
|
|
|
|
|
}
|
|
|
|
|
map.put("content", item.getContent());
|
|
|
|
|
map.put("picture1", item.getPicture1());
|
|
|
|
|
map.put("picture2", item.getPicture2());
|
|
|
|
|
map.put("picture3", item.getPicture3());
|
|
|
|
|
map.put("time", item.getTime());
|
|
|
|
|
/* 返回所有点赞id,点赞者id和姓名,以及点赞总数量 */
|
|
|
|
|
List<Map<String, String>> thumbList = new ArrayList<>();
|
|
|
|
|
CheerThumb cheerThumb = new CheerThumb();
|
|
|
|
|
cheerThumb.setMomentId(item.getId());
|
|
|
|
|
List<CheerThumb> cheerThumbList = cheerThumbService.selectCheerThumbList(cheerThumb);
|
|
|
|
|
for (CheerThumb thumb : cheerThumbList) {
|
|
|
|
|
Map<String, String> mapOfThumb = new HashMap<>();
|
|
|
|
|
mapOfThumb.put("thumbId", thumb.getId());
|
|
|
|
|
mapOfThumb.put("thumbedId", thumb.getThumbedId().toString());
|
|
|
|
|
mapOfThumb.put("thumbedName", thumb.getThumbedName());
|
|
|
|
|
thumbList.add(mapOfThumb);
|
|
|
|
|
}
|
|
|
|
|
map.put("thumbNum", cheerThumbList.size());
|
|
|
|
|
map.put("thumbs", thumbList);
|
|
|
|
|
/* 返回所有评论,具体评论id、评论者id、名称、头像、评论内容以及总评论数 */
|
|
|
|
|
List<Map<String, String>> commentList = new ArrayList<>();
|
|
|
|
|
CheerComment cheerComment = new CheerComment();
|
|
|
|
|
cheerComment.setMomentId(item.getId());
|
|
|
|
|
List<CheerComment> cheerCommentList = cheerCommentService.selectCheerCommentList(cheerComment);
|
|
|
|
|
for (int i = 0; i < cheerCommentList.size(); i++) {
|
|
|
|
|
CheerComment comment = cheerCommentList.get(i);
|
|
|
|
|
Map<String, String> mapOfComment = new HashMap<>();
|
|
|
|
|
mapOfComment.put("commentId", comment.getId().toString());
|
|
|
|
|
mapOfComment.put("commentatorId", comment.getFromId().toString());
|
|
|
|
|
mapOfComment.put("commentatorName", sysUserService.selectUserById(comment.getFromId()).getNickName());
|
|
|
|
|
mapOfComment.put("commentatorAvatar", sysUserService.selectUserById(comment.getFromId()).getAvatar());
|
|
|
|
|
mapOfComment.put("content", comment.getContent());
|
|
|
|
|
commentList.add(mapOfComment);
|
|
|
|
|
}
|
|
|
|
|
map.put("commentNum", cheerCommentList.size());
|
|
|
|
|
map.put("comments", commentList);
|
|
|
|
|
map = momentMap(item);
|
|
|
|
|
}
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|