diff --git a/nex-be/src/main/java/com/unisinsight/project/controller/DeviceImageMappingController.java b/nex-be/src/main/java/com/unisinsight/project/controller/DeviceImageMappingController.java index 4694bbb..da3145e 100644 --- a/nex-be/src/main/java/com/unisinsight/project/controller/DeviceImageMappingController.java +++ b/nex-be/src/main/java/com/unisinsight/project/controller/DeviceImageMappingController.java @@ -5,16 +5,20 @@ import cn.hutool.core.collection.CollectionUtil; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.unisinsight.project.entity.dao.DeviceImageMapping; +import com.unisinsight.project.entity.enums.GrpcTypeEnum; import com.unisinsight.project.entity.req.DeviceImageMappingReq; import com.unisinsight.project.entity.res.DeviceImageMappingRes; import com.unisinsight.project.entity.res.ListReq; import com.unisinsight.project.exception.BaseErrorCode; import com.unisinsight.project.exception.Result; +import com.unisinsight.project.grpc.generate.NotificationMessage; +import com.unisinsight.project.grpc.service.SendNotificationService; import com.unisinsight.project.service.DeviceImageMappingService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -39,7 +43,8 @@ public class DeviceImageMappingController { @Resource private DeviceImageMappingService deviceImageMappingService; - + @Autowired + private SendNotificationService notificationService; @ApiOperation(value = "终端镜像映射新增") @PostMapping("/add") public Result insert(@RequestBody ListReq deviceImageMappingReq) { @@ -95,7 +100,10 @@ public class DeviceImageMappingController { return Result.errorResult(BaseErrorCode.HTTP_ERROR_CODE_500); } } - + //发送消息 + notificationService.sendNotification(deviceImageMappingReq.getDeviceId(), NotificationMessage.newBuilder() + .setType(GrpcTypeEnum.IMAGE_UPDATE.getType()) + .setContent(GrpcTypeEnum.IMAGE_UPDATE.getDesc()).build()); return Result.successResult(); } diff --git a/nex-be/src/main/java/com/unisinsight/project/entity/req/LoginReq.java b/nex-be/src/main/java/com/unisinsight/project/entity/req/LoginReq.java index 5d81906..6342522 100644 --- a/nex-be/src/main/java/com/unisinsight/project/entity/req/LoginReq.java +++ b/nex-be/src/main/java/com/unisinsight/project/entity/req/LoginReq.java @@ -31,6 +31,7 @@ public class LoginReq { private String token; @ApiModelProperty("mac地址") + @JsonProperty("mac_addr") private String macAddr; diff --git a/nex-be/src/main/java/com/unisinsight/project/service/impl/ClientServiceImpl.java b/nex-be/src/main/java/com/unisinsight/project/service/impl/ClientServiceImpl.java index f745739..bad1d18 100644 --- a/nex-be/src/main/java/com/unisinsight/project/service/impl/ClientServiceImpl.java +++ b/nex-be/src/main/java/com/unisinsight/project/service/impl/ClientServiceImpl.java @@ -63,10 +63,10 @@ public class ClientServiceImpl implements ClientService { HashMap map = new HashMap<>(); map.put("id",e.getId()); if (StringUtils.isNotBlank(e.getDesktopName())) { - map.put("name", e.getDesktopName()); + map.put("name", e.getDesktopName()+"."+e.getDesktopType()); } if (StringUtils.isNotBlank(e.getFileSize())) { - map.put("file_size", e.getFileSize()); + map.put("file_size", StringUtils.isNotEmpty(e.getFileSize()) ? Long.parseLong(e.getFileSize()) : 0L); } if (StringUtils.isNotBlank(e.getStoragePath())) { map.put("storage_path", e.getStoragePath()); diff --git a/nex-be/src/main/java/com/unisinsight/project/service/impl/ImageVirtualMachinesServiceImpl.java b/nex-be/src/main/java/com/unisinsight/project/service/impl/ImageVirtualMachinesServiceImpl.java index 6abe3fc..a1033fc 100644 --- a/nex-be/src/main/java/com/unisinsight/project/service/impl/ImageVirtualMachinesServiceImpl.java +++ b/nex-be/src/main/java/com/unisinsight/project/service/impl/ImageVirtualMachinesServiceImpl.java @@ -165,7 +165,7 @@ public class ImageVirtualMachinesServiceImpl extends ServiceImpl desktopLambdaQueryWrapper=new LambdaQueryWrapper<>(); + desktopLambdaQueryWrapper.eq(ImageDesktop::getImageVirtualId, imageVirtualMachines.getId()); + int count = imageDesktopService.count(desktopLambdaQueryWrapper); + if (count>0){ + return Result.errorResult(BaseErrorCode.HTTP_ERROR_CODE_500, "该镜像有对应的克隆桌面,不允许删除"); + } // 调用镜像删除服务 ImageDeleteReq deleteReq = ImageDeleteReq.builder() @@ -298,7 +304,7 @@ public class ImageVirtualMachinesServiceImpl extends ServiceImpl