package com.yuanchu.mom.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.yuanchu.mom.pojo.DeviceLog; import com.yuanchu.mom.service.IDeviceLogService; import com.yuanchu.mom.vo.Result; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; @RestController @RequestMapping("/api/device-log") // 更新路径 //这里的接口全部是在设备校准的地方用到,但是其他地方会另外写 public class DeviceLogController { @Autowired private IDeviceLogService deviceLogService; // 更新Service引用 @GetMapping public List getAllDeviceLogs() { // 更新方法名 return deviceLogService.list(); } @GetMapping("/{id}") public Result getAllDeviceLogsBydId(@PathVariable int id) { // 更新方法名 LambdaQueryWrapper lambdaQueryWrapper=new LambdaQueryWrapper<>(); lambdaQueryWrapper.eq(DeviceLog::getDeviceId,id); lambdaQueryWrapper.eq(DeviceLog::getRelevanceForm,"device_maintenance"); return Result.success(deviceLogService.list(lambdaQueryWrapper)); } @PostMapping public Result createDeviceLog(DeviceLog deviceLog) { // 更新方法名 deviceLog.setRelevanceForm("device_maintenance");//关联设备校准 deviceLogService.save(deviceLog); return Result.success(); } @PutMapping("/{id}") public DeviceLog updateDeviceLog(@PathVariable Integer id, @RequestBody DeviceLog deviceLog) { // 更新方法名 deviceLog.setId(id); deviceLogService.updateById(deviceLog); return deviceLog; } @DeleteMapping("/{id}") public Result deleteDeviceLog(@PathVariable Integer id) { // 更新方法名 deviceLogService.removeById(id); return Result.success(); } }