|
@@ -2,16 +2,14 @@ package com.mirage.mirageservice.service;
|
|
|
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
+import com.mirage.core.annotation.RedisLock;
|
|
|
import com.mirage.core.meta.PageResultVo;
|
|
import com.mirage.core.meta.PageResultVo;
|
|
|
import com.mirage.core.meta.PageUtil;
|
|
import com.mirage.core.meta.PageUtil;
|
|
|
import com.mirage.core.utils.GsonUtil;
|
|
import com.mirage.core.utils.GsonUtil;
|
|
|
import com.mirage.mirageservice.domain.*;
|
|
import com.mirage.mirageservice.domain.*;
|
|
|
import com.mirage.mirageservice.enums.FamilyRelationEnum;
|
|
import com.mirage.mirageservice.enums.FamilyRelationEnum;
|
|
|
import com.mirage.mirageservice.enums.MomentsVisibleTypeEnum;
|
|
import com.mirage.mirageservice.enums.MomentsVisibleTypeEnum;
|
|
|
-import com.mirage.mirageservice.mapper.mysql.FamilyMemberInfoMapper;
|
|
|
|
|
-import com.mirage.mirageservice.mapper.mysql.FamilyMemberPhotoAlbumMapper;
|
|
|
|
|
-import com.mirage.mirageservice.mapper.mysql.FamilyMomentsMapper;
|
|
|
|
|
-import com.mirage.mirageservice.mapper.mysql.FamilyRelationInfoMapper;
|
|
|
|
|
|
|
+import com.mirage.mirageservice.mapper.mysql.*;
|
|
|
import com.mirage.mirageservice.meta.*;
|
|
import com.mirage.mirageservice.meta.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -44,6 +42,10 @@ public class FamilyService {
|
|
|
private FamilyMemberPhotoAlbumMapper familyMemberPhotoAlbumMapper;
|
|
private FamilyMemberPhotoAlbumMapper familyMemberPhotoAlbumMapper;
|
|
|
@Resource
|
|
@Resource
|
|
|
private FamilyMomentsMapper familyMomentsMapper;
|
|
private FamilyMomentsMapper familyMomentsMapper;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private FamilyMomentsLikeMapper familyMomentsLikeMapper;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private FamilyMomentsCommentMapper familyMomentsCommentMapper;
|
|
|
|
|
|
|
|
public SelfFamilyCardResponse getSelfFamilyMember(Long uid){
|
|
public SelfFamilyCardResponse getSelfFamilyMember(Long uid){
|
|
|
SelfFamilyCardResponse familyCardResponse = new SelfFamilyCardResponse();
|
|
SelfFamilyCardResponse familyCardResponse = new SelfFamilyCardResponse();
|
|
@@ -409,7 +411,9 @@ public class FamilyService {
|
|
|
}
|
|
}
|
|
|
for(FamilyMoments moments : familyMoments){
|
|
for(FamilyMoments moments : familyMoments){
|
|
|
FamilyMemberInfo memberInfo = familyMemberInfoMapper.selectByUid(moments.getPublishUid());
|
|
FamilyMemberInfo memberInfo = familyMemberInfoMapper.selectByUid(moments.getPublishUid());
|
|
|
- result.add(new FamilyMomentsAndPublishInfo(moments, memberInfo));
|
|
|
|
|
|
|
+ List<MomentsLikeInfo> likeInfoList = familyMomentsLikeMapper.selectMomentLikeListAndMemberInfo(moments.getId());
|
|
|
|
|
+ List<MomentsCommentsResponse> commentsResponses = familyMomentsCommentMapper.selectCommentsByMomentId(moments.getId());
|
|
|
|
|
+ result.add(new FamilyMomentsAndPublishInfo(moments, memberInfo, likeInfoList, commentsResponses));
|
|
|
}
|
|
}
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
@@ -427,7 +431,9 @@ public class FamilyService {
|
|
|
// 处理可见性
|
|
// 处理可见性
|
|
|
for(FamilyMoments moments : familyMoments){
|
|
for(FamilyMoments moments : familyMoments){
|
|
|
if(Objects.equals(moments.getVisibleType(), MomentsVisibleTypeEnum.ALL_MEMBER.getType())){
|
|
if(Objects.equals(moments.getVisibleType(), MomentsVisibleTypeEnum.ALL_MEMBER.getType())){
|
|
|
- result.add(new FamilyMomentsAndPublishInfo(moments, memberInfo));
|
|
|
|
|
|
|
+ List<MomentsLikeInfo> likeInfoList = familyMomentsLikeMapper.selectMomentLikeListAndMemberInfo(moments.getId());
|
|
|
|
|
+ List<MomentsCommentsResponse> commentsResponses = familyMomentsCommentMapper.selectCommentsByMomentId(moments.getId());
|
|
|
|
|
+ result.add(new FamilyMomentsAndPublishInfo(moments, memberInfo, likeInfoList, commentsResponses));
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
// 可见范围:0:全员 1:支系堂派 2:聚落 3:家族内男性 4:出生地
|
|
// 可见范围:0:全员 1:支系堂派 2:聚落 3:家族内男性 4:出生地
|
|
@@ -436,22 +442,30 @@ public class FamilyService {
|
|
|
&& (memberInfo.getBranchFamilyHall().equals(moments.getVisibleValue())
|
|
&& (memberInfo.getBranchFamilyHall().equals(moments.getVisibleValue())
|
|
|
|| memberInfo.getBranchFamilyHall().contains(moments.getVisibleValue())
|
|
|| memberInfo.getBranchFamilyHall().contains(moments.getVisibleValue())
|
|
|
|| moments.getVisibleValue().contains(memberInfo.getBranchFamilyHall()))){
|
|
|| moments.getVisibleValue().contains(memberInfo.getBranchFamilyHall()))){
|
|
|
- result.add(new FamilyMomentsAndPublishInfo(moments, memberInfo));
|
|
|
|
|
|
|
+ List<MomentsLikeInfo> likeInfoList = familyMomentsLikeMapper.selectMomentLikeListAndMemberInfo(moments.getId());
|
|
|
|
|
+ List<MomentsCommentsResponse> commentsResponses = familyMomentsCommentMapper.selectCommentsByMomentId(moments.getId());
|
|
|
|
|
+ result.add(new FamilyMomentsAndPublishInfo(moments, memberInfo, likeInfoList, commentsResponses));
|
|
|
} else if(Objects.equals(moments.getVisibleType(), MomentsVisibleTypeEnum.SPECIAL_CLUSTER_PLACE.getType())
|
|
} else if(Objects.equals(moments.getVisibleType(), MomentsVisibleTypeEnum.SPECIAL_CLUSTER_PLACE.getType())
|
|
|
&& StringUtils.isNotBlank(memberInfo.getClusterPlace())
|
|
&& StringUtils.isNotBlank(memberInfo.getClusterPlace())
|
|
|
&& (memberInfo.getClusterPlace().equals(moments.getVisibleValue())
|
|
&& (memberInfo.getClusterPlace().equals(moments.getVisibleValue())
|
|
|
|| memberInfo.getClusterPlace().contains(moments.getVisibleValue())
|
|
|| memberInfo.getClusterPlace().contains(moments.getVisibleValue())
|
|
|
|| moments.getVisibleValue().equals(memberInfo.getClusterPlace()))){
|
|
|| moments.getVisibleValue().equals(memberInfo.getClusterPlace()))){
|
|
|
- result.add(new FamilyMomentsAndPublishInfo(moments, memberInfo));
|
|
|
|
|
|
|
+ List<MomentsLikeInfo> likeInfoList = familyMomentsLikeMapper.selectMomentLikeListAndMemberInfo(moments.getId());
|
|
|
|
|
+ List<MomentsCommentsResponse> commentsResponses = familyMomentsCommentMapper.selectCommentsByMomentId(moments.getId());
|
|
|
|
|
+ result.add(new FamilyMomentsAndPublishInfo(moments, memberInfo, likeInfoList, commentsResponses));
|
|
|
} else if (Objects.equals(moments.getVisibleType(), MomentsVisibleTypeEnum.SPECIAL_SEX.getType())
|
|
} else if (Objects.equals(moments.getVisibleType(), MomentsVisibleTypeEnum.SPECIAL_SEX.getType())
|
|
|
&& Integer.parseInt(moments.getVisibleValue()) == memberInfo.getSex()) {
|
|
&& Integer.parseInt(moments.getVisibleValue()) == memberInfo.getSex()) {
|
|
|
- result.add(new FamilyMomentsAndPublishInfo(moments, memberInfo));
|
|
|
|
|
|
|
+ List<MomentsLikeInfo> likeInfoList = familyMomentsLikeMapper.selectMomentLikeListAndMemberInfo(moments.getId());
|
|
|
|
|
+ List<MomentsCommentsResponse> commentsResponses = familyMomentsCommentMapper.selectCommentsByMomentId(moments.getId());
|
|
|
|
|
+ result.add(new FamilyMomentsAndPublishInfo(moments, memberInfo, likeInfoList, commentsResponses));
|
|
|
} else if (Objects.equals(moments.getVisibleType(), MomentsVisibleTypeEnum.SPECIAL_BIRTH_PLACE.getType())
|
|
} else if (Objects.equals(moments.getVisibleType(), MomentsVisibleTypeEnum.SPECIAL_BIRTH_PLACE.getType())
|
|
|
&& StringUtils.isNotBlank(memberInfo.getBirthPlace())
|
|
&& StringUtils.isNotBlank(memberInfo.getBirthPlace())
|
|
|
&& (memberInfo.getBirthPlace().contains(moments.getVisibleValue())
|
|
&& (memberInfo.getBirthPlace().contains(moments.getVisibleValue())
|
|
|
|| moments.getVisibleValue().contains(memberInfo.getBirthPlace())
|
|
|| moments.getVisibleValue().contains(memberInfo.getBirthPlace())
|
|
|
|| memberInfo.getBirthPlace().equalsIgnoreCase(moments.getVisibleValue()))) {
|
|
|| memberInfo.getBirthPlace().equalsIgnoreCase(moments.getVisibleValue()))) {
|
|
|
- result.add(new FamilyMomentsAndPublishInfo(moments, memberInfo));
|
|
|
|
|
|
|
+ List<MomentsLikeInfo> likeInfoList = familyMomentsLikeMapper.selectMomentLikeListAndMemberInfo(moments.getId());
|
|
|
|
|
+ List<MomentsCommentsResponse> commentsResponses = familyMomentsCommentMapper.selectCommentsByMomentId(moments.getId());
|
|
|
|
|
+ result.add(new FamilyMomentsAndPublishInfo(moments, memberInfo, likeInfoList, commentsResponses));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
// 最后一个id记录,用于红点提示
|
|
// 最后一个id记录,用于红点提示
|
|
@@ -511,7 +525,89 @@ public class FamilyService {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public FamilyMoments getMomentsById(Long id){
|
|
|
|
|
+ if(null == id){
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ return familyMomentsMapper.selectByPrimaryKey(id);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @RedisLock(lockField = "#uid+'_'+#familyMoments.id", retries = -1)
|
|
|
|
|
+ public boolean likeMoment(Long uid, Integer likeOrNot, FamilyMoments familyMoments){
|
|
|
|
|
+ if(null == uid || null == familyMoments){
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ FamilyMomentsLike familyMomentsLike = familyMomentsLikeMapper.selectOneByMomentIdAndUidAndIsDeleted(familyMoments.getId(), uid, 0);
|
|
|
|
|
+ if(likeOrNot == 0){ //取消点赞
|
|
|
|
|
+ if(null == familyMomentsLike){
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ familyMomentsLike.setIsDeleted(1);
|
|
|
|
|
+ familyMomentsLike.setGmtModified(new Date());
|
|
|
|
|
+ familyMomentsLikeMapper.updateByPrimaryKeySelective(familyMomentsLike);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ } else if (likeOrNot == 1) { // 点赞
|
|
|
|
|
+ if(null != familyMomentsLike){
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ familyMomentsLike = new FamilyMomentsLike();
|
|
|
|
|
+ familyMomentsLike.setMomentId(familyMomentsLike.getMomentId());
|
|
|
|
|
+ familyMomentsLike.setUid(uid);
|
|
|
|
|
+ familyMomentsLike.setIsDeleted(0);
|
|
|
|
|
+ familyMomentsLike.setGmtModified(new Date());
|
|
|
|
|
+ familyMomentsLike.setGmtCreate(new Date());
|
|
|
|
|
+ familyMomentsLikeMapper.insertSelective(familyMomentsLike);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public FamilyMomentsComment getMomentsCommentById(Long id){
|
|
|
|
|
+ if(null == id){
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ return familyMomentsCommentMapper.selectByPrimaryKey(id);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ public boolean commentMoment(Long uid, FamilyMoments familyMoments, MomentsLikeAndCommentRequest request){
|
|
|
|
|
+ if(null == uid
|
|
|
|
|
+ || null == familyMoments
|
|
|
|
|
+ || null == request
|
|
|
|
|
+ || null == request.getMomentId()
|
|
|
|
|
+ || StringUtils.isBlank(request.getContent())){
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(null != request.getParentCommentId()){
|
|
|
|
|
+ FamilyMomentsComment momentsComment = familyMomentsCommentMapper.selectByPrimaryKey(request.getParentCommentId());
|
|
|
|
|
+ if(null == momentsComment || momentsComment.getIsDeleted() == 1){
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ FamilyMomentsComment familyMomentsComment = new FamilyMomentsComment();
|
|
|
|
|
+ familyMomentsComment.setMomentId(familyMoments.getId());
|
|
|
|
|
+ familyMomentsComment.setContent(request.getContent());
|
|
|
|
|
+ familyMomentsComment.setUid(uid);
|
|
|
|
|
+ familyMomentsComment.setParentCommentId(request.getParentCommentId());
|
|
|
|
|
+ familyMomentsComment.setIsDeleted(0);
|
|
|
|
|
+ familyMomentsComment.setGmtCreate(new Date());
|
|
|
|
|
+ familyMomentsComment.setGmtModified(new Date());
|
|
|
|
|
+ familyMomentsCommentMapper.insertSelective(familyMomentsComment);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public boolean deleteComment(Long commentId){
|
|
|
|
|
+ if(null == commentId){
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ FamilyMomentsComment familyMomentsComment = familyMomentsCommentMapper.selectByPrimaryKey(commentId);
|
|
|
|
|
+ if(null == familyMomentsComment || familyMomentsComment.getIsDeleted() == 1){
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ familyMomentsComment.setIsDeleted(1);
|
|
|
|
|
+ familyMomentsComment.setGmtModified(new Date());
|
|
|
|
|
+ familyMomentsCommentMapper.updateByPrimaryKeySelective(familyMomentsComment);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|