|
@@ -8,7 +8,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
import org.springframework.util.ObjectUtils;
|
|
@@ -21,6 +20,7 @@ import shop.alien.mapper.*;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 用户动态
|
|
* 用户动态
|
|
@@ -314,19 +314,19 @@ public class LifeUserDynamicsService extends ServiceImpl<LifeUserDynamicsMapper,
|
|
|
|
|
|
|
|
resultMap.put("fansListSum", fansList.size());
|
|
resultMap.put("fansListSum", fansList.size());
|
|
|
|
|
|
|
|
- //是否关注用户
|
|
|
|
|
- String targetPhone;
|
|
|
|
|
|
|
+ //通过phoneId查询userId
|
|
|
|
|
+ // 判断 targetPhone 是否在 fansList 中 1 已关注 0 未关注
|
|
|
|
|
+ // 处理 fansList
|
|
|
|
|
+ fansList = lifeFansList.stream().map(LifeFans::getFansId)
|
|
|
|
|
+// .map(id -> id.split("_")[id.split("_").length - 1])
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
|
|
-// // 查询好友的点赞
|
|
|
|
|
-// LambdaQueryWrapper<LifeLikeRecord> likeWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
-// likeWrapper.eq(LifeLikeRecord::getDianzanId, phoneId);
|
|
|
|
|
-// likeWrapper.eq(LifeLikeRecord::getType, "2");
|
|
|
|
|
-// List<LifeLikeRecord> lifeLikeList = lifeLikeRecordMapper.selectList(likeWrapper);
|
|
|
|
|
-// List<String> likeList = lifeLikeList.stream().map(LifeLikeRecord::getHuifuId).collect(Collectors.toList());
|
|
|
|
|
-//
|
|
|
|
|
-// resultMap.put("likeListSum", likeList.size());
|
|
|
|
|
|
|
+ int isFollowed = fansList.contains(myselfPhoneId) ? 1 : 0;
|
|
|
|
|
+ resultMap.put("isFollowed", isFollowed);
|
|
|
|
|
+ resultMap.put("isFollowedMe", myFansList.contains(phoneId) ? 1 : 0);
|
|
|
|
|
|
|
|
- //通过phoneId查询userId
|
|
|
|
|
|
|
+ //是否关注用户
|
|
|
|
|
+ String targetPhone;
|
|
|
LifeUser myLifeUser = new LifeUser();
|
|
LifeUser myLifeUser = new LifeUser();
|
|
|
StoreUser myStoreUser = new StoreUser();
|
|
StoreUser myStoreUser = new StoreUser();
|
|
|
if ("user".equals(myselfPhoneId.split("_")[0])) {
|
|
if ("user".equals(myselfPhoneId.split("_")[0])) {
|
|
@@ -339,16 +339,6 @@ public class LifeUserDynamicsService extends ServiceImpl<LifeUserDynamicsMapper,
|
|
|
targetPhone = myStoreUser.getPhone();
|
|
targetPhone = myStoreUser.getPhone();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 判断 targetPhone 是否在 fansList 中 1 已关注 0 未关注
|
|
|
|
|
- // 处理 fansList
|
|
|
|
|
- fansList = lifeFansList.stream().map(LifeFans::getFansId)
|
|
|
|
|
-// .map(id -> id.split("_")[id.split("_").length - 1])
|
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
|
-
|
|
|
|
|
- int isFollowed = fansList.contains(myselfPhoneId) ? 1 : 0;
|
|
|
|
|
- resultMap.put("isFollowed", isFollowed);
|
|
|
|
|
- resultMap.put("isFollowedMe", myFansList.contains(phoneId) ? 1 : 0);
|
|
|
|
|
-
|
|
|
|
|
//查询是否已拉黑
|
|
//查询是否已拉黑
|
|
|
LambdaQueryWrapper<LifeBlacklist> myLifeBlacklistWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<LifeBlacklist> myLifeBlacklistWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
|
|
@@ -486,8 +476,57 @@ public class LifeUserDynamicsService extends ServiceImpl<LifeUserDynamicsMapper,
|
|
|
|
|
|
|
|
public List<LifeUserDynamicsVo> getDianZanList(String phoneId) {
|
|
public List<LifeUserDynamicsVo> getDianZanList(String phoneId) {
|
|
|
List<LifeUserDynamicsVo> lifeUserDynamicsVos = lifeUserDynamicsMapper.selectDianZanList(phoneId);
|
|
List<LifeUserDynamicsVo> lifeUserDynamicsVos = lifeUserDynamicsMapper.selectDianZanList(phoneId);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // TODO bugfix: 过滤掉我拉黑的和拉黑我的。
|
|
|
|
|
+ //是否关注用户
|
|
|
|
|
+ String targetPhone;
|
|
|
|
|
+ LifeUser myLifeUser = new LifeUser();
|
|
|
|
|
+ StoreUser myStoreUser = new StoreUser();
|
|
|
|
|
+
|
|
|
|
|
+ if ("user".equals(phoneId.split("_")[0])) {
|
|
|
|
|
+ String myselfUserPhone = phoneId.split("_")[1];
|
|
|
|
|
+ myLifeUser = lifeUserService.getUserByPhone(myselfUserPhone);
|
|
|
|
|
+ targetPhone = myLifeUser.getUserPhone();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ String myselfStorePhone = phoneId.split("_")[1];
|
|
|
|
|
+ myStoreUser = storeUserService.getUserByPhone(myselfStorePhone);
|
|
|
|
|
+ targetPhone = myStoreUser.getPhone();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Integer myType ;
|
|
|
|
|
+ Integer myId ;
|
|
|
|
|
+ if (myLifeUser != null && myLifeUser.getId() != null) {
|
|
|
|
|
+ // 我是用户(类型1)
|
|
|
|
|
+ myType = 1;
|
|
|
|
|
+ myId = myLifeUser.getId();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 我是商户(类型2)
|
|
|
|
|
+ myType = 2;
|
|
|
|
|
+ myId = myStoreUser.getId();
|
|
|
|
|
+ }
|
|
|
|
|
+ // 2. 构建查询条件:(我拉黑的) OR (拉黑我的)
|
|
|
|
|
+ QueryWrapper<LifeBlacklist> wrapper = new QueryWrapper<>();
|
|
|
|
|
+ // 2.1 我拉黑的:blocker_type=我的类型 AND blocker_id=我的ID
|
|
|
|
|
+ // 使用 and() 嵌套子条件,对应 SQL:(blocker_type = ? AND blocker_id = ?)
|
|
|
|
|
+ wrapper.and(q -> q.eq("blocker_type", myType)
|
|
|
|
|
+ .eq("blocker_id", myId));
|
|
|
|
|
+ // 2.2 或者(OR)拉黑我的:blocked_type=我的类型 AND blocked_id=我的ID
|
|
|
|
|
+ // 使用 or() 嵌套子条件,对应 SQL:OR (blocked_type = ? AND blocked_id = ?)
|
|
|
|
|
+ wrapper.or(q -> q.eq("blocked_type", myType)
|
|
|
|
|
+ .eq("blocked_id", myId));
|
|
|
|
|
+ List<LifeBlacklist> result = lifeBlacklistMapper.selectList(wrapper);
|
|
|
|
|
+ Set<String> combinedSet = result.stream()
|
|
|
|
|
+ .flatMap(blacklist -> Stream.of(
|
|
|
|
|
+ blacklist.getBlockedPhoneId(),
|
|
|
|
|
+ blacklist.getBlockerPhoneId()
|
|
|
|
|
+ ).filter(Objects::nonNull)) // 过滤null
|
|
|
|
|
+ .collect(Collectors.toSet());
|
|
|
if (!CollectionUtils.isEmpty(lifeUserDynamicsVos)){
|
|
if (!CollectionUtils.isEmpty(lifeUserDynamicsVos)){
|
|
|
for (LifeUserDynamicsVo lifeUserDynamicsVo : lifeUserDynamicsVos) {
|
|
for (LifeUserDynamicsVo lifeUserDynamicsVo : lifeUserDynamicsVos) {
|
|
|
|
|
+ if(combinedSet.contains(lifeUserDynamicsVo.getPhoneId())){
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
if (lifeUserDynamicsVo.getType().equals("2")){
|
|
if (lifeUserDynamicsVo.getType().equals("2")){
|
|
|
String phoneIdNew = lifeUserDynamicsVo.getPhoneId().substring(6);
|
|
String phoneIdNew = lifeUserDynamicsVo.getPhoneId().substring(6);
|
|
|
StoreInfo storeInfo=storeInfoMapper.getStoreNameByPhone(phoneIdNew);
|
|
StoreInfo storeInfo=storeInfoMapper.getStoreNameByPhone(phoneIdNew);
|