package com.boying.controller.phone; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.boying.common.R; import com.boying.entity.EnterPark; import com.boying.entity.Park; import com.boying.service.EnterParkService; import com.boying.service.ParkService; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; @RestController @RequestMapping("ffzf/notice") @RequiredArgsConstructor public class NoticeController { private final EnterParkService enterParkService; private final ParkService parkService; //停车场内有违法的车辆 @PostMapping("/illegalCar") public Object illegalCar(Long parkId){ QueryWrapper wrapper = new QueryWrapper<>(); wrapper.lambda() .eq(EnterPark::getStatus,1) .eq(EnterPark::getParkId,parkId); return R.ok( enterParkService.list(wrapper)); } //停车场内有违法的车辆 @PostMapping("/illegalCar2") public Object illegalCar2(){ QueryWrapper wrapper = new QueryWrapper<>(); wrapper.lambda() .eq(EnterPark::getStatus,1); List all = enterParkService.list(wrapper); for(EnterPark enterPark:all){ Park park = parkService.getById(enterPark.getParkId()); enterPark.setParkName(park.getName()); } return R.ok(all); } //停车场内的车辆 根据状态查询 @PostMapping("/enterPark") public Object enterPark(Integer status, Page page){ if(status==null){ Page page1 = enterParkService.page(page); List records = page1.getRecords(); for (EnterPark record : records) { record.setParkName(parkService.getById(record.getParkId()).getName()); } page1.setRecords(records); return R.ok(page1); } QueryWrapper wrapper = new QueryWrapper<>(); wrapper.lambda() .eq(EnterPark::getStatus,status) .orderByDesc(EnterPark::getId); Page all = enterParkService.page(page,wrapper); for (EnterPark enterPark : all.getRecords()) { Park byId = parkService.getById(enterPark.getParkId()); if(byId != null){ enterPark.setParkName(byId.getName()); } } return R.ok(all); } }