use of com.ch999.haha.admin.entity.UserInfo in project haha by hahafreeasair666.
the class NewsCommentServiceImpl method getNewsCommentList.
@Override
public PageVO<NewsCommentBO> getNewsCommentList(Integer newsId, Pageable pageable, Integer userId) {
Page<NewsCommentBO> allByNewsIdAndIsDel = newsCommentRepository.findAllByNewsIdAndIsDel(newsId, false, pageable);
List<NewsCommentBO> commentList = allByNewsIdAndIsDel.getContent();
commentList.forEach(li -> {
// 评论中评论的回复只显示未删除的点赞最多的三条
if (li.getReplies().size() > 3) {
li.setReplies(li.getReplies().stream().filter(de -> !de.getIsDel()).sorted(Comparator.comparing(NewsCommentBO.Reply::getZan).reversed()).collect(Collectors.toList()).subList(0, 3));
li.setIsNeedOpen(true);
} else {
li.setIsNeedOpen(false);
}
// 评论字段赋值
UserInfo userInfo = userInfoService.selectById(li.getUserId());
li.setUserName(userInfo.getUsername());
li.setAvatar(userInfo.getPicPath());
if (li.getZan() > 0 && userId != null) {
CommentZanBO zanInfo = commentZanRepository.findOne(li.getId());
if (zanInfo != null && zanInfo.getZanUserList().parallelStream().anyMatch(zan -> zan.equals(userId))) {
li.setIsPraised(true);
} else {
li.setIsPraised(false);
}
} else {
li.setIsPraised(false);
}
// 设置能否删除该评论字段
if (li.getUserId().equals(userId)) {
li.setIsCanDel(true);
} else {
li.setIsCanDel(false);
}
// 回复字段赋值
li.getReplies().forEach(re -> handleReplies(re, userId));
});
return new PageVO(allByNewsIdAndIsDel, pageable.getPageNumber(), commentList);
}
use of com.ch999.haha.admin.entity.UserInfo in project haha by hahafreeasair666.
the class NewsCommentServiceImpl method handleReplies.
private void handleReplies(NewsCommentBO.Reply re, Integer userId) {
UserInfo replyUserInfo = userInfoService.selectById(re.getReplyUserId());
UserInfo toUserInfo = userInfoService.selectById(re.getToUserId());
re.setReplyUserAvatar(replyUserInfo.getPicPath());
re.setReplyUserName(replyUserInfo.getUsername());
re.setToUserName(toUserInfo.getUsername());
if (re.getZan() > 0 && userId != null) {
CommentZanBO toZanInfo = commentZanRepository.findOne(re.getReplyId());
if (toZanInfo != null) {
re.setIsPraised(toZanInfo.getZanUserList().parallelStream().anyMatch(z -> z.equals(userId)));
} else {
re.setIsPraised(false);
}
} else {
re.setIsPraised(false);
}
// 设置能否删除该评论字段
if (re.getReplyUserId().equals(userId)) {
re.setIsCanDel(true);
} else {
re.setIsCanDel(false);
}
}
use of com.ch999.haha.admin.entity.UserInfo in project haha by hahafreeasair666.
the class UserInfoServiceImpl method getMyCenterInfo.
@Override
public MyCenterVO getMyCenterInfo(UserInfoBO userInfo) {
MyCenterVO userCenterVO = new MyCenterVO();
UserCenterInfoCountVO userInfoCount = getUserInfoCount(userInfo.getUserInfo().getId());
userCenterVO.setUserName(userInfo.getUserInfo().getUsername());
userCenterVO.setFans(userInfoCount.getFans());
userCenterVO.setFollows(userInfoCount.getFollow());
userCenterVO.setMyCollection(userInfoCount.getCollections());
userCenterVO.setMyAdoption(userInfoCount.getMyAdoption());
userCenterVO.setAdoptionRequest(userInfoCount.getAdoptionRequest());
userCenterVO.setUserId(userInfoCount.getUserId());
userCenterVO.setZan(userInfoCount.getZan());
userCenterVO.setDescription(userInfo.getUserInfo().getAutograph());
userCenterVO.setMyCredit(userInfo.getCreditInfo().get("creditNum") != null ? (int) userInfo.getCreditInfo().get("creditNum") : 0);
userCenterVO.setAvatar(userInfo.getUserInfo().getPicPath());
userCenterVO.setMyRelease(userInfoCount.getReleases());
userCenterVO.setAdoptionPerson(userInfoCount.getAdoptionPerson());
return userCenterVO;
}
use of com.ch999.haha.admin.entity.UserInfo in project haha by hahafreeasair666.
the class UserInfoServiceImpl method loginByMobileOrUserName.
@Override
public Integer loginByMobileOrUserName(String type, String loginInfo, String pwd) {
Wrapper<UserInfo> wrapper = new EntityWrapper<>();
wrapper.eq(type, loginInfo);
UserInfo userInfo = this.selectOne(wrapper);
if (userInfo == null || !pwd.equals(userInfo.getPwd())) {
return null;
} else {
return userInfo.getId();
}
}
use of com.ch999.haha.admin.entity.UserInfo in project haha by hahafreeasair666.
the class UserComponent method updateUserAvatar.
public Boolean updateUserAvatar(Integer userId, MultipartFile file) {
Imgs imgs = imgService.uploadImg(file);
if (imgs == null) {
return false;
} else {
UserInfo userInfo = new UserInfo(userId);
userInfo.setPicPath(imgs.getImgUrl());
userInfoService.updateById(userInfo);
UserInfo userInfo1 = userInfoService.selectById(userId);
UserInfoBO one = userInfoBORepository.findOne(userId);
one.setUserInfo(userInfo1);
userInfoBORepository.save(one);
return true;
}
}
Aggregations