咨询列表和店铺 api 接口加入白名单,不需要登录。

This commit is contained in:
Jack 2025-11-25 16:36:58 +08:00
parent 9085dc7681
commit 200f66839b
3 changed files with 263 additions and 119 deletions

View File

@ -93,6 +93,8 @@ secure:
- "/mobile/shop/lakala/sign/ec/**" - "/mobile/shop/lakala/sign/ec/**"
- "/mobile/**/**/test/case" - "/mobile/**/**/test/case"
- "/**/**/testcase" - "/**/**/testcase"
- "/mobile/sns/Story/listComment"
- "/mobile/sns/Story/getStory"
universal: universal:
urls: urls:
- "/admin/account/account-user-base/info" - "/admin/account/account-user-base/info"

View File

@ -185,7 +185,7 @@ public class SnsStoryBaseServiceImpl extends BaseServiceImpl<SnsStoryBaseMapper,
} }
if (snsStoryBase.getStory_enable() != null) { if (snsStoryBase.getStory_enable() != null) {
queryWrapper.eq("story_enable", snsStoryBase.getStory_enable() ); queryWrapper.eq("story_enable", snsStoryBase.getStory_enable());
} }
if (CheckUtil.isNotEmpty(snsStoryBase.getStory_index())) { if (CheckUtil.isNotEmpty(snsStoryBase.getStory_index())) {
@ -201,7 +201,7 @@ public class SnsStoryBaseServiceImpl extends BaseServiceImpl<SnsStoryBaseMapper,
} }
@Override @Override
public Map getStoryList(StorySearchDTO storySearchDTO) { public Map getStoryList(StorySearchDTO storySearchDTO) {
QueryWrapper<SnsStoryBase> column_row = new QueryWrapper<>(); //查询获得相关的SnsStoryBase列表集合 QueryWrapper<SnsStoryBase> column_row = new QueryWrapper<>(); //查询获得相关的SnsStoryBase列表集合
if (storySearchDTO.getStory_type() != null) { if (storySearchDTO.getStory_type() != null) {
@ -266,44 +266,44 @@ public class SnsStoryBaseServiceImpl extends BaseServiceImpl<SnsStoryBaseMapper,
} }
UserDto user = ContextUtil.getCurrentUser(); UserDto user = ContextUtil.getCurrentUser();
if(user!=null){ if (user != null) {
//用户是否点赞 //用户是否点赞
QueryWrapper<SnsStoryLike> queryWrapper=new QueryWrapper<>(); QueryWrapper<SnsStoryLike> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("user_id",user.getId()); queryWrapper.eq("user_id", user.getId());
List<SnsStoryLike> snsStoryLikes = snsStoryLikeService.find(queryWrapper); List<SnsStoryLike> snsStoryLikes = snsStoryLikeService.find(queryWrapper);
List<Integer> collect = snsStoryLikes.stream().map(s -> s.getStory_id()).distinct().collect(Collectors.toList()); List<Integer> collect = snsStoryLikes.stream().map(s -> s.getStory_id()).distinct().collect(Collectors.toList());
for(Map item :items){ for (Map item : items) {
Integer story_id = Convert.toInt(item.get("story_id")); Integer story_id = Convert.toInt(item.get("story_id"));
if(collect.contains(story_id)){ if (collect.contains(story_id)) {
item.put("IsFabulous",1); item.put("IsFabulous", 1);
}else{ } else {
item.put("IsFabulous",0); item.put("IsFabulous", 0);
} }
} }
//用户是否收藏 //用户是否收藏
QueryWrapper<SnsStoryCollection> snsStoryCollectionQueryWrapper=new QueryWrapper<>(); QueryWrapper<SnsStoryCollection> snsStoryCollectionQueryWrapper = new QueryWrapper<>();
snsStoryCollectionQueryWrapper.eq("user_id",user.getId()); snsStoryCollectionQueryWrapper.eq("user_id", user.getId());
List<SnsStoryCollection> snsStoryCollections = snsStoryCollectionService.find(snsStoryCollectionQueryWrapper); List<SnsStoryCollection> snsStoryCollections = snsStoryCollectionService.find(snsStoryCollectionQueryWrapper);
List<Integer> collectionList = snsStoryCollections.stream().map(s -> s.getStory_id()).distinct().collect(Collectors.toList()); List<Integer> collectionList = snsStoryCollections.stream().map(s -> s.getStory_id()).distinct().collect(Collectors.toList());
for(Map item :items){ for (Map item : items) {
Integer story_id = Convert.toInt(item.get("story_id")); Integer story_id = Convert.toInt(item.get("story_id"));
if(collectionList.contains(story_id)){ if (collectionList.contains(story_id)) {
item.put("IsCollection",1); item.put("IsCollection", 1);
}else{ } else {
item.put("IsCollection",0); item.put("IsCollection", 0);
} }
} }
//用户是否关注 //用户是否关注
for(Map item:items){ for (Map item : items) {
QueryWrapper<SnsUserFriend> friendQueryWrapper=new QueryWrapper<>(); QueryWrapper<SnsUserFriend> friendQueryWrapper = new QueryWrapper<>();
friendQueryWrapper.eq("user_id",user.getId()).eq("friend_id",Convert.toInt(item.get("user_id"))); friendQueryWrapper.eq("user_id", user.getId()).eq("friend_id", Convert.toInt(item.get("user_id")));
SnsUserFriend one = snsUserFriendService.findOne(friendQueryWrapper); SnsUserFriend one = snsUserFriendService.findOne(friendQueryWrapper);
if(one!=null){ if (one != null) {
item.put("IsFollow",true); item.put("IsFollow", true);
}else{ } else {
item.put("IsFollow",false); item.put("IsFollow", false);
} }
} }
} }
@ -382,7 +382,7 @@ public class SnsStoryBaseServiceImpl extends BaseServiceImpl<SnsStoryBaseMapper,
if (story_id == null) { if (story_id == null) {
accountUserSns.setUser_story(accountUserSns.getUser_story() + 1); accountUserSns.setUser_story(accountUserSns.getUser_story() + 1);
if (!accountService.saveOrUpdateAccountUserSns(accountUserSns)) { if (!accountService.saveOrUpdateAccountUserSns(accountUserSns)) {
log.error(I18nUtil._("更新用户发帖数量失败bean[{}]"), accountUserSns.toString()); log.error(I18nUtil._("更新用户发帖数量失败bean[{}]"), accountUserSns);
throw new ApiException(I18nUtil._("更新用户发帖数量失败!")); throw new ApiException(I18nUtil._("更新用户发帖数量失败!"));
} }
} }
@ -406,28 +406,44 @@ public class SnsStoryBaseServiceImpl extends BaseServiceImpl<SnsStoryBaseMapper,
//帖子类型不是视频类型 //帖子类型不是视频类型
@Override @Override
public Map getStory(Integer story_id) { public Map getStory(Integer story_id) {
UserDto user = ContextUtil.getCurrentUser(); UserDto user = ContextUtil.getCurrentUser();
Integer user_id = 0; Integer user_id = null;
if (user == null) { // 允许未登录用户访问
throw new ApiException(ResultCode.NEED_LOGIN); if (user != null) {
} else {
user_id = user.getId(); user_id = user.getId();
} }
// 参数校验
if (story_id == null || story_id <= 0) {
throw new ApiException("无效的故事ID");
}
SnsStoryBase storyBase = get(story_id); SnsStoryBase storyBase = get(story_id);
// 检查故事是否存在
if (storyBase == null) {
throw new ApiException("故事不存在");
}
Map row = Convert.toMap(String.class, Object.class, storyBase); Map row = Convert.toMap(String.class, Object.class, storyBase);
row = accountService.fixUserAvatar(row, true); row = accountService.fixUserAvatar(row, true);
// 检查是否包含富文本 // 检查是否包含富文本
String story_content = Convert.toStr(row.get("story_content")); String story_content = Convert.toStr(row.get("story_content"));
if (StrUtil.isNotBlank(story_content)) { if (StrUtil.isNotBlank(story_content)) {
Document document = Jsoup.parse(story_content); try {
String text = document.text(); Document document = Jsoup.parse(story_content);
// 如果不相等就是富文本 String text = document.text();
row.put("has_rich", story_content.length() != text.length()); // 如果不相等就是富文本
row.put("has_rich", story_content.length() != text.length());
} catch (Exception e) {
// 解析失败时默认不是富文本
row.put("has_rich", false);
}
} else {
row.put("has_rich", false);
} }
row.put("product_item_name", ""); row.put("product_item_name", "");
@ -437,54 +453,108 @@ public class SnsStoryBaseServiceImpl extends BaseServiceImpl<SnsStoryBaseMapper,
String str_item_id = storyBase.getItem_id(); //获得帖子商品的item_id值 String str_item_id = storyBase.getItem_id(); //获得帖子商品的item_id值
if (StrUtil.isNotBlank(str_item_id)) { if (StrUtil.isNotBlank(str_item_id)) {
List<Long> item_ids = Convert.toList(Long.class, str_item_id); try {
Map product_row = shopService.getProductItemOne(item_ids.get(0)); List<Long> item_ids = Convert.toList(Long.class, str_item_id);
// 检查列表是否为空以及索引是否有效
if (CollUtil.isNotEmpty(item_ids) && item_ids.get(0) != null) {
Map product_row = shopService.getProductItemOne(item_ids.get(0));
if (CollUtil.isNotEmpty(product_row)) { if (CollUtil.isNotEmpty(product_row)) {
String product_name = Convert.toStr(product_row.get("product_name"), ""); String product_name = Convert.toStr(product_row.get("product_name"), "");
String item_name = Convert.toStr(product_row.get("item_name"), ""); String item_name = Convert.toStr(product_row.get("item_name"), "");
row.put("product_item_name", product_name + " " + item_name); row.put("product_item_name", product_name + " " + item_name);
row.put("item_unit_price", product_row.get("item_unit_price")); row.put("item_unit_price", product_row.get("item_unit_price"));
row.put("item_market_price", product_row.get("item_market_price")); row.put("item_market_price", product_row.get("item_market_price"));
row.put("product_image", product_row.get("product_image")); row.put("product_image", product_row.get("product_image"));
}
}
} catch (Exception e) {
log.warn("获取商品信息失败, story_id: {}, item_id: {}", story_id, str_item_id, e);
// 发生异常时保持默认值
} }
} }
// 是否点赞 // 是否点赞 - 只有登录用户才能查看点赞状态
QueryWrapper<SnsStoryLike> likeQueryWrapper = new QueryWrapper<>(); if (user_id != null) {
likeQueryWrapper.eq("story_id", story_id).eq("user_id", user_id); try {
SnsStoryLike story_like_row = snsStoryLikeService.findOne(likeQueryWrapper); QueryWrapper<SnsStoryLike> likeQueryWrapper = new QueryWrapper<>();
row.put("IsFabulous", story_like_row != null ? 1 : 0); likeQueryWrapper.eq("story_id", story_id).eq("user_id", user_id);
SnsStoryLike story_like_row = snsStoryLikeService.findOne(likeQueryWrapper);
row.put("IsFabulous", story_like_row != null ? 1 : 0);
} catch (Exception e) {
log.warn("查询点赞状态失败, story_id: {}, user_id: {}", story_id, user_id, e);
row.put("IsFabulous", 0);
}
} else {
row.put("IsFabulous", 0); // 未登录用户默认未点赞
}
// 下面两个查询用不到 // 下面两个查询用不到
/*QueryWrapper<SnsStoryAdvertisement> advertisementQueryWrapper = new QueryWrapper<>(); /*QueryWrapper<SnsStoryAdvertisement> advertisementQueryWrapper = new QueryWrapper<>();
advertisementQueryWrapper.eq("adv_enable", 1).eq("adv_is_top", 1); advertisementQueryWrapper.eq("adv_enable", 1).eq("adv_is_top", 1);
row.put("adv_top", snsStoryAdvertisementService.findOne(advertisementQueryWrapper)); row.put("adv_top", snsStoryAdvertisementService.findOne(advertisementQueryWrapper));
QueryWrapper<SnsStoryAdvertisement> advListQueryWrapper = new QueryWrapper<>(); QueryWrapper<SnsStoryAdvertisement> advListQueryWrapper = new QueryWrapper<>();
advListQueryWrapper.eq("adv_enable", 1).eq("adv_is_top", 0); advListQueryWrapper.eq("adv_enable", 1).eq("adv_is_top", 0);
row.put("adv_lists", snsStoryAdvertisementService.find(advListQueryWrapper));*/ row.put("adv_lists", snsStoryAdvertisementService.find(advListQueryWrapper));*/
// 移动端不需要分类 // 移动端不需要分类
if (!isMobile()) { if (!isMobile()) {
row.put("category_row", snsStoryCategoryService.find(new QueryWrapper<>())); try {
QueryWrapper<SnsStoryBase> baseQueryWrapper = new QueryWrapper<>(); row.put("category_row", snsStoryCategoryService.find(new QueryWrapper<>()));
baseQueryWrapper.eq("user_id", row.get("user_id")).eq("story_status", 1).eq("story_enable", 1).eq("story_privacy", 0).orderByDesc("story_time"); QueryWrapper<SnsStoryBase> baseQueryWrapper = new QueryWrapper<>();
row.put("story_user_items", snsStoryBaseService.lists(baseQueryWrapper, 1, 5).getRecords()); baseQueryWrapper.eq("user_id", row.get("user_id"))
.eq("story_status", 1)
.eq("story_enable", 1)
.eq("story_privacy", 0)
.orderByDesc("story_time");
Object userId = row.get("user_id");
if (userId != null) {
Page<SnsStoryBase> storyPage = snsStoryBaseService.lists(baseQueryWrapper, 1, 5);
row.put("story_user_items", storyPage.getRecords());
} else {
row.put("story_user_items", new ArrayList<>());
}
} catch (Exception e) {
log.warn("获取用户故事列表失败, user_id: {}", row.get("user_id"), e);
row.put("story_user_items", new ArrayList<>());
}
} }
QueryWrapper<SnsUserFriend> friendQueryWrapper = new QueryWrapper<>(); // 关注状态 - 只有登录用户才能查看关注状态
friendQueryWrapper.eq("friend_id", row.get("user_id")).eq("user_id", user_id); if (user_id != null && row.get("user_id") != null) {
SnsUserFriend friend_row = snsUserFriendService.findOne(friendQueryWrapper); try {
QueryWrapper<SnsUserFriend> friendQueryWrapper = new QueryWrapper<>();
friendQueryWrapper.eq("friend_id", row.get("user_id")).eq("user_id", user_id);
SnsUserFriend friend_row = snsUserFriendService.findOne(friendQueryWrapper);
if (friend_row != null) { if (friend_row != null) {
row.put("IsFollow", 1); row.put("IsFollow", 1);
} else {
row.put("IsFollow", 0);
}
} catch (Exception e) {
log.warn("查询关注状态失败, friend_id: {}, user_id: {}", row.get("user_id"), user_id, e);
row.put("IsFollow", 0);
}
} else { } else {
row.put("IsFollow", 0); row.put("IsFollow", 0); // 未登录用户默认未关注
} }
//row.put("story_file", StrUtil.split(row.get("story_file").toString(), ",")); // 处理故事文件
row.put("story_file", Convert.toList(String.class, row.get("story_file"))); try {
//row.put("story_file", StrUtil.split(row.get("story_file").toString(), ","));
Object storyFileObj = row.get("story_file");
if (storyFileObj != null) {
row.put("story_file", Convert.toList(String.class, storyFileObj));
} else {
row.put("story_file", new ArrayList<>());
}
} catch (Exception e) {
log.warn("处理故事文件失败, story_id: {}", story_id, e);
row.put("story_file", new ArrayList<>());
}
return row; return row;
} }

View File

@ -189,99 +189,170 @@ public class SnsStoryCategoryServiceImpl extends BaseServiceImpl<SnsStoryCategor
@Override @Override
public Map listComment() { public Map listComment() {
Integer user_id = null;
UserDto user = ContextUtil.getCurrentUser(); UserDto user = ContextUtil.getCurrentUser();
if (user == null) { if (user != null) {
throw new ApiUserException(I18nUtil._("用户信息异常!")); user_id = user.getId();
} }
Integer user_id = user.getId();
Integer page = getParameter("page", 1); //当前页码 Integer page = getParameter("page", 1); //当前页码
Integer rows = getParameter("rows", 20);//每页记录条数 Integer rows = getParameter("rows", 20);//每页记录条数
QueryWrapper<SnsStoryComment> wrapper = new QueryWrapper<>(); QueryWrapper<SnsStoryComment> wrapper = new QueryWrapper<>();
Integer story_id = Convert.toInt(getParameter("story_id")); Integer story_id = Convert.toInt(getParameter("story_id"));
// 参数校验
if (story_id == null || story_id <= 0) {
return new HashMap();
}
wrapper.eq("story_id", story_id); wrapper.eq("story_id", story_id);
wrapper.orderByDesc("comment_time"); wrapper.orderByDesc("comment_time");
Map data = snsStoryCommentService.getLists(wrapper, page, rows);
Map data = new HashMap();
try {
data = snsStoryCommentService.getLists(wrapper, page, rows);
} catch (Exception e) {
// 处理查询异常
data.put("items", new ArrayList<>());
data.put("total", 0);
}
// 确保 items 字段存在
if (data.get("items") == null) {
data.put("items", new ArrayList<>());
}
data.put("items", accountService.fixUserAvatar((List<Map>) data.get("items"), false)); data.put("items", accountService.fixUserAvatar((List<Map>) data.get("items"), false));
//读取评论回复 //读取评论回复
List<Map> items = (List<Map>) data.get("items"); List<Map> items = (List<Map>) data.get("items");
if (CollUtil.isEmpty(items)) { if (CollUtil.isEmpty(items)) {
return new HashMap(); return data;
} }
List<Integer> comment_id_row = items.stream().map(s -> Convert.toInt(s.get("comment_id"))).collect(Collectors.toList()); // 避免转换中的空值问题
List<Integer> comment_id_row = items.stream()
.map(s -> Convert.toInt(s.get("comment_id")))
.filter(id -> id != null)
.collect(Collectors.toList());
if (CollUtil.isEmpty(comment_id_row)) {
return data;
}
QueryWrapper<SnsStoryCommentHelpful> queryWrapper = new QueryWrapper<>(); QueryWrapper<SnsStoryCommentHelpful> queryWrapper = new QueryWrapper<>();
queryWrapper.in("comment_id", comment_id_row); queryWrapper.in("comment_id", comment_id_row);
queryWrapper.eq("user_id", user_id); if (user_id != null) {
// queryWrapper.eq("user_id", user_id);
}
//判断评论是否IsFabulous //判断评论是否IsFabulous
List<SnsStoryCommentHelpful> snsStoryCommentHelpfuls = snsStoryCommentHelpfulService.find(queryWrapper); List<SnsStoryCommentHelpful> snsStoryCommentHelpfuls = new ArrayList<>();
try {
snsStoryCommentHelpfuls = snsStoryCommentHelpfulService.find(queryWrapper);
} catch (Exception e) {
// 忽略查询异常
}
List<Map> comment_helpful_rows = Convert.toList(Map.class, snsStoryCommentHelpfuls); List<Map> comment_helpful_rows = Convert.toList(Map.class, snsStoryCommentHelpfuls);
if (comment_helpful_rows == null) {
comment_helpful_rows = new ArrayList<>();
}
QueryWrapper<SnsStoryCommentReply> snsStoryCommentReplyQueryWrapper = new QueryWrapper<>(); QueryWrapper<SnsStoryCommentReply> snsStoryCommentReplyQueryWrapper = new QueryWrapper<>();
snsStoryCommentReplyQueryWrapper.in("comment_id", comment_id_row); snsStoryCommentReplyQueryWrapper.in("comment_id", comment_id_row);
snsStoryCommentReplyQueryWrapper.eq("comment_reply_show_flag", 1); snsStoryCommentReplyQueryWrapper.eq("comment_reply_show_flag", 1);
snsStoryCommentReplyQueryWrapper.orderByDesc("comment_reply_time"); snsStoryCommentReplyQueryWrapper.orderByDesc("comment_reply_time");
List<SnsStoryCommentReply> snsStoryCommentReplies = snsStoryCommentReplyService.find(snsStoryCommentReplyQueryWrapper); List<SnsStoryCommentReply> snsStoryCommentReplies = new ArrayList<>();
List<Map> comment_reply_rows = Convert.toList(Map.class, snsStoryCommentReplies); try {
snsStoryCommentReplies = snsStoryCommentReplyService.find(snsStoryCommentReplyQueryWrapper);
} catch (Exception e) {
// 忽略查询异常
}
List<Map> comment_reply_rows = Convert.toList(Map.class, snsStoryCommentReplies);
if (comment_reply_rows == null) {
comment_reply_rows = new ArrayList<>();
}
try {
accountService.fixUserAvatar(comment_reply_rows, false);
} catch (Exception e) {
// 忽略头像修复异常
}
accountService.fixUserAvatar(comment_reply_rows, false);
Map comment_reply_tmp_rows = new HashMap(); Map comment_reply_tmp_rows = new HashMap();
for (Map comment_reply_row : comment_reply_rows) { for (Map comment_reply_row : comment_reply_rows) {
Integer comment_id = Convert.toInt(comment_reply_row.get("comment_id")); Integer comment_id = Convert.toInt(comment_reply_row.get("comment_id"));
if (comment_id == null) continue; // 避免空值
List comment_rows = (List) ObjectUtil.defaultIfNull(comment_reply_tmp_rows.get(comment_id), new ArrayList()); List comment_rows = (List) ObjectUtil.defaultIfNull(comment_reply_tmp_rows.get(comment_id), new ArrayList());
if (CollUtil.isEmpty(comment_rows)) comment_reply_tmp_rows.put(comment_id, comment_rows); if (CollUtil.isEmpty(comment_rows)) {
comment_reply_tmp_rows.put(comment_id, new ArrayList<>()); // 使用新实例
comment_rows = (List) comment_reply_tmp_rows.get(comment_id);
}
comment_rows.add(comment_reply_row); comment_rows.add(comment_reply_row);
} }
//判断子评论是否IsFabulous //判断子评论是否IsFabulous
List<Integer> comment_reply_id_row = comment_reply_rows.stream().map(s -> Convert List<Integer> comment_reply_id_row = comment_reply_rows.stream()
.toInt(s.get("comment_reply_id"))).collect(Collectors.toList()); .map(s -> Convert.toInt(s.get("comment_reply_id")))
.filter(id -> id != null)
.collect(Collectors.toList());
QueryWrapper<SnsStoryCommentReplyHelpful> helpfulQueryWrapper = new QueryWrapper<>(); Map comment_reply_helpful_tmp_rows = new HashMap(); // 提前定义变量
if (CollUtil.isNotEmpty(comment_reply_id_row)) helpfulQueryWrapper.in("comment_reply_id", comment_reply_id_row); if (CollUtil.isNotEmpty(comment_reply_id_row)) {
QueryWrapper<SnsStoryCommentReplyHelpful> helpfulQueryWrapper = new QueryWrapper<>();
helpfulQueryWrapper.in("comment_reply_id", comment_reply_id_row);
if (user_id != null) {
helpfulQueryWrapper.eq("user_id", user_id);
}
helpfulQueryWrapper.eq("user_id", user_id); List<SnsStoryCommentReplyHelpful> storyCommentHelpfuls = new ArrayList<>();
try {
storyCommentHelpfuls = snsStoryCommentReplyHelpfulService.find(helpfulQueryWrapper);
} catch (Exception e) {
// 忽略查询异常
}
List<SnsStoryCommentReplyHelpful> storyCommentHelpfuls = snsStoryCommentReplyHelpfulService.find(helpfulQueryWrapper); List<Map> comment_reply_helpful_rows = Convert.toList(Map.class, storyCommentHelpfuls);
List<Map> comment_reply_helpful_rows = Convert.toList(Map.class, storyCommentHelpfuls); if (comment_reply_helpful_rows == null) {
comment_reply_helpful_rows = new ArrayList<>();
}
Map comment_reply_helpful_tmp_rows = new HashMap(); for (Map comment_reply_helpful_row : comment_reply_helpful_rows) {
for (Map comment_reply_helpful_row : comment_reply_helpful_rows) { Integer comment_reply_id = Convert.toInt(comment_reply_helpful_row.get("comment_reply_id"));
Integer comment_reply_id = Convert.toInt(comment_reply_helpful_row.get("comment_reply_id")); if (comment_reply_id == null) continue; // 避免空值
List comment_rows = (List) ObjectUtil.defaultIfNull(comment_reply_helpful_tmp_rows.get(comment_reply_id), new ArrayList());
if (CollUtil.isEmpty(comment_rows)) comment_reply_helpful_tmp_rows.put(comment_reply_id, comment_rows); List comment_rows = (List) ObjectUtil.defaultIfNull(comment_reply_helpful_tmp_rows.get(comment_reply_id), new ArrayList());
comment_rows.add(comment_reply_helpful_row); if (CollUtil.isEmpty(comment_rows)) {
comment_reply_helpful_tmp_rows.put(comment_reply_id, new ArrayList<>()); // 使用新实例
comment_rows = (List) comment_reply_helpful_tmp_rows.get(comment_reply_id);
}
comment_rows.add(comment_reply_helpful_row);
}
} }
/*
QueryWrapper<SnsStoryCommentReply> wrapper1 = new QueryWrapper<>();
wrapper1.in("comment_id", comment_id_row);
wrapper1.eq("user_id", user_id);
List<SnsStoryCommentReply> storyCommentReplies = snsStoryCommentReplyService.find(wrapper1);
*/
comment_helpful_rows = Convert.toList(Map.class, snsStoryCommentHelpfuls);
Map comment_helpful_tmp_rows = new HashMap(); Map comment_helpful_tmp_rows = new HashMap();
for (Map comment_helpful_row : comment_helpful_rows) { for (Map comment_helpful_row : comment_helpful_rows) {
Integer comment_id = Convert.toInt(comment_helpful_row.get("comment_id")); Integer comment_id = Convert.toInt(comment_helpful_row.get("comment_id"));
List comment_rows = (List) ObjectUtil.defaultIfNull(comment_helpful_tmp_rows.get(comment_id), new ArrayList()); if (comment_id == null) continue; // 避免空值
if (CollUtil.isEmpty(comment_rows)) comment_reply_helpful_tmp_rows.put(comment_id, comment_rows);
List comment_rows = (List) ObjectUtil.defaultIfNull(comment_helpful_tmp_rows.get(comment_id), new ArrayList());
if (CollUtil.isEmpty(comment_rows)) {
comment_helpful_tmp_rows.put(comment_id, new ArrayList<>()); // 使用新实例
comment_rows = (List) comment_helpful_tmp_rows.get(comment_id);
}
comment_rows.add(comment_helpful_row); comment_rows.add(comment_helpful_row);
comment_helpful_tmp_rows.put(comment_helpful_row.get("comment_id"), comment_helpful_row);
} }
for (Map item : items) { for (Map item : items) {
Integer comment_id = Convert.toInt(item.get("comment_id")); Integer comment_id = Convert.toInt(item.get("comment_id"));
if (comment_id == null) continue; // 避免空值
if (ObjectUtil.isNotNull(comment_reply_tmp_rows.get(comment_id))) { if (ObjectUtil.isNotNull(comment_reply_tmp_rows.get(comment_id))) {
item.put("commentList", comment_reply_tmp_rows.get(comment_id)); item.put("commentList", comment_reply_tmp_rows.get(comment_id));
} else { } else {
@ -292,22 +363,22 @@ public class SnsStoryCategoryServiceImpl extends BaseServiceImpl<SnsStoryCategor
//评论回复是否点赞 //评论回复是否点赞
for (Map comment_reply_row : commentLists) { for (Map comment_reply_row : commentLists) {
if (ObjectUtil.isNotNull(comment_reply_helpful_tmp_rows.get(comment_reply_row.get("comment_reply_id")))) { Integer reply_id = Convert.toInt(comment_reply_row.get("comment_reply_id"));
comment_reply_row.put("IsFabulous", 1); if (reply_id != null && ObjectUtil.isNotNull(comment_reply_helpful_tmp_rows.get(reply_id))) {
// 检查具体的点赞记录而不仅仅是容器
List helpfulList = (List) comment_reply_helpful_tmp_rows.get(reply_id);
if (CollUtil.isNotEmpty(helpfulList)) {
comment_reply_row.put("IsFabulous", 1);
} else {
comment_reply_row.put("IsFabulous", 0);
}
} else { } else {
comment_reply_row.put("IsFabulous", 0); comment_reply_row.put("IsFabulous", 0);
} }
} }
//是否点赞 //是否点赞 - 修正重复判断逻辑
if (ObjectUtil.isNotNull(comment_reply_tmp_rows.get(item.get("comment_id")))) { if (ObjectUtil.isNotNull(comment_helpful_tmp_rows.get(comment_id))) {
item.put("IsFabulous", 1);
} else {
item.put("IsFabulous", 0);
}
//是否点赞
if (ObjectUtil.isNotNull(comment_helpful_tmp_rows.get(item.get("comment_id")))) {
item.put("IsFabulous", 1); item.put("IsFabulous", 1);
} else { } else {
item.put("IsFabulous", 0); item.put("IsFabulous", 0);
@ -317,6 +388,7 @@ public class SnsStoryCategoryServiceImpl extends BaseServiceImpl<SnsStoryCategor
return data; return data;
} }
@Override @Override
public Map story() { public Map story() {
Integer user_id = Convert.toInt(getParameter("user_id")); Integer user_id = Convert.toInt(getParameter("user_id"));
@ -401,7 +473,7 @@ public class SnsStoryCategoryServiceImpl extends BaseServiceImpl<SnsStoryCategor
AccountUserInfo user_info = accountService.getUserInfo(user_id); AccountUserInfo user_info = accountService.getUserInfo(user_id);
Integer user_certification = user_info.getUser_certification(); Integer user_certification = user_info.getUser_certification();
if (true || user_certification == 1) { if (true) {
/* /*
AccountUserType accountUserType = accountService.getAccountUserType(user_info.getUser_type_id()); AccountUserType accountUserType = accountService.getAccountUserType(user_info.getUser_type_id());