package com.boying.controller;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.boying.common.R;
|
import com.boying.entity.ViolationType;
|
import com.boying.entity.WhiteList;
|
import com.boying.service.ParkService;
|
import com.boying.service.WhiteListService;
|
import lombok.RequiredArgsConstructor;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
@RestController
|
@RequestMapping("whiteList")
|
@RequiredArgsConstructor
|
public class WhiteListController{
|
|
private final WhiteListService whiteListService;
|
private final ParkService parkService;
|
|
@PostMapping("/findPage")
|
public Object findPage(Page page, String carNo) {
|
QueryWrapper<WhiteList> wrapper = new QueryWrapper<>();
|
wrapper.lambda()
|
.orderByDesc(WhiteList::getId)
|
.eq(StringUtils.isNotBlank(carNo),WhiteList::getCarNo,carNo);
|
Page<WhiteList> page1 = whiteListService.page(page, wrapper);
|
for (WhiteList record : page1.getRecords()) {
|
if(record.getParkId() != null){
|
record.setName(parkService.getById(record.getParkId()).getName());
|
}
|
}
|
return R.ok(page1);
|
}
|
|
@PostMapping("/findPageNew")
|
public Object findPageNew(Page page, String carNo) {
|
QueryWrapper<WhiteList> wrapper = new QueryWrapper<>();
|
wrapper.lambda()
|
.orderByDesc(WhiteList::getId)
|
.eq(StringUtils.isNotBlank(carNo),WhiteList::getCarNo,carNo);
|
Page<WhiteList> page1 = whiteListService.page(page, wrapper);
|
for (WhiteList record : page1.getRecords()) {
|
if(record.getParkIds() != null){
|
String s = "";
|
String parkIds = record.getParkIds();
|
String[] split = parkIds.split(",");
|
for (int i = 0; i < split.length; i++) {
|
int id = Integer.parseInt(split[i]);
|
if(i != split.length -1){
|
s += parkService.getById(id).getName()+",";
|
}else {
|
s += parkService.getById(id).getName();
|
}
|
}
|
record.setName(s);
|
}
|
}
|
return R.ok(page1);
|
}
|
|
@PostMapping("/save")
|
public Object save(WhiteList whiteList) {
|
whiteListService.saveOrUpdate(whiteList);
|
return R.ok("保存成功");
|
}
|
|
@PostMapping("/delete")
|
public Object delete(Long id) {
|
whiteListService.removeById(id);
|
return R.ok("删除成功");
|
}
|
}
|