| @@ -35,25 +35,22 @@ public class ComponentController { | |||
| */ | |||
| @GetMapping | |||
| @ApiOperation("分页查询") | |||
| public AjaxResult queryByPage( Component component, int page, int size) { | |||
| PageRequest pageRequest = PageRequest.of(page,size); | |||
| return AjaxResult.success(this.componentService.queryByPage(component, pageRequest)); | |||
| public AjaxResult queryByPage(Component component, int page, int size) { | |||
| PageRequest pageRequest = PageRequest.of(page, size); | |||
| return AjaxResult.success(this.componentService.queryByPage(component, pageRequest)); | |||
| } | |||
| /** | |||
| * 查询全部 | |||
| * | |||
| * | |||
| * | |||
| * @return 查询结果 | |||
| */ | |||
| @GetMapping("/components/all") | |||
| @ApiOperation("查询全部") | |||
| public AjaxResult queryAll() throws Exception { | |||
| return AjaxResult.success(this.componentService.queryAllGroupedByCategory()); | |||
| } | |||
| @GetMapping("/components/all") | |||
| @ApiOperation("查询全部") | |||
| public AjaxResult queryAll() throws Exception { | |||
| return AjaxResult.success(this.componentService.queryAllGroupedByCategory()); | |||
| } | |||
| /** | |||
| @@ -77,7 +74,7 @@ public class ComponentController { | |||
| @PostMapping | |||
| @ApiOperation("添加组件") | |||
| public AjaxResult add(@RequestBody ComponentVo component) { | |||
| return AjaxResult.success(this.componentService.insert(component)); | |||
| return AjaxResult.success(this.componentService.insert(component)); | |||
| } | |||
| /** | |||
| @@ -89,7 +86,7 @@ public class ComponentController { | |||
| @PutMapping | |||
| @ApiOperation("编辑组件") | |||
| public AjaxResult edit(@RequestBody ComponentVo component) { | |||
| return AjaxResult.success(this.componentService.update(component)); | |||
| return AjaxResult.success(this.componentService.update(component)); | |||
| } | |||
| /** | |||
| @@ -101,7 +98,7 @@ public class ComponentController { | |||
| @DeleteMapping("{id}") | |||
| @ApiOperation("根据id删除组件") | |||
| public AjaxResult deleteById(@PathVariable("id") Integer id) throws Exception { | |||
| return AjaxResult.success(this.componentService.removeById(id)); | |||
| return AjaxResult.success(this.componentService.removeById(id)); | |||
| } | |||
| } | |||
| @@ -40,7 +40,7 @@ public class WorkflowController extends BaseController { | |||
| */ | |||
| @GetMapping | |||
| @ApiOperation("分页查询") | |||
| public GenericsAjaxResult<Page<Workflow>> queryByPage(Workflow workflow, int page, int size) { | |||
| public GenericsAjaxResult<Page<WorkflowVo>> queryByPage(Workflow workflow, int page, int size) throws IOException { | |||
| PageRequest pageRequest = PageRequest.of(page, size); | |||
| return genericsSuccess(this.workflowService.queryByPage(workflow, pageRequest)); | |||
| } | |||
| @@ -3,10 +3,19 @@ package com.ruoyi.platform.controller.workspace; | |||
| import com.ruoyi.common.core.web.controller.BaseController; | |||
| import com.ruoyi.common.core.web.domain.AjaxResult; | |||
| import com.ruoyi.common.core.web.domain.GenericsAjaxResult; | |||
| import com.ruoyi.platform.service.JupyterService; | |||
| import com.ruoyi.platform.service.WorkspaceService; | |||
| import com.ruoyi.common.security.utils.SecurityUtils; | |||
| import com.ruoyi.platform.domain.CodeConfig; | |||
| import com.ruoyi.platform.domain.Dataset; | |||
| import com.ruoyi.platform.domain.Image; | |||
| import com.ruoyi.platform.domain.Service; | |||
| import com.ruoyi.platform.service.*; | |||
| import com.ruoyi.platform.vo.ModelsVo; | |||
| import com.ruoyi.system.api.constant.Constant; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.springframework.beans.factory.annotation.Value; | |||
| import org.springframework.data.domain.Page; | |||
| import org.springframework.data.domain.PageRequest; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.annotation.Resource; | |||
| @@ -19,6 +28,23 @@ public class WorkspaceController extends BaseController { | |||
| @Resource | |||
| private WorkspaceService workspaceService; | |||
| @Resource | |||
| private NewDatasetService newDatasetService; | |||
| @Resource | |||
| private ModelsService modelsService; | |||
| @Resource | |||
| private CodeConfigService codeConfigService; | |||
| @Resource | |||
| private ServiceService serviceService; | |||
| @Resource | |||
| private ImageService imageService; | |||
| @Resource | |||
| private GitService gitService; | |||
| @Value("${git.publicUserName}") | |||
| private String publicUserName; | |||
| @Value("${git.publicUserPwd}") | |||
| private String publicUserPwd; | |||
| @GetMapping("/overview") | |||
| @ApiOperation("得到运行概览") | |||
| @@ -38,4 +64,47 @@ public class WorkspaceController extends BaseController { | |||
| public GenericsAjaxResult<Map<String, Integer>> getAssetPublicCount() throws Exception { | |||
| return genericsSuccess(this.workspaceService.getAssetPublicCount()); | |||
| } | |||
| @GetMapping("/getPublicDatasets") | |||
| @ApiOperation("前6个公开数据集") | |||
| public AjaxResult getPublicDatasets() throws Exception { | |||
| PageRequest pageRequest = PageRequest.of(0, 6); | |||
| Dataset dataset = new Dataset(); | |||
| String accessToken = gitService.login(publicUserName, SecurityUtils.encrypt(publicUserPwd)); | |||
| return AjaxResult.success(this.newDatasetService.newPubilcQueryByPage(dataset, pageRequest, accessToken)); | |||
| } | |||
| @GetMapping("/getPublicModels") | |||
| @ApiOperation("前6个公开模型") | |||
| public AjaxResult getPublicModels() throws Exception { | |||
| PageRequest pageRequest = PageRequest.of(0, 6); | |||
| ModelsVo modelsVo = new ModelsVo(); | |||
| String accessToken = gitService.login(publicUserName, SecurityUtils.encrypt(publicUserPwd)); | |||
| return AjaxResult.success(this.modelsService.newPubilcQueryByPage(modelsVo, pageRequest, accessToken)); | |||
| } | |||
| @GetMapping("/getPublicCodeConfigs") | |||
| @ApiOperation("前6个代码配置") | |||
| public GenericsAjaxResult<Page<CodeConfig>> getPublicCodeConfigs() { | |||
| PageRequest pageRequest = PageRequest.of(0, 6); | |||
| CodeConfig codeConfig = new CodeConfig(); | |||
| return genericsSuccess(this.codeConfigService.queryByPage(codeConfig, pageRequest)); | |||
| } | |||
| @GetMapping("/getPublicServices") | |||
| @ApiOperation("前6个服务") | |||
| public GenericsAjaxResult<Page<Service>> getPublicServices() throws Exception { | |||
| PageRequest pageRequest = PageRequest.of(0, 6); | |||
| Service service = new Service(); | |||
| return genericsSuccess(serviceService.queryByPageService(service, pageRequest)); | |||
| } | |||
| @GetMapping("/getPublicImages") | |||
| @ApiOperation("前6个镜像") | |||
| public GenericsAjaxResult<Page<Image>> getPublicImages() { | |||
| PageRequest pageRequest = PageRequest.of(0, 6); | |||
| Image image = new Image(); | |||
| image.setImageType(Constant.Image_Type_Pub); | |||
| return genericsSuccess(this.imageService.queryByPage(image, pageRequest)); | |||
| } | |||
| } | |||
| @@ -32,7 +32,7 @@ public interface WorkflowService { | |||
| * @param pageRequest 分页对象 | |||
| * @return 查询结果 | |||
| */ | |||
| Page<Workflow> queryByPage(Workflow workflow, PageRequest pageRequest); | |||
| Page<WorkflowVo> queryByPage(Workflow workflow, PageRequest pageRequest) throws IOException; | |||
| /** | |||
| * 新增数据 | |||
| @@ -7,6 +7,7 @@ import com.ruoyi.platform.domain.Component; | |||
| import com.ruoyi.platform.service.ComponentService; | |||
| import com.ruoyi.platform.mapper.ComponentDao; | |||
| import com.ruoyi.platform.utils.ConvertUtil; | |||
| import com.ruoyi.platform.utils.JacksonUtil; | |||
| import com.ruoyi.platform.utils.JsonUtils; | |||
| import com.ruoyi.platform.vo.ComponentVo; | |||
| import com.ruoyi.system.api.constant.Constant; | |||
| @@ -151,6 +152,19 @@ public class ComponentServiceImpl implements ComponentService { | |||
| component.setEnvVirables(envVariable); | |||
| component.setInParameters(inParameters); | |||
| component.setOutParameters(outParameters); | |||
| Map<String, Object> taskInfo = componentVo.getTaskInfo(); | |||
| Map<String, Object> image = (Map<String, Object>) taskInfo.get("image"); | |||
| Map<String, Object> workingDirectory = (Map<String, Object>) taskInfo.get("working_directory"); | |||
| Map<String, Object> command = (Map<String, Object>) taskInfo.get("command"); | |||
| Map<String, Object> runArgs = (Map<String, Object>) taskInfo.get("run_args"); | |||
| Map<String, Object> resourcesStandard = (Map<String, Object>) taskInfo.get("resources_standard"); | |||
| component.setImage(JacksonUtil.toJSONString(image)); | |||
| component.setWorkingDirectory(JacksonUtil.toJSONString(workingDirectory)); | |||
| component.setCommand(JacksonUtil.toJSONString(command)); | |||
| component.setRunArgs(JacksonUtil.toJSONString(runArgs)); | |||
| component.setResourcesStandard(JacksonUtil.toJSONString(resourcesStandard)); | |||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | |||
| component.setCreateBy(loginUser.getUsername()); | |||
| component.setUpdateBy(loginUser.getUsername()); | |||
| @@ -195,6 +209,19 @@ public class ComponentServiceImpl implements ComponentService { | |||
| component.setEnvVirables(envVariable); | |||
| component.setInParameters(inParameters); | |||
| component.setOutParameters(outParameters); | |||
| Map<String, Object> taskInfo = componentVo.getTaskInfo(); | |||
| Map<String, Object> image = (Map<String, Object>) taskInfo.get("image"); | |||
| Map<String, Object> workingDirectory = (Map<String, Object>) taskInfo.get("working_directory"); | |||
| Map<String, Object> command = (Map<String, Object>) taskInfo.get("command"); | |||
| Map<String, Object> runArgs = (Map<String, Object>) taskInfo.get("run_args"); | |||
| Map<String, Object> resourcesStandard = (Map<String, Object>) taskInfo.get("resources_standard"); | |||
| component.setImage(JacksonUtil.toJSONString(image)); | |||
| component.setWorkingDirectory(JacksonUtil.toJSONString(workingDirectory)); | |||
| component.setCommand(JacksonUtil.toJSONString(command)); | |||
| component.setRunArgs(JacksonUtil.toJSONString(runArgs)); | |||
| component.setResourcesStandard(JacksonUtil.toJSONString(resourcesStandard)); | |||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | |||
| component.setUpdateBy(loginUser.getUsername()); | |||
| component.setUpdateTime(new Date()); | |||
| @@ -96,9 +96,20 @@ public class WorkflowServiceImpl implements WorkflowService { | |||
| * @return 查询结果 | |||
| */ | |||
| @Override | |||
| public Page<Workflow> queryByPage(Workflow workflow, PageRequest pageRequest) { | |||
| public Page<WorkflowVo> queryByPage(Workflow workflow, PageRequest pageRequest) throws IOException { | |||
| long total = this.workflowDao.count(workflow); | |||
| return new PageImpl<>(this.workflowDao.queryAllByLimit(workflow, pageRequest), pageRequest, total); | |||
| List<Workflow> workflows = this.workflowDao.queryAllByLimit(workflow, pageRequest); | |||
| List<WorkflowVo> WorkflowVos = new ArrayList<>(); | |||
| for (Workflow workflow1 : workflows) { | |||
| WorkflowVo workflowVo = new WorkflowVo(); | |||
| BeanUtils.copyProperties(workflow1, workflowVo); | |||
| workflowVo.setGlobalParam(JacksonUtil.parseJSONStr2MapList(workflow1.getGlobalParam())); | |||
| if (StringUtils.isNotEmpty(workflow.getDag())) { | |||
| workflowVo.setDag(JsonUtils.jsonToMap(workflow.getDag())); | |||
| } | |||
| WorkflowVos.add(workflowVo); | |||
| } | |||
| return new PageImpl<>(WorkflowVos, pageRequest, total); | |||
| } | |||
| /** | |||