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
package com.yuanchu.mom.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yuanchu.mom.pojo.DeviceLease;
import com.yuanchu.mom.service.IDeviceLeaseService;
import com.yuanchu.mom.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
@RestController
@RequestMapping("/deviceleases")
public class DeviceLeaseController {
 
    @Autowired
    private IDeviceLeaseService deviceLeaseService;
 
    @PostMapping("")
    public Result create( DeviceLease deviceLease) {
        deviceLeaseService.save(deviceLease);
        return Result.success();
    }
 
//    @GetMapping("/{leaseId}")
//    public DeviceLease get(@PathVariable Integer leaseId) {
//        return deviceLeaseService.getById(leaseId);
//    }
    @GetMapping("/list/{id}")
    public Result get(@PathVariable Integer id) {
        LambdaQueryWrapper<DeviceLease> lambdaQueryWrapper=new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(DeviceLease::getDeviceId,id);
        return Result.success(deviceLeaseService.list(lambdaQueryWrapper));
    }
 
    @PutMapping("/{leaseId}")
    public boolean update(@PathVariable Integer leaseId, @RequestBody DeviceLease deviceLease) {
        deviceLease.setLeaseId(leaseId);
        return deviceLeaseService.updateById(deviceLease);
    }
 
    @DeleteMapping("/{leaseId}")
    public boolean delete(@PathVariable Integer leaseId) {
        return deviceLeaseService.removeById(leaseId);
    }
}