| @@ -3,6 +3,7 @@ package com.ruoyi.platform.domain; | |||||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | import com.fasterxml.jackson.databind.PropertyNamingStrategy; | ||||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||||
| import io.swagger.annotations.ApiModelProperty; | import io.swagger.annotations.ApiModelProperty; | ||||
| import lombok.Data; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.io.Serializable; | import java.io.Serializable; | ||||
| @@ -14,6 +15,7 @@ import java.io.Serializable; | |||||
| * @since 2024-03-05 15:00:02 | * @since 2024-03-05 15:00:02 | ||||
| */ | */ | ||||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | ||||
| @Data | |||||
| public class ImageVersion implements Serializable { | public class ImageVersion implements Serializable { | ||||
| private static final long serialVersionUID = 251017725389874890L; | private static final long serialVersionUID = 251017725389874890L; | ||||
| /** | /** | ||||
| @@ -56,102 +58,7 @@ public class ImageVersion implements Serializable { | |||||
| @ApiModelProperty(value = "状态,0失效,1生效") | @ApiModelProperty(value = "状态,0失效,1生效") | ||||
| private Integer state; | private Integer state; | ||||
| public Integer getId() { | |||||
| return id; | |||||
| } | |||||
| public void setId(Integer id) { | |||||
| this.id = id; | |||||
| } | |||||
| public Integer getImageId() { | |||||
| return imageId; | |||||
| } | |||||
| public void setImageId(Integer imageId) { | |||||
| this.imageId = imageId; | |||||
| } | |||||
| public String getVersion() { | |||||
| return version; | |||||
| } | |||||
| public void setVersion(String version) { | |||||
| this.version = version; | |||||
| } | |||||
| public String getUrl() { | |||||
| return url; | |||||
| } | |||||
| public void setUrl(String url) { | |||||
| this.url = url; | |||||
| } | |||||
| public String getTagName() { | |||||
| return tagName; | |||||
| } | |||||
| public void setTagName(String tagName) { | |||||
| this.tagName = tagName; | |||||
| } | |||||
| public String getFileSize() { | |||||
| return fileSize; | |||||
| } | |||||
| public void setFileSize(String fileSize) { | |||||
| this.fileSize = fileSize; | |||||
| } | |||||
| public String getStatus() { | |||||
| return status; | |||||
| } | |||||
| public void setStatus(String status) { | |||||
| this.status = status; | |||||
| } | |||||
| public String getCreateBy() { | |||||
| return createBy; | |||||
| } | |||||
| public void setCreateBy(String createBy) { | |||||
| this.createBy = createBy; | |||||
| } | |||||
| public Date getCreateTime() { | |||||
| return createTime; | |||||
| } | |||||
| public void setCreateTime(Date createTime) { | |||||
| this.createTime = createTime; | |||||
| } | |||||
| public String getUpdateBy() { | |||||
| return updateBy; | |||||
| } | |||||
| public void setUpdateBy(String updateBy) { | |||||
| this.updateBy = updateBy; | |||||
| } | |||||
| public Date getUpdateTime() { | |||||
| return updateTime; | |||||
| } | |||||
| public void setUpdateTime(Date updateTime) { | |||||
| this.updateTime = updateTime; | |||||
| } | |||||
| public Integer getState() { | |||||
| return state; | |||||
| } | |||||
| public void setState(Integer state) { | |||||
| this.state = state; | |||||
| } | |||||
| @ApiModelProperty(value = "镜像所在主机ip") | |||||
| private String hostIp; | |||||
| } | } | ||||
| @@ -24,7 +24,6 @@ import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.data.domain.Page; | import org.springframework.data.domain.Page; | ||||
| import org.springframework.data.domain.PageImpl; | import org.springframework.data.domain.PageImpl; | ||||
| import org.springframework.data.domain.PageRequest; | import org.springframework.data.domain.PageRequest; | ||||
| import org.springframework.scheduling.annotation.Async; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
| import org.springframework.web.multipart.MultipartFile; | import org.springframework.web.multipart.MultipartFile; | ||||
| @@ -182,12 +181,12 @@ public class ImageServiceImpl implements ImageService { | |||||
| // } | // } | ||||
| List<ImageVersion> imageVersions = imageVersionService.queryByImageId(id); | List<ImageVersion> imageVersions = imageVersionService.queryByImageId(id); | ||||
| for (ImageVersion imageVersion : imageVersions) { | |||||
| for (ImageVersion imageVersion :imageVersions) { | |||||
| dockerClientUtil.removeImage(imageVersion.getUrl(), imageVersion.getHostIp()); | dockerClientUtil.removeImage(imageVersion.getUrl(), imageVersion.getHostIp()); | ||||
| } | } | ||||
| image.setState(0); | image.setState(0); | ||||
| return this.imageDao.update(image) > 0 ? "删除成功" : "删除失败"; | |||||
| return this.imageDao.update(image) > 0 ? "删除成功" : "删除失败"; | |||||
| } | } | ||||
| @@ -368,18 +367,10 @@ public class ImageServiceImpl implements ImageService { | |||||
| @Override | @Override | ||||
| @Transactional | @Transactional | ||||
| @Async | |||||
| public String saveImage(ImageVo imageVo) { | public String saveImage(ImageVo imageVo) { | ||||
| Image oldImage = imageDao.getByName(imageVo.getName()); | |||||
| if (oldImage != null) { | |||||
| List<ImageVersion> oldImageVersions = imageVersionDao.queryByImageId(oldImage.getId()); | |||||
| for (ImageVersion oldImageVersion : oldImageVersions) { | |||||
| if(oldImageVersion.getTagName().equals(imageVo.getTagName())){ | |||||
| throw new IllegalStateException("镜像tag不能重复"); | |||||
| } | |||||
| } | |||||
| if (imageDao.getByName(imageVo.getName()) != null) { | |||||
| throw new IllegalStateException("镜像名称已存在"); | |||||
| } | } | ||||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | LoginUser loginUser = SecurityUtils.getLoginUser(); | ||||
| String username = loginUser.getUsername().toLowerCase(); | String username = loginUser.getUsername().toLowerCase(); | ||||
| String podName = username + "-editor-pod" + "-" + imageVo.getDevEnvironmentId().toString(); | String podName = username + "-editor-pod" + "-" + imageVo.getDevEnvironmentId().toString(); | ||||
| @@ -15,6 +15,7 @@ | |||||
| <result property="updateBy" column="update_by" jdbcType="VARCHAR"/> | <result property="updateBy" column="update_by" jdbcType="VARCHAR"/> | ||||
| <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> | <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> | ||||
| <result property="state" column="state" jdbcType="INTEGER"/> | <result property="state" column="state" jdbcType="INTEGER"/> | ||||
| <result property="hostIp" column="host_ip" jdbcType="VARCHAR"/> | |||||
| </resultMap> | </resultMap> | ||||
| <!--根据模型id返回版本列表--> | <!--根据模型id返回版本列表--> | ||||