feat:my available message

main
wangqing 10 months ago
parent 84c9a11eaf
commit f85e028cde

@ -177,9 +177,9 @@ public class CommentController extends BaseController {
comment.setNickName(userLoginDto.getNickName());
comment.setAvatar(Constants.RESOURCE_PREFIX+userLoginDto.getAvatar());
comment.setLocation(IpUtil.getIpLocation(getIpAddr(request)));
commentService.save(comment,userLoginDto);
Comment commentResp = commentService.save(comment,userLoginDto);
return Result.success();
return Result.success(commentResp);
}

@ -51,7 +51,7 @@ public class CommentService {
return commentDao.findById(id).get();
}
public void save(Comment comment, UserLoginDto userLoginDto) {
public Comment save(Comment comment, UserLoginDto userLoginDto) {
comment.set_id(idWorker.nextId()+"");
comment.setPublishTime(new Date());
comment.setThumbupCount(0); //点赞数
@ -102,6 +102,7 @@ public class CommentService {
}
commentDao.save(comment);
return comment;
}
public void update (Comment comment) {
@ -152,7 +153,7 @@ public class CommentService {
*
*/
UserMessageDto userMessageDto = new UserMessageDto();
userMessageDto.setType(MessageTypeEnum.COMMENT.getType()); //消息类型 1私信 2新赞3新关注 4新评论 5.系统消息
userMessageDto.setType(MessageTypeEnum.THUMB_UP.getType()); //消息类型 1私信 2新赞3新关注 4新评论 5.系统消息
userMessageDto.setUserId(parentComment.getUserId());
userMessageDto.setContent(userLoginDto.getNickName()+" 点赞了你的评论");
userMessageDto.setTitle("您有新的点赞");

@ -18,7 +18,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/userMessage")
@ -60,9 +62,9 @@ public class UserMessageController extends BaseController {
}
@ApiOperation(value = "获取消息分页列表")
@GetMapping("/list/{page}/{size}")
public Result list(@PathVariable int page,@PathVariable int size,@RequestHeader(value = "Authorization", required = true) String authorization){
@ApiOperation(value = "获取消息")
@GetMapping("/list")
public Result list(@RequestHeader(value = "Authorization", required = true) String authorization){
// List list = userMessageService.findByUserId(userId);
//验证是否登录并且拿到ID
UserLoginDto userLoginDto = getUserLoginDto(authorization);
@ -70,8 +72,25 @@ public class UserMessageController extends BaseController {
return Result.unauthorized(null);
}
String userId = userLoginDto.getUserId();
Page<UserMessage> pageList = userMessageService.findSearch(userId,page,size);
return Result.success(new PageResult<UserMessage>(pageList.getTotalElements(),pageList.getContent()));
Map map = new HashMap();
map.put("comment","");
map.put("follow","");
map.put("thumbup","");
/**
* 1 23 4 5.
*/
UserMessage userMessageComment = userMessageService.findByUseridAndType(userId,MessageTypeEnum.COMMENT.getType());// 评论
UserMessage userMessageFollow = userMessageService.findByUseridAndType(userId,MessageTypeEnum.FOLLOW.getType());//
UserMessage userMessageThumbup = userMessageService.findByUseridAndType(userId,MessageTypeEnum.THUMB_UP.getType());//
map.put("comment",userMessageComment);
map.put("follow",userMessageFollow);
map.put("thumbup",userMessageThumbup);
// Page<UserMessage> pageList = userMessageService.findSearch(userId,page,size);
// return Result.success(new PageResult<UserMessage>(pageList.getTotalElements(),pageList.getContent()));
return Result.success(map);
}
@ApiOperation(value = "更新消息状态为已读")

@ -15,5 +15,7 @@ public interface UserMessageDao extends MongoRepository<UserMessage,String> {
Page<UserMessage> findByUserIdOrderBySendTimeDesc(String userId, Pageable pageable);
UserMessage findTopByUserIdAndTypeOrderBySendTimeDesc(String userId,int type);
}

@ -87,4 +87,8 @@ public class UserMessageService {
BulkWriteResult result = bulkOps.execute();
}
public UserMessage findByUseridAndType(String userId, int type) {
return userMessageDao.findTopByUserIdAndTypeOrderBySendTimeDesc(userId,type);
}
}

Loading…
Cancel
Save