ZengTao
2023-11-09 d3d50f064a38c3eebed88c3831e77b826f2ad057
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
package com.example.springboot.controller.device;
 
 
 
import com.example.springboot.service.device.DeviceService;
import com.example.springboot.entity.device.DeviceEntity;
import com.example.springboot.entity.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
@RestController
@RequestMapping("/api/device") // 修改请求路径为 "/api/device"
public class DeviceController {
 
    private final DeviceService deviceService;
 
    @Autowired
    public DeviceController(DeviceService deviceService) {
        this.deviceService = deviceService;
    }
 
    @GetMapping("/getAllDevices")  // 修改接口路径为 "/getAllDevices"
    public Result getAllDevices() {
        List<DeviceEntity> devices = deviceService.getAllDevices();
        return Result.success(devices);
    }
 
    @PostMapping("/updateDeviceName")  // 修改接口路径为 "/updateDeviceName"
    public Result updateDeviceName(@RequestBody DeviceEntity device) {
        deviceService.updateDeviceName(device);
        return Result.success();
    }
    @PostMapping("/call-stored-proc")
    public Result  callStoredProc(@RequestBody DeviceEntity device) {
        List<DeviceEntity> result = deviceService.callStoredProc(device); // 获取多行查询结果
        return Result.success(result); // 返回包含多行结果的 Result 对象
    }
 
}