DriverInfoController.java
6.4 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
package com.sunyo.wlpt.dispatch.controller;
import com.github.pagehelper.PageInfo;
import com.sunyo.wlpt.dispatch.domain.DriverInfo;
import com.sunyo.wlpt.dispatch.response.ResultJson;
import com.sunyo.wlpt.dispatch.service.DriverInfoService;
import com.sunyo.wlpt.dispatch.utils.GetUUID;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* @author 子诚
* Description:驾驶员信息管理.
* 时间:2020/4/26 14:04
*/
@CrossOrigin
@Api(value = "驾驶员信息管理", tags = "业务管理——驾驶员信息管理")
@RequestMapping("dispatch/driverInfo")
@RestController
public class DriverInfoController {
@Resource
private DriverInfoService driverInfoService;
/**
* 分页查询,驾驶员信息.
*
* @param driverName 驾驶员姓名
* @param driverMobile 驾驶员联系方式
* @param driverCompany 驾驶员所属公司
* @param driverStatus 驾驶员状态
* @param pageNum 当前页数
* @param pageSize 每页数量
* @return 成功返回查询列表
*/
@ApiOperation("获取驾驶员列表")
@GetMapping("/selectDriverInfoList")
public ResultJson<PageInfo> selectDriverInfoList(
@ApiParam(name = "driverName", value = "驾驶员姓名", required = false)
@RequestParam(value = "driverName", required = false) String driverName,
@ApiParam(name = "driverMobile", value = "驾驶员联系方式", required = false)
@RequestParam(value = "driverMobile", required = false) String driverMobile,
@ApiParam(name = "driverCompany", value = "驾驶员所属公司", required = false)
@RequestParam(value = "driverCompany", required = false) String driverCompany,
@ApiParam(name = "driverStatus", value = "驾驶员状态:驾驶员状态:1.空闲状态;2.执行状态;3.轮休状态;4.请假状态", required = false)
@RequestParam(value = "driverStatus", required = false) String driverStatus,
@ApiParam(name = "pageNum", value = "第几页,默认为第一页", required = false)
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@ApiParam(name = "pageSize", value = "每页数量,默认10条", required = false)
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
ResultJson<PageInfo> result = new ResultJson<>();
DriverInfo driverInfo = new DriverInfo();
//获取参数,驾驶员姓名
driverInfo.setDriverName(driverName);
//获取参数,驾驶员联系方式
driverInfo.setDriverMobile(driverMobile);
//获取参数,驾驶员所属公司
driverInfo.setDriverCompany(driverCompany);
//获取参数,驾驶员状态
driverInfo.setDriverStatus(driverStatus);
PageInfo pageInfo = driverInfoService.selectDriverInfoList(driverInfo, pageNum, pageSize);
if (pageInfo.getTotal() > 0) {
result.setData(pageInfo);
result.setCode("200");
result.setMsg("查询驾驶员信息列表,成功");
} else {
result.setCode("400");
result.setMsg("查询驾驶员信息列表,失败");
}
return result;
}
/**
* 删除驾驶员信息.
*
* @param driverInfo {@link DriverInfo}
* @return
*/
@ApiOperation("删除驾驶员信息")
@DeleteMapping("/deleteDriverInfo")
public ResultJson deleteDriverInfo(@RequestBody DriverInfo driverInfo) {
ResultJson result = new ResultJson();
/**
* 删除驾驶员信息,根据主键删除
*/
int num = driverInfoService.deleteByPrimaryKey(driverInfo.getId());
if (num > 0) {
result.setCode("200");
result.setMsg("删除驾驶员信息,成功");
} else {
result.setCode("400");
result.setMsg("删除驾驶员信息,失败");
}
return result;
}
/**
* 批量删除驾驶员信息.
*
* @param ids 所要删除的id以','相连接的字符串
* @return
*/
@ApiOperation("批量删除驾驶员信息")
@GetMapping("/batchRemove")
public ResultJson batchRemoveDriverInfo(String ids) {
ResultJson result = new ResultJson();
int num = driverInfoService.deleteByPrimaryKey(ids);
if (num > 0) {
result.setCode("200");
result.setMsg("批量删除驾驶员信息,成功");
} else {
result.setCode("400");
result.setMsg("批量删除驾驶员信息,失败");
}
return result;
}
/**
* 编辑驾驶员信息.
*
* @param driverInfo {@link DriverInfo}
* @return
*/
@ApiOperation("编辑驾驶员信息")
@PutMapping("/updateDriverInfo")
public ResultJson updateDriverInfo(@RequestBody DriverInfo driverInfo) {
ResultJson result = new ResultJson();
/**
* 编辑驾驶员信息,根据主键选择性修改
*/
int num = driverInfoService.updateByPrimaryKeySelective(driverInfo);
if (num > 0) {
result.setCode("200");
result.setMsg("编辑驾驶员信息,成功");
} else {
result.setCode("400");
result.setMsg("编辑驾驶员信息,失败");
}
return result;
}
/**
* 增加驾驶员信息.
*
* @param driverInfo {@link DriverInfo}
* @return
*/
@ApiOperation("增加驾驶员信息")
@PostMapping("/insertDriverInfo")
public ResultJson insertDriverInfo(@RequestBody DriverInfo driverInfo) {
ResultJson result = new ResultJson();
//设置驾驶员信息主键,UUID
driverInfo.setId(GetUUID.getuuid());
/**
* 选择性插入,驾驶员信息
*/
//新增的驾驶员的状态为 空闲状态("1")
driverInfo.setDriverStatus("1");
int num = driverInfoService.insertSelective(driverInfo);
if (num > 0) {
result.setCode("200");
result.setMsg("新增驾驶员信息,成功");
} else {
result.setCode("400");
result.setMsg("新增驾驶员信息,失败");
}
return result;
}
}