Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
0fef82c9f2 | |||
ce5a5c3bcb |
2
pom.xml
2
pom.xml
@ -10,7 +10,7 @@
|
||||
</parent>
|
||||
<groupId>github.benjamin</groupId>
|
||||
<artifactId>equip-reserve-backend</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.1</version>
|
||||
<name>equip-reserve-backend</name>
|
||||
<description>equip-reserve-backend</description>
|
||||
<url/>
|
||||
|
@ -53,10 +53,10 @@ public class DeviceController {
|
||||
|
||||
@PreAuthorize("hasRole('DEVICE_ADMIN')")
|
||||
@PostMapping("/{userId}")
|
||||
public ResponseResult<Device> addDevice(@PathVariable("userId") Long userId,
|
||||
public ResponseResult<DeviceAdminVO> addDevice(@PathVariable("userId") Long userId,
|
||||
@RequestBody Device device) {
|
||||
deviceService.addDevice(userId, device);
|
||||
return ResponseResult.success(device);
|
||||
return ResponseResult.success(new DeviceAdminVO(device));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasRole('DEVICE_ADMIN')")
|
||||
@ -68,11 +68,11 @@ public class DeviceController {
|
||||
|
||||
@PreAuthorize("hasRole('DEVICE_ADMIN')")
|
||||
@PutMapping("/{id}")
|
||||
public ResponseResult<?> updateDevice(@PathVariable("id") Long id,
|
||||
public ResponseResult<DeviceAdminVO> updateDevice(@PathVariable("id") Long id,
|
||||
@RequestBody Device device) {
|
||||
device.setId(id);
|
||||
Device updatedDevice = deviceService.updateDevice(device);
|
||||
return ResponseResult.success(updatedDevice);
|
||||
return ResponseResult.success(new DeviceAdminVO(updatedDevice));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasRole('DEVICE_ADMIN')")
|
||||
|
@ -80,6 +80,14 @@ public class DeviceServiceImpl implements DeviceService {
|
||||
|
||||
@Override
|
||||
public void deleteDevice(Long id) {
|
||||
Device device = deviceMapper.selectById(id);
|
||||
if (StringUtils.hasText(device.getImagePath())) {
|
||||
Path fullPath = Paths.get(System.getProperty("user.dir"), device.getImagePath()).normalize();
|
||||
File file = fullPath.toFile();
|
||||
if (file.exists() && file.isFile()) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
deviceMapper.delete(new LambdaQueryWrapper<Device>()
|
||||
.eq(Device::getId, id));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user