NewDriverController.java
3.24 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package com.ruoyi.controller.driver;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.ResponseResult;
import com.ruoyi.domain.driver.NewDriver;
import com.ruoyi.domain.driver.dto.NewDriverAddDTO;
import com.ruoyi.domain.driver.dto.NewDriverQueryDTO;
import com.ruoyi.domain.driver.dto.NewDriverUpdateDTO;
import com.ruoyi.domain.driver.vo.NewDriverVO;
import com.ruoyi.service.driver.NewDriverService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
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("new/driver")
@Api(tags = "新-驾驶员信息")
public class NewDriverController extends BaseController {
@Autowired
private NewDriverService newDriverService;
@PostMapping(value = "/list/select")
@ApiOperation("(页面选择)")
public ResponseResult listSelect() {
NewDriver entity = new NewDriver();
List<NewDriver> selectList = newDriverService.listOfSelect(entity);
return ResponseResult.success(convert(selectList));
}
private NewDriver convert(NewDriverQueryDTO source) {
return java.util.Optional.ofNullable(source).map(sc -> {
NewDriver target = new NewDriver();
BeanUtils.copyProperties(sc, target);
return target;
}).orElse(null);
}
private NewDriver convert(NewDriverUpdateDTO source) {
return java.util.Optional.ofNullable(source).map(sc -> {
NewDriver target = new NewDriver();
BeanUtils.copyProperties(sc, target);
return target;
}).orElse(null);
}
private NewDriver convert(NewDriverAddDTO source) {
return java.util.Optional.ofNullable(source).map(sc -> {
NewDriver target = new NewDriver();
BeanUtils.copyProperties(sc, target);
return target;
}).orElseGet(null);
}
private NewDriverVO convert(NewDriver source) {
return java.util.Optional.ofNullable(source).map(sc -> {
NewDriverVO target = new NewDriverVO();
BeanUtils.copyProperties(source, target);
return target;
}).orElseGet(null);
}
private List<NewDriverVO> convert(List<NewDriver> sources) {
return java.util.Optional.ofNullable(sources).map(scs -> {
return scs.stream().map(source -> {
return convert(source);
}).collect(java.util.stream.Collectors.toList());
}).orElseGet(null);
}
private IPage<NewDriverVO> convert(IPage<NewDriver> sources) {
return java.util.Optional.ofNullable(sources).map(scs -> {
IPage<NewDriverVO> target = new com.baomidou.mybatisplus.extension.plugins.pagination.Page();
BeanUtils.copyProperties(scs, target);
List<NewDriverVO> voNames = convert(scs.getRecords());
target.setRecords(voNames);
return target;
}).orElseGet(null);
}
}