DeviceController.java
1.88 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
package cn.com.glsx.admin.modules.controller;
import cn.com.glsx.admin.modules.model.DropOptions;
import cn.com.glsx.admin.modules.model.vo.DeviceInformationVO;
import cn.com.glsx.admin.modules.service.DeviceService;
import cn.com.glsx.stdinterface.enums.DeviceComposeEnum;
import com.glsx.plat.core.web.R;
import com.google.common.collect.Lists;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@Slf4j
@RestController
@RequestMapping(value = "/device")
@Api(value = "设备管理", tags = {"设备管理"})
public class DeviceController {
@Autowired
private DeviceService deviceService;
@ApiOperation(value = "设备组合")
@GetMapping("/compose")
public R compose() {
List<DropOptions> options = Lists.newArrayList();
DeviceComposeEnum[] composeEnums = DeviceComposeEnum.values();
for (int i = 0; i < composeEnums.length; i++) {
DeviceComposeEnum composeEnum = composeEnums[i];
DropOptions option = new DropOptions();
option.setId(i + 1L);
option.setCode(composeEnum.getCode());
option.setName(composeEnum.getName());
options.add(option);
}
return R.ok().data(options);
}
@ApiOperation(value = "通过车辆id查找绑定的设备列表信息")
@GetMapping("/getByVehicleId")
public R getByVehicleId(@RequestParam("vehicleId") Long vehicleId) {
List<DeviceInformationVO> devices = deviceService.getByVehicleId(vehicleId);
return R.ok().data(devices);
}
}