|
|
@@ -8,6 +8,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import space.anyi.serve.entity.order.OrderTip;
|
|
|
import space.anyi.serve.entity.post.Post;
|
|
|
import space.anyi.serve.entity.post.PostVo;
|
|
|
+import space.anyi.serve.entity.profile.UserProfile;
|
|
|
import space.anyi.serve.entity.user.User;
|
|
|
import space.anyi.serve.mapper.OrderTipMapper;
|
|
|
import space.anyi.serve.mapper.PostMapper;
|
|
|
@@ -15,6 +16,7 @@ import space.anyi.serve.mapper.PostViewRecordMapper;
|
|
|
import space.anyi.serve.entity.post.PostViewRecord;
|
|
|
import space.anyi.serve.service.PostService;
|
|
|
import space.anyi.serve.service.UserService;
|
|
|
+import space.anyi.serve.service.UserProfileService;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
|
@@ -26,13 +28,16 @@ public class PostServiceImpl extends ServiceImpl<PostMapper, Post> implements Po
|
|
|
private final PostViewRecordMapper postViewRecordMapper;
|
|
|
private final OrderTipMapper orderTipMapper;
|
|
|
private final UserService userService;
|
|
|
+ private final UserProfileService userProfileService;
|
|
|
|
|
|
public PostServiceImpl(PostViewRecordMapper postViewRecordMapper,
|
|
|
OrderTipMapper orderTipMapper,
|
|
|
- UserService userService) {
|
|
|
+ UserService userService,
|
|
|
+ UserProfileService userProfileService) {
|
|
|
this.postViewRecordMapper = postViewRecordMapper;
|
|
|
this.orderTipMapper = orderTipMapper;
|
|
|
this.userService = userService;
|
|
|
+ this.userProfileService = userProfileService;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -66,6 +71,7 @@ public class PostServiceImpl extends ServiceImpl<PostMapper, Post> implements Po
|
|
|
vo.setExpertName(expert.getUsername());
|
|
|
vo.setExpertAvatar(expert.getAvatar());
|
|
|
}
|
|
|
+ applyExpertProfile(vo, post.getExpertId());
|
|
|
if (currentUserId != null) {
|
|
|
vo.setIsPaid(hasUserPaid(post.getId(), currentUserId));
|
|
|
}
|
|
|
@@ -93,6 +99,7 @@ public class PostServiceImpl extends ServiceImpl<PostMapper, Post> implements Po
|
|
|
vo.setExpertName(expert.getUsername());
|
|
|
vo.setExpertAvatar(expert.getAvatar());
|
|
|
}
|
|
|
+ applyExpertProfile(vo, post.getExpertId());
|
|
|
|
|
|
boolean isExpired = LocalDateTime.now().isAfter(post.getExpireTime());
|
|
|
boolean isPaid = currentUserId != null && hasUserPaid(id, currentUserId);
|
|
|
@@ -176,6 +183,15 @@ public class PostServiceImpl extends ServiceImpl<PostMapper, Post> implements Po
|
|
|
return page(page, wrapper);
|
|
|
}
|
|
|
|
|
|
+ private void applyExpertProfile(PostVo vo, Long expertUserId) {
|
|
|
+ if (expertUserId == null) return;
|
|
|
+ UserProfile profile = userProfileService.getByUserId(expertUserId);
|
|
|
+ if (profile != null) {
|
|
|
+ vo.setExpertLevel(profile.getLevel());
|
|
|
+ vo.setExpertIsRealname(profile.getIsRealname());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void recordView(Long userId, List<Post> posts) {
|
|
|
for (Post post : posts) {
|
|
|
Long count = postViewRecordMapper.selectCount(
|