|
|
@@ -2,6 +2,7 @@ package com.ruoyi.platform.service.impl; |
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON; |
|
|
import com.alibaba.fastjson2.JSON; |
|
|
import com.alibaba.fastjson2.util.DateUtils; |
|
|
import com.alibaba.fastjson2.util.DateUtils; |
|
|
|
|
|
import com.ruoyi.common.core.web.domain.GenericsAjaxResult; |
|
|
import com.ruoyi.common.security.utils.SecurityUtils; |
|
|
import com.ruoyi.common.security.utils.SecurityUtils; |
|
|
import com.ruoyi.system.api.constant.Constant; |
|
|
import com.ruoyi.system.api.constant.Constant; |
|
|
import com.ruoyi.platform.domain.*; |
|
|
import com.ruoyi.platform.domain.*; |
|
|
@@ -227,7 +228,7 @@ public class ImageServiceImpl implements ImageService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@Transactional |
|
|
@Transactional |
|
|
public String insertImageAndVersion(ImageVo imageVo) throws Exception { |
|
|
|
|
|
|
|
|
public GenericsAjaxResult<String> insertImageAndVersion(ImageVo imageVo) throws Exception { |
|
|
Image existingImage = getByName(imageVo.getName()); |
|
|
Image existingImage = getByName(imageVo.getName()); |
|
|
Image imageToUse; |
|
|
Image imageToUse; |
|
|
if (existingImage == null) { |
|
|
if (existingImage == null) { |
|
|
@@ -243,6 +244,13 @@ public class ImageServiceImpl implements ImageService { |
|
|
} else { |
|
|
} else { |
|
|
// 如果已存在相同名称的镜像,使用已存在的镜像 |
|
|
// 如果已存在相同名称的镜像,使用已存在的镜像 |
|
|
imageToUse = existingImage; |
|
|
imageToUse = existingImage; |
|
|
|
|
|
ImageVersion query = new ImageVersion(); |
|
|
|
|
|
query.setImageId(imageToUse.getId()); |
|
|
|
|
|
query.setTagName(imageVo.getTagName()); |
|
|
|
|
|
long count = imageVersionDao.count(query); |
|
|
|
|
|
if (count != 0) { |
|
|
|
|
|
return GenericsAjaxResult.error("镜像版本已存在"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
ImageVersion imageVersion = new ImageVersion(); |
|
|
ImageVersion imageVersion = new ImageVersion(); |
|
|
imageVersion.setImageId(imageToUse.getId()); |
|
|
imageVersion.setImageId(imageToUse.getId()); |
|
|
@@ -250,7 +258,7 @@ public class ImageServiceImpl implements ImageService { |
|
|
imageVersion.setTagName(imageVo.getTagName()); |
|
|
imageVersion.setTagName(imageVo.getTagName()); |
|
|
imageVersion.setFileSize(imageVo.getFileSize()); |
|
|
imageVersion.setFileSize(imageVo.getFileSize()); |
|
|
imageVersion.setDescription(imageVo.getDescription()); |
|
|
imageVersion.setDescription(imageVo.getDescription()); |
|
|
imageVersion.setStatus("building"); |
|
|
|
|
|
|
|
|
imageVersion.setStatus(Constant.Building); |
|
|
ImageVersion imageVersionInsert = this.imageVersionService.insert(imageVersion); |
|
|
ImageVersion imageVersionInsert = this.imageVersionService.insert(imageVersion); |
|
|
if (imageVersionInsert == null) { |
|
|
if (imageVersionInsert == null) { |
|
|
throw new Exception("新增镜像版本失败"); |
|
|
throw new Exception("新增镜像版本失败"); |
|
|
@@ -286,8 +294,7 @@ public class ImageServiceImpl implements ImageService { |
|
|
return null; |
|
|
return null; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return "新增镜像成功,镜像构建中..."; |
|
|
|
|
|
|
|
|
return GenericsAjaxResult.success("新增镜像成功,镜像构建中..."); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
|