From 754d59c9b4537d94cdc7a740aacfc5f47206e63a Mon Sep 17 00:00:00 2001 From: yjxx <1055683039@qq.com> Date: Wed, 13 Nov 2024 16:33:44 +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 --- .../java/jty/expressdistributionsystem/DTO/GoodsDTO.java | 7 +++++-- .../controller/UserController.java | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/jty/expressdistributionsystem/DTO/GoodsDTO.java b/src/main/java/jty/expressdistributionsystem/DTO/GoodsDTO.java index 5f892d5..a520f8d 100644 --- a/src/main/java/jty/expressdistributionsystem/DTO/GoodsDTO.java +++ b/src/main/java/jty/expressdistributionsystem/DTO/GoodsDTO.java @@ -18,13 +18,16 @@ public class GoodsDTO { @NotBlank(message = "快递名称不能为空") private String name; - @NotBlank(message = "快递重量不能为空") + /** + * 此处不能使用 @NotBlank + * NotBlank是用于字符串类型的 + */ @ValidQuality private Double quality; @NotBlank(message = "发货地不能为空") private String addressFrom; - @NotBlank(message = "运送地址不能为空") + @NotBlank(message = "收件地址不能为空") private String addressTo; } diff --git a/src/main/java/jty/expressdistributionsystem/controller/UserController.java b/src/main/java/jty/expressdistributionsystem/controller/UserController.java index 4205aaa..6af7f2b 100644 --- a/src/main/java/jty/expressdistributionsystem/controller/UserController.java +++ b/src/main/java/jty/expressdistributionsystem/controller/UserController.java @@ -162,6 +162,7 @@ public class UserController { if (address == null) { return new Result<>(404, "地址不存在", null); } + addressLambdaQueryWrapper.clear(); // 如果寄件和收件是一个地方,禁止 if (goodsDTO.getAddressFrom().equals(goodsDTO.getAddressTo())) { return new Result<>(400, "寄件和收件不能是同一个地方", null); @@ -178,7 +179,11 @@ public class UserController { goods.setQuality(goodsDTO.getQuality()); goodsService.save(goods); // 存进历史记录 + // 寄件方位置 + addressLambdaQueryWrapper.eq(Address::getAddress, goodsDTO.getAddressFrom()); + Address addressFrom = addressService.getOne(addressLambdaQueryWrapper); Records records = new Records(); + records.setAddressFrom(addressFrom.getId()); records.setSendUserId(GetIdUtil.getId()); records.setGetUserId(getUser.getId()); records.setAddressId(address.getId());