|
@@ -9,7 +9,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;
|
|
@@ -30,6 +29,7 @@ import java.time.LocalDateTime;
|
|
|
import java.time.LocalTime;
|
|
import java.time.LocalTime;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 用户动态
|
|
* 用户动态
|
|
@@ -79,7 +79,6 @@ public class LifeUserDynamicsService extends ServiceImpl<LifeUserDynamicsMapper,
|
|
|
return lifeUserDynamicsMapper.update(null, lambdaUpdateWrapper);
|
|
return lifeUserDynamicsMapper.update(null, lambdaUpdateWrapper);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
public int setTopStatus(LifeUserDynamicsVo lifeUserDynamicsVo) {
|
|
public int setTopStatus(LifeUserDynamicsVo lifeUserDynamicsVo) {
|
|
|
if (!StringUtils.isEmpty(lifeUserDynamicsVo.getId()) && !StringUtils.isEmpty(lifeUserDynamicsVo.getTopStatus())) {
|
|
if (!StringUtils.isEmpty(lifeUserDynamicsVo.getId()) && !StringUtils.isEmpty(lifeUserDynamicsVo.getTopStatus())) {
|
|
|
LambdaUpdateWrapper<LifeUserDynamics> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
LambdaUpdateWrapper<LifeUserDynamics> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
@@ -334,19 +333,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])) {
|
|
@@ -359,16 +358,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<>();
|
|
|
|
|
|
|
@@ -506,11 +495,60 @@ 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);
|
|
|
- if (!CollectionUtils.isEmpty(lifeUserDynamicsVos)) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // 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)){
|
|
|
for (LifeUserDynamicsVo lifeUserDynamicsVo : lifeUserDynamicsVos) {
|
|
for (LifeUserDynamicsVo lifeUserDynamicsVo : lifeUserDynamicsVos) {
|
|
|
- if (lifeUserDynamicsVo.getType().equals("2")) {
|
|
|
|
|
|
|
+ if(combinedSet.contains(lifeUserDynamicsVo.getPhoneId())){
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ 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);
|
|
|
lifeUserDynamicsVo.setStoreName(storeInfo.getStoreName());
|
|
lifeUserDynamicsVo.setStoreName(storeInfo.getStoreName());
|
|
|
} else if (lifeUserDynamicsVo.getType().equals("1")) {
|
|
} else if (lifeUserDynamicsVo.getType().equals("1")) {
|
|
|
String phoneIdNew = lifeUserDynamicsVo.getPhoneId().substring(5);
|
|
String phoneIdNew = lifeUserDynamicsVo.getPhoneId().substring(5);
|
|
@@ -520,7 +558,7 @@ public class LifeUserDynamicsService extends ServiceImpl<LifeUserDynamicsMapper,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- return lifeUserDynamicsVos;
|
|
|
|
|
|
|
+ return lifeUserDynamicsVos;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public List<LifeUserDynamicsVo> getDynamicsList(Integer page, Integer size, String nickName, String userType, Integer dynamicsType, String releaseStartTime, String releaseEndTime) {
|
|
public List<LifeUserDynamicsVo> getDynamicsList(Integer page, Integer size, String nickName, String userType, Integer dynamicsType, String releaseStartTime, String releaseEndTime) {
|
|
@@ -532,10 +570,10 @@ public class LifeUserDynamicsService extends ServiceImpl<LifeUserDynamicsMapper,
|
|
|
// 查询动态数据并按类型过滤
|
|
// 查询动态数据并按类型过滤
|
|
|
LifeUserDynamicsVo lifeUserDynamicsVo = new LifeUserDynamicsVo();
|
|
LifeUserDynamicsVo lifeUserDynamicsVo = new LifeUserDynamicsVo();
|
|
|
List<LifeUserDynamicsVo> lifeUserDynamicsVoList = lifeUserDynamicsMapper.getDynamicsDetail(id);
|
|
List<LifeUserDynamicsVo> lifeUserDynamicsVoList = lifeUserDynamicsMapper.getDynamicsDetail(id);
|
|
|
- if (!CollectionUtils.isEmpty(lifeUserDynamicsVoList)) {
|
|
|
|
|
|
|
+ if(!CollectionUtils.isEmpty(lifeUserDynamicsVoList)){
|
|
|
lifeUserDynamicsVo = lifeUserDynamicsVoList.get(0);
|
|
lifeUserDynamicsVo = lifeUserDynamicsVoList.get(0);
|
|
|
String imagePath = lifeUserDynamicsVo.getImagePath();
|
|
String imagePath = lifeUserDynamicsVo.getImagePath();
|
|
|
- if (!StringUtils.isEmpty(imagePath)) {
|
|
|
|
|
|
|
+ if(!StringUtils.isEmpty(imagePath)){
|
|
|
List<String> imagePathList = Arrays.asList(imagePath.split(","));
|
|
List<String> imagePathList = Arrays.asList(imagePath.split(","));
|
|
|
lifeUserDynamicsVo.setImagePathList(imagePathList);
|
|
lifeUserDynamicsVo.setImagePathList(imagePathList);
|
|
|
}
|
|
}
|