咨询列表和店铺 api 接口加入白名单,不需要登录。
This commit is contained in:
parent
9085dc7681
commit
200f66839b
@ -93,6 +93,8 @@ secure:
|
||||
- "/mobile/shop/lakala/sign/ec/**"
|
||||
- "/mobile/**/**/test/case"
|
||||
- "/**/**/testcase"
|
||||
- "/mobile/sns/Story/listComment"
|
||||
- "/mobile/sns/Story/getStory"
|
||||
universal:
|
||||
urls:
|
||||
- "/admin/account/account-user-base/info"
|
||||
|
||||
@ -185,7 +185,7 @@ public class SnsStoryBaseServiceImpl extends BaseServiceImpl<SnsStoryBaseMapper,
|
||||
}
|
||||
|
||||
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())) {
|
||||
@ -201,7 +201,7 @@ public class SnsStoryBaseServiceImpl extends BaseServiceImpl<SnsStoryBaseMapper,
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map getStoryList(StorySearchDTO storySearchDTO) {
|
||||
public Map getStoryList(StorySearchDTO storySearchDTO) {
|
||||
QueryWrapper<SnsStoryBase> column_row = new QueryWrapper<>(); //查询获得相关的SnsStoryBase列表集合
|
||||
|
||||
if (storySearchDTO.getStory_type() != null) {
|
||||
@ -266,44 +266,44 @@ public class SnsStoryBaseServiceImpl extends BaseServiceImpl<SnsStoryBaseMapper,
|
||||
}
|
||||
|
||||
UserDto user = ContextUtil.getCurrentUser();
|
||||
if(user!=null){
|
||||
if (user != null) {
|
||||
//用户是否点赞
|
||||
QueryWrapper<SnsStoryLike> queryWrapper=new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id",user.getId());
|
||||
QueryWrapper<SnsStoryLike> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id", user.getId());
|
||||
List<SnsStoryLike> snsStoryLikes = snsStoryLikeService.find(queryWrapper);
|
||||
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"));
|
||||
if(collect.contains(story_id)){
|
||||
item.put("IsFabulous",1);
|
||||
}else{
|
||||
item.put("IsFabulous",0);
|
||||
if (collect.contains(story_id)) {
|
||||
item.put("IsFabulous", 1);
|
||||
} else {
|
||||
item.put("IsFabulous", 0);
|
||||
}
|
||||
}
|
||||
|
||||
//用户是否收藏
|
||||
QueryWrapper<SnsStoryCollection> snsStoryCollectionQueryWrapper=new QueryWrapper<>();
|
||||
snsStoryCollectionQueryWrapper.eq("user_id",user.getId());
|
||||
QueryWrapper<SnsStoryCollection> snsStoryCollectionQueryWrapper = new QueryWrapper<>();
|
||||
snsStoryCollectionQueryWrapper.eq("user_id", user.getId());
|
||||
List<SnsStoryCollection> snsStoryCollections = snsStoryCollectionService.find(snsStoryCollectionQueryWrapper);
|
||||
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"));
|
||||
if(collectionList.contains(story_id)){
|
||||
item.put("IsCollection",1);
|
||||
}else{
|
||||
item.put("IsCollection",0);
|
||||
if (collectionList.contains(story_id)) {
|
||||
item.put("IsCollection", 1);
|
||||
} else {
|
||||
item.put("IsCollection", 0);
|
||||
}
|
||||
}
|
||||
|
||||
//用户是否关注
|
||||
for(Map item:items){
|
||||
QueryWrapper<SnsUserFriend> friendQueryWrapper=new QueryWrapper<>();
|
||||
friendQueryWrapper.eq("user_id",user.getId()).eq("friend_id",Convert.toInt(item.get("user_id")));
|
||||
for (Map item : items) {
|
||||
QueryWrapper<SnsUserFriend> friendQueryWrapper = new QueryWrapper<>();
|
||||
friendQueryWrapper.eq("user_id", user.getId()).eq("friend_id", Convert.toInt(item.get("user_id")));
|
||||
SnsUserFriend one = snsUserFriendService.findOne(friendQueryWrapper);
|
||||
if(one!=null){
|
||||
item.put("IsFollow",true);
|
||||
}else{
|
||||
item.put("IsFollow",false);
|
||||
if (one != null) {
|
||||
item.put("IsFollow", true);
|
||||
} else {
|
||||
item.put("IsFollow", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -382,7 +382,7 @@ public class SnsStoryBaseServiceImpl extends BaseServiceImpl<SnsStoryBaseMapper,
|
||||
if (story_id == null) {
|
||||
accountUserSns.setUser_story(accountUserSns.getUser_story() + 1);
|
||||
if (!accountService.saveOrUpdateAccountUserSns(accountUserSns)) {
|
||||
log.error(I18nUtil._("更新用户发帖数量失败!bean[{}]"), accountUserSns.toString());
|
||||
log.error(I18nUtil._("更新用户发帖数量失败!bean[{}]"), accountUserSns);
|
||||
throw new ApiException(I18nUtil._("更新用户发帖数量失败!"));
|
||||
}
|
||||
}
|
||||
@ -406,28 +406,44 @@ public class SnsStoryBaseServiceImpl extends BaseServiceImpl<SnsStoryBaseMapper,
|
||||
|
||||
//帖子类型不是视频类型
|
||||
@Override
|
||||
public Map getStory(Integer story_id) {
|
||||
public Map getStory(Integer story_id) {
|
||||
UserDto user = ContextUtil.getCurrentUser();
|
||||
Integer user_id = 0;
|
||||
Integer user_id = null;
|
||||
|
||||
if (user == null) {
|
||||
throw new ApiException(ResultCode.NEED_LOGIN);
|
||||
} else {
|
||||
// 允许未登录用户访问
|
||||
if (user != null) {
|
||||
user_id = user.getId();
|
||||
}
|
||||
|
||||
// 参数校验
|
||||
if (story_id == null || story_id <= 0) {
|
||||
throw new ApiException("无效的故事ID");
|
||||
}
|
||||
|
||||
SnsStoryBase storyBase = get(story_id);
|
||||
|
||||
// 检查故事是否存在
|
||||
if (storyBase == null) {
|
||||
throw new ApiException("故事不存在");
|
||||
}
|
||||
|
||||
Map row = Convert.toMap(String.class, Object.class, storyBase);
|
||||
row = accountService.fixUserAvatar(row, true);
|
||||
|
||||
// 检查是否包含富文本
|
||||
String story_content = Convert.toStr(row.get("story_content"));
|
||||
if (StrUtil.isNotBlank(story_content)) {
|
||||
Document document = Jsoup.parse(story_content);
|
||||
String text = document.text();
|
||||
// 如果不相等就是富文本
|
||||
row.put("has_rich", story_content.length() != text.length());
|
||||
try {
|
||||
Document document = Jsoup.parse(story_content);
|
||||
String text = document.text();
|
||||
// 如果不相等就是富文本
|
||||
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", "");
|
||||
@ -437,54 +453,108 @@ public class SnsStoryBaseServiceImpl extends BaseServiceImpl<SnsStoryBaseMapper,
|
||||
|
||||
String str_item_id = storyBase.getItem_id(); //获得帖子商品的item_id值
|
||||
if (StrUtil.isNotBlank(str_item_id)) {
|
||||
List<Long> item_ids = Convert.toList(Long.class, str_item_id);
|
||||
Map product_row = shopService.getProductItemOne(item_ids.get(0));
|
||||
try {
|
||||
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)) {
|
||||
String product_name = Convert.toStr(product_row.get("product_name"), "");
|
||||
String item_name = Convert.toStr(product_row.get("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_market_price", product_row.get("item_market_price"));
|
||||
row.put("product_image", product_row.get("product_image"));
|
||||
if (CollUtil.isNotEmpty(product_row)) {
|
||||
String product_name = Convert.toStr(product_row.get("product_name"), "");
|
||||
String item_name = Convert.toStr(product_row.get("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_market_price", product_row.get("item_market_price"));
|
||||
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<>();
|
||||
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);
|
||||
// 是否点赞 - 只有登录用户才能查看点赞状态
|
||||
if (user_id != null) {
|
||||
try {
|
||||
QueryWrapper<SnsStoryLike> likeQueryWrapper = new QueryWrapper<>();
|
||||
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<>();
|
||||
advertisementQueryWrapper.eq("adv_enable", 1).eq("adv_is_top", 1);
|
||||
row.put("adv_top", snsStoryAdvertisementService.findOne(advertisementQueryWrapper));
|
||||
/*QueryWrapper<SnsStoryAdvertisement> advertisementQueryWrapper = new QueryWrapper<>();
|
||||
advertisementQueryWrapper.eq("adv_enable", 1).eq("adv_is_top", 1);
|
||||
row.put("adv_top", snsStoryAdvertisementService.findOne(advertisementQueryWrapper));
|
||||
|
||||
QueryWrapper<SnsStoryAdvertisement> advListQueryWrapper = new QueryWrapper<>();
|
||||
advListQueryWrapper.eq("adv_enable", 1).eq("adv_is_top", 0);
|
||||
row.put("adv_lists", snsStoryAdvertisementService.find(advListQueryWrapper));*/
|
||||
QueryWrapper<SnsStoryAdvertisement> advListQueryWrapper = new QueryWrapper<>();
|
||||
advListQueryWrapper.eq("adv_enable", 1).eq("adv_is_top", 0);
|
||||
row.put("adv_lists", snsStoryAdvertisementService.find(advListQueryWrapper));*/
|
||||
|
||||
// 移动端不需要分类
|
||||
if (!isMobile()) {
|
||||
row.put("category_row", snsStoryCategoryService.find(new QueryWrapper<>()));
|
||||
QueryWrapper<SnsStoryBase> baseQueryWrapper = 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");
|
||||
row.put("story_user_items", snsStoryBaseService.lists(baseQueryWrapper, 1, 5).getRecords());
|
||||
try {
|
||||
row.put("category_row", snsStoryCategoryService.find(new QueryWrapper<>()));
|
||||
QueryWrapper<SnsStoryBase> baseQueryWrapper = 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");
|
||||
|
||||
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);
|
||||
SnsUserFriend friend_row = snsUserFriendService.findOne(friendQueryWrapper);
|
||||
// 关注状态 - 只有登录用户才能查看关注状态
|
||||
if (user_id != null && row.get("user_id") != null) {
|
||||
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) {
|
||||
row.put("IsFollow", 1);
|
||||
if (friend_row != null) {
|
||||
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 {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -189,99 +189,170 @@ public class SnsStoryCategoryServiceImpl extends BaseServiceImpl<SnsStoryCategor
|
||||
|
||||
@Override
|
||||
public Map listComment() {
|
||||
|
||||
Integer user_id = null;
|
||||
UserDto user = ContextUtil.getCurrentUser();
|
||||
if (user == null) {
|
||||
throw new ApiUserException(I18nUtil._("用户信息异常!"));
|
||||
if (user != null) {
|
||||
user_id = user.getId();
|
||||
}
|
||||
Integer user_id = user.getId();
|
||||
|
||||
Integer page = getParameter("page", 1); //当前页码
|
||||
Integer rows = getParameter("rows", 20);//每页记录条数
|
||||
|
||||
QueryWrapper<SnsStoryComment> wrapper = new QueryWrapper<>();
|
||||
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.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));
|
||||
|
||||
//读取评论回复
|
||||
List<Map> items = (List<Map>) data.get("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.in("comment_id", comment_id_row);
|
||||
queryWrapper.eq("user_id", user_id);
|
||||
//
|
||||
if (user_id != null) {
|
||||
queryWrapper.eq("user_id", user_id);
|
||||
}
|
||||
|
||||
//判断评论是否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);
|
||||
if (comment_helpful_rows == null) {
|
||||
comment_helpful_rows = new ArrayList<>();
|
||||
}
|
||||
|
||||
QueryWrapper<SnsStoryCommentReply> snsStoryCommentReplyQueryWrapper = new QueryWrapper<>();
|
||||
snsStoryCommentReplyQueryWrapper.in("comment_id", comment_id_row);
|
||||
snsStoryCommentReplyQueryWrapper.eq("comment_reply_show_flag", 1);
|
||||
snsStoryCommentReplyQueryWrapper.orderByDesc("comment_reply_time");
|
||||
|
||||
List<SnsStoryCommentReply> snsStoryCommentReplies = snsStoryCommentReplyService.find(snsStoryCommentReplyQueryWrapper);
|
||||
List<Map> comment_reply_rows = Convert.toList(Map.class, snsStoryCommentReplies);
|
||||
List<SnsStoryCommentReply> snsStoryCommentReplies = new ArrayList<>();
|
||||
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();
|
||||
for (Map comment_reply_row : comment_reply_rows) {
|
||||
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());
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
//判断子评论是否IsFabulous
|
||||
List<Integer> comment_reply_id_row = comment_reply_rows.stream().map(s -> Convert
|
||||
.toInt(s.get("comment_reply_id"))).collect(Collectors.toList());
|
||||
List<Integer> comment_reply_id_row = comment_reply_rows.stream()
|
||||
.map(s -> Convert.toInt(s.get("comment_reply_id")))
|
||||
.filter(id -> id != null)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
QueryWrapper<SnsStoryCommentReplyHelpful> helpfulQueryWrapper = new QueryWrapper<>();
|
||||
if (CollUtil.isNotEmpty(comment_reply_id_row)) helpfulQueryWrapper.in("comment_reply_id", comment_reply_id_row);
|
||||
Map comment_reply_helpful_tmp_rows = new HashMap(); // 提前定义变量
|
||||
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) {
|
||||
Integer comment_reply_id = Convert.toInt(comment_reply_helpful_row.get("comment_reply_id"));
|
||||
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);
|
||||
comment_rows.add(comment_reply_helpful_row);
|
||||
for (Map comment_reply_helpful_row : comment_reply_helpful_rows) {
|
||||
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, 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();
|
||||
for (Map comment_helpful_row : comment_helpful_rows) {
|
||||
|
||||
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 (CollUtil.isEmpty(comment_rows)) comment_reply_helpful_tmp_rows.put(comment_id, comment_rows);
|
||||
if (comment_id == null) continue; // 避免空值
|
||||
|
||||
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_helpful_tmp_rows.put(comment_helpful_row.get("comment_id"), comment_helpful_row);
|
||||
}
|
||||
|
||||
for (Map item : items) {
|
||||
Integer comment_id = Convert.toInt(item.get("comment_id"));
|
||||
if (comment_id == null) continue; // 避免空值
|
||||
|
||||
if (ObjectUtil.isNotNull(comment_reply_tmp_rows.get(comment_id))) {
|
||||
item.put("commentList", comment_reply_tmp_rows.get(comment_id));
|
||||
} else {
|
||||
@ -292,22 +363,22 @@ public class SnsStoryCategoryServiceImpl extends BaseServiceImpl<SnsStoryCategor
|
||||
|
||||
//评论回复是否点赞
|
||||
for (Map comment_reply_row : commentLists) {
|
||||
if (ObjectUtil.isNotNull(comment_reply_helpful_tmp_rows.get(comment_reply_row.get("comment_reply_id")))) {
|
||||
comment_reply_row.put("IsFabulous", 1);
|
||||
Integer reply_id = Convert.toInt(comment_reply_row.get("comment_reply_id"));
|
||||
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 {
|
||||
comment_reply_row.put("IsFabulous", 0);
|
||||
}
|
||||
}
|
||||
|
||||
//是否点赞
|
||||
if (ObjectUtil.isNotNull(comment_reply_tmp_rows.get(item.get("comment_id")))) {
|
||||
item.put("IsFabulous", 1);
|
||||
} else {
|
||||
item.put("IsFabulous", 0);
|
||||
}
|
||||
|
||||
//是否点赞
|
||||
if (ObjectUtil.isNotNull(comment_helpful_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);
|
||||
@ -317,6 +388,7 @@ public class SnsStoryCategoryServiceImpl extends BaseServiceImpl<SnsStoryCategor
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map story() {
|
||||
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);
|
||||
Integer user_certification = user_info.getUser_certification();
|
||||
|
||||
if (true || user_certification == 1) {
|
||||
if (true) {
|
||||
|
||||
/*
|
||||
AccountUserType accountUserType = accountService.getAccountUserType(user_info.getUser_type_id());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user