wu
2023-12-04 a93a3f1532d33849187dcd1a372c315ec4511e04
springboot-vue3/src/main/java/com/example/springboot/controller/device/DeviceController.java
New file
@@ -0,0 +1,43 @@
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 对象
    }
}