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 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 result = deviceService.callStoredProc(device); // 获取多行查询结果 return Result.success(result); // 返回包含多行结果的 Result 对象 } }