From 9ef8ec7a6b16a12f19aa189c03aaaf217d7a56ee Mon Sep 17 00:00:00 2001 From: yjxx <1055683039@qq.com> Date: Tue, 12 Nov 2024 12:45:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9C=9F=E5=AF=B9=E5=AF=84=E4=BB=B6=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../expressdistributionsystem/DTO/ExpressListDTO.java | 8 +++++--- .../java/jty/expressdistributionsystem/DTO/GoodsDTO.java | 5 ++++- .../controller/AdminController.java | 7 ++++--- .../controller/UserController.java | 2 +- .../jty/expressdistributionsystem/entity/Records.java | 9 ++++++++- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/main/java/jty/expressdistributionsystem/DTO/ExpressListDTO.java b/src/main/java/jty/expressdistributionsystem/DTO/ExpressListDTO.java index d9205f6..9d5e721 100644 --- a/src/main/java/jty/expressdistributionsystem/DTO/ExpressListDTO.java +++ b/src/main/java/jty/expressdistributionsystem/DTO/ExpressListDTO.java @@ -14,15 +14,17 @@ public class ExpressListDTO { private User recipient; // 收件人 private User addressee; // 签收者 private User courier; // 派送的快递员 - private Address address; // 送到哪里 + private Address addressFrom; // 从哪里送的 + private Address addressTo; // 送到哪里 - public ExpressListDTO(Records records, Goods goods, User sender, User recipient, User addressee, User courier, Address address) { + public ExpressListDTO(Records records, Goods goods, User sender, User recipient, User addressee, User courier, Address addressFrom, Address addressTo) { this.records = records; this.goods = goods; this.sender = sender; this.recipient = recipient; this.addressee = addressee; this.courier = courier; - this.address = address; + this.addressFrom = addressFrom; + this.addressTo = addressTo; } } diff --git a/src/main/java/jty/expressdistributionsystem/DTO/GoodsDTO.java b/src/main/java/jty/expressdistributionsystem/DTO/GoodsDTO.java index 08b4773..f33fb46 100644 --- a/src/main/java/jty/expressdistributionsystem/DTO/GoodsDTO.java +++ b/src/main/java/jty/expressdistributionsystem/DTO/GoodsDTO.java @@ -20,8 +20,11 @@ public class GoodsDTO { @NotBlank(message = "快递重量不能为空") private String quality; + @NotBlank(message = "发货地不能为空") + private String addressFrom; + @NotBlank(message = "运送地址不能为空") - private String address; + private String addressTo; @JsonSerialize(using = ToStringSerializer.class) @NotNull diff --git a/src/main/java/jty/expressdistributionsystem/controller/AdminController.java b/src/main/java/jty/expressdistributionsystem/controller/AdminController.java index ea969cd..a69c40e 100644 --- a/src/main/java/jty/expressdistributionsystem/controller/AdminController.java +++ b/src/main/java/jty/expressdistributionsystem/controller/AdminController.java @@ -118,9 +118,10 @@ public class AdminController { User recipient = userService.getById(records.getGetUserId()); User addressee = userService.getById(records.getAddresseeId()); User courier = userService.getById(records.getExpressId()); - // 查询地址信息 - Address address = addressService.getById(records.getAddressId()); - ExpressListDTO expressListDTO = new ExpressListDTO(records, goods, sender, recipient, addressee, courier, address); + // 查询地址信息: 从哪里送的 送到哪里 + Address addressTo = addressService.getById(records.getAddressId()); + Address addressFrom = addressService.getById(records.getAddressFrom()); + ExpressListDTO expressListDTO = new ExpressListDTO(records, goods, sender, recipient, addressee, courier, addressFrom, addressTo); expressListDTOList.add(expressListDTO); } Page expressDTOPage = new Page<>(recordsPage.getCurrent(), recordsPage.getSize(), recordsPage.getTotal()); diff --git a/src/main/java/jty/expressdistributionsystem/controller/UserController.java b/src/main/java/jty/expressdistributionsystem/controller/UserController.java index 5955264..f85a720 100644 --- a/src/main/java/jty/expressdistributionsystem/controller/UserController.java +++ b/src/main/java/jty/expressdistributionsystem/controller/UserController.java @@ -156,7 +156,7 @@ public class UserController { } // 判断地址是否存在 LambdaQueryWrapper
addressLambdaQueryWrapper = new LambdaQueryWrapper<>(); - addressLambdaQueryWrapper.eq(Address::getAddress, goodsDTO.getAddress()); + addressLambdaQueryWrapper.eq(Address::getAddress, goodsDTO.getAddressTo()); Address address = addressService.getOne(addressLambdaQueryWrapper); if (address == null) { return new Result<>(404, "地址不存在", null); diff --git a/src/main/java/jty/expressdistributionsystem/entity/Records.java b/src/main/java/jty/expressdistributionsystem/entity/Records.java index d9d20f4..3a12b19 100644 --- a/src/main/java/jty/expressdistributionsystem/entity/Records.java +++ b/src/main/java/jty/expressdistributionsystem/entity/Records.java @@ -33,6 +33,7 @@ public class Records implements Serializable { @NotNull private Long getUserId; + @TableField("express_id") @JsonSerialize(using = ToStringSerializer.class) @NotNull private Long expressId; @@ -45,7 +46,13 @@ public class Records implements Serializable { @TableField("mark") private Integer mark; - @TableField + // 从哪里送的 + @TableField("address_from") + @JsonSerialize(using = ToStringSerializer.class) + private Long addressFrom; + + // 送到哪里 + @TableField("address_id") @JsonSerialize(using = ToStringSerializer.class) private Long addressId;