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);
|
}
|
}
|