zss
2025-01-13 8d85246f061e3da623c7b9eb4e323ee724b4de0b
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
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<DeviceLog> getAllDeviceLogs() { // 更新方法名
        return deviceLogService.list();
    }
    @GetMapping("/{id}")
    public Result getAllDeviceLogsBydId(@PathVariable int id) { // 更新方法名
        LambdaQueryWrapper<DeviceLog> 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();
    }
}