From c97c4a15db2d48f46cf74e7da30760d79d302bf8 Mon Sep 17 00:00:00 2001 From: yjxx <1055683039@qq.com> Date: Thu, 7 Nov 2024 14:02:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../expressdistributionsystem/DTO/SendMessageDTO.java | 4 +++- .../controller/AdminController.java | 10 ++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main/java/jty/expressdistributionsystem/DTO/SendMessageDTO.java b/src/main/java/jty/expressdistributionsystem/DTO/SendMessageDTO.java index efc673d..690db4b 100644 --- a/src/main/java/jty/expressdistributionsystem/DTO/SendMessageDTO.java +++ b/src/main/java/jty/expressdistributionsystem/DTO/SendMessageDTO.java @@ -4,8 +4,10 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import lombok.Data; +import java.io.Serializable; + @Data -public class SendMessageDTO { +public class SendMessageDTO implements Serializable { @JsonSerialize(using = ToStringSerializer.class) private Long Id; diff --git a/src/main/java/jty/expressdistributionsystem/controller/AdminController.java b/src/main/java/jty/expressdistributionsystem/controller/AdminController.java index c7f08f7..6b18fd5 100644 --- a/src/main/java/jty/expressdistributionsystem/controller/AdminController.java +++ b/src/main/java/jty/expressdistributionsystem/controller/AdminController.java @@ -56,7 +56,7 @@ public class AdminController { @DeleteMapping("/delete/{id}") public Result delete(@PathVariable Long id, @RequestParam @NotNull String operation) { User user = userService.getById(id); - if(user == null) { + if (user == null) { return new Result<>(401, "账号不存在", ""); } switch (operation) { @@ -77,12 +77,6 @@ public class AdminController { // 管理员发送消息 @PostMapping("/sendMessage") public Result sendMessage(@RequestBody @NotNull SendMessageDTO sendMessageDTO) { - LambdaQueryWrapper userLambdaQueryWrapper = new LambdaQueryWrapper<>(); - userLambdaQueryWrapper.eq(User::getId, sendMessageDTO.getId()); - User user = userService.getOne(userLambdaQueryWrapper); - if(user == null) { - return new Result<>(404, "用户不存在", ""); - } Message message = SendMessageUtil.sendMessage(sendMessageDTO); messageService.save(message); return new Result<>(200, "发送成功", ""); @@ -96,7 +90,7 @@ public class AdminController { List expressListDTOList = new ArrayList<>(); // 获取所有的快递记录 List recordsList = recordsService.list(); - for(Records records : recordsList) { + for (Records records : recordsList) { Goods goods = goodsService.getById(records.getGoodsId()); // 查询寄件人、收件人、签收者、快递员信息 User sender = userService.getById(records.getSendUserId());