From 90cfec7d93e1274f88272f60299f68883a5d61d4 Mon Sep 17 00:00:00 2001 From: yjxx <1055683039@qq.com> Date: Tue, 5 Nov 2024 12:54:08 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=89=80=E6=9C=89=E5=BF=AB=E9=80=92=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DTO/ExpressListDTO.java | 16 +++++++++ .../controller/AdminController.java | 34 +++++++++++++++++-- 2 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 src/main/java/jty/expressdistributionsystem/DTO/ExpressListDTO.java diff --git a/src/main/java/jty/expressdistributionsystem/DTO/ExpressListDTO.java b/src/main/java/jty/expressdistributionsystem/DTO/ExpressListDTO.java new file mode 100644 index 0000000..5994afb --- /dev/null +++ b/src/main/java/jty/expressdistributionsystem/DTO/ExpressListDTO.java @@ -0,0 +1,16 @@ +package jty.expressdistributionsystem.DTO; + +import jty.expressdistributionsystem.entity.Goods; +import jty.expressdistributionsystem.entity.Records; +import lombok.Data; + +@Data +public class ExpressListDTO { + private Records records; + private Goods goods; + + public ExpressListDTO(Records records, Goods goods) { + this.records = records; + this.goods = goods; + } +} diff --git a/src/main/java/jty/expressdistributionsystem/controller/AdminController.java b/src/main/java/jty/expressdistributionsystem/controller/AdminController.java index 41bde0c..1706092 100644 --- a/src/main/java/jty/expressdistributionsystem/controller/AdminController.java +++ b/src/main/java/jty/expressdistributionsystem/controller/AdminController.java @@ -3,17 +3,22 @@ package jty.expressdistributionsystem.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import jakarta.annotation.Resource; +import jty.expressdistributionsystem.DTO.ExpressListDTO; import jty.expressdistributionsystem.DTO.SendMessageDTO; -import jty.expressdistributionsystem.entity.Message; -import jty.expressdistributionsystem.entity.Result; -import jty.expressdistributionsystem.entity.User; +import jty.expressdistributionsystem.entity.*; +import jty.expressdistributionsystem.service.GoodsService; import jty.expressdistributionsystem.service.MessageService; +import jty.expressdistributionsystem.service.RecordsService; import jty.expressdistributionsystem.service.UserService; import jty.expressdistributionsystem.utils.SendMessageUtil; import lombok.extern.slf4j.Slf4j; import org.jetbrains.annotations.NotNull; +import org.springframework.data.domain.PageImpl; import org.springframework.web.bind.annotation.*; +import java.util.ArrayList; +import java.util.List; + @RestController @RequestMapping("/admin") @Slf4j @@ -24,6 +29,12 @@ public class AdminController { @Resource private MessageService messageService; + @Resource + private RecordsService recordsService; + + @Resource + private GoodsService goodsService; + // 管理员查看用户或者快递员信息 @GetMapping("/infoList") public Result> getUserList(@RequestParam int page, @RequestParam int pageSize, @RequestParam int mark) { @@ -77,4 +88,21 @@ public class AdminController { messageService.save(message); return new Result<>(200, "发送成功", ""); } + + // 管理员获取所有快递信息 + @GetMapping("/express") + public Result> getAllExpress(@RequestParam int page, @RequestParam int pageSize) { + Page recordsPage = new Page<>(page, pageSize); + recordsService.page(recordsPage); + List expressListDTOList = new ArrayList<>(); + // 获取所有的快递记录 + List recordsList = recordsService.list(); + for(Records records : recordsList) { + Goods goods = goodsService.getById(records.getGoodsId()); + expressListDTOList.add(new ExpressListDTO(records, goods)); + } + Page expressDTOPage = new Page<>(recordsPage.getCurrent(), recordsPage.getSize(), recordsPage.getTotal()); + expressDTOPage.setRecords(expressListDTOList); + return new Result<>(200, "", expressDTOPage); + } }