From 18d187869d098a2893d79acdadc7d7a99aad28e6 Mon Sep 17 00:00:00 2001
From: kongdeqiang <123456>
Date: 星期一, 24 三月 2025 15:23:37 +0800
Subject: [PATCH] fix: 更新设备项目表和项目子表接口
---
platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceInventoryController.java | 56 +++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 45 insertions(+), 11 deletions(-)
diff --git a/platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceInventoryController.java b/platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceInventoryController.java
index 0856eae..955925f 100644
--- a/platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceInventoryController.java
+++ b/platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceInventoryController.java
@@ -3,6 +3,8 @@
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ArrayUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.by4cloud.platformx.common.core.util.R;
@@ -34,7 +36,7 @@
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class DeviceInventoryController {
- private final DeviceInventoryService DeviceInventoryService;
+ private final DeviceInventoryService deviceInventoryService;
/**
* 鍒嗛〉鏌ヨ
@@ -46,7 +48,10 @@
@GetMapping("/page" )
public R getDeviceInventoryPage(@ParameterObject Page page, @ParameterObject DeviceInventory deviceInventory) {
LambdaQueryWrapper<DeviceInventory> wrapper = Wrappers.lambdaQuery();
- return R.ok(DeviceInventoryService.page(page, wrapper));
+ wrapper.like(StringUtils.isNotBlank(deviceInventory.getDeviceNumber()),DeviceInventory::getDeviceNumber,deviceInventory.getDeviceNumber());
+ wrapper.like(StringUtils.isNotBlank(deviceInventory.getSerialNo()),DeviceInventory::getSerialNo,deviceInventory.getSerialNo());
+ wrapper.like(StringUtils.isNotBlank(deviceInventory.getName()),DeviceInventory::getName,deviceInventory.getName());
+ return R.ok(deviceInventoryService.page(page, wrapper));
}
@@ -58,30 +63,59 @@
@Operation(summary = "閫氳繃id鏌ヨ" , description = "閫氳繃id鏌ヨ" )
@GetMapping("/{id}" )
public R getById(@PathVariable("id" ) Long id) {
- return R.ok(DeviceInventoryService.getById(id));
+ return R.ok(deviceInventoryService.getById(id));
}
/**
* 鏂板搴撳瓨娴佹按琛�
- * @param DeviceInventory 搴撳瓨琛�
+ * @param deviceInventory 搴撳瓨琛�
* @return R
*/
@Operation(summary = "鏂板搴撳瓨琛�" , description = "鏂板搴撳瓨琛�" )
@SysLog("鏂板搴撳瓨娴佹按琛�" )
@PostMapping
- public R save(@RequestBody DeviceInventory DeviceInventory) {
- return R.ok(DeviceInventoryService.save(DeviceInventory));
+ public R save(@RequestBody DeviceInventory deviceInventory) {
+ if(deviceInventory.getDeviceId()==null){
+ return R.failed("璇烽�夋嫨璁惧娓呭崟");
+ }
+ if(deviceInventory.getSerialNo()==null){
+ return R.failed("璇峰~鍐欒澶囧簭鍒楀彿");
+ }
+ QueryWrapper<DeviceInventory> wrapper = new QueryWrapper<>();
+ wrapper.lambda().eq(DeviceInventory::getDeviceId,deviceInventory.getDeviceId())
+ .eq(DeviceInventory::getSerialNo,deviceInventory.getSerialNo());
+ List<DeviceInventory> list = deviceInventoryService.list(wrapper);
+ if(list !=null && list.size()>0){
+ return R.failed("宸插瓨鍦ㄨ搴忓垪鍙凤紝璇烽噸鏂版坊鍔�");
+ }
+ return R.ok(deviceInventoryService.save(deviceInventory));
}
/**
* 淇敼搴撳瓨琛�
- * @param DeviceInventory 搴撳瓨琛�
+ * @param deviceInventory 搴撳瓨琛�
* @return R
*/
@SysLog("淇敼搴撳瓨琛�" )
@PutMapping
- public R updateById(@RequestBody DeviceInventory DeviceInventory) {
- return R.ok(DeviceInventoryService.updateById(DeviceInventory));
+ public R updateById(@RequestBody DeviceInventory deviceInventory) {
+ if(deviceInventory.getDeviceId()==null){
+ return R.failed("璇烽�夋嫨璁惧娓呭崟");
+ }
+ if(deviceInventory.getSerialNo()==null){
+ return R.failed("璇峰~鍐欒澶囧簭鍒楀彿");
+ }
+ QueryWrapper<DeviceInventory> wrapper = new QueryWrapper<>();
+ wrapper.lambda().eq(DeviceInventory::getDeviceId,deviceInventory.getDeviceId())
+ .eq(DeviceInventory::getSerialNo,deviceInventory.getSerialNo());
+ List<DeviceInventory> list = deviceInventoryService.list(wrapper);
+ if(list !=null && list.size()>0){
+ DeviceInventory deviceInventory1 = list.get(0);
+ if(!deviceInventory1.getId().equals(deviceInventory.getId())){
+ return R.failed("宸插瓨鍦ㄨ搴忓垪鍙凤紝璇烽噸鏂版坊鍔�");
+ }
+ }
+ return R.ok(deviceInventoryService.updateById(deviceInventory));
}
/**
@@ -93,7 +127,7 @@
@SysLog("閫氳繃id鍒犻櫎搴撳瓨娴佹按琛�" )
@DeleteMapping
public R removeById(@RequestBody Long[] ids) {
- return R.ok(DeviceInventoryService.removeBatchByIds(CollUtil.toList(ids)));
+ return R.ok(deviceInventoryService.removeBatchByIds(CollUtil.toList(ids)));
}
@@ -107,6 +141,6 @@
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('platformx_DeviceInventory_export')" )
public List<DeviceInventory> export(DeviceInventory deviceInventory,Long[] ids) {
- return DeviceInventoryService.list(Wrappers.lambdaQuery(deviceInventory).in(ArrayUtil.isNotEmpty(ids), DeviceInventory::getId, ids));
+ return deviceInventoryService.list(Wrappers.lambdaQuery(deviceInventory).in(ArrayUtil.isNotEmpty(ids), DeviceInventory::getId, ids));
}
}
--
Gitblit v1.9.1