BatteryController.java
1.64 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
package cn.com.glsx.stdinterface.modules.controller;
import cn.com.glsx.stdinterface.api.BatteryClient;
import cn.com.glsx.stdinterface.dto.DevicePowerDTO;
import cn.com.glsx.stdinterface.modules.service.BatteryService;
import com.glsx.plat.core.web.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
/**
* @author xiangyanlin
* @date 2022/4/12
*/
@RestController
@RequestMapping("/battery")
public class BatteryController implements BatteryClient {
@Resource
private BatteryService batteryService;
@PostMapping("/save")
@Override
public R saveBatteryInfo(@RequestBody DevicePowerDTO devicePowerDTO) {
batteryService.saveBatteryInfo(devicePowerDTO);
return R.ok();
}
@PostMapping("/initDataFromOld")
public R moveDataFromOldDatabase() {
batteryService.initDataFromOld();
return R.ok();
}
@GetMapping("/queryOneBySn")
@Override
public R<DevicePowerDTO> getDevicePowerBySn(@RequestParam("sn")String sn) {
return R.ok().data(batteryService.getDevicePowerBySn(sn));
}
@GetMapping("/queryListBySn")
@Override
public R<List<DevicePowerDTO>> getDevicePowerListBySn(Collection<String> sn) {
return R.ok().data(batteryService.getDevicePowerListBySn(sn));
}
}