kongdeqiang
2023-01-17 fb1a96ec056ee660ff3c264cdd64cdb8ac5d7540
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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("notice")
@RequiredArgsConstructor
public class NoticeController {
 
    private final EnterParkService enterParkService;
    private final ParkService parkService;
 
    //停车场内有违法的车辆
    @PostMapping("/illegalCar")
    public Object illegalCar(Long parkId){
        QueryWrapper<EnterPark> 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<EnterPark> wrapper = new QueryWrapper<>();
        wrapper.lambda()
                .eq(EnterPark::getStatus,1);
 
        List<EnterPark> 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<EnterPark> records = page1.getRecords();
            for (EnterPark record : records) {
                record.setParkName(parkService.getById(record.getParkId()).getName());
            }
            page1.setRecords(records);
            return R.ok(page1);
        }
        QueryWrapper<EnterPark> wrapper = new QueryWrapper<>();
        wrapper.lambda()
                .eq(EnterPark::getStatus,status)
                .orderByDesc(EnterPark::getId);
        Page<EnterPark> 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);
    }
}