From 072686bfa0e29ca6f0473c906e9e3ec9f22ec56e Mon Sep 17 00:00:00 2001
From: chenzhihang <709011834@qq.com>
Date: Fri, 30 Aug 2024 11:15:36 +0800
Subject: [PATCH 01/12] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=94=B9=E7=94=A8?=
=?UTF-8?q?=E6=88=B7=E4=BF=A1=E6=81=AF=E6=9F=A5=E8=AF=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../resources/mapper/system/SysUserMapper.xml | 375 ++++++++++--------
1 file changed, 200 insertions(+), 175 deletions(-)
diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
index b7c9797..5d1900b 100644
--- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
+++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
@@ -1,52 +1,54 @@
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
+
+
select u.user_id,
u.dept_id,
u.user_name,
@@ -83,9 +85,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join sys_user_role ur on u.user_id = ur.user_id
left join sys_role r on r.role_id = ur.role_id
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- insert into sys_user(
- user_id,
- dept_id,
- user_name,
- nick_name,
- email,
- avatar,
- phonenumber,
- sex,
- password,
- status,
- create_by,
- remark,
- create_time
- )values(
- #{userId},
- #{deptId},
- #{userName},
- #{nickName},
- #{email},
- #{avatar},
- #{phonenumber},
- #{sex},
- #{password},
- #{status},
- #{createBy},
- #{remark},
- sysdate()
- )
-
-
-
- update sys_user
-
- dept_id = #{deptId},
- user_name = #{userName},
- nick_name = #{nickName},
- email = #{email},
- phonenumber = #{phonenumber},
- sex = #{sex},
- avatar = #{avatar},
- password = #{password},
- status = #{status},
- login_ip = #{loginIp},
- login_date = #{loginDate},
- update_by = #{updateBy},
- remark = #{remark},
- git_link_username = #{gitLinkUsername},
- git_link_password = #{gitLinkPassword},
- update_time = sysdate()
-
- where user_id = #{userId}
-
-
-
- update sys_user set status = #{status} where user_id = #{userId}
-
-
-
- update sys_user set avatar = #{avatar} where user_name = #{userName}
-
-
-
- update sys_user set password = #{password} where user_name = #{userName}
-
-
-
- update sys_user set del_flag = '2' where user_id = #{userId}
-
-
-
- update sys_user set del_flag = '2' where user_id in
-
- #{userId}
-
-
-
+ insert into sys_user(
+ user_id,
+ dept_id,
+ user_name,
+ nick_name,
+ email,
+ avatar,
+ phonenumber,
+ sex,
+ password,
+ status,
+ create_by,
+ remark,
+ git_link_username,
+ git_link_password,
+ create_time
+ )values(
+ #{userId},
+ #{deptId},
+ #{userName},
+ #{nickName},
+ #{email},
+ #{avatar},
+ #{phonenumber},
+ #{sex},
+ #{password},
+ #{status},
+ #{createBy},
+ #{remark},
+ #{gitLinkUsername},
+ #{gitLinkPassword},
+ sysdate()
+ )
+
+
+
+ update sys_user
+
+ dept_id = #{deptId},
+ user_name = #{userName},
+ nick_name = #{nickName},
+ email = #{email},
+ phonenumber = #{phonenumber},
+ sex = #{sex},
+ avatar = #{avatar},
+ password = #{password},
+ status = #{status},
+ login_ip = #{loginIp},
+ login_date = #{loginDate},
+ update_by = #{updateBy},
+ remark = #{remark},
+ git_link_username = #{gitLinkUsername},
+ git_link_password = #{gitLinkPassword},
+ update_time = sysdate()
+
+ where user_id = #{userId}
+
+
+
+ update sys_user
+ set status = #{status}
+ where user_id = #{userId}
+
+
+
+ update sys_user
+ set avatar = #{avatar}
+ where user_name = #{userName}
+
+
+
+ update sys_user
+ set password = #{password}
+ where user_name = #{userName}
+
+
+
+ update sys_user
+ set del_flag = '2'
+ where user_id = #{userId}
+
+
+
+ update sys_user set del_flag = '2' where user_id in
+
+ #{userId}
+
+
+
\ No newline at end of file
From 36b13448fdbe3f01b75be58ae73e5a145206c3a3 Mon Sep 17 00:00:00 2001
From: chenzhihang <709011834@qq.com>
Date: Mon, 2 Sep 2024 10:37:18 +0800
Subject: [PATCH 02/12] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=94=B9=E7=94=A8?=
=?UTF-8?q?=E6=88=B7=E4=BF=A1=E6=81=AF=E6=9F=A5=E8=AF=A2=E8=A7=92=E8=89=B2?=
=?UTF-8?q?=E8=BF=94=E5=9B=9E=202=E3=80=81=E4=BF=AE=E6=94=B9=E4=BB=A3?=
=?UTF-8?q?=E7=A0=81=E9=85=8D=E7=BD=AE=EF=BC=8C=E8=AE=BE=E7=BD=AE=E4=BB=93?=
=?UTF-8?q?=E5=BA=93=E5=90=8D=E7=A7=B0=E5=94=AF=E4=B8=80=E6=80=A7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../com/ruoyi/platform/mapper/CodeConfigDao.java | 2 ++
.../service/impl/CodeConfigServiceImpl.java | 8 ++++++++
.../managementPlatform/CodeConfigDaoMapper.xml | 16 +++++++++++++---
.../system/controller/SysUserController.java | 3 ++-
4 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/CodeConfigDao.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/CodeConfigDao.java
index db896b5..9025960 100644
--- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/CodeConfigDao.java
+++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/mapper/CodeConfigDao.java
@@ -14,6 +14,8 @@ public interface CodeConfigDao {
CodeConfig queryById(Long id);
+ Long queryByCodeRepoName(@Param("codeRepoName") String codeRepoName);
+
int insert(@Param("codeConfig") CodeConfig codeConfig);
int update(@Param("codeConfig") CodeConfig codeConfig);
diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/CodeConfigServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/CodeConfigServiceImpl.java
index c857374..68effa5 100644
--- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/CodeConfigServiceImpl.java
+++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/CodeConfigServiceImpl.java
@@ -38,6 +38,10 @@ public class CodeConfigServiceImpl implements CodeConfigService {
@Override
public CodeConfig insert(CodeConfig codeConfig) {
+ Long id = this.codeConfigDao.queryByCodeRepoName(codeConfig.getCodeRepoName());
+ if(id != null){
+ throw new IllegalStateException("代码仓库名称已存在");
+ }
LoginUser loginUser = SecurityUtils.getLoginUser();
codeConfig.setCreateBy(loginUser.getUsername());
codeConfig.setUpdateBy(loginUser.getUsername());
@@ -49,6 +53,10 @@ public class CodeConfigServiceImpl implements CodeConfigService {
@Override
public CodeConfig update(CodeConfig codeConfig) {
+ Long id = this.codeConfigDao.queryByCodeRepoName(codeConfig.getCodeRepoName());
+ if(id != null){
+ throw new IllegalStateException("代码仓库名称已存在");
+ }
LoginUser loginUser = SecurityUtils.getLoginUser();
codeConfig.setUpdateBy(loginUser.getUsername());
diff --git a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/CodeConfigDaoMapper.xml b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/CodeConfigDaoMapper.xml
index 1056bf8..8dce9cc 100644
--- a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/CodeConfigDaoMapper.xml
+++ b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/CodeConfigDaoMapper.xml
@@ -3,9 +3,12 @@
- insert into code_config(code_repo_name, code_repo_vis, git_url, git_branch, verify_mode, git_user_name, git_password,ssh_key, create_by, create_time, update_by, update_time)
- values(#{codeConfig.codeRepoName}, #{codeConfig.codeRepoVis}, #{codeConfig.gitUrl}, #{codeConfig.gitBranch}, #{codeConfig.verifyMode}, #{codeConfig.gitUserName}, #{codeConfig.gitPassword},
- #{codeConfig.sshKey}, #{codeConfig.createBy}, #{codeConfig.createTime}, #{codeConfig.updateBy}, #{codeConfig.updateTime})
+ insert into code_config(code_repo_name, code_repo_vis, git_url, git_branch, verify_mode, git_user_name,
+ git_password, ssh_key, create_by, create_time, update_by, update_time)
+ values (#{codeConfig.codeRepoName}, #{codeConfig.codeRepoVis}, #{codeConfig.gitUrl}, #{codeConfig.gitBranch},
+ #{codeConfig.verifyMode}, #{codeConfig.gitUserName}, #{codeConfig.gitPassword},
+ #{codeConfig.sshKey}, #{codeConfig.createBy}, #{codeConfig.createTime}, #{codeConfig.updateBy},
+ #{codeConfig.updateTime})
@@ -64,6 +67,13 @@
and state = 1
+
+
state = 1
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java
index ed46bc7..713c6cd 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/SysUserController.java
@@ -156,7 +156,8 @@ public class SysUserController extends BaseController {
userService.checkUserDataScope(userId);
AjaxResult ajax = AjaxResult.success();
List roles = roleService.selectRoleAll();
- ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
+ ajax.put("roles", roles);
+// ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
ajax.put("posts", postService.selectPostAll());
if (StringUtils.isNotNull(userId)) {
SysUser sysUser = userService.selectUserById(userId);
From 48e05b03971e1325407bf72fb09682281e7ed04d Mon Sep 17 00:00:00 2001
From: chenzhihang <709011834@qq.com>
Date: Mon, 2 Sep 2024 10:58:15 +0800
Subject: [PATCH 03/12] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?=
=?UTF-8?q?=E9=85=8D=E7=BD=AE=EF=BC=8C=E8=AE=BE=E7=BD=AE=E4=BB=93=E5=BA=93?=
=?UTF-8?q?=E5=90=8D=E7=A7=B0=E5=94=AF=E4=B8=80=E6=80=A7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../com/ruoyi/platform/service/impl/CodeConfigServiceImpl.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/CodeConfigServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/CodeConfigServiceImpl.java
index 68effa5..445c095 100644
--- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/CodeConfigServiceImpl.java
+++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/CodeConfigServiceImpl.java
@@ -54,7 +54,7 @@ public class CodeConfigServiceImpl implements CodeConfigService {
@Override
public CodeConfig update(CodeConfig codeConfig) {
Long id = this.codeConfigDao.queryByCodeRepoName(codeConfig.getCodeRepoName());
- if(id != null){
+ if(id != null && !id.equals(codeConfig.getId())){
throw new IllegalStateException("代码仓库名称已存在");
}
From d447a6f0f3d1ebc4dfc37c9c83f8768cbdfdb7c2 Mon Sep 17 00:00:00 2001
From: chenzhihang <709011834@qq.com>
Date: Mon, 2 Sep 2024 15:23:14 +0800
Subject: [PATCH 04/12] =?UTF-8?q?1=E3=80=81=E4=BC=98=E5=8C=96=E4=BF=9D?=
=?UTF-8?q?=E5=AD=98=E9=95=9C=E5=83=8F=E6=96=B9=E6=B3=95=202=E3=80=81?=
=?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=A0=E9=99=A4=E9=95=9C=E5=83=8F=E6=96=B9?=
=?UTF-8?q?=E6=B3=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../service/impl/ImageServiceImpl.java | 106 ++++++++++--------
.../platform/utils/DockerClientUtil.java | 5 +
2 files changed, 65 insertions(+), 46 deletions(-)
diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java
index b13c414..591628a 100644
--- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java
+++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java
@@ -32,6 +32,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
@@ -85,6 +86,7 @@ public class ImageServiceImpl implements ImageService {
private String pvcName;
@Value("${jupyter.namespace}")
private String namespace;
+
/**
* 通过ID查询单条数据
*
@@ -99,8 +101,8 @@ public class ImageServiceImpl implements ImageService {
/**
* 分页查询
*
- * @param image 筛选条件
- * @param pageRequest 分页对象
+ * @param image 筛选条件
+ * @param pageRequest 分页对象
* @return 查询结果
*/
@Override
@@ -110,7 +112,6 @@ public class ImageServiceImpl implements ImageService {
}
-
/**
* 新增数据
*
@@ -138,7 +139,7 @@ public class ImageServiceImpl implements ImageService {
@Override
public Image update(Image image) {
int currentState = image.getState();
- if(currentState == 0){
+ if (currentState == 0) {
throw new RuntimeException("镜像已被删除,无法更新。");
}
LoginUser loginUser = SecurityUtils.getLoginUser();
@@ -163,7 +164,7 @@ public class ImageServiceImpl implements ImageService {
@Override
public String removeById(Integer id) throws Exception {
Image image = this.imageDao.queryById(id);
- if (image == null){
+ if (image == null) {
throw new Exception("镜像不存在");
}
@@ -173,14 +174,20 @@ public class ImageServiceImpl implements ImageService {
String createdBy = image.getCreateBy();
- if (!(StringUtils.equals(username,"admin") || !StringUtils.equals(username,createdBy))){
+ if (!(StringUtils.equals(username, "admin") || !StringUtils.equals(username, createdBy))) {
throw new Exception("无权限删除该镜像");
}
- if (!imageVersionService.queryByImageId(id).isEmpty()){
- throw new Exception("请先删除该镜像下的版本文件");
+// if (!imageVersionService.queryByImageId(id).isEmpty()){
+// throw new Exception("请先删除该镜像下的版本文件");
+// }
+ List imageVersions = imageVersionService.queryByImageId(id);
+
+ for (ImageVersion imageVersion : imageVersions) {
+ dockerClientUtil.removeImage(imageVersion.getUrl(), imageVersion.getHostIp());
}
+
image.setState(0);
- return this.imageDao.update(image)>0?"删除成功":"删除失败";
+ return this.imageDao.update(image) > 0 ? "删除成功" : "删除失败";
}
@@ -207,7 +214,7 @@ public class ImageServiceImpl implements ImageService {
public String insertImageAndVersion(ImageVo imageVo) throws Exception {
Image existingImage = getByName(imageVo.getName());
Image imageToUse;
- if(existingImage == null) {
+ if (existingImage == null) {
// 如果不存在相同名称的镜像,则创建新的镜像记录
Image newImage = new Image();
newImage.setName(imageVo.getName());
@@ -217,7 +224,7 @@ public class ImageServiceImpl implements ImageService {
if (imageToUse == null) {
throw new Exception("新增镜像失败");
}
- }else{
+ } else {
// 如果已存在相同名称的镜像,使用已存在的镜像
imageToUse = existingImage;
}
@@ -235,9 +242,9 @@ public class ImageServiceImpl implements ImageService {
CompletableFuture.supplyAsync(() -> {
Map resultMap = new HashMap<>();
try {
- if(imageVo.getUploadType()==0){
- resultMap = createImageFromNet(imageVo.getName(), imageVo.getTagName(), imageVo.getPath());
- }else{
+ if (imageVo.getUploadType() == 0) {
+ resultMap = createImageFromNet(imageVo.getName(), imageVo.getTagName(), imageVo.getPath());
+ } else {
resultMap = createImageFromLocal(imageVo.getName(), imageVo.getTagName(), imageVo.getPath());
}
} catch (Exception e) {
@@ -246,7 +253,7 @@ public class ImageServiceImpl implements ImageService {
throw new RuntimeException("镜像构建失败: " + e.getMessage(), e);
}
return resultMap;
- }).thenAccept(resultMap ->{
+ }).thenAccept(resultMap -> {
try {
String imageUrl = resultMap.get("url");
String fileSize = resultMap.get("fileSize");
@@ -272,27 +279,27 @@ public class ImageServiceImpl implements ImageService {
// 得到容器
V1Pod pod = k8sClientUtil.getNSPodList(serviceNS, deploymentName);
if (pod == null) {
- String podName = deploymentName+"-"+ DateUtils.formatYMD10(new Date());
- pod = k8sClientUtil.createPodWithEnv(podName,serviceNS,proxyUrl,mountPath,pvcName,image);
+ String podName = deploymentName + "-" + DateUtils.formatYMD10(new Date());
+ pod = k8sClientUtil.createPodWithEnv(podName, serviceNS, proxyUrl, mountPath, pvcName, image);
}
- String loginCmd = "docker login -u " + harborUser +" -p "+harborpassword+" "+harborUrl;
+ String loginCmd = "docker login -u " + harborUser + " -p " + harborpassword + " " + harborUrl;
// 执行命令 docker login -u admin -p Harbor12345 172.20.32.187
- String loginlog = k8sClientUtil.executeCommand(pod,loginCmd);
+ String loginlog = k8sClientUtil.executeCommand(pod, loginCmd);
// 在这个容器的/data/admin 目录下执行命令 docker load -i fileName 得到返回的镜像名字name:tag
String username = SecurityUtils.getLoginUser().getUsername();
//
- String logs2 = k8sClientUtil.executeCommand(pod,"docker pull "+ netPath);
+ String logs2 = k8sClientUtil.executeCommand(pod, "docker pull " + netPath);
// 在容器里执行 docker tag name:tag nexus3.kube-system.svc:8083/imageName:imageTag
- if (StringUtils.isNoneBlank(logs2)){
+ if (StringUtils.isNoneBlank(logs2)) {
String[] lines = logs2.split("\n");
String lastLine = lines[lines.length - 1].trim();
String tagCmd = "docker tag " + lastLine + " " + harborUrl + "/" + repository + "/" + username + "/" + imageName + ":" + imageTag;
String imageUrl = harborUrl + "/" + repository + "/" + username + "/" + imageName + ":" + imageTag;
- String pushCmd = "docker push " + imageUrl;
+ String pushCmd = "docker push " + imageUrl;
String sizeCmd = "docker inspect --format='{{.Size}}' " + imageUrl;
String s = k8sClientUtil.executeCommand(pod, tagCmd);
- if (StringUtils.isNotEmpty(k8sClientUtil.executeCommand(pod, pushCmd))){
+ if (StringUtils.isNotEmpty(k8sClientUtil.executeCommand(pod, pushCmd))) {
resultMap.put("url", imageUrl);
//得到镜像文件大小
String imageSizeStr = k8sClientUtil.executeCommand(pod, sizeCmd);
@@ -301,10 +308,10 @@ public class ImageServiceImpl implements ImageService {
resultMap.put("fileSize", formattedImageSize);
return resultMap;
- }else {
+ } else {
throw new Exception("拉取公网镜像失败,请检查网络或者镜像地址");
}
- }else {
+ } else {
throw new Exception("拉取公网镜像失败,请检查网络或者镜像地址");
}
}
@@ -315,27 +322,27 @@ public class ImageServiceImpl implements ImageService {
// 得到容器
V1Pod pod = k8sClientUtil.getNSPodList(serviceNS, deploymentName);
if (pod == null) {
- String podName = deploymentName+"-"+ DateUtils.formatYMD10(new Date());
- pod = k8sClientUtil.createPodWithEnv(podName,serviceNS,proxyUrl,mountPath,pvcName,image);
+ String podName = deploymentName + "-" + DateUtils.formatYMD10(new Date());
+ pod = k8sClientUtil.createPodWithEnv(podName, serviceNS, proxyUrl, mountPath, pvcName, image);
}
- String loginCmd = "docker login -u " + harborUser +" -p "+harborpassword+" "+harborUrl;
+ String loginCmd = "docker login -u " + harborUser + " -p " + harborpassword + " " + harborUrl;
// 执行命令 docker login -u admin -p Harbor12345 172.20.32.187
- String loginlog = k8sClientUtil.executeCommand(pod,loginCmd);
+ String loginlog = k8sClientUtil.executeCommand(pod, loginCmd);
// 在这个容器的/data/admin 目录下执行命令 docker load -i fileName 得到返回的镜像名字name:tag
String username = SecurityUtils.getLoginUser().getUsername();
//
- String filePath = "/data/argo-workflow/" + bucketName + "/" +path;
- String logs2 = k8sClientUtil.executeCommand(pod,"docker load -i "+filePath);
+ String filePath = "/data/argo-workflow/" + bucketName + "/" + path;
+ String logs2 = k8sClientUtil.executeCommand(pod, "docker load -i " + filePath);
// 在容器里执行 docker tag name:tag nexus3.kube-system.svc:8083/imageName:imageTag
- if (StringUtils.isNoneBlank(logs2)){
- String substring = logs2.substring(logs2.indexOf(":")+1).trim();
+ if (StringUtils.isNoneBlank(logs2)) {
+ String substring = logs2.substring(logs2.indexOf(":") + 1).trim();
String tagCmd = "docker tag " + substring + " " + harborUrl + "/" + repository + "/" + username + "/" + imageName + ":" + imageTag;
String imageUrl = harborUrl + "/" + repository + "/" + username + "/" + imageName + ":" + imageTag;
- String pushCmd = "docker push " + imageUrl;
+ String pushCmd = "docker push " + imageUrl;
String sizeCmd = "docker inspect --format='{{.Size}}' " + imageUrl;
String s = k8sClientUtil.executeCommand(pod, tagCmd);
- if (StringUtils.isNotEmpty(k8sClientUtil.executeCommand(pod, pushCmd))){
+ if (StringUtils.isNotEmpty(k8sClientUtil.executeCommand(pod, pushCmd))) {
resultMap.put("url", imageUrl);
//得到镜像文件大小
String imageSizeStr = k8sClientUtil.executeCommand(pod, sizeCmd);
@@ -343,43 +350,49 @@ public class ImageServiceImpl implements ImageService {
String formattedImageSize = FileUtil.formatFileSize(sizeInBytes); // 格式化镜像文件大小
resultMap.put("fileSize", formattedImageSize);
return resultMap;
- }else {
+ } else {
throw new Exception("解析镜像压缩包失败,请检查镜像文件");
}
- }else {
+ } else {
throw new Exception("解析镜像压缩包失败,请检查镜像文件");
}
}
-
-
@Override
public Map uploadImageFiles(MultipartFile file) throws Exception {
LoginUser loginUser = SecurityUtils.getLoginUser();
- String path = loginUser.getUsername()+"/"+file.getOriginalFilename();
+ String path = loginUser.getUsername() + "/" + file.getOriginalFilename();
return minioService.uploadFile(bucketName, path, file);
}
@Override
@Transactional
+ @Async
public String saveImage(ImageVo imageVo) {
- if(imageDao.getByName(imageVo.getName()) != null){
- throw new IllegalStateException("镜像名称已存在");
+ Image oldImage = imageDao.getByName(imageVo.getName());
+ if (oldImage != null) {
+ List oldImageVersions = imageVersionDao.queryByImageId(oldImage.getId());
+ for (ImageVersion oldImageVersion : oldImageVersions) {
+ if(oldImageVersion.getTagName().equals(imageVo.getTagName())){
+ throw new IllegalStateException("镜像tag不能重复");
+ }
+ }
}
+
LoginUser loginUser = SecurityUtils.getLoginUser();
String username = loginUser.getUsername().toLowerCase();
- String podName = username +"-editor-pod" + "-" + imageVo.getDevEnvironmentId().toString();
+ String podName = username + "-editor-pod" + "-" + imageVo.getDevEnvironmentId().toString();
try {
String containerId = k8sClientUtil.getPodContainerId(podName, namespace);
String hostIp = k8sClientUtil.getHostIp(podName, namespace);
- dockerClientUtil.commitImage(imageVo,containerId,hostIp,username);
+ dockerClientUtil.commitImage(imageVo, containerId, hostIp, username);
HashMap resultMap = dockerClientUtil.pushImageToHorbor(imageVo, hostIp);
Image image = new Image();
- BeanUtils.copyProperties(imageVo,image);
+ BeanUtils.copyProperties(imageVo, image);
image.setImageType(Constant.Image_Type_Pri);
image.setCreateBy(username);
image.setUpdateBy(username);
@@ -396,6 +409,7 @@ public class ImageServiceImpl implements ImageService {
imageVersion.setFileSize(resultMap.get("size"));
imageVersion.setCreateBy(username);
imageVersion.setUpdateBy(username);
+ imageVersion.setHostIp(hostIp);
imageVersion.setUpdateTime(new Date());
imageVersion.setCreateTime(new Date());
imageVersion.setState(1);
@@ -410,7 +424,7 @@ public class ImageServiceImpl implements ImageService {
return "保存镜像成功";
} catch (Exception e) {
- throw new RuntimeException("保存镜像失败:" +e);
+ throw new RuntimeException("保存镜像失败:" + e);
}
}
}
diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DockerClientUtil.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DockerClientUtil.java
index b20fa07..552b025 100644
--- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DockerClientUtil.java
+++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/DockerClientUtil.java
@@ -106,4 +106,9 @@ public class DockerClientUtil {
}
}
+
+ public void removeImage(String imageName, String hostIp){
+ DockerClient dockerClient = getDockerClient(hostIp);
+ dockerClient.removeImageCmd(imageName).withForce(true).exec();
+ }
}
\ No newline at end of file
From dc93dc0438ea66ab849e57e718f514c3764cc137 Mon Sep 17 00:00:00 2001
From: chenzhihang <709011834@qq.com>
Date: Mon, 2 Sep 2024 15:38:42 +0800
Subject: [PATCH 05/12] =?UTF-8?q?=E5=90=88=E5=B9=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
react-ui/config/routes.ts | 11 ++++
react-ui/src/enums/index.ts | 6 ++
.../Dataset/components/ResourceList/index.tsx | 4 +-
.../Dataset/components/Resourcetem/index.less | 61 -------------------
.../Dataset/components/Resourcetem/index.tsx | 54 ----------------
.../DevelopmentEnvironment/List/index.tsx | 2 +-
6 files changed, 20 insertions(+), 118 deletions(-)
delete mode 100644 react-ui/src/pages/Dataset/components/Resourcetem/index.less
delete mode 100644 react-ui/src/pages/Dataset/components/Resourcetem/index.tsx
diff --git a/react-ui/config/routes.ts b/react-ui/config/routes.ts
index c2b1c2a..8838c75 100644
--- a/react-ui/config/routes.ts
+++ b/react-ui/config/routes.ts
@@ -198,6 +198,17 @@ export default [
},
],
},
+ {
+ name: '代码配置',
+ path: 'codeConfig',
+ routes: [
+ {
+ name: '代码配置',
+ path: '',
+ component: './CodeConfig/List',
+ },
+ ],
+ },
],
},
{
diff --git a/react-ui/src/enums/index.ts b/react-ui/src/enums/index.ts
index b75eeca..5585725 100644
--- a/react-ui/src/enums/index.ts
+++ b/react-ui/src/enums/index.ts
@@ -10,6 +10,12 @@ export enum CommonTabKeys {
Public = 'Public', // 公开
}
+// 公开还是私有
+export enum AvailableRange {
+ Public = 1, // 公开
+ Private = 0, // 私有
+}
+
// 实验状态
export enum ExperimentStatus {
Running = 'Running', // 运行中
diff --git a/react-ui/src/pages/Dataset/components/ResourceList/index.tsx b/react-ui/src/pages/Dataset/components/ResourceList/index.tsx
index 60626fa..53df0e3 100644
--- a/react-ui/src/pages/Dataset/components/ResourceList/index.tsx
+++ b/react-ui/src/pages/Dataset/components/ResourceList/index.tsx
@@ -9,7 +9,7 @@ import { App, Button, Input, Pagination, PaginationProps } from 'antd';
import { Ref, forwardRef, useEffect, useImperativeHandle, useState } from 'react';
import { CategoryData, ResourceData, ResourceType, resourceConfig } from '../../config';
import AddDatasetModal from '../AddDatasetModal';
-import ResourceItem from '../Resourcetem';
+import ResourceItem from '../ResourceItem';
import styles from './index.less';
export type ResourceListRef = {
@@ -161,7 +161,7 @@ function ResourceList(
数据总数:{total}个
void;
- onClick: (item: ResourceData) => void;
-};
-
-function ResourceItem({ item, isPublic, onClick, onRemove }: ResourceItemProps) {
- return (
- onClick(item)}>
-
-
- {item.name}
-
- {!isPublic && (
-
- )}
-
-
{item.description}
-
-
-
-
{item.create_by}
-
-
-
-
最近更新: {formatDate(item.update_time, 'YYYY-MM-DD')}
-
-
-
- );
-}
-
-export default ResourceItem;
diff --git a/react-ui/src/pages/DevelopmentEnvironment/List/index.tsx b/react-ui/src/pages/DevelopmentEnvironment/List/index.tsx
index 2b8fdf4..8f7d767 100644
--- a/react-ui/src/pages/DevelopmentEnvironment/List/index.tsx
+++ b/react-ui/src/pages/DevelopmentEnvironment/List/index.tsx
@@ -166,7 +166,7 @@ function EditorList() {
key: 'name',
width: '30%',
render: (text, record) =>
- record.url ? (
+ record.url && record.status === DevEditorStatus.Running ? (
gotoEditorPage(e, record)}>
{text}
From 40f8a9d775c4cbbd75a4a6ea66a2971a8debff6b Mon Sep 17 00:00:00 2001
From: chenzhihang <709011834@qq.com>
Date: Mon, 2 Sep 2024 16:06:45 +0800
Subject: [PATCH 06/12] =?UTF-8?q?=E4=BC=98=E5=8C=96nacos=E9=85=8D=E7=BD=AE?=
=?UTF-8?q?=E7=9B=91=E5=90=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ruoyi-auth/src/main/resources/bootstrap.yml | 11 ++++++++++-
ruoyi-gateway/src/main/resources/bootstrap.yml | 13 +++++++++++--
.../src/main/resources/bootstrap.yml | 11 ++++++++++-
.../ruoyi-file/src/main/resources/bootstrap.yml | 8 +++++++-
.../ruoyi-gen/src/main/resources/bootstrap.yml | 8 +++++++-
.../ruoyi-job/src/main/resources/bootstrap.yml | 13 +++++++++++--
.../ruoyi-system/src/main/resources/bootstrap.yml | 8 +++++++-
.../ruoyi-monitor/src/main/resources/bootstrap.yml | 8 +++++++-
8 files changed, 70 insertions(+), 10 deletions(-)
diff --git a/ruoyi-auth/src/main/resources/bootstrap.yml b/ruoyi-auth/src/main/resources/bootstrap.yml
index c8b1658..a660761 100644
--- a/ruoyi-auth/src/main/resources/bootstrap.yml
+++ b/ruoyi-auth/src/main/resources/bootstrap.yml
@@ -15,6 +15,10 @@ spring:
discovery:
# 服务注册地址
server-addr: nacos-ci4s.ci4s-test.svc:8848
+ username: nacos
+ password: nacos
+ retry:
+ enabled: true
config:
# 配置中心地址
server-addr: nacos-ci4s.ci4s-test.svc:8848
@@ -22,4 +26,9 @@ spring:
file-extension: yml
# 共享配置
shared-configs:
- - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ - data-id: application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ group: DEFAULT_GROUP
+ refresh: true
+ - data-id: ${spring.application.name}-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ group: DEFAULT_GROUP
+ refresh: true
\ No newline at end of file
diff --git a/ruoyi-gateway/src/main/resources/bootstrap.yml b/ruoyi-gateway/src/main/resources/bootstrap.yml
index d3abcc6..cce7444 100644
--- a/ruoyi-gateway/src/main/resources/bootstrap.yml
+++ b/ruoyi-gateway/src/main/resources/bootstrap.yml
@@ -15,6 +15,10 @@ spring:
discovery:
# 服务注册地址
server-addr: nacos-ci4s.ci4s-test.svc:8848
+ username: nacos
+ password: nacos
+ retry:
+ enabled: true
config:
# 配置中心地址
server-addr: nacos-ci4s.ci4s-test.svc:8848
@@ -22,7 +26,12 @@ spring:
file-extension: yml
# 共享配置
shared-configs:
- - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ - data-id: application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ group: DEFAULT_GROUP
+ refresh: true
+ - data-id: ${spring.application.name}-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ group: DEFAULT_GROUP
+ refresh: true
sentinel:
# 取消控制台懒加载
eager: true
@@ -33,7 +42,7 @@ spring:
datasource:
ds1:
nacos:
- server-addr: nacos-ci4s.ci4s-test.svc:8848
+ server-addr: nacos-ci4s.ci4s-test.svc:18848
dataId: sentinel-ruoyi-gateway
groupId: DEFAULT_GROUP
data-type: json
diff --git a/ruoyi-modules/management-platform/src/main/resources/bootstrap.yml b/ruoyi-modules/management-platform/src/main/resources/bootstrap.yml
index 70d87bb..11095bb 100644
--- a/ruoyi-modules/management-platform/src/main/resources/bootstrap.yml
+++ b/ruoyi-modules/management-platform/src/main/resources/bootstrap.yml
@@ -15,6 +15,10 @@ spring:
discovery:
# 服务注册地址
server-addr: nacos-ci4s.ci4s-test.svc:8848
+ username: nacos
+ password: nacos
+ retry:
+ enabled: true
config:
# 配置中心地址
server-addr: nacos-ci4s.ci4s-test.svc:8848
@@ -22,4 +26,9 @@ spring:
file-extension: yml
# 共享配置
shared-configs:
- - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ - data-id: application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ group: DEFAULT_GROUP
+ refresh: true
+ - data-id: management-platform-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ group: DEFAULT_GROUP
+ refresh: true
\ No newline at end of file
diff --git a/ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml b/ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml
index e2649cf..30ee8b1 100644
--- a/ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml
+++ b/ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml
@@ -15,6 +15,10 @@ spring:
discovery:
# 服务注册地址
server-addr: nacos-ci4s.ci4s-test.svc:8848
+ username: nacos
+ password: nacos
+ retry:
+ enabled: true
config:
# 配置中心地址
server-addr: nacos-ci4s.ci4s-test.svc:8848
@@ -22,4 +26,6 @@ spring:
file-extension: yml
# 共享配置
shared-configs:
- - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ - data-id: application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ group: DEFAULT_GROUP
+ refresh: true
diff --git a/ruoyi-modules/ruoyi-gen/src/main/resources/bootstrap.yml b/ruoyi-modules/ruoyi-gen/src/main/resources/bootstrap.yml
index 664f531..b2f6791 100644
--- a/ruoyi-modules/ruoyi-gen/src/main/resources/bootstrap.yml
+++ b/ruoyi-modules/ruoyi-gen/src/main/resources/bootstrap.yml
@@ -15,6 +15,10 @@ spring:
discovery:
# 服务注册地址
server-addr: nacos-ci4s.ci4s-test.svc:8848
+ username: nacos
+ password: nacos
+ retry:
+ enabled: true
config:
# 配置中心地址
server-addr: nacos-ci4s.ci4s-test.svc:8848
@@ -22,4 +26,6 @@ spring:
file-extension: yml
# 共享配置
shared-configs:
- - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ - data-id: application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ group: DEFAULT_GROUP
+ refresh: true
diff --git a/ruoyi-modules/ruoyi-job/src/main/resources/bootstrap.yml b/ruoyi-modules/ruoyi-job/src/main/resources/bootstrap.yml
index c182158..8c79d3a 100644
--- a/ruoyi-modules/ruoyi-job/src/main/resources/bootstrap.yml
+++ b/ruoyi-modules/ruoyi-job/src/main/resources/bootstrap.yml
@@ -3,7 +3,7 @@ server:
port: 9203
# Spring
-spring:
+spring:
application:
# 应用名称
name: ruoyi-job
@@ -15,6 +15,10 @@ spring:
discovery:
# 服务注册地址
server-addr: nacos-ci4s.ci4s-test.svc:8848
+ username: nacos
+ password: nacos
+ retry:
+ enabled: true
config:
# 配置中心地址
server-addr: nacos-ci4s.ci4s-test.svc:8848
@@ -22,4 +26,9 @@ spring:
file-extension: yml
# 共享配置
shared-configs:
- - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ - data-id: application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ group: DEFAULT_GROUP
+ refresh: true
+ - data-id: ${spring.application.name}-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ group: DEFAULT_GROUP
+ refresh: true
\ No newline at end of file
diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml b/ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml
index 62cc1c2..c7ddcd4 100644
--- a/ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml
+++ b/ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml
@@ -15,6 +15,10 @@ spring:
discovery:
# 服务注册地址
server-addr: nacos-ci4s.ci4s-test.svc:8848
+ username: nacos
+ password: nacos
+ retry:
+ enabled: true
config:
# 配置中心地址
server-addr: nacos-ci4s.ci4s-test.svc:8848
@@ -22,4 +26,6 @@ spring:
file-extension: yml
# 共享配置
shared-configs:
- - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ - data-id: application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ group: DEFAULT_GROUP
+ refresh: true
diff --git a/ruoyi-visual/ruoyi-monitor/src/main/resources/bootstrap.yml b/ruoyi-visual/ruoyi-monitor/src/main/resources/bootstrap.yml
index 394a74d..c2876a0 100644
--- a/ruoyi-visual/ruoyi-monitor/src/main/resources/bootstrap.yml
+++ b/ruoyi-visual/ruoyi-monitor/src/main/resources/bootstrap.yml
@@ -15,6 +15,10 @@ spring:
discovery:
# 服务注册地址
server-addr: nacos-ci4s.ci4s-test.svc:8848
+ username: nacos
+ password: nacos
+ retry:
+ enabled: true
config:
# 配置中心地址
server-addr: nacos-ci4s.ci4s-test.svc:8848
@@ -22,4 +26,6 @@ spring:
file-extension: yml
# 共享配置
shared-configs:
- - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ - data-id: application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ group: DEFAULT_GROUP
+ refresh: true
From f393b8883ac2838e27f645d88bf52ff37055aa26 Mon Sep 17 00:00:00 2001
From: chenzhihang <709011834@qq.com>
Date: Mon, 2 Sep 2024 16:13:16 +0800
Subject: [PATCH 07/12] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?=
=?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=9F=A5=E8=AF=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../platform/controller/codeConfig/CodeConfigController.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/codeConfig/CodeConfigController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/codeConfig/CodeConfigController.java
index 058188b..e79b7e3 100644
--- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/codeConfig/CodeConfigController.java
+++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/codeConfig/CodeConfigController.java
@@ -31,10 +31,12 @@ public class CodeConfigController extends BaseController {
@GetMapping
public GenericsAjaxResult> queryByPage(@RequestParam("page") int page,
@RequestParam("size") int size,
- @RequestParam(value = "code_repo_name", required = false) String codeRepoName) {
+ @RequestParam(value = "code_repo_name", required = false) String codeRepoName,
+ @RequestParam(value = "code_repo_vis", required = false)Integer codeRepoVis) {
PageRequest pageRequest = PageRequest.of(page, size);
CodeConfig codeConfig = new CodeConfig();
codeConfig.setCodeRepoName(codeRepoName);
+ codeConfig.setCodeRepoVis(codeRepoVis);
return genericsSuccess(this.codeConfigService.queryByPage(codeConfig, pageRequest));
}
From 4b27ca173b3bbc76ff5d4ef1a415a91952b1ef24 Mon Sep 17 00:00:00 2001
From: chenzhihang <709011834@qq.com>
Date: Mon, 2 Sep 2024 16:19:58 +0800
Subject: [PATCH 08/12] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?=
=?UTF-8?q?=E9=85=8D=E7=BD=AE=E8=AF=A6=E6=83=85=E6=9F=A5=E8=AF=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../platform/controller/codeConfig/CodeConfigController.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/codeConfig/CodeConfigController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/codeConfig/CodeConfigController.java
index e79b7e3..3aa6c37 100644
--- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/codeConfig/CodeConfigController.java
+++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/codeConfig/CodeConfigController.java
@@ -47,8 +47,8 @@ public class CodeConfigController extends BaseController {
* @return 单条数据
*/
@GetMapping("{id}")
- public ResponseEntity queryById(@PathVariable("id") Long id) {
- return ResponseEntity.ok(this.codeConfigService.queryById(id));
+ public GenericsAjaxResult queryById(@PathVariable("id") Long id) {
+ return genericsSuccess(this.codeConfigService.queryById(id));
}
From f6827de6da9610c7db4e5716c75b3b5efc4de534 Mon Sep 17 00:00:00 2001
From: chenzhihang <709011834@qq.com>
Date: Mon, 2 Sep 2024 16:55:02 +0800
Subject: [PATCH 09/12] =?UTF-8?q?1=E3=80=81=E4=BC=98=E5=8C=96=E4=BF=9D?=
=?UTF-8?q?=E5=AD=98=E9=95=9C=E5=83=8F=E6=96=B9=E6=B3=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../platform/service/impl/ImageServiceImpl.java | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java
index 591628a..ad436ce 100644
--- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java
+++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java
@@ -24,7 +24,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
-import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
@@ -182,12 +181,12 @@ public class ImageServiceImpl implements ImageService {
// }
List imageVersions = imageVersionService.queryByImageId(id);
- for (ImageVersion imageVersion : imageVersions) {
+ for (ImageVersion imageVersion :imageVersions) {
dockerClientUtil.removeImage(imageVersion.getUrl(), imageVersion.getHostIp());
}
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
@Transactional
- @Async
public String saveImage(ImageVo imageVo) {
- Image oldImage = imageDao.getByName(imageVo.getName());
- if (oldImage != null) {
- List 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();
String username = loginUser.getUsername().toLowerCase();
String podName = username + "-editor-pod" + "-" + imageVo.getDevEnvironmentId().toString();
From 56c1f854c627693dbe16c240150e2cfed24b9981 Mon Sep 17 00:00:00 2001
From: chenzhihang <709011834@qq.com>
Date: Mon, 2 Sep 2024 16:56:54 +0800
Subject: [PATCH 10/12] =?UTF-8?q?1=E3=80=81=E4=BC=98=E5=8C=96=E4=BF=9D?=
=?UTF-8?q?=E5=AD=98=E9=95=9C=E5=83=8F=E6=96=B9=E6=B3=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ruoyi/platform/domain/ImageVersion.java | 101 +-----------------
.../ImageVersionDaoMapper.xml | 1 +
2 files changed, 5 insertions(+), 97 deletions(-)
diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ImageVersion.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ImageVersion.java
index ca20c4f..6441333 100644
--- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ImageVersion.java
+++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ImageVersion.java
@@ -3,6 +3,7 @@ package com.ruoyi.platform.domain;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
import java.util.Date;
import java.io.Serializable;
@@ -14,6 +15,7 @@ import java.io.Serializable;
* @since 2024-03-05 15:00:02
*/
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
+@Data
public class ImageVersion implements Serializable {
private static final long serialVersionUID = 251017725389874890L;
/**
@@ -56,102 +58,7 @@ public class ImageVersion implements Serializable {
@ApiModelProperty(value = "状态,0失效,1生效")
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;
}
diff --git a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ImageVersionDaoMapper.xml b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ImageVersionDaoMapper.xml
index d7775b1..6371090 100644
--- a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ImageVersionDaoMapper.xml
+++ b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ImageVersionDaoMapper.xml
@@ -15,6 +15,7 @@
+
From 86511836d7194423347dc5731b14b3461246574d Mon Sep 17 00:00:00 2001
From: chenzhihang <709011834@qq.com>
Date: Mon, 2 Sep 2024 18:13:37 +0800
Subject: [PATCH 11/12] =?UTF-8?q?1=E3=80=81=E4=BC=98=E5=8C=96=E4=BF=9D?=
=?UTF-8?q?=E5=AD=98=E9=95=9C=E5=83=8F=E6=96=B9=E6=B3=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../controller/image/ImageController.java | 25 +++++++++----------
.../ruoyi/platform/service/ImageService.java | 2 +-
.../service/impl/ImageServiceImpl.java | 17 +++++++++----
3 files changed, 25 insertions(+), 19 deletions(-)
diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/image/ImageController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/image/ImageController.java
index 1af9c98..624ff5e 100644
--- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/image/ImageController.java
+++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/image/ImageController.java
@@ -45,7 +45,7 @@ public class ImageController extends BaseController {
@RequestParam("size") int size,
@RequestParam(value = "image_type") int imageType) {
image.setImageType(imageType);
- PageRequest pageRequest = PageRequest.of(page,size);
+ PageRequest pageRequest = PageRequest.of(page, size);
return genericsSuccess(this.imageService.queryByPage(image, pageRequest));
}
@@ -72,6 +72,7 @@ public class ImageController extends BaseController {
public GenericsAjaxResult> queryByName(@PathVariable("name") String name) {
return genericsSuccess(this.imageService.queryByName(name));
}
+
/**
* 新增数据
*
@@ -84,9 +85,8 @@ public class ImageController extends BaseController {
}
/**
- *
* @param imageVo 实体
- * 新增镜像和版本 @PostMapping
+ * 新增镜像和版本 @PostMapping
* @return 新增结果
*/
@PostMapping("/addImageAndVersion")
@@ -122,21 +122,20 @@ public class ImageController extends BaseController {
@PostMapping("/net")
@ApiOperation("从网络上传构建镜像")
public GenericsAjaxResult