临时提交

结构优化
648540858 2023-12-26 23:46:24 +08:00
parent 14fe1936d0
commit a7f1bd95df
2 changed files with 18 additions and 10 deletions

View File

@ -579,7 +579,9 @@ public class DeviceServiceImpl implements IDeviceService {
@Transactional @Transactional
public boolean delete(String deviceId) { public boolean delete(String deviceId) {
List<Integer> commonChannelIdList = deviceChannelMapper.getCommonChannelIdList(deviceId); List<Integer> commonChannelIdList = deviceChannelMapper.getCommonChannelIdList(deviceId);
if (!commonChannelIdList.isEmpty()) {
commonGbChannelService.deleteByIdList(commonChannelIdList); commonGbChannelService.deleteByIdList(commonChannelIdList);
}
deviceChannelMapper.cleanChannelsByDeviceId(deviceId); deviceChannelMapper.cleanChannelsByDeviceId(deviceId);
deviceMapper.del(deviceId); deviceMapper.del(deviceId);
return true; return true;

View File

@ -307,11 +307,14 @@ public class DeviceQuery {
*/ */
@Operation(summary = "添加设备信息", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Operation(summary = "添加设备信息", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "device", description = "设备", required = true) @Parameter(name = "device", description = "设备", required = true)
@PostMapping("/device/add/") @PostMapping("/device/add")
public void addDevice(Device device){ public void addDevice(@RequestBody Device device){
if (device == null || device.getDeviceId() == null) { if (device == null) {
throw new ControllerException(ErrorCode.ERROR400); throw new ControllerException(ErrorCode.ERROR100.getCode(), "参数不可为空");
}
if (device.getDeviceId() == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "DeviceId不可为空");
} }
// 查看deviceId是否存在 // 查看deviceId是否存在
@ -329,12 +332,15 @@ public class DeviceQuery {
*/ */
@Operation(summary = "更新设备信息", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Operation(summary = "更新设备信息", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "device", description = "设备", required = true) @Parameter(name = "device", description = "设备", required = true)
@PostMapping("/device/update/") @PostMapping("/device/update")
public void updateDevice(Device device){ public void updateDevice(@RequestBody Device device){
if (device == null) {
if (device != null && device.getDeviceId() != null) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "参数不可为空");
deviceService.updateCustomDevice(device);
} }
if (device.getDeviceId() == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "DeviceId不可为空");
}
deviceService.updateCustomDevice(device);
} }
/** /**