|
|
|
@@ -1,8 +1,8 @@ |
|
|
|
package com.ruoyi.platform.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON; |
|
|
|
import com.ruoyi.common.core.web.domain.GenericsAjaxResult; |
|
|
|
import com.ruoyi.common.security.utils.SecurityUtils; |
|
|
|
import com.ruoyi.system.api.constant.Constant; |
|
|
|
import com.ruoyi.platform.domain.AssetWorkflow; |
|
|
|
import com.ruoyi.platform.domain.ImageVersion; |
|
|
|
import com.ruoyi.platform.domain.Ray; |
|
|
|
@@ -10,6 +10,7 @@ import com.ruoyi.platform.mapper.AssetWorkflowDao; |
|
|
|
import com.ruoyi.platform.mapper.ImageVersionDao; |
|
|
|
import com.ruoyi.platform.mapper.RayDao; |
|
|
|
import com.ruoyi.platform.service.ImageVersionService; |
|
|
|
import com.ruoyi.system.api.constant.Constant; |
|
|
|
import com.ruoyi.system.api.model.LoginUser; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.data.domain.Page; |
|
|
|
@@ -68,16 +69,23 @@ public class ImageVersionServiceImpl implements ImageVersionService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public String removeById(Integer id) throws Exception { |
|
|
|
public GenericsAjaxResult<String> removeById(Integer id) throws Exception { |
|
|
|
ImageVersion imageVersion = this.imageVersionDao.queryById(id); |
|
|
|
ImageVersion query = new ImageVersion(); |
|
|
|
query.setImageId(imageVersion.getImageId()); |
|
|
|
long count = this.imageVersionDao.count(query); |
|
|
|
if (count == 1) { |
|
|
|
return GenericsAjaxResult.error("当前镜像只有一个版本,不能删除该版本"); |
|
|
|
} |
|
|
|
|
|
|
|
if (imageVersion == null) { |
|
|
|
return "该版本下模型文件信息不存在"; |
|
|
|
return GenericsAjaxResult.error("该版本下模型文件信息不存在"); |
|
|
|
} |
|
|
|
|
|
|
|
List<AssetWorkflow> assetWorkflow = assetWorkflowDao.getAssetWorkflow(Long.valueOf(imageVersion.getImageId()), Constant.Asset_Type_Image, imageVersion.getTagName()); |
|
|
|
if (assetWorkflow != null && !assetWorkflow.isEmpty()) { |
|
|
|
String workflows = String.join(",", assetWorkflow.stream().map(AssetWorkflow::getWorkflowName).collect(Collectors.toSet())); |
|
|
|
throw new Exception("该镜像版本被流水线:" + workflows + "使用,不能删除,请先删除流水线。"); |
|
|
|
return GenericsAjaxResult.error("该镜像版本被流水线:" + workflows + "使用,不能删除,请先删除流水线。"); |
|
|
|
} |
|
|
|
|
|
|
|
HashMap<String, String> map = new HashMap<>(); |
|
|
|
@@ -85,7 +93,7 @@ public class ImageVersionServiceImpl implements ImageVersionService { |
|
|
|
List<Ray> rayList = rayDao.queryByImageId(JSON.toJSONString(map)); |
|
|
|
if (rayList != null && !rayList.isEmpty()) { |
|
|
|
String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); |
|
|
|
throw new Exception("该镜像版本被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优。"); |
|
|
|
return GenericsAjaxResult.error("该镜像版本被超参数自动寻优:" + rays + "使用,不能删除,请先删除超参数自动寻优。"); |
|
|
|
} |
|
|
|
|
|
|
|
//判断权限,只有admin和创建者本身可以删除该数据集 |
|
|
|
@@ -93,11 +101,11 @@ public class ImageVersionServiceImpl implements ImageVersionService { |
|
|
|
String username = loginUser.getUsername(); |
|
|
|
String createdBy = imageVersion.getCreateBy(); |
|
|
|
if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createdBy))) { |
|
|
|
return "无权限删除该版本下模型信息"; |
|
|
|
return GenericsAjaxResult.error("无权限删除该版本下模型信息"); |
|
|
|
} |
|
|
|
|
|
|
|
imageVersion.setState(Constant.State_invalid); |
|
|
|
return this.imageVersionDao.update(imageVersion) > 0 ? "删除成功" : "删除失败"; |
|
|
|
return this.imageVersionDao.update(imageVersion) > 0 ? GenericsAjaxResult.success("删除成功") : GenericsAjaxResult.error("删除失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|