管理员获取所有快递信息

grs
yjxx 4 weeks ago
parent 31ba23d47f
commit 90cfec7d93

@ -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;
}
}

@ -3,17 +3,22 @@ package jty.expressdistributionsystem.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jty.expressdistributionsystem.DTO.ExpressListDTO;
import jty.expressdistributionsystem.DTO.SendMessageDTO; import jty.expressdistributionsystem.DTO.SendMessageDTO;
import jty.expressdistributionsystem.entity.Message; import jty.expressdistributionsystem.entity.*;
import jty.expressdistributionsystem.entity.Result; import jty.expressdistributionsystem.service.GoodsService;
import jty.expressdistributionsystem.entity.User;
import jty.expressdistributionsystem.service.MessageService; import jty.expressdistributionsystem.service.MessageService;
import jty.expressdistributionsystem.service.RecordsService;
import jty.expressdistributionsystem.service.UserService; import jty.expressdistributionsystem.service.UserService;
import jty.expressdistributionsystem.utils.SendMessageUtil; import jty.expressdistributionsystem.utils.SendMessageUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.data.domain.PageImpl;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
@RestController @RestController
@RequestMapping("/admin") @RequestMapping("/admin")
@Slf4j @Slf4j
@ -24,6 +29,12 @@ public class AdminController {
@Resource @Resource
private MessageService messageService; private MessageService messageService;
@Resource
private RecordsService recordsService;
@Resource
private GoodsService goodsService;
// 管理员查看用户或者快递员信息 // 管理员查看用户或者快递员信息
@GetMapping("/infoList") @GetMapping("/infoList")
public Result<Page<User>> getUserList(@RequestParam int page, @RequestParam int pageSize, @RequestParam int mark) { public Result<Page<User>> getUserList(@RequestParam int page, @RequestParam int pageSize, @RequestParam int mark) {
@ -77,4 +88,21 @@ public class AdminController {
messageService.save(message); messageService.save(message);
return new Result<>(200, "发送成功", ""); return new Result<>(200, "发送成功", "");
} }
// 管理员获取所有快递信息
@GetMapping("/express")
public Result<Page<ExpressListDTO>> getAllExpress(@RequestParam int page, @RequestParam int pageSize) {
Page<Records> recordsPage = new Page<>(page, pageSize);
recordsService.page(recordsPage);
List<ExpressListDTO> expressListDTOList = new ArrayList<>();
// 获取所有的快递记录
List<Records> recordsList = recordsService.list();
for(Records records : recordsList) {
Goods goods = goodsService.getById(records.getGoodsId());
expressListDTOList.add(new ExpressListDTO(records, goods));
}
Page<ExpressListDTO> expressDTOPage = new Page<>(recordsPage.getCurrent(), recordsPage.getSize(), recordsPage.getTotal());
expressDTOPage.setRecords(expressListDTOList);
return new Result<>(200, "", expressDTOPage);
}
} }

Loading…
Cancel
Save