|
|
|
@ -39,15 +39,15 @@ public class UserController {
|
|
|
|
|
@Resource
|
|
|
|
|
private AddressService addressService;
|
|
|
|
|
|
|
|
|
|
// 用户给快递员发消息
|
|
|
|
|
// 用户发消息(finish)
|
|
|
|
|
@PostMapping("/sendMessage")
|
|
|
|
|
public Result<String> sendMessage(@Validated @RequestBody SendMessageDTO sendMessageDTO) {
|
|
|
|
|
Message message = SendMessageUtil.sendMessage(sendMessageDTO);
|
|
|
|
|
Message message = SendMessageUtil.sendMessage(sendMessageDTO, userService);
|
|
|
|
|
messageService.save(message);
|
|
|
|
|
return new Result<>(200, "发送成功", "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 给快递员点赞
|
|
|
|
|
// 给快递员点赞(finish)
|
|
|
|
|
@PostMapping("/likes")
|
|
|
|
|
public Result<String> like(@RequestParam Long id) {
|
|
|
|
|
User employee = userService.getById(id);
|
|
|
|
@ -56,22 +56,18 @@ public class UserController {
|
|
|
|
|
return new Result<>(200, "点赞成功", "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 用户查看发给别人消息
|
|
|
|
|
// 用户查看发给别人消息(finish)
|
|
|
|
|
@GetMapping("/sendToMessage")
|
|
|
|
|
public Result<Page<Message>> sendToMessage(@RequestParam int page, @RequestParam int pageSize) {
|
|
|
|
|
if (page <= 0 || pageSize == 0) {
|
|
|
|
|
return new Result<>(400, "页码和每页大小必须大于0", null);
|
|
|
|
|
}
|
|
|
|
|
Long id = GetIdUtil.getId();
|
|
|
|
|
Page<Message> messagePage = new Page<>(page, pageSize);
|
|
|
|
|
public Result<List<Message>> sendToMessage(@RequestParam String toUserName) {
|
|
|
|
|
LambdaQueryWrapper<User> userLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
userLambdaQueryWrapper.eq(User::getUserName, toUserName);
|
|
|
|
|
User toUser = userService.getOne(userLambdaQueryWrapper);
|
|
|
|
|
Long userId = GetIdUtil.getId();
|
|
|
|
|
LambdaQueryWrapper<Message> messageLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
// 添加查询条件
|
|
|
|
|
messageLambdaQueryWrapper.eq(Message::getSendUserId, id);
|
|
|
|
|
// 排序条件:先按 mark 对应值排序,然后按时间排序
|
|
|
|
|
messageLambdaQueryWrapper.orderByDesc(Message::getMark) // mark 值大的排前面
|
|
|
|
|
.orderByDesc(Message::getCreateTime); // 时间新的排前面
|
|
|
|
|
messageService.page(messagePage, messageLambdaQueryWrapper);
|
|
|
|
|
return new Result<>(200, "获取成功", messagePage);
|
|
|
|
|
messageLambdaQueryWrapper.eq(Message::getSendUserId, userId)
|
|
|
|
|
.eq(Message::getGetUserId, toUser.getId());
|
|
|
|
|
List<Message> list = messageService.list(messageLambdaQueryWrapper);
|
|
|
|
|
return new Result<>(200, "", list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 用户查看别人发给自己的消息(finish)
|
|
|
|
|