diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/aim/AimController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/aim/AimController.java index 35b274d..f175013 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/aim/AimController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/aim/AimController.java @@ -4,6 +4,7 @@ import com.ruoyi.common.core.web.controller.BaseController; import com.ruoyi.common.core.web.domain.GenericsAjaxResult; import com.ruoyi.platform.service.AimService; import com.ruoyi.platform.vo.FrameLogPathVo; +import com.ruoyi.platform.vo.PodStatusVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.v3.oas.annotations.responses.ApiResponse; diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/JupyterServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/JupyterServiceImpl.java index 152af37..b3eb4bd 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/JupyterServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/JupyterServiceImpl.java @@ -1,8 +1,10 @@ package com.ruoyi.platform.service.impl; +import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.redis.service.RedisService; import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.platform.domain.DevEnvironment; +import com.ruoyi.platform.domain.PodStatus; import com.ruoyi.platform.mapper.DevEnvironmentDao; import com.ruoyi.platform.service.DevEnvironmentService; import com.ruoyi.platform.service.JupyterService; @@ -76,9 +78,9 @@ public class JupyterServiceImpl implements JupyterService { @Override public String runJupyterService(Integer id) { DevEnvironment devEnvironment = this.devEnvironmentDao.queryById(id); - if(devEnvironment == null){ - - } +// if(devEnvironment == null){ +// +// } String envName = devEnvironment.getName(); //TODO 设置环境变量 @@ -124,7 +126,34 @@ public class JupyterServiceImpl implements JupyterService { @Override public PodStatusVo getJupyterStatus(FrameLogPathVo frameLogPathVo) { - return null; + String status = PodStatus.Terminated.getName(); + PodStatusVo JupyterStatusVo = new PodStatusVo(); + JupyterStatusVo.setStatus(status); + if(StringUtils.isEmpty(frameLogPathVo.getPath())){ + return JupyterStatusVo; + } + + LoginUser loginUser = SecurityUtils.getLoginUser(); + String podName = loginUser.getUsername().toLowerCase() + "-editor-pod"; + + try { + // 查询相应pod状态 + String podStatus = k8sClientUtil.getPodStatus(podName, StringUtils.isEmpty(frameLogPathVo.getNamespace()) ? "default" : frameLogPathVo.getNamespace()); + for (PodStatus s : PodStatus.values()) { + if (s.getName().equals(podStatus)) { + status = s.getName(); + break; + } + } + + } catch (Exception e) { + return JupyterStatusVo; + } + String url = redisService.getCacheObject(podName); + JupyterStatusVo.setStatus(status); + JupyterStatusVo.setUrl(url); + return JupyterStatusVo; + } diff --git a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ModelDependencyDaoMapper.xml b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ModelDependencyDaoMapper.xml index 939df96..1275528 100644 --- a/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ModelDependencyDaoMapper.xml +++ b/ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ModelDependencyDaoMapper.xml @@ -321,7 +321,7 @@ state = #{state}, - where id = #{id} and state = 1 + where id = #{id}