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); + } }