commit e2743c1873c1c1724bd0e0d1eee9b35694a8edc5
Author: 之江实验室
Date: Fri Jul 31 17:23:02 2020 +0800
init
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..ef4ea8b
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,211 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+Other dependencies and licenses:
+----------------------------------------------------------------------------------------
+
+Open Source Software Licensed Under the Apache License, Version 2.0:
+The below software in this distribution may have been modified.
+----------------------------------------------------------------------------------------
+1. EL-ADMIN
+Copyright 2019-2020 Zheng Jie
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..c755c4d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,103 @@
+
+
+## 技术架构
+![技术架构](./docs/images/tech-arc.jpg "技术架构")
+
+## 技术栈
+- 后端: [Spring Boot](https://spring.io/projects/spring-boot)
+- 前端: [Vue.js](https://vuejs.org/), [Element](https://element.eleme.cn/)
+- 数据处理 [Yolo](https://pjreddie.com/darknet/yolo/) ...
+- 可视化: [Django](https://www.djangoproject.com/) ...
+- 中间件: [MySQL](https://www.mysql.com/), [MyBatis-Plus](https://mp.baomidou.com/), [Redis](https://redis.io/)
+- 基础设施: [Docker](https://www.docker.com/), [Kubernetes](https://kubernetes.io/)
+
+## 目录结构
+
+```
+├── dubhe_data_process 数据处理服务
+├── dubhe-server 后端服务
+├── dubhe-visual-server 可视化服务
+├── webapp 前端服务
+```
+
+## 反馈问题
+
+- [在线社区](http://www.aiiaos.cn/index.php?s=/forum/index/forum/id/45.html)
+- 钉钉交流群
+
+
+
+
+## 许可证书
+本项目的发布受[Apache 2.0 license](./LICENSE)许可认证。
diff --git a/docs/images/dingtalk.jpg b/docs/images/dingtalk.jpg
new file mode 100644
index 0000000..d047e63
Binary files /dev/null and b/docs/images/dingtalk.jpg differ
diff --git a/docs/images/dubhe_dashboard.png b/docs/images/dubhe_dashboard.png
new file mode 100644
index 0000000..f417819
Binary files /dev/null and b/docs/images/dubhe_dashboard.png differ
diff --git a/docs/images/logo.svg b/docs/images/logo.svg
new file mode 100644
index 0000000..317b636
--- /dev/null
+++ b/docs/images/logo.svg
@@ -0,0 +1,22 @@
+
+
\ No newline at end of file
diff --git a/docs/images/tech-arc.jpg b/docs/images/tech-arc.jpg
new file mode 100644
index 0000000..150291c
Binary files /dev/null and b/docs/images/tech-arc.jpg differ
diff --git a/dubhe-server/.gitignore b/dubhe-server/.gitignore
new file mode 100644
index 0000000..ab86f52
--- /dev/null
+++ b/dubhe-server/.gitignore
@@ -0,0 +1,53 @@
+/target/
+.mvn*
+mvnw
+mvnw.cmd
+kubeconfig
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/build/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+
+# system ignore
+.DS_Store
+Thumbs.db
+*.orig
+
+# maven ignore
+target/
+output/
+*.jar
+!.mvn/wrapper/*
+*.war
+*.zip
+*.tar
+#*.tar.gz
+
+# eclipse ignore
+.settings/
+.project
+.classpath
+logs/
+/dubhe-k8s/src/main/resources/kubeconfig
+/dubhe-k8s/src/main/resources
+*.log
+/dubhe-admin/kubeconfig
\ No newline at end of file
diff --git a/dubhe-server/.gitmessage b/dubhe-server/.gitmessage
new file mode 100644
index 0000000..f893509
--- /dev/null
+++ b/dubhe-server/.gitmessage
@@ -0,0 +1,10 @@
+
+# type: subject
+# type:feat增加新功能;fix修复错误;docs修改文档;style修改样式;refactor代码重构;test增加测试模块,不涉及生产环境的代码;chore更新核心模块,包配置文件,不涉及生产环境的代码
+# subject: 一两句话简述提交原因,与下方详细描述间隔一行
+
+
+# body:提交详细原因,与下方脚注间隔一行
+
+
+# footer(可选):1.提供链接关联issue、2.关闭issue
diff --git a/dubhe-server/README.md b/dubhe-server/README.md
new file mode 100644
index 0000000..609205f
--- /dev/null
+++ b/dubhe-server/README.md
@@ -0,0 +1,98 @@
+# 之江天枢-服务端
+
+**之江天枢一站式人工智能开源平台**(简称:**之江天枢**),包括海量数据处理、交互式模型构建(包含Notebook和模型可视化)、AI模型高效训练。多维度产品形态满足从开发者到大型企业的不同需求,将提升人工智能技术的研发效率、扩大算法模型的应用范围,进一步构建人工智能生态“朋友圈”。
+
+## 源码部署
+
+### 准备环境
+安装如下软件环境。
+- OpenJDK:1.8+
+- Redis: 3.0+
+- Maven: 3.0+
+- MYSQL: 5.5.0+
+
+### 下载源码
+``` bash
+git clone https://codeup.teambition.com/zhejianglab/dubhe-server.git
+# 进入项目根目录
+cd dubhe-server
+```
+
+### 创建DB
+在MySQL中依次执行如下sql文件
+```
+sql/v1/00-Dubhe-DB.sql
+sql/v1/01-Dubhe-DDL.sql
+sql/v1/02-Dubhe-DML.sql
+```
+
+### 配置
+根据实际情况修改如下配置文件。
+```
+dubhe-admin/src/main/resources/config/application-prod.yml
+```
+
+### 构建
+``` bash
+# 构建,生成的 jar 包位于 ./dubhe-admin/target/dubhe-admin-1.0.jar
+mvn clean compile package
+```
+
+### 启动
+``` bash
+# 指定启动环境为 prod
+java -jar ./dubhe-admin/target/dubhe-admin-1.0.jar --spring.profiles.active=prod
+```
+
+## 本地开发
+
+### 必要条件:
+ 导入maven项目,下载所需的依赖包
+ mysql下创建数据库dubhe,初始化数据脚本
+ 安装redis
+
+### 启动:
+ mvn spring-boot:run
+
+## 代码结构:
+```
+├── common 公共模块
+├── dubhe-admin 开发与训练模块
+│ ├── src
+│ │ └── main
+│ │ ├── java
+│ │ │ └── org
+│ │ │ └── dubhe
+│ │ │ ├── AppRun.java
+│ │ │ ├── domain 实体对象
+│ │ │ ├── repository 数据库层
+│ │ │ ├── rest 控制层
+│ │ │ └── service 服务层
+│ │ │ ├── dto 数据传输对象
+│ │ │ ├── impl 服务实现
+│ │ │ └── mapper 对象转化
+│ │ └── resources 配置文件
+├── dubhe-data 数据处理模块
+├── dubhe-model 模型管理模块
+├── dubhe-system 系统管理
+```
+
+## docker服务器
+ 上传镜像功能依赖docker服务,harbor与dokcer的信任配置如下:
+### 1、对外开放端口
+ vi /lib/systemd/system/docker.service
+ ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
+### 2、信任harbor地址
+ vi /etc/docker/daemon.json
+ {
+ "exec-opts": ["native.cgroupdriver=systemd"],
+ "log-driver": "json-file",
+ "insecure-registries":[harbor地址],
+ "log-opts": {
+ "max-size": "100m"
+ }
+ }
+### 3、重新启动
+ systemctl daemon-reload
+ service docker restart
+ systemctl status docker
diff --git a/dubhe-server/common/pom.xml b/dubhe-server/common/pom.xml
new file mode 100644
index 0000000..21b9ea8
--- /dev/null
+++ b/dubhe-server/common/pom.xml
@@ -0,0 +1,121 @@
+
+
+
+ dubheplatform
+ zhejianglab
+ 1.0
+
+ 4.0.0
+
+ 5.0.6
+ 7.0.2
+ 1.8.9
+
+
+ common
+ 公共模块
+
+
+
+
+ cn.hutool
+ hutool-all
+ ${hutool.version}
+
+
+ com.google.guava
+ guava
+ 21.0
+
+
+ com.github.penggle
+ kaptcha
+ ${kaptcha.version}
+
+
+
+ org.apache.shiro
+ shiro-spring
+ ${shiro.version}
+
+
+ com.auth0
+ java-jwt
+ ${jwt.version}
+
+
+ *
+ *
+
+
+
+
+ io.minio
+ minio
+ ${minio.version}
+
+
+
+
+ org.aspectj
+ aspectjweaver
+ ${aspectjweaver.version}
+
+
+
+ javax.xml.bind
+ jaxb-api
+ 2.3.0
+
+
+ com.sun.xml.bind
+ jaxb-impl
+ 2.3.0
+
+
+ com.sun.xml.bind
+ jaxb-core
+ 2.3.0
+
+
+ commons-io
+ commons-io
+ 1.3.2
+ compile
+
+
+ net.lingala.zip4j
+ zip4j
+ 1.3.2
+
+
+ org.apache.commons
+ commons-compress
+ 1.20
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ true
+
+
+
+
+
+ true
+ src/main/resources
+
+
+
+
diff --git a/dubhe-server/common/src/main/java/org/dubhe/annotation/ApiVersion.java b/dubhe-server/common/src/main/java/org/dubhe/annotation/ApiVersion.java
new file mode 100644
index 0000000..6cc1bb5
--- /dev/null
+++ b/dubhe-server/common/src/main/java/org/dubhe/annotation/ApiVersion.java
@@ -0,0 +1,32 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * @description API版本控制注解
+ * @date 2020-04-06
+ */
+@Target({ElementType.METHOD, ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface ApiVersion {
+ //标识版本号
+ int value() default 1;
+}
diff --git a/dubhe-server/common/src/main/java/org/dubhe/annotation/DataPermission.java b/dubhe-server/common/src/main/java/org/dubhe/annotation/DataPermission.java
new file mode 100644
index 0000000..96361bb
--- /dev/null
+++ b/dubhe-server/common/src/main/java/org/dubhe/annotation/DataPermission.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * 数据权限过滤Mapper拦截
+ *
+ * @date 2020-06-22
+ */
+@Target({ElementType.METHOD, ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface DataPermission {
+
+ /**
+ * 不需要数据权限的方法名
+ */
+ String[] ignores() default {};
+
+ /**
+ * 只在方法的注解上使用,代表方法的数据权限类型,如果不加注解,只会识别带"select"方法名的方法
+ *
+ * @return
+ */
+ String[] permission() default {};
+
+}
diff --git a/dubhe-server/common/src/main/java/org/dubhe/annotation/EnumValue.java b/dubhe-server/common/src/main/java/org/dubhe/annotation/EnumValue.java
new file mode 100644
index 0000000..1fb7c93
--- /dev/null
+++ b/dubhe-server/common/src/main/java/org/dubhe/annotation/EnumValue.java
@@ -0,0 +1,87 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import javax.validation.Constraint;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.Payload;
+
+/**
+ * @date: 2020-05-21
+ */
+@Target({ ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE })
+@Retention(RetentionPolicy.RUNTIME)
+@Constraint(validatedBy = EnumValue.Validator.class)
+public @interface EnumValue {
+
+ String message() default "custom.value.invalid";
+
+ Class>[] groups() default {};
+
+ Class extends Payload>[] payload() default {};
+
+ Class extends Enum>> enumClass();
+
+ String enumMethod();
+
+ class Validator implements ConstraintValidator {
+
+ private Class extends Enum>> enumClass;
+ private String enumMethod;
+
+ @Override
+ public void initialize(EnumValue enumValue) {
+ enumMethod = enumValue.enumMethod();
+ enumClass = enumValue.enumClass();
+ }
+
+ @Override
+ public boolean isValid(Object value, ConstraintValidatorContext constraintValidatorContext) {
+ if (value == null) {
+ return Boolean.TRUE;
+ }
+
+ if (enumClass == null || enumMethod == null) {
+ return Boolean.TRUE;
+ }
+ Class> valueClass = value.getClass();
+
+ try {
+ Method method = enumClass.getMethod(enumMethod, valueClass);
+ if (!Boolean.TYPE.equals(method.getReturnType()) && !Boolean.class.equals(method.getReturnType())) {
+ throw new RuntimeException(String.format("%s method return is not boolean type in the %s class", enumMethod, enumClass));
+ }
+
+ Boolean result = (Boolean)method.invoke(null, value);
+ return result == null ? false : result;
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ throw new RuntimeException(e);
+ } catch (NoSuchMethodException | SecurityException e) {
+ throw new RuntimeException(String.format("This %s(%s) method does not exist in the %s", enumMethod, valueClass, enumClass), e);
+ }
+ }
+
+ }
+}
diff --git a/dubhe-server/common/src/main/java/org/dubhe/annotation/Log.java b/dubhe-server/common/src/main/java/org/dubhe/annotation/Log.java
new file mode 100644
index 0000000..15714ae
--- /dev/null
+++ b/dubhe-server/common/src/main/java/org/dubhe/annotation/Log.java
@@ -0,0 +1,23 @@
+ /**
+ * Copyright 2019-2020 Zheng Jie
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.dubhe.annotation;
+
+/**
+ * @description 日志
+ * @date 2020-03-15
+ */
+public @interface Log {
+}
diff --git a/dubhe-server/common/src/main/java/org/dubhe/annotation/Query.java b/dubhe-server/common/src/main/java/org/dubhe/annotation/Query.java
new file mode 100644
index 0000000..40e1b77
--- /dev/null
+++ b/dubhe-server/common/src/main/java/org/dubhe/annotation/Query.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright 2019-2020 Zheng Jie
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.dubhe.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @description 构建Wrapper的注解
+ * @date 2020-03-26
+ */
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Query {
+
+
+ String propName() default "";
+
+ Type type() default Type.EQ;
+
+
+ String blurry() default "";
+
+ enum Type {
+ // 相等
+ EQ
+ // 不等于
+ , NE
+ // 大于
+ , GT
+ // 大于等于
+ , GE
+ // 小于
+ , LT
+ // 小于等于
+ , LE,
+ BETWEEN,
+ NOT_BETWEEN,
+ LIKE,
+ NOT_LIKE,
+ LIkE_LEFT,
+ LIKE_RIGHT,
+ IS_NULL,
+ IS_NOT_NULL,
+ IN,
+ NOT_IN,
+ INSQL,
+ NOT_INSQL,
+ ORDER_BY
+ }
+
+}
+
diff --git a/dubhe-server/common/src/main/java/org/dubhe/annotation/RateLimit.java b/dubhe-server/common/src/main/java/org/dubhe/annotation/RateLimit.java
new file mode 100644
index 0000000..f7bc427
--- /dev/null
+++ b/dubhe-server/common/src/main/java/org/dubhe/annotation/RateLimit.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @description 限流
+ * @date 2020-03-15
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface RateLimit {
+ double limitNum() default 20;
+}
diff --git a/dubhe-server/common/src/main/java/org/dubhe/aspect/LogAspect.java b/dubhe-server/common/src/main/java/org/dubhe/aspect/LogAspect.java
new file mode 100644
index 0000000..ce7485f
--- /dev/null
+++ b/dubhe-server/common/src/main/java/org/dubhe/aspect/LogAspect.java
@@ -0,0 +1,87 @@
+/**
+ * Copyright 2019-2020 Zheng Jie
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.dubhe.aspect;
+
+import java.util.UUID;
+
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.dubhe.enums.LogEnum;
+import org.dubhe.utils.LogUtil;
+import org.slf4j.MDC;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
+
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * @date 2020/04/10
+ */
+@Component
+@Aspect
+@Slf4j
+public class LogAspect {
+
+ public static final String TRACE_ID = "traceId";
+
+ @Pointcut("execution(* org.dubhe..service..*.*(..))) "
+ + "and execution(* org.dubhe..schedule..*.*(..))) "
+ + "and execution(* org.dubhe..util*..*.*(..)))")
+ public void serviceAspect() {
+ }
+
+ @Pointcut("execution(* org.dubhe..rest..*.*(..))) ")
+ public void restAspect() {
+ }
+
+ @Pointcut(" execution(* org.dubhe..task..*.*(..))) ")
+ public void taskAspect() {
+ }
+
+ @Pointcut(" serviceAspect() || taskAspect() ")
+ public void aroundAspect() {
+ }
+
+ @Around("aroundAspect()")
+ public Object around(JoinPoint joinPoint) throws Throwable {
+ if (StringUtils.isEmpty(MDC.get(TRACE_ID))) {
+ MDC.put(TRACE_ID, UUID.randomUUID().toString());
+ }
+ return combineLogInfo(joinPoint);
+ }
+
+ @Around("restAspect()")
+ public Object aroundRest(JoinPoint joinPoint) throws Throwable {
+ MDC.clear();
+ MDC.put(TRACE_ID, UUID.randomUUID().toString());
+ return combineLogInfo(joinPoint);
+ }
+
+ private Object combineLogInfo(JoinPoint joinPoint) throws Throwable {
+ Object[] param = joinPoint.getArgs();
+ LogUtil.info(LogEnum.REST_REQ, "uri:{},input:{},==>begin", joinPoint.getSignature(), param);
+ long start = System.currentTimeMillis();
+ Object result = ((ProceedingJoinPoint) joinPoint).proceed();
+ long end = System.currentTimeMillis();
+ LogUtil.info(LogEnum.REST_REQ, "uri:{},output:{},proc_time:{},<==end", joinPoint.getSignature().toString(),
+ result, end - start);
+ return result;
+ }
+
+}
diff --git a/dubhe-server/common/src/main/java/org/dubhe/base/BaseConvert.java b/dubhe-server/common/src/main/java/org/dubhe/base/BaseConvert.java
new file mode 100644
index 0000000..4b75c40
--- /dev/null
+++ b/dubhe-server/common/src/main/java/org/dubhe/base/BaseConvert.java
@@ -0,0 +1,58 @@
+/**
+ * Copyright 2019-2020 Zheng Jie
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.dubhe.base;
+
+import java.util.List;
+
+/**
+ * @description DTO Entity 转换
+ * @date 2020-03-15
+ */
+public interface BaseConvert {
+
+ /**
+ * DTO转Entity
+ *
+ * @param dto /
+ * @return /
+ */
+ E toEntity(D dto);
+
+ /**
+ * Entity转DTO
+ *
+ * @param entity /
+ * @return /
+ */
+ D toDto(E entity);
+
+ /**
+ * DTO集合转Entity集合
+ *
+ * @param dtoList /
+ * @return /
+ */
+ List toEntity(List dtoList);
+
+ /**
+ * Entity集合转DTO集合
+ *
+ * @param entityList /
+ * @return /
+ */
+ List toDto(List entityList);
+
+}
diff --git a/dubhe-server/common/src/main/java/org/dubhe/base/BaseDTO.java b/dubhe-server/common/src/main/java/org/dubhe/base/BaseDTO.java
new file mode 100644
index 0000000..c868f28
--- /dev/null
+++ b/dubhe-server/common/src/main/java/org/dubhe/base/BaseDTO.java
@@ -0,0 +1,48 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.base;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+/**
+ * @description DTO基础类
+ * @date 2020-03-15
+ */
+@Getter
+@Setter
+public class BaseDTO implements Serializable {
+
+ private Boolean deleted;
+
+ private Timestamp createTime;
+
+ private Timestamp updateTime;
+
+ @Override
+ public String toString() {
+ return "BaseDTO{" +
+ "deleted=" + deleted +
+ ", createTime=" + createTime +
+ ", updateTime=" + updateTime +
+ '}';
+ }
+}
diff --git a/dubhe-server/common/src/main/java/org/dubhe/base/BaseEntity.java b/dubhe-server/common/src/main/java/org/dubhe/base/BaseEntity.java
new file mode 100644
index 0000000..95d527c
--- /dev/null
+++ b/dubhe-server/common/src/main/java/org/dubhe/base/BaseEntity.java
@@ -0,0 +1,76 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.base;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import lombok.Data;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.sql.Timestamp;
+
+/**
+ * @description Entity基础类
+ * @date 2020-03-15
+ */
+@Data
+public class BaseEntity implements Serializable {
+
+ private static final long serialVersionUID = 4936056317364745513L;
+
+ /**
+ * 删除标识
+ **/
+ @TableField(value = "deleted",fill = FieldFill.INSERT)
+ @TableLogic
+ private Boolean deleted = false;
+
+ @TableField(value = "create_user_id",fill = FieldFill.INSERT)
+ private Long createUserId;
+
+ @TableField(value = "update_user_id",fill = FieldFill.INSERT_UPDATE)
+ private Long updateUserId;
+
+ @TableField(value = "create_time",fill = FieldFill.INSERT)
+ private Timestamp createTime;
+
+
+ @TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE)
+ private Timestamp updateTime;
+
+ @Override
+ public String toString() {
+ ToStringBuilder builder = new ToStringBuilder(this);
+ Field[] fields = this.getClass().getDeclaredFields();
+ try {
+ for (Field f : fields) {
+ f.setAccessible(true);
+ builder.append(f.getName(), f.get(this)).append("\n");
+ }
+ } catch (Exception e) {
+ builder.append("toString builder encounter an error");
+ }
+ return builder.toString();
+ }
+
+ public @interface Update {
+ }
+}
diff --git a/dubhe-server/common/src/main/java/org/dubhe/base/BaseImageDTO.java b/dubhe-server/common/src/main/java/org/dubhe/base/BaseImageDTO.java
new file mode 100644
index 0000000..950e453
--- /dev/null
+++ b/dubhe-server/common/src/main/java/org/dubhe/base/BaseImageDTO.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+package org.dubhe.base;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotBlank;
+import java.io.Serializable;
+
+/**
+ * @description 镜像基础类DTO
+ * @date: 2020-07-14
+ */
+@Data
+@Accessors(chain = true)
+public class BaseImageDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "镜像版本", required = true)
+ @NotBlank(message = "镜像版本不能为空")
+ private String imageTag;
+
+ @ApiModelProperty(value = "镜像名称", required = true)
+ @NotBlank(message = "镜像名称不能为空")
+ private String imageName;
+
+}
\ No newline at end of file
diff --git a/dubhe-server/common/src/main/java/org/dubhe/base/BaseVO.java b/dubhe-server/common/src/main/java/org/dubhe/base/BaseVO.java
new file mode 100644
index 0000000..7a6fff0
--- /dev/null
+++ b/dubhe-server/common/src/main/java/org/dubhe/base/BaseVO.java
@@ -0,0 +1,46 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.base;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+/**
+ * @description: VO基础类
+ * @date: 2020-05-22
+ */
+@Data
+public class BaseVO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("创建人")
+ private Long createUserId;
+
+ @ApiModelProperty("创建时间")
+ private Timestamp createTime;
+
+ @ApiModelProperty("修改人")
+ private Long updateUserId;
+
+ @ApiModelProperty("修改时间")
+ private Timestamp updateTime;
+}
diff --git a/dubhe-server/common/src/main/java/org/dubhe/base/DataResponseBody.java b/dubhe-server/common/src/main/java/org/dubhe/base/DataResponseBody.java
new file mode 100644
index 0000000..97ff300
--- /dev/null
+++ b/dubhe-server/common/src/main/java/org/dubhe/base/DataResponseBody.java
@@ -0,0 +1,76 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.base;
+
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.slf4j.MDC;
+
+import java.io.Serializable;
+
+/**
+ * @description 统一的公共响应体
+ * @date 2020-03-16
+ */
+@Data
+@ApiModel(description = "统一的公共响应体")
+public class DataResponseBody implements Serializable {
+
+ /**
+ * 返回状态码
+ */
+ @ApiModelProperty("返回状态码")
+ private Integer code;
+ /**
+ * 返回信息
+ */
+ @ApiModelProperty("返回信息")
+ private String msg;
+ /**
+ * 泛型数据
+ */
+ @ApiModelProperty("泛型数据")
+ private T data;
+ /**
+ * 链路追踪ID
+ */
+ @ApiModelProperty("链路追踪ID")
+ private String traceId;
+
+ public DataResponseBody() {
+ this(ResponseCode.SUCCESS, null);
+ }
+
+ public DataResponseBody(T data) {
+ this(ResponseCode.SUCCESS, null, data);
+ }
+
+ public DataResponseBody(Integer code, String msg) {
+ this(code, msg, null);
+ }
+
+ public DataResponseBody(Integer code, String msg, T data) {
+ this.code = code;
+ this.msg = msg;
+ this.data = data;
+ this.traceId = MDC.get("traceId");
+ }
+
+}
diff --git a/dubhe-server/common/src/main/java/org/dubhe/base/MagicNumConstant.java b/dubhe-server/common/src/main/java/org/dubhe/base/MagicNumConstant.java
new file mode 100644
index 0000000..a4376e7
--- /dev/null
+++ b/dubhe-server/common/src/main/java/org/dubhe/base/MagicNumConstant.java
@@ -0,0 +1,99 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.base;
+
+/**
+ * @date: 2020-05-14
+ */
+public final class MagicNumConstant {
+
+ public static final int NEGATIVE_ONE = -1;
+ public static final int ZERO = 0;
+ public static final int ONE = 1;
+ public static final int TWO = 2;
+ public static final int THREE = 3;
+ public static final int FOUR = 4;
+ public static final int FIVE = 5;
+ public static final int SIX = 6;
+ public static final int SEVEN = 7;
+ public static final int EIGHT = 8;
+ public static final int NINE = 9;
+ public static final int TEN = 10;
+
+ public static final int ELEVEN = 11;
+ public static final int SIXTEEN = 16;
+ public static final int TWENTY = 20;
+ public static final int FIFTY = 50;
+ public static final int SIXTY = 60;
+ public static final int SIXTY_TWO = 62;
+ public static final int SIXTY_FOUR = 64;
+ public static final int INTEGER_TWO_HUNDRED_AND_FIFTY_FIVE = 255;
+ public static final int ONE_HUNDRED = 100;
+ public static final int ONE_HUNDRED_TWENTY_EIGHT = 128;
+ public static final int TWO_HUNDRED = 200;
+ public static final int FIVE_HUNDRED = 500;
+ public static final int FIVE_HUNDRED_AND_SIXTEEN = 516;
+ public static final int ONE_THOUSAND = 1000;
+ public static final int BINARY_TEN_EXP = 1024;
+ public static final int ONE_THOUSAND_ONE_HUNDRED = 1100;
+ public static final int ONE_THOUSAND_ONE_HUNDRED_ONE = 1101;
+ public static final int ONE_THOUSAND_TWO_HUNDRED = 1200;
+ public static final int ONE_THOUSAND_TWO_HUNDRED_ONE = 1201;
+ public static final int ONE_THOUSAND_TWENTY_FOUR = 1024;
+ public static final int ONE_THOUSAND_THREE_HUNDRED = 1300;
+ public static final int ONE_THOUSAND_THREE_HUNDRED_ONE = 1301;
+ public static final int ONE_THOUSAND_THREE_HUNDRED_NINE = 1309;
+ public static final int ONE_THOUSAND_FIVE_HUNDRED = 1500;
+ public static final int TWO_THOUSAND = 2000;
+ public static final int TWO_THOUSAND_TWENTY_EIGHT = 2048;
+ public static final int THREE_THOUSAND = 3000;
+ public static final int FOUR_THOUSAND = 4000;
+ public static final int NINE_THOUSAND = 9000;
+ public static final int NINE_THOUSAND_NINE_HUNDRED_NINTY_NINE = 9999;
+ public static final int TEN_THOUSAND = 10000;
+ public static final int FIFTEEN_THOUSAND = 15000;
+ public static final int HUNDRED_THOUSAND = 100000;
+ public static final int MILLION = 1000000;
+ public static final int ONE_MINUTE = 60000;
+
+ public static final long NEGATIVE_ONE__LONG = -1L;
+ public static final long ZERO_LONG = 0L;
+ public static final long ONE_LONG = 1L;
+ public static final long TWO_LONG = 2L;
+ public static final long THREE_LONG = 3L;
+ public static final long FOUR_LONG = 4L;
+ public static final long FIVE_LONG = 5L;
+ public static final long SIX_LONG = 6L;
+ public static final long SEVEN_LONG = 7L;
+ public static final long EIGHT_LONG = 8L;
+ public static final long NINE_LONG = 9L;
+ public static final long TEN_LONG = 10L;
+
+ public static final long TWELVE_LONG = 12L;
+ public static final long SIXTY_LONG = 60L;
+ public static final long TEN_THOUSAND_LONG = 10000L;
+ public static final long ONE_ZERO_ONE_ZERO_ONE_ZERO_LONG = 101010L;
+ public static final long NINE_ZERO_NINE_ZERO_NINE_ZERO_LONG = 909090L;
+ public static final long ONE_YEAR_BEFORE_LONG = 1552579200000L;
+
+ public static final int SIXITY_0XFF = 0xFF;
+
+
+ private MagicNumConstant() {
+ }
+}
diff --git a/dubhe-server/common/src/main/java/org/dubhe/base/PageQueryBase.java b/dubhe-server/common/src/main/java/org/dubhe/base/PageQueryBase.java
new file mode 100644
index 0000000..e39aaa2
--- /dev/null
+++ b/dubhe-server/common/src/main/java/org/dubhe/base/PageQueryBase.java
@@ -0,0 +1,62 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.base;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.dubhe.constant.NumberConstant;
+
+import javax.validation.constraints.Min;
+
+/**
+ * @description: 分页基类
+ * @date: 2020-05-8
+ */
+@Data
+@Accessors(chain = true)
+public class PageQueryBase {
+
+ @ApiModelProperty(value = "分页-当前页数")
+ @Min(value = 1, message = "current不能小于1")
+ private Integer current;
+
+ @ApiModelProperty(value = "分页-每页展示数")
+ @Min(value = 1, message = "size不能小于1")
+ private Integer size;
+
+
+ @ApiModelProperty(value = "排序字段")
+ private String sort;
+
+ @ApiModelProperty(value = "排序方式,asc | desc")
+ private String order;
+
+ public Page toPage() {
+ Page page = new Page();
+ if (this.current != null) {
+ page.setCurrent(this.current);
+ }
+ if (this.size != null && this.size < NumberConstant.MAX_PAGE_SIZE) {
+ page.setSize(this.size);
+ }
+ return page;
+ }
+
+}
diff --git a/dubhe-server/common/src/main/java/org/dubhe/base/ResponseCode.java b/dubhe-server/common/src/main/java/org/dubhe/base/ResponseCode.java
new file mode 100644
index 0000000..5ee446f
--- /dev/null
+++ b/dubhe-server/common/src/main/java/org/dubhe/base/ResponseCode.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.base;
+
+/**
+ * @description 返回状态码
+ * @date 2020-02-23
+ */
+public class ResponseCode {
+ public static Integer SUCCESS = 200;
+ public static Integer UNAUTHORIZED = 401;
+ public static Integer ERROR = 10000;
+ public static Integer ENTITY_NOT_EXIST = 10001;
+ public static Integer BADREQUEST = 10002;
+ public static Integer SERVICE_ERROR = 10003;
+ public static Integer DOCKER_ERROR = 10004;
+
+}
diff --git a/dubhe-server/common/src/main/java/org/dubhe/config/GlobalCorsConfig.java b/dubhe-server/common/src/main/java/org/dubhe/config/GlobalCorsConfig.java
new file mode 100644
index 0000000..45a57c8
--- /dev/null
+++ b/dubhe-server/common/src/main/java/org/dubhe/config/GlobalCorsConfig.java
@@ -0,0 +1,56 @@
+/**
+ * Copyright 2019-2020 Zheng Jie
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.dubhe.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+import org.springframework.web.filter.CorsFilter;
+
+/**
+ * @description 允许跨域
+ * @date 2020-02-23
+ */
+@Configuration
+public class GlobalCorsConfig {
+
+ @Bean
+ public CorsFilter corsFilter() {
+ //1.添加CORS配置信息
+ CorsConfiguration config = new CorsConfiguration();
+ //放行哪些原始域
+ config.addAllowedOrigin("*");
+ //是否发送Cookie信息
+ config.setAllowCredentials(true);
+ //放行哪些原始域(请求方式)
+ config.addAllowedMethod("OPTIONS");
+ config.addAllowedMethod("HEAD");
+ config.addAllowedMethod("GET");
+ config.addAllowedMethod("PUT");
+ config.addAllowedMethod("POST");
+ config.addAllowedMethod("DELETE");
+ config.addAllowedMethod("PATCH");
+ config.addAllowedHeader("*");
+
+ //2.添加映射路径
+ UrlBasedCorsConfigurationSource configSource = new UrlBasedCorsConfigurationSource();
+ configSource.registerCorsConfiguration("/**", config);
+
+ //3.返回新的CorsFilter.
+ return new CorsFilter(configSource);
+ }
+}
diff --git a/dubhe-server/common/src/main/java/org/dubhe/config/K8sNameConfig.java b/dubhe-server/common/src/main/java/org/dubhe/config/K8sNameConfig.java
new file mode 100644
index 0000000..9c03757
--- /dev/null
+++ b/dubhe-server/common/src/main/java/org/dubhe/config/K8sNameConfig.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.config;
+
+import lombok.Getter;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @description k8s命名相关配置
+ *
+ * @date 2020-05-13
+ */
+@Getter
+@Configuration
+public class K8sNameConfig {
+
+ @Value("${k8s.nfs-root-path}")
+ private String nfsRootPath;
+
+ @Value("${k8s.namespace}")
+ private String namespace;
+
+ @Value("${minio.bucketName}")
+ private String fileBucket;
+
+ @Value("${train-job.docker-dataset-path}")
+ private String datasetPath;
+}
diff --git a/dubhe-server/common/src/main/java/org/dubhe/config/KaptchaConfig.java b/dubhe-server/common/src/main/java/org/dubhe/config/KaptchaConfig.java
new file mode 100644
index 0000000..86bf416
--- /dev/null
+++ b/dubhe-server/common/src/main/java/org/dubhe/config/KaptchaConfig.java
@@ -0,0 +1,65 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.config;
+
+import com.google.code.kaptcha.impl.DefaultKaptcha;
+import com.google.code.kaptcha.util.Config;
+import org.springframework.context.annotation.Bean;
+import org.springframework.stereotype.Component;
+
+import java.util.Properties;
+
+/**
+ * @description 验证码配置
+ * @date 2020-02-23
+ */
+@Component
+public class KaptchaConfig {
+ private final static String CODE_LENGTH = "4";
+ private final static String SESSION_KEY = "verification_session_key";
+
+ @Bean
+ public DefaultKaptcha defaultKaptcha() {
+ DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
+ Properties properties = new Properties();
+
+ // 设置边框
+ properties.setProperty("kaptcha.border", "yes");
+ // 设置边框颜色
+ properties.setProperty("kaptcha.border.color", "105,179,90");
+ // 设置字体颜色
+ properties.setProperty("kaptcha.textproducer.font.color", "blue");
+ // 设置图片宽度
+ properties.setProperty("kaptcha.image.width", "108");
+ // 设置图片高度
+ properties.setProperty("kaptcha.image.height", "28");
+ // 设置字体尺寸
+ properties.setProperty("kaptcha.textproducer.font.size", "26");
+ // 设置session key
+ properties.setProperty("kaptcha.session.key", SESSION_KEY);
+ // 设置验证码长度
+ properties.setProperty("kaptcha.textproducer.char.length", CODE_LENGTH);
+ // 设置字体
+ properties.setProperty("kaptcha.textproducer.font.names", "宋体,楷体,黑体");
+ //去噪点
+ properties.setProperty("kaptcha.noise.impl", "com.google.code.kaptcha.impl.NoNoise");
+ Config config = new Config(properties);
+ defaultKaptcha.setConfig(config);
+ return defaultKaptcha;
+ }
+}
diff --git a/dubhe-server/common/src/main/java/org/dubhe/config/LocalDateTimeSerializerConfig.java b/dubhe-server/common/src/main/java/org/dubhe/config/LocalDateTimeSerializerConfig.java
new file mode 100644
index 0000000..ffb7788
--- /dev/null
+++ b/dubhe-server/common/src/main/java/org/dubhe/config/LocalDateTimeSerializerConfig.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.config;
+
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+
+@Configuration
+public class LocalDateTimeSerializerConfig {
+ @Value("${spring.jackson.date-format}")
+ private String pattern;
+
+ @Bean
+ public LocalDateTimeSerializer localDateTimeDeserializer() {
+ return new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(pattern));
+ }
+
+ @Bean
+ public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
+ return builder -> builder.serializerByType(LocalDateTime.class, localDateTimeDeserializer());
+ }
+
+}
diff --git a/dubhe-server/common/src/main/java/org/dubhe/config/MetaHandlerConfig.java b/dubhe-server/common/src/main/java/org/dubhe/config/MetaHandlerConfig.java
new file mode 100644
index 0000000..b7e9860
--- /dev/null
+++ b/dubhe-server/common/src/main/java/org/dubhe/config/MetaHandlerConfig.java
@@ -0,0 +1,95 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.config;
+
+import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
+import org.apache.ibatis.reflection.MetaObject;
+import org.dubhe.constant.StringConstant;
+import org.dubhe.domain.dto.UserDTO;
+import org.dubhe.enums.SwitchEnum;
+import org.dubhe.utils.DateUtil;
+import org.dubhe.utils.JwtUtils;
+import org.springframework.stereotype.Component;
+
+import java.util.Objects;
+
+/**
+ * @description 处理新增和更新的基础数据填充,配合BaseEntity和MyBatisPlusConfig使用
+ * @date 2020-6-10
+ */
+@Component
+public class MetaHandlerConfig implements MetaObjectHandler {
+
+
+ private final String LOCK_USER_ID = "LOCK_USER_ID";
+
+
+ /**
+ * 新增数据执行
+ *
+ * @param metaObject
+ */
+
+ @Override
+ public void insertFill(MetaObject metaObject) {
+ if (Objects.isNull(getFieldValByName(StringConstant.CREATE_TIME, metaObject))) {
+ this.setFieldValByName(StringConstant.CREATE_TIME, DateUtil.getCurrentTimestamp(), metaObject);
+ }
+ if (Objects.isNull(getFieldValByName(StringConstant.UPDATE_TIME, metaObject))) {
+ this.setFieldValByName(StringConstant.UPDATE_TIME, DateUtil.getCurrentTimestamp(), metaObject);
+ }
+ synchronized (LOCK_USER_ID){
+ if (Objects.isNull(getFieldValByName(StringConstant.UPDATE_USER_ID, metaObject))) {
+ this.setFieldValByName(StringConstant.UPDATE_USER_ID, getUserId(), metaObject);
+ }
+ if (Objects.isNull(getFieldValByName(StringConstant.CREATE_USER_ID, metaObject))) {
+ this.setFieldValByName(StringConstant.CREATE_USER_ID, getUserId(), metaObject);
+ }
+ }
+ if (Objects.isNull(getFieldValByName(StringConstant.DELETED, metaObject))) {
+ this.setFieldValByName(StringConstant.DELETED, SwitchEnum.getBooleanValue(SwitchEnum.OFF.getValue()), metaObject);
+ }
+ }
+
+ /**
+ * 更新数据执行
+ *
+ * @param metaObject
+ */
+ @Override
+ public void updateFill(MetaObject metaObject) {
+ if (Objects.isNull(getFieldValByName(StringConstant.UPDATE_TIME, metaObject))) {
+ this.setFieldValByName(StringConstant.UPDATE_TIME, DateUtil.getCurrentTimestamp(), metaObject);
+ }
+ if (Objects.isNull(getFieldValByName(StringConstant.UPDATE_USER_ID, metaObject))) {
+ this.setFieldValByName(StringConstant.UPDATE_USER_ID, getUserId(), metaObject);
+ }
+
+ }
+
+
+ /**
+ * 获取用户ID
+ *
+ * @return
+ */
+ private Long getUserId() {
+ UserDTO userDTO = JwtUtils.getCurrentUserDto();
+ return Objects.isNull(userDTO) ? null : userDTO.getId();
+ }
+}
diff --git a/dubhe-server/common/src/main/java/org/dubhe/config/MybatisPlusConfig.java b/dubhe-server/common/src/main/java/org/dubhe/config/MybatisPlusConfig.java
new file mode 100644
index 0000000..18deab6
--- /dev/null
+++ b/dubhe-server/common/src/main/java/org/dubhe/config/MybatisPlusConfig.java
@@ -0,0 +1,310 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.config;
+
+import com.baomidou.mybatisplus.core.override.MybatisMapperProxy;
+import com.baomidou.mybatisplus.core.parser.ISqlParser;
+import com.baomidou.mybatisplus.core.parser.SqlParserHelper;
+import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.tenant.TenantHandler;
+import com.baomidou.mybatisplus.extension.plugins.tenant.TenantSqlParser;
+import com.google.common.collect.Sets;
+import net.sf.jsqlparser.expression.Expression;
+import net.sf.jsqlparser.expression.LongValue;
+import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
+import net.sf.jsqlparser.expression.operators.relational.InExpression;
+import net.sf.jsqlparser.schema.Column;
+import org.apache.ibatis.mapping.MappedStatement;
+import org.apache.shiro.UnavailableSecurityManagerException;
+import org.dubhe.annotation.DataPermission;
+import org.dubhe.base.MagicNumConstant;
+import org.dubhe.constant.PermissionConstant;
+import org.dubhe.domain.dto.UserDTO;
+import org.dubhe.domain.entity.Role;
+import org.dubhe.enums.LogEnum;
+import org.dubhe.utils.JwtUtils;
+import org.dubhe.utils.LogUtil;
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.event.ContextRefreshedEvent;
+import org.springframework.core.annotation.AnnotationUtils;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+import org.springframework.util.CollectionUtils;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * @description MybatisPlus配置类
+ * @date 2020-06-24
+ */
+@EnableTransactionManagement
+@Configuration
+public class MybatisPlusConfig implements ApplicationListener, ApplicationContextAware {
+
+ /**
+ * 以此字段作为租户实现数据隔离
+ */
+ private static final String TENANT_ID_COLUMN = "create_user_id";
+ /**
+ * 以0作为公共数据的标识
+ */
+ private static final long PUBLIC_TENANT_ID = MagicNumConstant.ZERO;
+ private static final Set PUBLIC_TENANT_ID_SET = new HashSet() {{
+ add(PUBLIC_TENANT_ID);
+ }};
+ private static final String PACKAGE_SEPARATOR = ".";
+ private static final Set SELECT_PERMISSION = new HashSet() {{
+ add(PermissionConstant.SELECT);
+ }};
+ private static final Set UPDATE_DELETE_PERMISSION = new HashSet() {{
+ add(PermissionConstant.UPDATE);
+ add(PermissionConstant.DELETE);
+ }};
+
+ private static final String SELECT_STR = "select";
+ /**
+ * 优先级高于dataFilters,如果ignore,则不进行sql注入
+ */
+ private Map> dataFilters = new HashMap<>();
+
+ private ApplicationContext applicationContext;
+ public Set tenantId;
+
+ /**
+ * mybatis plus 分页插件
+ * 其中增加了通过多租户实现了数据权限功能
+ *
+ * @return
+ */
+ @Bean
+ public PaginationInterceptor paginationInterceptor() {
+ PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
+ List sqlParserList = new ArrayList<>();
+ TenantSqlParser tenantSqlParser = new TenantSqlParser();
+ tenantSqlParser.setTenantHandler(new TenantHandler() {
+ @Override
+ public Expression getTenantId(boolean where) {
+ Set tenants = tenantId;
+
+ final boolean multipleTenantIds = tenants.size() > MagicNumConstant.ONE;
+ if (multipleTenantIds) {
+ return multipleTenantIdCondition(tenants);
+ } else {
+ return singleTenantIdCondition(tenants);
+ }
+ }
+
+ private Expression singleTenantIdCondition(Set tenants) {
+ return new LongValue((Long) tenants.toArray()[0]);
+ }
+
+ private Expression multipleTenantIdCondition(Set tenants) {
+ final InExpression inExpression = new InExpression();
+ inExpression.setLeftExpression(new Column(getTenantIdColumn()));
+ final ExpressionList itemsList = new ExpressionList();
+ final List inValues = new ArrayList<>(tenants.size());
+ tenants.forEach(i ->
+ inValues.add(new LongValue(i))
+ );
+ itemsList.setExpressions(inValues);
+ inExpression.setRightItemsList(itemsList);
+ return inExpression;
+ }
+
+ @Override
+ public String getTenantIdColumn() {
+ return TENANT_ID_COLUMN;
+ }
+
+ @Override
+ public boolean doTableFilter(String tableName) {
+ return false;
+ }
+ });
+ sqlParserList.add(tenantSqlParser);
+ paginationInterceptor.setSqlParserList(sqlParserList);
+ paginationInterceptor.setSqlParserFilter(metaObject -> {
+ MappedStatement ms = SqlParserHelper.getMappedStatement(metaObject);
+ String method = ms.getId();
+ if (!dataFilters.containsKey(method) || isAdmin()) {
+ return true;
+ }
+ Set permission = dataFilters.get(method);
+ tenantId = getTenantId(permission);
+ return false;
+ });
+ return paginationInterceptor;
+ }
+
+ /**
+ * 判断用户是否是管理员
+ * 如果未登录,无法请求任何接口,所以不会到该层,因此匿名认为是定时任务,给予admin权限。
+ *
+ * @return 判断用户是否是管理员
+ */
+ private boolean isAdmin() {
+ UserDTO user;
+ try {
+ user = JwtUtils.getCurrentUserDto();
+ } catch (UnavailableSecurityManagerException e) {
+ return true;
+ }
+ if (Objects.isNull(user)) {
+ return true;
+ }
+ List roles;
+ if ((roles = user.getRoles()) == null) {
+ return false;
+ }
+ Set permissions = roles.stream().map(Role::getPermission).collect(Collectors.toSet());
+ if (CollectionUtils.isEmpty(permissions)) {
+ return false;
+ }
+ return user.getId() == PermissionConstant.ANONYMOUS_USER || user.getId() == PermissionConstant.ADMIN_USER_ID;
+ }
+
+ /**
+ * 如果是管理员,在前一步isAdmin已过滤;
+ * 如果是匿名用户,在shiro层被过滤;
+ * 因此只会是无角色、权限用户或普通用户
+ *
+ * @return Set 租户ID集合
+ */
+ private Set getTenantId(Set permission) {
+ UserDTO user = JwtUtils.getCurrentUserDto();
+ List roles;
+ if (Objects.isNull(user) || (roles = user.getRoles()) == null) {
+ if (permission.contains(PermissionConstant.SELECT)) {
+ return PUBLIC_TENANT_ID_SET;
+ }
+ return Collections.EMPTY_SET;
+ }
+ Set permissions = roles.stream().map(Role::getPermission).collect(Collectors.toSet());
+ if (CollectionUtils.isEmpty(permissions)) {
+ if (permission.contains(PermissionConstant.SELECT)) {
+ return PUBLIC_TENANT_ID_SET;
+ }
+ return Collections.EMPTY_SET;
+ }
+ if (permission.contains(PermissionConstant.SELECT)) {
+ return new HashSet() {{
+ add(PUBLIC_TENANT_ID);
+ add(user.getId());
+ }};
+ }
+ return new HashSet() {{
+ add(user.getId());
+ }};
+ }
+
+ /**
+ * 设置上下文
+ * #需要通过上下文 获取SpringBean
+ *
+ * @param applicationContext spring上下文
+ * @throws BeansException 找不到bean异常
+ */
+ @Override
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ this.applicationContext = applicationContext;
+ }
+
+ @Override
+ public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
+ Class extends Annotation> annotationClass = DataPermission.class;
+ Map beanWithAnnotation = applicationContext.getBeansWithAnnotation(annotationClass);
+ Set> entitySet = beanWithAnnotation.entrySet();
+ for (Map.Entry entry : entitySet) {
+ Proxy proxy = (Proxy) entry.getValue();
+ Class clazz = getMapperClass(proxy);
+ populateDataFilters(clazz);
+ }
+ }
+
+ /**
+ * 根据mapper对应代理对象获取Class
+ *
+ * @param proxy mapper对应代理对象
+ * @return
+ */
+ private Class getMapperClass(Proxy proxy) {
+ try {
+ Field field = proxy.getClass().getSuperclass().getDeclaredField("h");
+ field.setAccessible(true);
+ MybatisMapperProxy mapperProxy = (MybatisMapperProxy) field.get(proxy);
+ field = mapperProxy.getClass().getDeclaredField("mapperInterface");
+ field.setAccessible(true);
+ return (Class) field.get(mapperProxy);
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ LogUtil.error(LogEnum.BIZ_DATASET, "reflect error", e);
+ }
+ return null;
+ }
+
+ /**
+ * 填充数据权限过滤,处理那些需要排除的方法
+ *
+ * @param clazz 需要处理的类(mapper)
+ */
+ private void populateDataFilters(Class clazz) {
+ if (clazz == null) {
+ return;
+ }
+ Method[] methods = clazz.getMethods();
+ DataPermission dataPermission = AnnotationUtils.findAnnotation((Class>) clazz, DataPermission.class);
+ Set ignores = Sets.newHashSet(dataPermission.ignores());
+ for (Method method : methods) {
+ if (ignores.contains(method.getName())) {
+ continue;
+ }
+ Set permission = getDataPermission(method);
+ dataFilters.put(clazz.getName() + PACKAGE_SEPARATOR + method.getName(), permission);
+ }
+ }
+
+ /**
+ * 获取方法上权限注解
+ * 权限注解包含
+ * 1.用户拥有指定权限才可以执行该方法:比如 PermissionConstant.SELECT 表示用户必须拥有select权限,才可以使用该方法
+ * 2.方法权限校验排除:比如 ignores = {"insert"} 表示insert方法不做权限处理
+ *
+ * @param method 方法对象
+ * @return
+ */
+ private Set getDataPermission(Method method) {
+ DataPermission dataPermission = AnnotationUtils.findAnnotation(method, DataPermission.class);
+ // 无注解时以方法名判断
+ if (dataPermission == null) {
+ if (method.getName().contains(SELECT_STR)) {
+ return SELECT_PERMISSION;
+ }
+ return UPDATE_DELETE_PERMISSION;
+ }
+ return Sets.newHashSet(dataPermission.permission());
+ }
+
+}
diff --git a/dubhe-server/common/src/main/java/org/dubhe/config/NfsConfig.java b/dubhe-server/common/src/main/java/org/dubhe/config/NfsConfig.java
new file mode 100644
index 0000000..c399147
--- /dev/null
+++ b/dubhe-server/common/src/main/java/org/dubhe/config/NfsConfig.java
@@ -0,0 +1,41 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.config;
+
+import lombok.Data;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+/**
+ * @description NFS config
+ * @create 2020/5/13
+ */
+@Data
+@Component
+public class NfsConfig {
+
+ @Value("${k8s.nfs}")
+ private String nfsIp;
+
+ @Value("${k8s.nfs-root-path}")
+ private String rootDir;
+
+ @Value("/${minio.bucketName}/")
+ private String bucket;
+
+}
diff --git a/dubhe-server/common/src/main/java/org/dubhe/config/RedisConfig.java b/dubhe-server/common/src/main/java/org/dubhe/config/RedisConfig.java
new file mode 100644
index 0000000..dad8e7c
--- /dev/null
+++ b/dubhe-server/common/src/main/java/org/dubhe/config/RedisConfig.java
@@ -0,0 +1,214 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.config;
+
+import cn.hutool.core.lang.Assert;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.parser.ParserConfig;
+import com.alibaba.fastjson.serializer.SerializerFeature;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.dubhe.utils.StringUtils;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.cache.Cache;
+import org.springframework.cache.annotation.CachingConfigurerSupport;
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.cache.interceptor.CacheErrorHandler;
+import org.springframework.cache.interceptor.KeyGenerator;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.cache.RedisCacheConfiguration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisOperations;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.RedisSerializationContext;
+import org.springframework.data.redis.serializer.RedisSerializer;
+
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.time.Duration;
+import java.util.HashMap;
+import java.util.Map;
+/**
+ * @description redis配置类
+ * @date 2020-03-25
+ */
+@Slf4j
+@Configuration
+@EnableCaching
+@ConditionalOnClass(RedisOperations.class)
+@EnableConfigurationProperties(RedisProperties.class)
+public class RedisConfig extends CachingConfigurerSupport {
+
+ /**
+ * 设置 redis 数据默认过期时间,默认2小时
+ * 设置@cacheable 序列化方式
+ */
+ @Bean
+ public RedisCacheConfiguration redisCacheConfiguration() {
+ FastJsonRedisSerializer
+ *
+ * @since 2020-06-23
+ */
+public interface PtTrainAlgorithmUsageMapper extends BaseMapper {
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/dao/PtTrainJobMapper.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/dao/PtTrainJobMapper.java
new file mode 100644
index 0000000..5d9edd7
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/dao/PtTrainJobMapper.java
@@ -0,0 +1,59 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.dubhe.domain.entity.PtTrainJob;
+import org.dubhe.domain.vo.PtTrainVO;
+
+/**
+ * @description 训练作业job Mapper 接口
+ * @date 2020-04-27
+ */
+public interface PtTrainJobMapper extends BaseMapper {
+
+ /**
+ * 获取训练列表,并进行分页。
+ *
+ * @param page 页
+ * @param createUserId 用户id
+ * @param trainStatus 训练状态
+ * @param trainName 训练名称
+ * @param sort 排序字段
+ * @param order 排序方式
+ *
+ * @return PtTrainVO
+ */
+ Page getPageTrain(Page page, @Param("createUserId") Long createUserId,
+ @Param("trainStatus") Integer trainStatus, @Param("trainName") String trainName, @Param("sort") String sort,
+ @Param("order") String order);
+
+ /**
+ * 根据状态进行统计数量
+ *
+ * @param userId 当前用户id
+ * @param param sql片段
+ * @return 统计的数量
+ */
+ @Select("select count(1) from pt_train_job t1 inner join pt_train t2 on t1.train_id = t2.id where t1.create_user_id= #{userId} and t1.train_status in ${param} and t1.deleted= 0 and t2.deleted = 0 ")
+ Integer selectCountByStatus(@Param("userId") Long userId, @Param("param") String param);
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/dao/PtTrainJobSpecsMapper.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/dao/PtTrainJobSpecsMapper.java
new file mode 100644
index 0000000..886b966
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/dao/PtTrainJobSpecsMapper.java
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.dubhe.domain.entity.PtTrainJobSpecs;
+
+/**
+ * @description 训练作业规格 Mapper 接口
+ * @date 2020-05-06
+ */
+public interface PtTrainJobSpecsMapper extends BaseMapper {
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/dao/PtTrainMapper.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/dao/PtTrainMapper.java
new file mode 100644
index 0000000..c70db46
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/dao/PtTrainMapper.java
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.dubhe.domain.entity.PtTrain;
+
+/**
+ * @description 训练作业主 Mapper 接口
+ * @date 2020-04-27
+ */
+public interface PtTrainMapper extends BaseMapper {
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/dao/PtTrainParamMapper.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/dao/PtTrainParamMapper.java
new file mode 100644
index 0000000..9ceff8e
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/dao/PtTrainParamMapper.java
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.dao;
+
+import org.dubhe.domain.entity.PtTrainParam;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * @description 任务参数 Mapper 接口
+ * @date 2020-04-27
+ */
+public interface PtTrainParamMapper extends BaseMapper {
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/PtDataset.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/PtDataset.java
new file mode 100644
index 0000000..4cee51f
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/PtDataset.java
@@ -0,0 +1,71 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.bean.copier.CopyOptions;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import org.dubhe.base.BaseEntity;
+import org.dubhe.domain.entity.Team;
+import org.dubhe.domain.entity.User;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * @description 数据集
+ * @date 2020-03-17
+ */
+@Data
+@TableName("pt_dataset")
+public class PtDataset extends BaseEntity {
+
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ @TableField(value = "name")
+ @NotBlank
+ private String name;
+
+ @TableField(value = "remark")
+ private String remark;
+
+ @TableField(value = "type")
+ @NotBlank
+ private String type;
+ /**
+ * 团队
+ */
+ @TableField(exist = false)
+ private Team team;
+ /**
+ * 创建用户
+ */
+ @TableField(exist = false)
+ private User createUser;
+
+ public void copy(PtDataset source) {
+ BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
+ }
+
+ public @interface Update {
+ }
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/PtDevEnvs.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/PtDevEnvs.java
new file mode 100644
index 0000000..776bf9f
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/PtDevEnvs.java
@@ -0,0 +1,114 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.bean.copier.CopyOptions;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import org.dubhe.base.BaseEntity;
+import org.dubhe.domain.entity.PtImage;
+import org.dubhe.domain.entity.Team;
+import org.dubhe.domain.entity.User;
+
+import javax.validation.constraints.NotBlank;
+import java.sql.Timestamp;
+
+/**
+ * @description 开发环境
+ * @date 2020-03-17
+ */
+
+@Data
+@TableName("pt_dev_envs")
+public class PtDevEnvs extends BaseEntity {
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ @NotBlank
+ private String name;
+
+ @TableField(value = "remark")
+ private String remark;
+
+ @TableField(value = "type")
+ @NotBlank
+ private String type;
+
+ @TableField(value = "pod_num")
+ private Integer podNum;
+
+ @TableField(value = "gpu_num")
+ private Integer gpuNum;
+
+ @TableField(value = "mem_num")
+ private Integer memNum;
+
+ @TableField(value = "cpu_num")
+ private Integer cpuNum;
+
+ @TableField(value = "duration")
+ private Integer duration;
+
+ @TableField(value = "start_time")
+ private Timestamp startTime;
+
+ @TableField(value = "close_time")
+ private Timestamp closeTime;
+
+ /**
+ * 数据集
+ */
+ @TableField(exist = false)
+ private PtDataset dataset;
+
+ /**
+ * 镜像
+ */
+ @TableField(exist = false)
+ private PtImage image;
+
+ /**
+ * 存储
+ */
+ @TableField(exist = false)
+ private PtStorage storage;
+
+ /**
+ * 团队
+ */
+ @TableField(exist = false)
+ private Team team;
+
+ /**
+ * 创建用户
+ */
+ @TableField(exist = false)
+ private User createUser;
+
+
+ public void copy(PtDevEnvs source) {
+ BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
+ }
+
+ public @interface Update {
+ }
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/PtStorage.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/PtStorage.java
new file mode 100644
index 0000000..75a41fd
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/PtStorage.java
@@ -0,0 +1,69 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.bean.copier.CopyOptions;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import org.dubhe.base.BaseEntity;
+import org.dubhe.domain.entity.Team;
+import org.dubhe.domain.entity.User;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+/**
+ * @description 存储
+ * @date 2020-03-17
+ */
+@Data
+@TableName("pt_storage")
+public class PtStorage extends BaseEntity {
+ @TableId(value = "id", type = IdType.AUTO)
+ @NotNull(groups = {Update.class})
+ private Long id;
+
+ @TableField(value = "name")
+ @NotBlank
+ private String name;
+
+ @TableField(value = "size")
+ private Integer size;
+
+ @TableField(value = "storageclass")
+ @NotBlank
+ private String storageclass;
+
+ @TableField(exist = false)
+ private Team team;
+
+ @TableField(exist = false)
+ private User createUser;
+
+
+ public void copy(PtStorage source) {
+ BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
+ }
+
+ public @interface Update {
+ }
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/BaseTrainJobDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/BaseTrainJobDTO.java
new file mode 100644
index 0000000..fa63396
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/BaseTrainJobDTO.java
@@ -0,0 +1,43 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+package org.dubhe.domain.dto;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.dubhe.domain.entity.PtTrainJobSpecs;
+
+import java.io.Serializable;
+
+/**
+ * @description 创建训练任务的数据包
+ * @date 2020-07-15
+ */
+@Data
+@Accessors(chain = true)
+public class BaseTrainJobDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private JSONObject runParams;
+ private String jobName;
+ private String dataSourcePath;
+ private PtTrainJobSpecs ptTrainJobSpecs;
+ private String outPath;
+ private String logPath;
+ private String visualizedLogPath;
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/NoteBookCreateDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/NoteBookCreateDTO.java
new file mode 100644
index 0000000..29d4b94
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/NoteBookCreateDTO.java
@@ -0,0 +1,75 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.dubhe.utils.NotebookUtil;
+
+import javax.validation.constraints.*;
+
+/**
+ * @description 创建notebook请求体
+ * @date 2020-06-28
+ */
+@Data
+public class NoteBookCreateDTO {
+
+ @NotBlank
+ @Pattern(regexp = NotebookUtil.K8S_NOTEBOOK_REGEX, message = "Notebook 名称仅支持字母、数字、汉字、英文横杠和下划线")
+ @Size(max = 30, message = "名称内容超长")
+ @ApiModelProperty(value = "notebook 名称")
+ private String noteBookName;
+
+ @Size(max = 255, message = "描述内容超长")
+ @ApiModelProperty(value = "notebook 描述")
+ private String description;
+
+ @ApiModelProperty(hidden = true)
+ private String url;
+
+ @ApiModelProperty(hidden = true)
+ private Integer totalRunMin;
+
+ @NotNull
+ @Min(value = NotebookUtil.CPU_MIN_NUMBER, message = "最少需要一个CPU")
+ @Max(value = NotebookUtil.CPU_MAX_NUMBER, message = "CPU数量超过限制,不可大于8")
+ @ApiModelProperty(value = "cpu数量")
+ private Integer cpuNum;
+
+ @Min(value = NotebookUtil.GPU_MIN_NUMBER, message = "最少需要一个GPU")
+ @Max(value = NotebookUtil.GPU_MAX_NUMBER, message = "GPU数量超过限制,不可大于4")
+ @ApiModelProperty(value = "gpu数量")
+ private Integer gpuNum;
+
+ @NotNull
+ @Min(value = NotebookUtil.MEMORY_MIN_NUMBER, message = "最少需要1G内存")
+ @Max(value = NotebookUtil.MEMORY_MAX_NUMBER, message = "内存超出限制,不可大于8")
+ @ApiModelProperty(value = "内存大小")
+ private Integer memNum;
+
+ @NotNull
+ @Min(value = NotebookUtil.DISK_MEMORY_MIN_NUMBER, message = "至少需要1G硬盘内存")
+ @Max(value = NotebookUtil.DISK_MEMORY_MAX_NUMBER, message = "硬盘内存超出限制,不可大于1024")
+ @ApiModelProperty(value = "硬盘内存大小")
+ private Integer diskMemNum;
+
+ @ApiModelProperty("镜像名称")
+ @NotNull(message = "请选择镜像")
+ private String k8sImageName;
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/NoteBookListQueryDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/NoteBookListQueryDTO.java
new file mode 100644
index 0000000..485d3d3
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/NoteBookListQueryDTO.java
@@ -0,0 +1,45 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.dubhe.annotation.Query;
+
+import java.io.Serializable;
+
+/**
+ * @description 查询请求体
+ * @date 2020-06-28
+ */
+@Data
+public class NoteBookListQueryDTO implements Serializable {
+
+ @Query(propName = "status", type = Query.Type.EQ)
+ @ApiModelProperty("0运行中,1停止, 2删除, 3启动中,4停止中,5删除中,6运行异常(暂未启用)")
+ private Integer status;
+
+ @Query(propName = "notebook_name", type = Query.Type.LIKE)
+ @ApiModelProperty("notebook名称")
+ private String noteBookName;
+
+ @Query(propName = "user_id", type = Query.Type.EQ)
+ @ApiModelProperty(value = "所属用户ID", hidden = true)
+ private Long userId;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/NoteBookQueryDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/NoteBookQueryDTO.java
new file mode 100644
index 0000000..93712f8
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/NoteBookQueryDTO.java
@@ -0,0 +1,93 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import lombok.Data;
+import org.dubhe.annotation.Query;
+import org.dubhe.enums.NoteBookStatusEnum;
+import org.dubhe.utils.K8sCallBackTool;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @description 查询notebook请求体
+ * @date 2020-04-28
+ */
+@Data
+public class NoteBookQueryDTO implements Serializable {
+
+ @Query(propName = "status", type = Query.Type.NE)
+ private Integer neStatus;
+
+ @Query(propName = "status", type = Query.Type.IN)
+ private List statusList;
+
+ @Query(propName = "k8s_pvc_path", type = Query.Type.EQ)
+ private String k8sPvcPath;
+
+ @Query(propName = "user_id", type = Query.Type.EQ)
+ private Long userId;
+
+ @Query(propName = "last_operation_timeout", type = Query.Type.LT)
+ private Long lastOperationTimeout;
+
+
+ private static final NoteBookQueryDTO QUERY_CRITERIA;
+
+ public NoteBookQueryDTO() {
+ }
+
+ public NoteBookQueryDTO(Integer neStatus, String k8sPvcPath, Long userId) {
+ this.neStatus = neStatus;
+ this.k8sPvcPath = k8sPvcPath;
+ this.userId = userId;
+ }
+
+ static {
+ QUERY_CRITERIA = new NoteBookQueryDTO();
+ QUERY_CRITERIA.setNeStatus(NoteBookStatusEnum.DELETE.getCode());
+ }
+
+ /**
+ * 获取需要刷新状态的查询条件
+ *
+ * @return
+ */
+ public static NoteBookQueryDTO getToRefreshCriteria() {
+ NoteBookQueryDTO refreshCriteria = new NoteBookQueryDTO();
+ refreshCriteria.setStatusList(Arrays.asList(
+ NoteBookStatusEnum.STARTING.getCode()
+ , NoteBookStatusEnum.STOPPING.getCode()
+ , NoteBookStatusEnum.DELETING.getCode()));
+ refreshCriteria.setLastOperationTimeout(K8sCallBackTool.getCurrentSecondLong());
+ return refreshCriteria;
+ }
+
+ /**
+ * 获取查询列表需要的查询条件
+ *
+ * @return
+ */
+ public static NoteBookQueryDTO getListCriteria() {
+ return QUERY_CRITERIA;
+ }
+
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/NoteBookStatusDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/NoteBookStatusDTO.java
new file mode 100644
index 0000000..196a973
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/NoteBookStatusDTO.java
@@ -0,0 +1,37 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @description note book status
+ * @date 2020-05-14
+ */
+@Data
+public class NoteBookStatusDTO implements Serializable {
+
+ @ApiModelProperty("状态编码")
+ private Integer statusCode;
+
+ @ApiModelProperty("状态名称")
+ private String statusName;
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtDatasetDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtDatasetDTO.java
new file mode 100644
index 0000000..76b06fa
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtDatasetDTO.java
@@ -0,0 +1,43 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+/**
+ * @description 数据集
+ * @date 2020-03-17
+ */
+@Data
+public class PtDatasetDTO implements Serializable {
+ private Long id;
+ private String name;
+ private String remark;
+ private String type;
+ private TeamSmallDTO team;
+ /**
+ * 创建用户
+ */
+ private UserSmallDTO createUser;
+ private Timestamp createTime;
+ private Timestamp updateTime;
+ private Boolean deleted;
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtDatasetQueryCriteria.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtDatasetQueryCriteria.java
new file mode 100644
index 0000000..d15dd2a
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtDatasetQueryCriteria.java
@@ -0,0 +1,28 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import lombok.Data;
+
+/**
+ * @description 数据集查询条件
+ * @date 2020-03-17
+ */
+@Data
+public class PtDatasetQueryCriteria {
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtDatasetSmallDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtDatasetSmallDTO.java
new file mode 100644
index 0000000..3f5b30b
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtDatasetSmallDTO.java
@@ -0,0 +1,32 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @description 数据集
+ * @date 2020-03-17
+ */
+@Data
+public class PtDatasetSmallDTO implements Serializable {
+ private Long id;
+ private String name;
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtDevEnvsDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtDevEnvsDTO.java
new file mode 100644
index 0000000..ea6cf40
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtDevEnvsDTO.java
@@ -0,0 +1,51 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+/**
+ * @description 开发环境
+ * @date 2020-03-17
+ */
+@Data
+public class PtDevEnvsDTO implements Serializable {
+
+ private Long id;
+ private String name;
+ private String remark;
+ private String type;
+ private Integer podNum;
+ private Integer gpuNum;
+ private Integer memNum;
+ private Integer cpuNum;
+ private Integer duration;
+ private Timestamp startTime;
+ private Timestamp closeTime;
+ private PtDatasetSmallDTO dataset;
+ private PtImageSmallDTO image;
+ private PtStorageSmallDTO storage;
+ private TeamSmallDTO team;
+ private UserSmallDTO createUser;
+ private Timestamp createTime;
+ private Timestamp updateTime;
+ private Boolean deleted;
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtDevEnvsQueryCriteria.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtDevEnvsQueryCriteria.java
new file mode 100644
index 0000000..46973ec
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtDevEnvsQueryCriteria.java
@@ -0,0 +1,28 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import lombok.Data;
+
+/**
+ * @description 开发环境查询条件
+ * @date 2020-03-17
+ */
+@Data
+public class PtDevEnvsQueryCriteria {
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtImageDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtImageDTO.java
new file mode 100644
index 0000000..85e0d41
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtImageDTO.java
@@ -0,0 +1,69 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.dubhe.domain.entity.Team;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+/**
+ * @description: 镜像
+ * @date 2020-03-17
+ */
+@Data
+public class PtImageDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("镜像ID")
+ private Long id;
+
+ @ApiModelProperty("镜像名称")
+ private String name;
+
+ @ApiModelProperty("镜像描述")
+ private String remark;
+
+ @ApiModelProperty("类型")
+ private String type;
+
+ @ApiModelProperty("标签")
+ private String label;
+
+ @ApiModelProperty("地址")
+ private String uri;
+
+ @ApiModelProperty("团队")
+ private Team team;
+
+ @ApiModelProperty("创建人")
+ private UserSmallDTO createUser;
+
+ @ApiModelProperty("创建时间")
+ private Timestamp createTime;
+
+ @ApiModelProperty("更新时间")
+ private Timestamp updateTime;
+
+ @ApiModelProperty("删除(0正常,1已删除)")
+ private Boolean deleted;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtImageQueryDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtImageQueryDTO.java
new file mode 100644
index 0000000..e1bc556
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtImageQueryDTO.java
@@ -0,0 +1,43 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.dubhe.base.PageQueryBase;
+
+import java.io.Serializable;
+
+/**
+ * @description 镜像查询
+ * @date 2020-05-09
+ */
+@Data
+@Accessors(chain = true)
+public class PtImageQueryDTO extends PageQueryBase implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "镜像来源(0为我的镜像, 1为预置镜像)")
+ private Integer imageResource;
+
+ @ApiModelProperty(value = "镜像状态,0为制作中,1位制作成功,2位制作失败")
+ private Integer imageStatus;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtImageSmallDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtImageSmallDTO.java
new file mode 100644
index 0000000..8d3c7a1
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtImageSmallDTO.java
@@ -0,0 +1,40 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @description: 镜像
+ * @date 2020-03-17
+ */
+@Data
+public class PtImageSmallDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("镜像ID")
+ private Long id;
+
+ @ApiModelProperty("镜像名称")
+ private String name;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtImageUploadDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtImageUploadDTO.java
new file mode 100644
index 0000000..a3ae025
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtImageUploadDTO.java
@@ -0,0 +1,61 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.dubhe.utils.TrainUtil;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Pattern;
+import java.io.Serializable;
+
+
+/**
+ * @description 上传镜像
+ * @date 2020-06-11
+ */
+@Data
+@Accessors(chain = true)
+public class PtImageUploadDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+
+ @ApiModelProperty(value = "镜像文件路径", required = true)
+ @NotBlank(message = "镜像文件路径不能为空")
+ private String imagePath;
+
+ @ApiModelProperty(value = "镜像名称", required = true)
+ @NotBlank(message = "源镜像名称不能为空")
+ @Length(min = TrainUtil.NUMBER_ONE, max = TrainUtil.NUMBER_SIXTY_FOUR, message = "镜像名称长度在1-64个字符")
+ @Pattern(regexp = TrainUtil.REGEXP_NAME, message = "镜像名称支持字母、数字、英文横杠和下划线")
+ private String imageName;
+
+ @ApiModelProperty(value = "镜像版本号", required = true)
+ @NotBlank(message = "镜像版本号不能为空")
+ @Length(max = TrainUtil.NUMBER_THIRTY_TWO, message = "镜像版本号长度在1-32个字符")
+ @Pattern(regexp = TrainUtil.REGEXP_TAG, message = "镜像版本号支持字母、数字、英文横杠、英文.号和下划线")
+ private String imageTag;
+
+ @ApiModelProperty("备注")
+ @Length(max = TrainUtil.NUMBER_ONE_THOUSAND_AND_TWENTY_FOUR, message = "备注-输入长度不能超过1024个字符")
+ private String remark;
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtStorageDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtStorageDTO.java
new file mode 100644
index 0000000..8354adc
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtStorageDTO.java
@@ -0,0 +1,41 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+/**
+ * @description 存储
+ * @date 2020-03-17
+ */
+@Data
+public class PtStorageDTO implements Serializable {
+
+ private Long id;
+ private String name;
+ private Integer size;
+ private String storageclass;
+ private TeamSmallDTO team;
+ private UserSmallDTO createUser;
+ private Timestamp createTime;
+ private Timestamp updateTime;
+ private Boolean deleted;
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtStorageQueryCriteria.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtStorageQueryCriteria.java
new file mode 100644
index 0000000..4f5528a
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtStorageQueryCriteria.java
@@ -0,0 +1,28 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import lombok.Data;
+
+/**
+ * @description 存储
+ * @date 2020-03-17
+ */
+@Data
+public class PtStorageQueryCriteria {
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtStorageSmallDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtStorageSmallDTO.java
new file mode 100644
index 0000000..4544556
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtStorageSmallDTO.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @description 存储
+ * @date 2020-03-17
+ */
+@Data
+public class PtStorageSmallDTO implements Serializable {
+ private Long id;
+ private String name;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainAlgorithmCreateDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainAlgorithmCreateDTO.java
new file mode 100644
index 0000000..4109495
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainAlgorithmCreateDTO.java
@@ -0,0 +1,88 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import com.alibaba.fastjson.JSONObject;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.dubhe.utils.TrainUtil;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Pattern;
+import java.io.Serializable;
+
+/**
+ * @desciption 创建算法条件
+ * @date 2020-04-29
+ */
+@Data
+@Accessors(chain = true)
+public class PtTrainAlgorithmCreateDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "算法名称,输入长度不能超过32个字符", required = true)
+ @NotBlank(message = "算法名称不能为空")
+ @Length(max = TrainUtil.NUMBER_THIRTY_TWO, message = "算法名称-输入长度不能超过32个字符")
+ @Pattern(regexp = TrainUtil.REGEXP, message = "算法名称支持字母、数字、汉字、英文横杠和下划线")
+ private String algorithmName;
+
+ @ApiModelProperty("算法描述,输入长度不能超过256个字符")
+ @Length(max = TrainUtil.NUMBER_TWO_HUNDRED_AND_FIFTY_FIVE, message = "算法描述-输入长度不能超过256个字符")
+ private String description;
+
+ @ApiModelProperty(value = "镜像版本")
+ private String imageTag;
+
+ @ApiModelProperty(value = "镜像名称")
+ private String imageName;
+
+ @ApiModelProperty(value = "创建算法来源(true:由fork创建算法,false:其它创建算法方式)")
+ private Boolean fork;
+
+ @ApiModelProperty(value = "代码目录(路径规则:/algorithm-manage/{userId}/{YYYYMMDDhhmmssSSS+四位随机数}/用户上传的算法具体文件(zip文件)名称或从notebook跳转时为/notebook/{userId}/{YYYYMMDDhhmmssSSS+四位随机数}/)", required = true)
+ @NotBlank(message = "代码目录不能为空")
+ @Length(max = TrainUtil.NUMBER_ONE_HUNDRED_AND_TWENTY_EIGHT, message = "代码目录-输入长度不能超过128个字符")
+ private String codeDir;
+
+ @ApiModelProperty(value = "运行命令")
+ @Length(max = TrainUtil.NUMBER_ONE_HUNDRED_AND_TWENTY_EIGHT, message = "运行命令-输入长度不能超过128个字符")
+ private String runCommand;
+
+ @ApiModelProperty("运行参数(算法来源为我的算法时为调优参数,算法来源为预置算法时为运行参数)")
+ private JSONObject runParams;
+
+ @ApiModelProperty("算法用途,输入长度不能超过128个字符")
+ @Length(max = TrainUtil.NUMBER_ONE_HUNDRED_AND_TWENTY_EIGHT, message = "算法用途-输入长度不能超过128个字符")
+ private String algorithmUsage;
+
+ @ApiModelProperty("是否输出训练结果,不填则默认为true")
+ private Boolean isTrainOut;
+
+ @ApiModelProperty("是否输出训练日志,不填则默认为true")
+ private Boolean isTrainLog;
+
+ @ApiModelProperty("是否输出可视化日志,不填则默认为false")
+ private Boolean isVisualizedLog;
+
+ @ApiModelProperty("noteBookId")
+ private Long noteBookId;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainAlgorithmDeleteDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainAlgorithmDeleteDTO.java
new file mode 100644
index 0000000..08daa8d
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainAlgorithmDeleteDTO.java
@@ -0,0 +1,42 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.Set;
+
+/**
+ * @description 算法删除
+ * @date 2020-07-02
+ */
+@Data
+@Accessors(chain = true)
+public class PtTrainAlgorithmDeleteDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "id", required = true)
+ @NotNull(message = "id不能为空")
+ private Set ids;
+
+}
\ No newline at end of file
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainAlgorithmQueryDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainAlgorithmQueryDTO.java
new file mode 100644
index 0000000..21bec33
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainAlgorithmQueryDTO.java
@@ -0,0 +1,57 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.dubhe.annotation.Query;
+import org.dubhe.base.PageQueryBase;
+import org.dubhe.utils.TrainUtil;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import java.io.Serializable;
+
+/**
+ * @description 查询算法条件
+ * @date 2020-04-29
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Accessors(chain = true)
+public class PtTrainAlgorithmQueryDTO extends PageQueryBase implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "算法来源(1为我的算法, 2为预置算法)")
+ @Min(value = TrainUtil.NUMBER_ONE, message = "算法来源错误")
+ @Max(value = TrainUtil.NUMBER_TWO, message = "算法来源错误")
+ @Query(propName = "algorithm_source", type = Query.Type.EQ)
+ private Integer algorithmSource;
+
+ @ApiModelProperty(value = "算法名称或者id")
+ @Length(max = TrainUtil.NUMBER_THIRTY_TWO, message = "算法名称或者id有误")
+ private String algorithmName;
+
+ @ApiModelProperty(value = "算法用途")
+ private String algorithmUsage;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainAlgorithmUpdateDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainAlgorithmUpdateDTO.java
new file mode 100644
index 0000000..9c83be2
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainAlgorithmUpdateDTO.java
@@ -0,0 +1,64 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.dubhe.utils.TrainUtil;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+import java.io.Serializable;
+
+/**
+ * @description 修改算法
+ * @date 2020-06-19
+ */
+@Data
+@Accessors(chain = true)
+public class PtTrainAlgorithmUpdateDTO implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "id", required = true)
+ @NotNull(message = "id不能为null")
+ @Min(value = TrainUtil.NUMBER_ONE, message = "id必须大于1")
+ private Long id;
+
+ @ApiModelProperty(value = "算法名称,输入长度不能超过32个字符")
+ @Length(max = TrainUtil.NUMBER_THIRTY_TWO, message = "算法名称-输入长度不能超过32个字符")
+ @Pattern(regexp = TrainUtil.REGEXP, message = "算法名称支持字母、数字、汉字、英文横杠和下划线")
+ private String algorithmName;
+
+ @ApiModelProperty("算法描述,输入长度不能超过256个字符")
+ @Length(max = TrainUtil.NUMBER_TWO_HUNDRED_AND_FIFTY_FIVE, message = "算法描述-输入长度不能超过256个字符")
+ private String description;
+
+ @ApiModelProperty("算法用途,输入长度不能超过128个字符")
+ @Length(max = TrainUtil.NUMBER_ONE_HUNDRED_AND_TWENTY_EIGHT, message = "算法用途-输入长度不能超过128个字符")
+ private String algorithmUsage;
+
+ @ApiModelProperty("是否输出训练日志")
+ private Boolean isTrainLog;
+
+ @ApiModelProperty("是否输出可视化日志")
+ private Boolean isVisualizedLog;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainAlgorithmUsageCreateDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainAlgorithmUsageCreateDTO.java
new file mode 100644
index 0000000..4dba0f8
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainAlgorithmUsageCreateDTO.java
@@ -0,0 +1,50 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.dubhe.utils.TrainUtil;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Pattern;
+import java.io.Serializable;
+
+/**
+ * @description 创建算法用途条件
+ * @date 2020-06-23
+ */
+@Data
+@Accessors(chain = true)
+public class PtTrainAlgorithmUsageCreateDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "名称输入长度不能超过32个字符", required = true)
+ @NotBlank(message = "名称不能为空")
+ @Length(max = TrainUtil.NUMBER_THIRTY_TWO, message = "名称-输入长度不能超过32个字符")
+ @Pattern(regexp = TrainUtil.REGEXP, message = "名称支持字母、数字、汉字、英文横杠和下划线")
+ private String auxInfo;
+
+ @ApiModelProperty(value = "类型", hidden = true)
+ private String type;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainAlgorithmUsageDeleteDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainAlgorithmUsageDeleteDTO.java
new file mode 100644
index 0000000..e2e3abd
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainAlgorithmUsageDeleteDTO.java
@@ -0,0 +1,40 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @description 算法用途删除
+ * @date 2020/7/2
+ */
+@Data
+@Accessors(chain = true)
+public class PtTrainAlgorithmUsageDeleteDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "id", required = true)
+ @NotNull(message = "id不能为空")
+ private Long[] ids;
+
+}
\ No newline at end of file
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainAlgorithmUsageQueryDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainAlgorithmUsageQueryDTO.java
new file mode 100644
index 0000000..f3612f1
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainAlgorithmUsageQueryDTO.java
@@ -0,0 +1,45 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotNull;
+
+import org.dubhe.base.PageQueryBase;
+
+/**
+ * @description 查询算法用途条件
+ * @date 2020-06-23
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Accessors(chain = true)
+public class PtTrainAlgorithmUsageQueryDTO extends PageQueryBase {
+
+ @ApiModelProperty(value = "类型", hidden = true)
+ private String type;
+
+ @ApiModelProperty(value = "是否包含默认值 0:不包含 1包含", required = true)
+ @NotNull
+ private Boolean isContainDefault;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainAlgorithmUsageUpdateDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainAlgorithmUsageUpdateDTO.java
new file mode 100644
index 0000000..6c12f7e
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainAlgorithmUsageUpdateDTO.java
@@ -0,0 +1,49 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.dubhe.utils.TrainUtil;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @description 算法用途修改
+ * @date 2020-06-23
+ */
+@Data
+@Accessors(chain = true)
+public class PtTrainAlgorithmUsageUpdateDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "id", required = true)
+ @NotNull(message = "id不能为null")
+ @Min(value = TrainUtil.NUMBER_ONE, message = "id必须大于1")
+ private Long id;
+
+ @ApiModelProperty("描述, 长度不能超过20个字符")
+ @Length(max = TrainUtil.NUMBER_TWENTY, message = "名称长度不能超过20个字符")
+ private String auxInfo;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainDataSourceStatusQueryDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainDataSourceStatusQueryDTO.java
new file mode 100644
index 0000000..5d43e8e
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainDataSourceStatusQueryDTO.java
@@ -0,0 +1,40 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @description 查询数据集对应训练状态查询条件
+ * @date 2020-05-21
+ */
+@Data
+@Accessors(chain = true)
+public class PtTrainDataSourceStatusQueryDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("数据集路径")
+ private List dataSourcePath;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobCreateDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobCreateDTO.java
new file mode 100644
index 0000000..d380647
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobCreateDTO.java
@@ -0,0 +1,96 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import com.alibaba.fastjson.JSONObject;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.dubhe.base.BaseImageDTO;
+import org.dubhe.utils.TrainUtil;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.*;
+
+/**
+ * @description 创建训练任务
+ * @date 2020-04-27
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Accessors(chain = true)
+public class PtTrainJobCreateDTO extends BaseImageDTO {
+
+ @ApiModelProperty(value = "训练作业名, 长度在1-32个字符", required = true)
+ @NotNull(message = "训练作业名不能为空")
+ @Length(min = TrainUtil.NUMBER_ONE, max = TrainUtil.NUMBER_THIRTY_TWO, message = "训练作业名长度在1-32个字符")
+ @Pattern(regexp = TrainUtil.REGEXP, message = "训练作业名称支持字母、数字、汉字、英文横杠和下划线")
+ private String trainName;
+
+ @ApiModelProperty("描述, 长度不能超过255个字符")
+ @Length(max = TrainUtil.NUMBER_TWO_HUNDRED_AND_FIFTY_FIVE, message = "描述长度不能超过255个字符")
+ private String description;
+
+ @ApiModelProperty(value = "算法来源id", required = true)
+ @NotNull(message = "algorithmId不能为空")
+ @Min(value = TrainUtil.NUMBER_ONE, message = "algorithmId必须不小于1")
+ private Long algorithmId;
+
+ @ApiModelProperty(value = "运行命令,输入长度不能超过128个字符", required = true)
+ @NotBlank(message = "运行命令不能为空")
+ @Length(max = TrainUtil.NUMBER_ONE_HUNDRED_AND_TWENTY_EIGHT, message = "运行命令-输入长度不能超过128个字符")
+ private String runCommand;
+
+ @ApiModelProperty(value = "数据来源名称, 长度在1-127个字符", required = true)
+ @NotNull(message = "数据来源名称不能为空")
+ @Length(min = TrainUtil.NUMBER_ONE, max = TrainUtil.NUMBER_ONE_HUNDRED_AND_TWENTY_SEVEN, message = "数据来源名称长度在1-127个字符")
+ private String dataSourceName;
+
+ @ApiModelProperty(value = "数据来源路径, 长度在1-127个字符", required = true)
+ @NotNull(message = "数据来源路径不能为空")
+ @Length(min = TrainUtil.NUMBER_ONE, max = TrainUtil.NUMBER_ONE_HUNDRED_AND_TWENTY_SEVEN, message = "数据来源路径长度在1-127个字符")
+ private String dataSourcePath;
+
+ @ApiModelProperty("运行参数(算法来源为我的算法时为调优参数,算法来源为预置算法时为运行参数)")
+ private JSONObject runParams;
+
+ @ApiModelProperty(value = "类型(0为CPU,1为GPU)", required = true)
+ @Min(value = TrainUtil.NUMBER_ZERO, message = "类型错误")
+ @Max(value = TrainUtil.NUMBER_ONE, message = "类型错误")
+ @NotNull(message = "类型(0为CPU,1为GPU)不能为空")
+ private Integer resourcesPoolType;
+
+ @ApiModelProperty(value = "规格类型Id", required = true)
+ @NotNull(message = "规格类型id不能为空")
+ @Min(value = TrainUtil.NUMBER_ONE, message = "规格类型id必须不小于1")
+ private Integer trainJobSpecsId;
+
+ @ApiModelProperty("true代表保存作业参数")
+ private Boolean saveParams;
+
+ @ApiModelProperty("作业参数名称,当saveParams为true的时候传递, 输入长度不能超过32个字符")
+ @Length(max = TrainUtil.NUMBER_THIRTY_TWO, message = "作业参数名称-输入长度不能超过32个字符")
+ @Pattern(regexp = TrainUtil.REGEXP, message = "作业参数名称支持字母、数字、汉字、英文横杠和下划线")
+ private String trainParamName;
+
+ @ApiModelProperty("作业参数描述,当saveParams为true的时候传递, 长度不能超过255个字符")
+ @Length(max = TrainUtil.NUMBER_TWO_HUNDRED_AND_FIFTY_FIVE, message = "作业参数描述-输入长度不能超过255个字符")
+ private String trainParamDesc;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobDTO.java
new file mode 100644
index 0000000..306dca3
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobDTO.java
@@ -0,0 +1,53 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+/**
+ * @description: 训练任务
+ * @date 2020-03-17
+ */
+@Data
+public class PtTrainJobDTO implements Serializable {
+ private Long id;
+ private String name;
+ private String remark;
+ private PtDatasetSmallDTO dataset;
+ private PtImageSmallDTO image;
+ private PtStorageSmallDTO storage;
+ private TeamSmallDTO team;
+ private String selectorLabel;
+ private Integer podNum;
+ private Integer gpuNum;
+ private Integer memNum;
+ private Integer cpuNum;
+ private Integer level;
+ private Timestamp startTime;
+ private Timestamp closeTime;
+ private String cmd;
+ private String status;
+ private UserSmallDTO confirmUser;
+ private UserSmallDTO createUser;
+ private Timestamp createTime;
+ private Timestamp updateTime;
+ private Boolean deleted;
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobDeleteDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobDeleteDTO.java
new file mode 100644
index 0000000..6bfdc09
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobDeleteDTO.java
@@ -0,0 +1,48 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.dubhe.utils.TrainUtil;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @description 删除训练任务
+ * @date 2020-04-27
+ */
+@Data
+@Accessors(chain = true)
+public class PtTrainJobDeleteDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "trainId,如果只传递trainId,代表删除该trainId下的所有job", required = true)
+ @NotNull(message = "trainId不能为空")
+ @Min(value = TrainUtil.NUMBER_ONE, message = "trainId数值不合法")
+ private Long trainId;
+
+ @ApiModelProperty(value = "jobId")
+ @Min(value = TrainUtil.NUMBER_ONE, message = "jobId数值不合法")
+ private Long id;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobDetailQueryDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobDetailQueryDTO.java
new file mode 100644
index 0000000..ba044de
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobDetailQueryDTO.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.dubhe.utils.TrainUtil;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @description 根据jobId查询训练任务详情查询条件
+ * @date 2020-06-12
+ */
+@Data
+@Accessors(chain = true)
+public class PtTrainJobDetailQueryDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "id", required = true)
+ @NotNull(message = "id不能为null")
+ @Min(value = TrainUtil.NUMBER_ONE, message = "id必须大于1")
+ private Long id;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobResumeDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobResumeDTO.java
new file mode 100644
index 0000000..2637c7c
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobResumeDTO.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.dubhe.utils.TrainUtil;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @description: 恢复训练
+ * @date: 2020-04-27
+ */
+@Data
+@Accessors(chain = true)
+public class PtTrainJobResumeDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "id", required = true)
+ @NotNull(message = "id不能为空")
+ @Min(value = TrainUtil.NUMBER_ONE, message = "id数值不合法")
+ private Long id;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobSpecsQueryDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobSpecsQueryDTO.java
new file mode 100644
index 0000000..f217fbb
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobSpecsQueryDTO.java
@@ -0,0 +1,37 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @description: 训练作业规格查询
+ * @date 2020-05-06
+ */
+@Data
+public class PtTrainJobSpecsQueryDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "规格类型(0为CPU, 1为GPU)")
+ private Integer resourcesPoolType;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobStopDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobStopDTO.java
new file mode 100644
index 0000000..c953cdf
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobStopDTO.java
@@ -0,0 +1,48 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.dubhe.utils.TrainUtil;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @description 停止训练
+ * @date 2020-04-27
+ */
+@Data
+@Accessors(chain = true)
+public class PtTrainJobStopDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "trainId,如果只传递trainId,代表删除该trainId下的所有job", required = true)
+ @NotNull(message = "trainId不能为空")
+ @Min(value = TrainUtil.NUMBER_ONE, message = "trainId数值不合法")
+ private Long trainId;
+
+ @ApiModelProperty(value = "jobId")
+ @Min(value = TrainUtil.NUMBER_ONE, message = "jobId数值不合法")
+ private Long id;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobUpdateDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobUpdateDTO.java
new file mode 100644
index 0000000..401f454
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobUpdateDTO.java
@@ -0,0 +1,86 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import com.alibaba.fastjson.JSONObject;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.dubhe.base.BaseImageDTO;
+import org.dubhe.utils.TrainUtil;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+/**
+ * @description 训练任务修改
+ * @date 2020-04-27
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Accessors(chain = true)
+public class PtTrainJobUpdateDTO extends BaseImageDTO {
+
+ @ApiModelProperty(value = "id", required = true)
+ @NotNull(message = "id不能为null")
+ @Min(value = TrainUtil.NUMBER_ONE, message = "id必须大于1")
+ private Long id;
+
+ @ApiModelProperty("描述, 长度不能超过255个字符")
+ @Length(max = TrainUtil.NUMBER_TWO_HUNDRED_AND_FIFTY_FIVE, message = "描述长度不能超过255个字符")
+ private String description;
+
+ @ApiModelProperty("算法id")
+ @NotNull(message = "algorithmId不能为空")
+ @Min(value = TrainUtil.NUMBER_ONE, message = "algorithmId必须大于1")
+ private Long algorithmId;
+
+ @ApiModelProperty(value = "运行命令,输入长度不能超过128个字符", required = true)
+ @NotBlank(message = "运行命令不能为空")
+ @Length(max = TrainUtil.NUMBER_ONE_HUNDRED_AND_TWENTY_EIGHT, message = "运行命令-输入长度不能超过128个字符")
+ private String runCommand;
+
+ @ApiModelProperty(value = "数据集来源路径,输入长度不能超过127个字符", required = true)
+ @NotBlank(message = "数据集来源路径不能为空")
+ @Length(max = TrainUtil.NUMBER_ONE_HUNDRED_AND_TWENTY_SEVEN, message = "数据集来源路径-输入长度不能超过127个字符")
+ private String dataSourcePath;
+
+ @ApiModelProperty(value = "数据集来源名称,输入长度不能超过127个字符", required = true)
+ @NotBlank(message = "数据集来源名称不能为空")
+ @Length(max = TrainUtil.NUMBER_ONE_HUNDRED_AND_TWENTY_SEVEN, message = "数据集来源名称-输入长度不能超过127个字符")
+ private String dataSourceName;
+
+ @ApiModelProperty("运行参数(算法来源为我的算法时为调优参数,算法来源为预置算法时为运行参数)")
+ private JSONObject runParams;
+
+ @ApiModelProperty(value = "类型(0为CPU,1为GPU)", required = true)
+ @Min(value = TrainUtil.NUMBER_ZERO, message = "类型错误")
+ @Max(value = TrainUtil.NUMBER_ONE, message = "类型错误")
+ @NotNull(message = "类型(0为CPU,1为GPU)不能为空")
+ private Integer resourcesPoolType;
+
+ @ApiModelProperty(value = "规格类型Id", required = true)
+ @NotNull(message = "规格类型id不能为空")
+ @Min(value = TrainUtil.NUMBER_ONE, message = "规格类型id必须不小于1")
+ private Integer trainJobSpecsId;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobVersionQueryDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobVersionQueryDTO.java
new file mode 100644
index 0000000..cbe33b1
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainJobVersionQueryDTO.java
@@ -0,0 +1,48 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.dubhe.base.PageQueryBase;
+import org.dubhe.utils.TrainUtil;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @description 训练任务版本查询
+ * @date 2020-06-30
+ */
+@Data
+@Accessors(chain = true)
+public class PtTrainJobVersionQueryDTO extends PageQueryBase implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "训练作业id", required = true)
+ @NotNull(message = "训练作业id不能为空")
+ @Min(value = TrainUtil.NUMBER_ONE, message = "训练作业id必须不小于1")
+ private Long trainId;
+
+ @ApiModelProperty("训练作业job状态, 0为待处理,1为运行中,2为运行完成,3为失败,4为停止,5为未知,6为删除,7为创建失败")
+ private Integer trainStatus;
+
+}
\ No newline at end of file
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainLogQueryDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainLogQueryDTO.java
new file mode 100644
index 0000000..3be8dec
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainLogQueryDTO.java
@@ -0,0 +1,53 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.dubhe.utils.TrainUtil;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @description 训练日志 查询DTO
+ * @date 2020-05-08
+ */
+@Data
+@Accessors(chain = true)
+public class PtTrainLogQueryDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("训练job的id")
+ @NotNull(message = "训练job的id不能为空")
+ private Integer jobId;
+
+ @ApiModelProperty(value = "起始行")
+ @Min(value = TrainUtil.NUMBER_ZERO, message = "startLine不能小于0")
+ private Integer startLine;
+
+ @ApiModelProperty(value = "行数")
+ @Min(value = TrainUtil.NUMBER_ONE, message = "lines不能小于1")
+ @Max(value = TrainUtil.NUMBER_ONE_THOUSAND, message = "lines不能大于1000")
+ private Integer lines;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainParamCreateDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainParamCreateDTO.java
new file mode 100644
index 0000000..1b9e636
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainParamCreateDTO.java
@@ -0,0 +1,84 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import com.alibaba.fastjson.JSONObject;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.dubhe.base.BaseImageDTO;
+import org.dubhe.utils.TrainUtil;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.*;
+
+/**
+ * @description 任务参数创建条件
+ * @date 2020-04-27
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Accessors(chain = true)
+public class PtTrainParamCreateDTO extends BaseImageDTO {
+
+ @ApiModelProperty(value = "任务参数名称,输入长度不能超过32个字符", required = true)
+ @NotBlank(message = "任务参数名称不能为空")
+ @Length(max = TrainUtil.NUMBER_THIRTY_TWO, message = "任务参数名称-输入长度不能超过32个字符")
+ @Pattern(regexp = TrainUtil.REGEXP, message = "任务参数名称支持字母、数字、汉字、英文横杠和下划线")
+ private String paramName;
+
+ @ApiModelProperty("描述,输入长度不能超过256个字符")
+ @Length(max = TrainUtil.NUMBER_TWO_HUNDRED_AND_FIFTY_FIVE, message = "任务参数描述-输入长度不能超过256个字符")
+ private String description;
+
+ @ApiModelProperty(value = "算法id,算法id不能小于1", required = true)
+ @NotNull(message = "算法id不能为空")
+ @Min(value = TrainUtil.NUMBER_ONE, message = "算法id不能小于1")
+ private Long algorithmId;
+
+ @ApiModelProperty(value = "运行命令,输入长度不能超过128个字符", required = true)
+ @NotBlank(message = "运行命令不能为空")
+ @Length(max = TrainUtil.NUMBER_ONE_HUNDRED_AND_TWENTY_EIGHT, message = "运行命令-输入长度不能超过128个字符")
+ private String runCommand;
+
+ @ApiModelProperty(value = "数据集来源路径,输入长度不能超过127个字符", required = true)
+ @NotBlank(message = "数据集来源路径不能为空")
+ @Length(max = TrainUtil.NUMBER_ONE_HUNDRED_AND_TWENTY_SEVEN, message = "数据集来源路径-输入长度不能超过127个字符")
+ private String dataSourcePath;
+
+ @ApiModelProperty(value = "数据集来源名称,输入长度不能超过127个字符", required = true)
+ @NotBlank(message = "数据集来源名称不能为空")
+ @Length(max = TrainUtil.NUMBER_ONE_HUNDRED_AND_TWENTY_SEVEN, message = "数据集来源名称-输入长度不能超过127个字符")
+ private String dataSourceName;
+
+ @ApiModelProperty("运行参数(算法来源为我的算法时为调优参数,算法来源为预置算法时为运行参数)")
+ private JSONObject runParams;
+
+ @ApiModelProperty(value = "类型(0为CPU,1为GPU)", required = true)
+ @Min(value = TrainUtil.NUMBER_ZERO, message = "类型错误")
+ @Max(value = TrainUtil.NUMBER_ONE, message = "类型错误")
+ @NotNull(message = "类型(0为CPU,1为GPU)不能为空")
+ private Integer resourcesPoolType;
+
+ @ApiModelProperty(value = "规格类型Id", required = true)
+ @NotNull(message = "规格类型id不能为空")
+ @Min(value = TrainUtil.NUMBER_ONE, message = "规格类型id必须不小于1")
+ private Integer trainJobSpecsId;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainParamDeleteDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainParamDeleteDTO.java
new file mode 100644
index 0000000..b0635f2
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainParamDeleteDTO.java
@@ -0,0 +1,42 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.Set;
+
+/**
+ * @description 训练模板删除
+ * @date 2020-07-02
+ */
+@Data
+@Accessors(chain = true)
+public class PtTrainParamDeleteDTO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "id", required = true)
+ @NotNull(message = "id不能为空")
+ private Set ids;
+
+}
\ No newline at end of file
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainParamQueryDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainParamQueryDTO.java
new file mode 100644
index 0000000..c470f37
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainParamQueryDTO.java
@@ -0,0 +1,46 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.dubhe.base.PageQueryBase;
+import org.dubhe.utils.TrainUtil;
+import org.hibernate.validator.constraints.Length;
+
+import java.io.Serializable;
+
+/**
+ * @description 任务参数查询条件
+ * @date 2020-4-27
+ */
+@Data
+@Accessors(chain = true)
+public class PtTrainParamQueryDTO extends PageQueryBase implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("任务参数名称,输入长度不能超过128个字符")
+ @Length(max = TrainUtil.NUMBER_ONE_HUNDRED_AND_TWENTY_EIGHT, message = "任务参数名称-输入长度不能超过128个字符")
+ private String paramName;
+
+ @ApiModelProperty(value = "规格类型(0为CPU, 1为GPU)")
+ private Integer resourcesPoolType;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainParamUpdateDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainParamUpdateDTO.java
new file mode 100644
index 0000000..59675e0
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainParamUpdateDTO.java
@@ -0,0 +1,89 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import com.alibaba.fastjson.JSONObject;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.dubhe.base.BaseImageDTO;
+import org.dubhe.utils.TrainUtil;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.*;
+
+/**
+ * @description 任务参数修改条件
+ * @date 2020-04-27
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Accessors(chain = true)
+public class PtTrainParamUpdateDTO extends BaseImageDTO {
+
+ @ApiModelProperty(value = "任务参数id,任务参数id不能小于1", required = true)
+ @NotNull(message = "任务参数id不能为空")
+ @Min(value = TrainUtil.NUMBER_ONE, message = "任务参数id不能小于1")
+ private Long id;
+
+ @ApiModelProperty(value = "任务参数名称,输入长度不能超过32个字符", required = true)
+ @Length(max = TrainUtil.NUMBER_THIRTY_TWO, message = "任务参数名称-输入长度不能超过32个字符")
+ @NotBlank(message = "任务参数名称不能为空")
+ @Pattern(regexp = TrainUtil.REGEXP, message = "任务参数名称支持字母、数字、汉字、英文横杠和下划线")
+ private String paramName;
+
+ @ApiModelProperty("描述,输入长度不能超过256个字符")
+ @Length(max = TrainUtil.NUMBER_TWO_HUNDRED_AND_FIFTY_FIVE, message = "任务参数描述-输入长度不能超过256个字符")
+ private String description;
+
+ @ApiModelProperty(value = "算法id,算法id不能小于1", required = true)
+ @NotNull(message = "算法id不能为空")
+ @Min(value = TrainUtil.NUMBER_ONE, message = "算法id不能小于1")
+ private Long algorithmId;
+
+ @ApiModelProperty(value = "运行命令,输入长度不能超过128个字符", required = true)
+ @NotBlank(message = "运行命令不能为空")
+ @Length(max = TrainUtil.NUMBER_ONE_HUNDRED_AND_TWENTY_EIGHT, message = "运行命令-输入长度不能超过128个字符")
+ private String runCommand;
+
+ @ApiModelProperty(value = "数据集来源路径,输入长度不能超过127个字符", required = true)
+ @NotBlank(message = "数据集来源路径不能为空")
+ @Length(max = TrainUtil.NUMBER_ONE_HUNDRED_AND_TWENTY_SEVEN, message = "数据集来源路径-输入长度不能超过127个字符")
+ private String dataSourcePath;
+
+ @ApiModelProperty(value = "数据集来源名称,输入长度不能超过127个字符", required = true)
+ @NotBlank(message = "数据集来源名称不能为空")
+ @Length(max = TrainUtil.NUMBER_ONE_HUNDRED_AND_TWENTY_SEVEN, message = "数据集来源名称-输入长度不能超过127个字符")
+ private String dataSourceName;
+
+ @ApiModelProperty("运行参数(算法来源为我的算法时为调优参数,算法来源为预置算法时为运行参数)")
+ private JSONObject runParams;
+
+ @ApiModelProperty(value = "类型(0为CPU,1为GPU)", required = true)
+ @Min(value = TrainUtil.NUMBER_ZERO, message = "类型错误")
+ @Max(value = TrainUtil.NUMBER_ONE, message = "类型错误")
+ @NotNull(message = "类型(0为CPU,1为GPU)不能为空")
+ private Integer resourcesPoolType;
+
+ @ApiModelProperty(value = "规格类型Id", required = true)
+ @NotNull(message = "规格类型id不能为空")
+ @Min(value = TrainUtil.NUMBER_ONE, message = "规格类型id必须不小于1")
+ private Integer trainJobSpecsId;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainQueryDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainQueryDTO.java
new file mode 100644
index 0000000..f50746d
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/PtTrainQueryDTO.java
@@ -0,0 +1,50 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.dubhe.base.PageQueryBase;
+import org.dubhe.utils.TrainUtil;
+import org.hibernate.validator.constraints.Length;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import java.io.Serializable;
+
+/**
+ * @description 查询训练
+ * @date 2020-04-27
+ */
+@Data
+@Accessors(chain = true)
+public class PtTrainQueryDTO extends PageQueryBase implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("训练作业名称或者id")
+ @Length(max = TrainUtil.NUMBER_THIRTY_TWO, message = "训练作业名称或者id有误")
+ private String trainName;
+
+ @ApiModelProperty("训练作业job状态, 0为待处理,1为运行中,2为运行完成,3为失败,4为停止,5为未知,6为删除,7为创建失败")
+ @Min(value = TrainUtil.NUMBER_ZERO, message = "trainStatus错误")
+ @Max(value = TrainUtil.NUMBER_SEVEN, message = "trainStatus错误")
+ private Integer trainStatus;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/SourceNoteBookDTO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/SourceNoteBookDTO.java
new file mode 100644
index 0000000..eff7890
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/dto/SourceNoteBookDTO.java
@@ -0,0 +1,46 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @description 第三方创建NoteBook请求对象
+ *
+ * @date 2020.05.15
+ */
+@Data
+public class SourceNoteBookDTO implements Serializable {
+
+ @ApiModelProperty("第三方源主键")
+ @NotNull
+ private Long sourceId;
+
+ @ApiModelProperty("第三方源资源路径")
+ @NotBlank
+ private String sourceFilePath;
+
+ @ApiModelProperty(value = "当前登录人", hidden = true)
+ private Long curUserId;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/NoteBook.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/NoteBook.java
new file mode 100644
index 0000000..2d822a9
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/NoteBook.java
@@ -0,0 +1,202 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.*;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @description note book 实体
+ * @date 2020-04-28
+ */
+@Data
+@TableName("notebook")
+public class NoteBook implements Serializable {
+
+ @TableId(value = "id", type = IdType.AUTO)
+ @ApiModelProperty(hidden = true)
+ private Long id;
+
+ @TableField(value = "user_id")
+ @ApiModelProperty(hidden = true)
+ private Long userId;
+
+ @TableField(value = "name")
+ @JsonIgnore
+ private String name;
+
+ @TableField(value = "notebook_name")
+ private String noteBookName;
+
+ @TableField(value = "description")
+ private String description;
+
+ @TableField(value = "url")
+ @ApiModelProperty(hidden = true)
+ private String url;
+
+ @TableField(value = "total_run_min")
+ @ApiModelProperty(hidden = true)
+ private Integer totalRunMin;
+
+ @TableField(value = "cpu_num")
+ @ApiModelProperty(value = "cpu数量")
+ private Integer cpuNum;
+
+ @TableField(value = "gpu_num")
+ @ApiModelProperty(value = "gpu数量")
+ private Integer gpuNum;
+
+ @TableField(value = "mem_num")
+ @ApiModelProperty(value = "内存大小")
+ private Integer memNum;
+
+ @TableField(value = "disk_mem_num")
+ @ApiModelProperty(value = "硬盘内存大小")
+ private Integer diskMemNum;
+
+ /**
+ * 0运行中,1停止, 2删除, 3启动中,4停止中,5删除中,6运行异常(暂未启用)
+ */
+ @TableField(value = "status")
+ @ApiModelProperty(hidden = true)
+ private Integer status;
+
+ @TableField(value = "last_start_time")
+ @ApiModelProperty(hidden = true)
+ private Date lastStartTime;
+
+ @TableField(value = "last_operation_timeout")
+ @ApiModelProperty(hidden = true)
+ private Long lastOperationTimeout;
+
+ /**
+ * 0 - notebook 创建 1- 其它系统创建
+ */
+ @TableField(value = "create_resource")
+ @ApiModelProperty(hidden = true)
+ private Integer createResource;
+
+ @TableField(value = "k8s_status_code")
+ @ApiModelProperty(hidden = true)
+ private String k8sStatusCode;
+
+ @TableField(value = "k8s_status_info")
+ @ApiModelProperty(hidden = true)
+ private String k8sStatusInfo;
+
+ @TableField(value = "k8s_namespace")
+ @ApiModelProperty(hidden = true)
+ private String k8sNamespace;
+
+ @TableField(value = "k8s_resource_name")
+ @ApiModelProperty(hidden = true)
+ private String k8sResourceName;
+
+ @TableField(value = "k8s_image_name")
+ @ApiModelProperty("镜像名称")
+ @NotNull(message = "请选择镜像")
+ private String k8sImageName;
+
+ @TableField(value = "k8s_mount_path")
+ @ApiModelProperty(hidden = true)
+ private String k8sMountPath;
+
+ @TableField(value = "k8s_pvc_path")
+ @ApiModelProperty(hidden = true)
+ private String k8sPvcPath;
+
+ @TableField(value = "create_time")
+ @ApiModelProperty(hidden = true)
+ private Date createTime;
+
+ @TableField(value = "create_user_id")
+ @ApiModelProperty(hidden = true)
+ private Long createUserId;
+
+ @TableField(value = "update_time")
+ @ApiModelProperty(hidden = true)
+ private Date updateTime;
+
+ @TableField(value = "update_user_id")
+ @ApiModelProperty(hidden = true)
+ private Long updateUserId;
+
+ @TableField(value = "deleted")
+ @ApiModelProperty(hidden = true)
+ private Integer deleted;
+
+ @TableField(value = "data_source_name")
+ @ApiModelProperty(hidden = true)
+ @Size(max = 255, message = "数据集名称超长")
+ private String dataSourceName;
+
+ @TableField(value = "data_source_path")
+ @Size(max = 255, message = "数据集路径超长")
+ @ApiModelProperty(hidden = true)
+ private String dataSourcePath;
+
+ @TableField(value = "algorithm_id")
+ @ApiModelProperty(hidden = true)
+ private Long algorithmId;
+
+ @Override
+ public String toString() {
+ return "NoteBook{" +
+ "id=" + id +
+ ", userId=" + userId +
+ ", name='" + name + '\'' +
+ ", noteBookName='" + noteBookName + '\'' +
+ ", description='" + description + '\'' +
+ ", url='" + url + '\'' +
+ ", totalRunMin=" + totalRunMin +
+ ", cpuNum=" + cpuNum +
+ ", gpuNum=" + gpuNum +
+ ", memNum=" + memNum +
+ ", diskMemNum=" + diskMemNum +
+ ", status=" + status +
+ ", lastStartTime=" + lastStartTime +
+ ", lastOperationTimeout=" + lastOperationTimeout +
+ ", createResource=" + createResource +
+ ", k8sStatusCode='" + k8sStatusCode + '\'' +
+ ", k8sStatusInfo='" + k8sStatusInfo + '\'' +
+ ", k8sNamespace='" + k8sNamespace + '\'' +
+ ", k8sResourceName='" + k8sResourceName + '\'' +
+ ", k8sImageName='" + k8sImageName + '\'' +
+ ", k8sMountPath='" + k8sMountPath + '\'' +
+ ", k8sPvcPath='" + k8sPvcPath + '\'' +
+ ", createTime=" + createTime +
+ ", createUserId=" + createUserId +
+ ", updateTime=" + updateTime +
+ ", updateUserId=" + updateUserId +
+ ", deleted=" + deleted +
+ ", dataSourceName='" + dataSourceName + '\'' +
+ ", dataSourcePath='" + dataSourcePath + '\'' +
+ ", algorithmId=" + algorithmId +
+ '}';
+ }
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/NoteBookModel.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/NoteBookModel.java
new file mode 100644
index 0000000..41fb51c
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/NoteBookModel.java
@@ -0,0 +1,61 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.dubhe.base.BaseEntity;
+
+/**
+ * @description notebook 模板
+ * @date 2020-06-01
+ */
+@Data
+@TableName("notebook_model")
+public class NoteBookModel extends BaseEntity {
+
+ @TableField(value = "model_type")
+ private String modelType;
+
+ @TableField(value = "cpu_num")
+ @ApiModelProperty("cpu数量")
+ private Integer cpuNum;
+
+ @TableField(value = "gpu_num")
+ @ApiModelProperty("gpu数量")
+ private Integer gpuNum;
+
+ @TableField(value = "mem_num")
+ @ApiModelProperty("内存大小")
+ private Integer memNum;
+
+ @TableField(value = "spec")
+ @ApiModelProperty("GPU规格")
+ private String spec;
+
+ @TableField(value = "disk_mem_num")
+ @ApiModelProperty("硬盘内存大小")
+ private Integer diskMemNum;
+
+ @TableField(value = "default_status")
+ @ApiModelProperty("默认值状态 0 - 非默认 1- 默认")
+ private Integer defaultStatus;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/PtImage.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/PtImage.java
new file mode 100644
index 0000000..cc64ce1
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/PtImage.java
@@ -0,0 +1,87 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.dubhe.base.BaseEntity;
+
+/**
+ * @description 镜像
+ * @date 2020-04-27
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Accessors(chain = true)
+@TableName(value = "pt_image")
+public class PtImage extends BaseEntity {
+
+ /**
+ * 主键
+ */
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ /**
+ * 镜像名称
+ */
+ @TableField(value = "image_name")
+ private String imageName;
+
+ /**
+ * 镜像地址
+ */
+ @TableField(value = "image_url")
+ private String imageUrl;
+
+ /**
+ * 镜像版本
+ */
+ @TableField(value = "image_tag")
+ private String imageTag;
+
+ /**
+ * 镜像描述
+ */
+ @TableField(value = "remark")
+ private String remark;
+
+ /**
+ * projectName
+ */
+ @TableField(value = "project_name")
+ private String projectName;
+
+ /**
+ * 镜像来源
+ */
+ @TableField(value = "image_resource")
+ private Integer imageResource;
+
+
+ /**
+ * 镜像状态
+ */
+ @TableField(value = "image_status")
+ private Integer imageStatus;
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/PtJobParam.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/PtJobParam.java
new file mode 100644
index 0000000..4cba152
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/PtJobParam.java
@@ -0,0 +1,101 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.entity;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.dubhe.base.BaseEntity;
+
+/**
+ * @description job运行参数及结果
+ * @date 2020-04-27
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Accessors(chain = true)
+@TableName(value = "pt_job_param", autoResultMap = true)
+public class PtJobParam extends BaseEntity {
+
+ /**
+ * 主键id
+ */
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ /**
+ * 训练作业jobId
+ */
+ @TableField(value = "train_job_id")
+ private Long trainJobId;
+
+ /**
+ * 算法来源id
+ */
+ @TableField(value = "algorithm_id")
+ private Long algorithmId;
+
+ /**
+ * 运行命令
+ */
+ @TableField(value = "run_command")
+ private String runCommand;
+
+ /**
+ * 镜像名称
+ */
+ @TableField(value = "image_name")
+ private String imageName;
+
+ /**
+ * 运行参数(算法来源为我的算法时为调优参数,算法来源为预置算法时为运行参数)
+ */
+ @TableField(value = "run_params", typeHandler = FastjsonTypeHandler.class)
+ private JSONObject runParams;
+
+ /**
+ * F1值
+ */
+ @TableField(value = "param_f1")
+ private String paramF1;
+
+ /**
+ * 召回率
+ */
+ @TableField(value = "param_callback")
+ private String paramCallback;
+
+ /**
+ * 精确率
+ */
+ @TableField(value = "param_precise")
+ private String paramPrecise;
+
+ /**
+ * 准确率
+ */
+ @TableField(value = "param_accuracy")
+ private String paramAccuracy;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/PtTrain.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/PtTrain.java
new file mode 100644
index 0000000..9f6251c
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/PtTrain.java
@@ -0,0 +1,68 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.dubhe.base.BaseEntity;
+
+/**
+ * @description 训练作业主
+ * @date 2020-04-27
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Accessors(chain = true)
+@TableName("pt_train")
+public class PtTrain extends BaseEntity {
+
+ /**
+ * 主键id
+ */
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ /**
+ * 训练作业名
+ */
+ @TableField(value = "train_name")
+ private String trainName;
+
+ /**
+ * 训练作业名
+ */
+ @TableField(value = "train_key")
+ private String trainKey;
+
+ /**
+ * 训练作业有效job版本数量
+ */
+ @TableField(value = "version_num")
+ private Integer versionNum;
+
+ /**
+ * 训练作业job总版本数量
+ */
+ @TableField(value = "total_num")
+ private Integer totalNum;
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/PtTrainAlgorithm.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/PtTrainAlgorithm.java
new file mode 100644
index 0000000..8f1f6b4
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/PtTrainAlgorithm.java
@@ -0,0 +1,129 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.entity;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.dubhe.base.BaseEntity;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @description 算法
+ * @date 2020-04-29
+ */
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@TableName(value = "pt_train_algorithm", autoResultMap = true)
+@Accessors(chain = true)
+public class PtTrainAlgorithm extends BaseEntity {
+
+ /**
+ * 主键
+ */
+ @TableId(value = "id", type = IdType.AUTO)
+ @NotNull(groups = {Update.class})
+ private Long id;
+
+ /**
+ * 算法名称
+ */
+ @TableField(value = "algorithm_name")
+ private String algorithmName;
+
+ /**
+ * 算法描述
+ */
+ @TableField(value = "description")
+ private String description;
+
+ /**
+ * 算法来源(1为我的算法,2为预置算法)
+ */
+ @TableField(value = "algorithm_source")
+ private Integer algorithmSource;
+
+ /**
+ * 环境镜像名称
+ */
+ @TableField(value = "image_name")
+ private String imageName;
+
+ /**
+ * 代码目录
+ */
+ @TableField(value = "code_dir")
+ private String codeDir;
+
+ /**
+ * 运行命令
+ */
+ @TableField(value = "run_command")
+ private String runCommand;
+
+ /**
+ * 运行参数
+ */
+ @TableField(value = "run_params", typeHandler = FastjsonTypeHandler.class)
+ private JSONObject runParams;
+
+ /**
+ * 算法用途
+ */
+ @TableField(value = "algorithm_usage")
+ private String algorithmUsage;
+
+ /**
+ * 算法精度
+ */
+ @TableField(value = "accuracy")
+ private String accuracy;
+
+ /**
+ * P4推理速度(ms)
+ */
+ @TableField(value = "p4_inference_speed")
+ private Integer p4InferenceSpeed;
+
+ /**
+ * 输出结果(1是,0否)
+ */
+ @TableField(value = "is_train_out")
+ private Boolean isTrainOut;
+
+ /**
+ * 输出日志(1是,0否)
+ */
+ @TableField(value = "is_train_log")
+ private Boolean isTrainLog;
+
+ /**
+ * 可视化日志(1是,0否)
+ */
+ @TableField(value = "is_visualized_log")
+ private Boolean isVisualizedLog;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/PtTrainAlgorithmUsage.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/PtTrainAlgorithmUsage.java
new file mode 100644
index 0000000..9739e7a
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/PtTrainAlgorithmUsage.java
@@ -0,0 +1,74 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.dubhe.base.BaseEntity;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @description 算法
+ * @date 2020-06-23
+ */
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@TableName("pt_auxiliary_info")
+@Accessors(chain = true)
+public class PtTrainAlgorithmUsage extends BaseEntity {
+
+ /**
+ * 主键
+ */
+ @TableId(value = "id", type = IdType.AUTO)
+ @NotNull(groups = {Update.class})
+ private Long id;
+
+ /**
+ * 用户id
+ */
+ @TableField(value = "user_id")
+ private Long userId;
+
+ /**
+ * 类型
+ */
+ @TableField(value = "type")
+ private String type;
+
+ /**
+ * 算法来源(1为我的算法,2为预置算法)
+ */
+ @TableField(value = "aux_info")
+ private String auxInfo;
+
+ /**
+ * 是否为默认值(0否,1是默认值)
+ */
+ @TableField(value = "is_default")
+ private Boolean isDefault;
+
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/PtTrainJob.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/PtTrainJob.java
new file mode 100644
index 0000000..2e7f752
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/PtTrainJob.java
@@ -0,0 +1,148 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.dubhe.base.BaseEntity;
+
+/**
+ * @description 训练作业job
+ * @date 2020-04-27
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Accessors(chain = true)
+@TableName(value = "pt_train_job", autoResultMap = true)
+public class PtTrainJob extends BaseEntity {
+
+ /**
+ * 主键id
+ */
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ /**
+ * 训练作业id
+ */
+ @TableField(value = "train_id")
+ private Long trainId;
+
+ /**
+ * job版本
+ */
+ @TableField(value = "train_version")
+ private String trainVersion;
+
+ /**
+ * job父版本
+ */
+ @TableField(value = "parent_train_version")
+ private String parentTrainVersion;
+
+ /**
+ * 任务名称
+ */
+ @TableField(value = "job_name")
+ private String jobName;
+
+ /**
+ * 描述
+ */
+ @TableField(value = "description")
+ private String description;
+
+ /**
+ * 数据来源路径
+ */
+ @TableField(value = "data_source_path")
+ private String dataSourcePath;
+
+
+ /**
+ * 数据来源名称
+ */
+ @TableField(value = "data_source_name")
+ private String dataSourceName;
+
+ /**
+ * 训练时长
+ */
+ @TableField(value = "runtime")
+ private String runtime;
+
+ /**
+ * 训练输出位置
+ */
+ @TableField(value = "out_path")
+ private String outPath;
+
+ /**
+ * 作业日志路径
+ */
+ @TableField(value = "log_path")
+ private String logPath;
+
+ /**
+ * 规格Id
+ */
+ @TableField(value = "train_job_specs_id")
+ private Integer trainJobSpecsId;
+
+ /**
+ * 类型(0为CPU,1为GPU)
+ */
+ @TableField(value = "resources_pool_type")
+ private Integer resourcesPoolType;
+
+ /**
+ * 规格
+ */
+ @TableField(value = "resources_pool_specs")
+ private String resourcesPoolSpecs;
+
+ /**
+ * 节点个数
+ */
+ @TableField(value = "resources_pool_node")
+ private Integer resourcesPoolNode;
+
+ /**
+ * 训练作业job状态, 0为待处理,1为运行中,2为运行完成,3为失败,4为停止,5为未知,6为删除,7为创建失败
+ */
+ @TableField(value = "train_status")
+ private Integer trainStatus;
+
+ /**
+ * 可视化日志路径
+ */
+ @TableField(value = "visualized_log_path")
+ private String visualizedLogPath;
+
+ /**
+ * k8s返回的job名称
+ */
+ @TableField(value = "k8s_job_name")
+ private String k8sJobName;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/PtTrainJobSpecs.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/PtTrainJobSpecs.java
new file mode 100644
index 0000000..9ca2eae
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/PtTrainJobSpecs.java
@@ -0,0 +1,65 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.entity;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.dubhe.base.BaseEntity;
+
+/**
+ * @decription 训练作业规格
+ * @date 2020-05-06
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Accessors(chain = true)
+@TableName(value = "pt_train_job_specs", autoResultMap = true)
+public class PtTrainJobSpecs extends BaseEntity {
+
+ /**
+ * 主键id
+ */
+ @TableId(value = "id", type = IdType.AUTO)
+ private Integer id;
+
+ /**
+ * 规格名称
+ */
+ @TableField(value = "specs_name")
+ private String specsName;
+
+ /**
+ * 规格信息
+ */
+ @TableField(value = "specs_info", typeHandler = FastjsonTypeHandler.class)
+ private JSONObject specsInfo;
+
+ /**
+ * 规格类型
+ */
+ @TableField(value = "resources_pool_type")
+ private Integer resourcesPoolType;
+
+}
\ No newline at end of file
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/PtTrainParam.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/PtTrainParam.java
new file mode 100644
index 0000000..34543e6
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/entity/PtTrainParam.java
@@ -0,0 +1,130 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.entity;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.dubhe.base.BaseEntity;
+
+/**
+ * @descrption 任务参数
+ * @date 2020-04-27
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Accessors(chain = true)
+@TableName(value = "pt_train_param", autoResultMap = true)
+public class PtTrainParam extends BaseEntity {
+
+ /**
+ * 主键
+ */
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ /**
+ * 任务参数名称
+ */
+ @TableField(value = "param_name")
+ private String paramName;
+
+ /**
+ * 描述
+ */
+ @TableField(value = "description")
+ private String description;
+
+ /**
+ * 算法id
+ */
+ @TableField(value = "algorithm_id")
+ private Long algorithmId;
+
+ /**
+ * 运行命令
+ */
+ @TableField(value = "run_command")
+ private String runCommand;
+
+ /**
+ * 镜像名称
+ */
+ @TableField(value = "image_name")
+ private String imageName;
+
+ /**
+ * 数据集来源名称
+ */
+ @TableField(value = "data_source_name")
+ private String dataSourceName;
+
+ /**
+ * 数据集来源路径
+ */
+ @TableField(value = "data_source_path")
+ private String dataSourcePath;
+
+ /**
+ * 输出路径
+ */
+ @TableField(value = "out_path")
+ private String outPath;
+
+ /**
+ * 运行参数(算法来源为我的算法时为调优参数,算法来源为预置算法时为运行参数)
+ */
+ @TableField(value = "run_params", typeHandler = FastjsonTypeHandler.class)
+ private JSONObject runParams;
+
+ /**
+ * 算法来源(1为我的算法,2为预置算法)
+ */
+ @TableField(value = "algorithm_source")
+ private Integer algorithmSource;
+
+ /**
+ * 日志输出路径
+ */
+ @TableField(value = "log_path")
+ private String logPath;
+
+ /**
+ * 规格Id
+ */
+ @TableField(value = "train_job_specs_id")
+ private Integer trainJobSpecsId;
+
+ /**
+ * 类型(0为CPU,1为GPU)
+ */
+ @TableField(value = "resources_pool_type")
+ private Integer resourcesPoolType;
+
+ /**
+ * 节点个数
+ */
+ @TableField(value = "resources_pool_node")
+ private Integer resourcesPoolNode;
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/NoteBookVO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/NoteBookVO.java
new file mode 100644
index 0000000..65c1470
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/NoteBookVO.java
@@ -0,0 +1,115 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.vo;
+
+import cn.hutool.core.date.DatePattern;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.Size;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @description 返回前端请求体
+ * @create 2020/4/28
+ */
+@Data
+@ApiModel("NoteBookDTO 响应")
+public class NoteBookVO implements Serializable {
+
+ @ApiModelProperty("ID")
+ private Long id;
+
+ @ApiModelProperty("所属用户")
+ private Long userId;
+
+ @ApiModelProperty("NoteBook 名称")
+ @JsonIgnore
+ private String name;
+
+ @ApiModelProperty("NoteBook 名称")
+ private String noteBookName;
+
+ @ApiModelProperty("备注描述")
+ private String description;
+
+ @ApiModelProperty("可访问jupyter地址")
+ private String url;
+
+ @JsonIgnore
+ private Integer totalRunMin;
+
+ @ApiModelProperty("CPU数量")
+ private Integer cpuNum;
+
+ @ApiModelProperty("GPU数量")
+ private Integer gpuNum;
+
+ @ApiModelProperty("内存大小(G)")
+ private Integer memNum;
+
+ @ApiModelProperty("硬盘内存大小(G)")
+ private Integer diskMemNum;
+
+ @ApiModelProperty("0运行,1停止, 2删除, 3启动中,4停止中,5删除中,6运行异常(暂未启用)")
+ private Integer status;
+
+ @ApiModelProperty("k8s响应状态码")
+ private String k8sStatusCode;
+
+ @ApiModelProperty("k8s响应状态信息")
+ private String k8sStatusInfo;
+
+ @JsonIgnore
+ private String k8sNamespace;
+
+ @JsonIgnore
+ private String k8sResourceName;
+
+ private String k8sImageName;
+
+ @ApiModelProperty("k8s中pvc存储路径")
+ private String k8sPvcPath;
+
+ @JsonFormat(pattern = DatePattern.NORM_DATETIME_MS_PATTERN)
+ private Date createTime;
+
+ @JsonIgnore
+ private Long createUserId;
+
+ @JsonFormat(pattern = DatePattern.NORM_DATETIME_MS_PATTERN)
+ private Date updateTime;
+
+ @JsonIgnore
+ private Long updateUserId;
+
+ @ApiModelProperty("数据集名称")
+ private String dataSourceName;
+
+ @ApiModelProperty("数据集路径")
+ private String dataSourcePath;
+
+ @ApiModelProperty("算法ID")
+ private Long algorithmId;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtDoJobResultVO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtDoJobResultVO.java
new file mode 100644
index 0000000..9f7669f
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtDoJobResultVO.java
@@ -0,0 +1,40 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.vo;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * @description: doJob返回封装
+ * @Date:2020-07-03
+ */
+@Data
+@Accessors(chain = true)
+public class PtDoJobResultVO {
+ /**
+ * 返回是否成功
+ */
+ private Boolean isSuccess;
+
+ /**
+ * 返回k8s返回的JobName
+ */
+ private String k8sJobName;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtImageAndAlgorithmVO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtImageAndAlgorithmVO.java
new file mode 100644
index 0000000..124efdd
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtImageAndAlgorithmVO.java
@@ -0,0 +1,57 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * @description: 镜像
+ * @date 2020-04-27
+ */
+@Data
+@Accessors(chain = true)
+public class PtImageAndAlgorithmVO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("镜像名称")
+ private String imageName;
+
+ @ApiModelProperty("镜像地址")
+ private String imageUrl;
+
+ @ApiModelProperty("代码目录")
+ private String codeDir;
+
+ @ApiModelProperty("运行命令")
+ private String runCommand;
+
+ @ApiModelProperty("输出目录")
+ private Boolean isTrainOut;
+
+ @ApiModelProperty("输出日志")
+ private Boolean isTrainLog;
+
+ @ApiModelProperty("输出可视化日志")
+ private Boolean isVisualizedLog;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtImageQueryVO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtImageQueryVO.java
new file mode 100644
index 0000000..033a79b
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtImageQueryVO.java
@@ -0,0 +1,55 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+/**
+ * @description: 返回镜像查询结果
+ * @date: 2020-04-27
+ */
+@Data
+public class PtImageQueryVO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ @ApiModelProperty("镜像ID")
+ private Long id;
+
+ @ApiModelProperty("镜像项目名")
+ private String projectName;
+
+ @ApiModelProperty("镜像名称")
+ private String imageName;
+
+ @ApiModelProperty("镜像版本")
+ private String imageTag;
+
+ @ApiModelProperty("镜像状态(0:上传中,1:上传成功,2:上传失败)")
+ private Integer imageStatus;
+
+ @ApiModelProperty("备注")
+ private String remark;
+
+ @ApiModelProperty("创建时间")
+ private Timestamp createTime;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtJobMetricsGrafanaVO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtJobMetricsGrafanaVO.java
new file mode 100644
index 0000000..a367563
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtJobMetricsGrafanaVO.java
@@ -0,0 +1,36 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * @description Pod Metrics Grafana url
+ * @date 2020-06-30
+ */
+@Data
+@Accessors(chain = true)
+public class PtJobMetricsGrafanaVO implements Serializable {
+
+ @ApiModelProperty("job监控地址")
+ private String jobMetricsGrafanaUrl;
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainAlgorithmQueryVO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainAlgorithmQueryVO.java
new file mode 100644
index 0000000..cdb2278
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainAlgorithmQueryVO.java
@@ -0,0 +1,87 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.vo;
+
+import com.alibaba.fastjson.JSONObject;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+/**
+ * @description: 训练算法返回列表
+ * @date 2020-04-27
+ */
+@Data
+public class PtTrainAlgorithmQueryVO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "算法ID")
+ private Long id;
+
+ @ApiModelProperty(value = "算法名称")
+ private String algorithmName;
+
+ @ApiModelProperty(value = "描述信息")
+ private String description;
+
+ @ApiModelProperty(value = "算法来源")
+ private Integer algorithmSource;
+
+ @ApiModelProperty(value = "镜像名称")
+ private String imageName;
+
+ @ApiModelProperty(value = "镜像Project")
+ private String imageNameProject;
+
+ @ApiModelProperty(value = "镜像版本")
+ private String imageTag;
+
+ @ApiModelProperty(value = "代码目录")
+ private String codeDir;
+
+ @ApiModelProperty(value = "运行命令")
+ private String runCommand;
+
+ @ApiModelProperty(value = "运行参数")
+ private JSONObject runParams;
+
+ @ApiModelProperty(value = "算法用途")
+ private String algorithmUsage;
+
+ @ApiModelProperty(value = "精度")
+ private String accuracy;
+
+ @ApiModelProperty(value = "P4推理速度")
+ private Integer p4InferenceSpeed;
+
+ @ApiModelProperty(value = "创建时间")
+ private Timestamp createTime;
+
+ @ApiModelProperty(value = "输出结果(1是,0否)")
+ private Boolean isTrainOut;
+
+ @ApiModelProperty(value = "输出日志(1是,0否)")
+ private Boolean isTrainLog;
+
+ @ApiModelProperty(value = "可视化日志(1是,0否)")
+ private Boolean isVisualizedLog;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainAlgorithmUsageQueryVO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainAlgorithmUsageQueryVO.java
new file mode 100644
index 0000000..b5e7db9
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainAlgorithmUsageQueryVO.java
@@ -0,0 +1,59 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+/**
+ * @description: 算法用途返回列表
+ * @date 2020-06-23
+ */
+@Data
+public class PtTrainAlgorithmUsageQueryVO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "ID")
+ private Long id;
+
+ @ApiModelProperty(value = "用户ID")
+ private Long userId;
+
+ @ApiModelProperty(value = "类型")
+ private String type;
+
+ @ApiModelProperty(value = "辅助信息")
+ private String auxInfo;
+
+ @ApiModelProperty(value = "辅助信息")
+ private Boolean deleted;
+
+ @ApiModelProperty(value = "创建时间")
+ private Timestamp createTime;
+
+ @ApiModelProperty(value = "更新时间")
+ private Timestamp updateTime;
+
+ @ApiModelProperty(value = "是否为默认值")
+ private Boolean isDefault;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainDataSourceStatusQueryVO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainDataSourceStatusQueryVO.java
new file mode 100644
index 0000000..712b9eb
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainDataSourceStatusQueryVO.java
@@ -0,0 +1,45 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.Setter;
+
+import java.io.Serializable;
+
+/**
+ * @description: 查询数据集状态查询结果
+ * @date: 2020-05-21
+ */
+@Data
+@Setter
+public class PtTrainDataSourceStatusQueryVO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("数据集名称")
+ private String dataSourceName;
+
+ @ApiModelProperty("数据集路径")
+ private String dataSourcePath;
+
+ @ApiModelProperty("数据集状态(true为当前没有训练在使用,可以删除;false为有训练使用,不可以删除)")
+ private Boolean status;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainJobDeleteVO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainJobDeleteVO.java
new file mode 100644
index 0000000..1a03ee0
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainJobDeleteVO.java
@@ -0,0 +1,40 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @description: 返回删除训练任务结果
+ * @date: 2020-04-28
+ */
+@Data
+public class PtTrainJobDeleteVO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("trainID,如果只传递trainID,代表删除该trainID下的所有job")
+ private Long trainId;
+
+ @ApiModelProperty("训练作业jobID")
+ private Long id;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainJobDetailQueryVO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainJobDetailQueryVO.java
new file mode 100644
index 0000000..6228c3e
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainJobDetailQueryVO.java
@@ -0,0 +1,135 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.vo;
+
+import com.alibaba.fastjson.JSONObject;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+/**
+ * @description: 根据jobId查询训练任务详情返回结果
+ * @date: 2020-06-12
+ */
+@Data
+@Accessors(chain = true)
+public class PtTrainJobDetailQueryVO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("jobID")
+ private Long id;
+
+ @ApiModelProperty("训练作业ID")
+ private Long trainId;
+
+ @ApiModelProperty("训练作业job版本")
+ private String trainVersion;
+
+ @ApiModelProperty("训练作业job父版本")
+ private String parentTrainVersion;
+
+ @ApiModelProperty("训练作业jobName")
+ private String jobName;
+
+ @ApiModelProperty("描述信息")
+ private String description;
+
+ @ApiModelProperty("数据集名称")
+ private String dataSourceName;
+
+ @ApiModelProperty("数据集路径")
+ private String dataSourcePath;
+
+ @ApiModelProperty("训练时长")
+ private String runtime;
+
+ @ApiModelProperty("训练输出位置")
+ private String outPath;
+
+ @ApiModelProperty("日志输出路径")
+ private String logPath;
+
+ @ApiModelProperty("可视化日志路径")
+ private String visualizedLogPath;
+
+ @ApiModelProperty("规格ID")
+ private Integer trainJobSpecsId;
+
+ @ApiModelProperty("类型(0为CPU,1为GPU)")
+ private Integer resourcesPoolType;
+
+ @ApiModelProperty("节点个数")
+ private Integer resourcesPoolNode;
+
+ @ApiModelProperty("训练作业job状态, 0为待处理,1为运行中,2为运行完成,3为失败,4为停止,5为未知,6为删除,7为创建失败")
+ private Integer trainStatus;
+
+ @ApiModelProperty("创建时间")
+ private Timestamp createTime;
+
+ @ApiModelProperty("算法ID")
+ private Long algorithmId;
+
+ @ApiModelProperty("镜像名称")
+ private String imageName;
+
+ @ApiModelProperty(value = "镜像Project")
+ private String imageNameProject;
+
+ @ApiModelProperty(value = "镜像版本")
+ private String imageTag;
+
+ @ApiModelProperty("运行命令,输入长度不能超过128个字符")
+ private String runCommand;
+
+ @ApiModelProperty("运行参数(算法来源为我的算法时为调优参数,算法来源为预置算法时为运行参数)")
+ private JSONObject runParams;
+
+ @ApiModelProperty("F1值")
+ private String paramF1;
+
+ @ApiModelProperty("召回率")
+ private String paramCallback;
+
+ @ApiModelProperty("精确率")
+ private String paramPrecise;
+
+ @ApiModelProperty("准确率")
+ private String paramAccuracy;
+
+ @ApiModelProperty("算法名称")
+ private String algorithmName;
+
+ @ApiModelProperty("算法来源(1为我的算法,2为预置算法)")
+ private Integer algorithmSource;
+
+ @ApiModelProperty("算法用途")
+ private String algorithmUsage;
+
+ @ApiModelProperty("算法精度")
+ private String accuracy;
+
+ @ApiModelProperty("P4推理速度(ms)")
+ private Integer p4InferenceSpeed;
+
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainJobDetailVO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainJobDetailVO.java
new file mode 100644
index 0000000..29987c6
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainJobDetailVO.java
@@ -0,0 +1,137 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.vo;
+
+import com.alibaba.fastjson.JSONObject;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+/**
+ * @description: 返回训练版本查询详情
+ * @date 2020-04-27
+ */
+@Data
+@Accessors(chain = true)
+public class PtTrainJobDetailVO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("训练作业名")
+ private String trainName;
+
+ @ApiModelProperty("jobID")
+ private Long id;
+
+ @ApiModelProperty("训练作业ID")
+ private Long trainId;
+
+ @ApiModelProperty("训练作业job版本")
+ private String trainVersion;
+
+ @ApiModelProperty("训练作业job父版本")
+ private String parentTrainVersion;
+
+ @ApiModelProperty("训练作业jobName")
+ private String jobName;
+
+ @ApiModelProperty("描述信息")
+ private String description;
+
+ @ApiModelProperty("数据集名称")
+ private String dataSourceName;
+
+ @ApiModelProperty("数据集路径")
+ private String dataSourcePath;
+
+ @ApiModelProperty("训练时长")
+ private String runtime;
+
+ @ApiModelProperty("训练输出位置")
+ private String outPath;
+
+ @ApiModelProperty("日志输出路径")
+ private String logPath;
+
+ @ApiModelProperty("可视化日志路径")
+ private String visualizedLogPath;
+
+ @ApiModelProperty("规格ID")
+ private Integer trainJobSpecsId;
+
+ @ApiModelProperty("类型(0为CPU,1为GPU)")
+ private Integer resourcesPoolType;
+
+ @ApiModelProperty("节点个数")
+ private Integer resourcesPoolNode;
+
+ @ApiModelProperty("训练作业job状态, 0为待处理,1为运行中,2为运行完成,3为失败,4为停止,5为未知,6为删除,7为创建失败")
+ private Integer trainStatus;
+
+ @ApiModelProperty("创建时间")
+ private Timestamp createTime;
+
+ @ApiModelProperty("算法ID")
+ private Long algorithmId;
+
+ @ApiModelProperty("镜像名称")
+ private String imageName;
+
+ @ApiModelProperty(value = "镜像Project")
+ private String imageNameProject;
+
+ @ApiModelProperty(value = "镜像版本")
+ private String imageTag;
+
+ @ApiModelProperty("运行命令,输入长度不能超过128个字符")
+ private String runCommand;
+
+ @ApiModelProperty("运行参数(算法来源为我的算法时为调优参数,算法来源为预置算法时为运行参数)")
+ private JSONObject runParams;
+
+ @ApiModelProperty("F1值")
+ private String paramF1;
+
+ @ApiModelProperty("召回率")
+ private String paramCallback;
+
+ @ApiModelProperty("精确率")
+ private String paramPrecise;
+
+ @ApiModelProperty("准确率")
+ private String paramAccuracy;
+
+ @ApiModelProperty("算法名称")
+ private String algorithmName;
+
+ @ApiModelProperty("算法来源(1为我的算法,2为预置算法)")
+ private Integer algorithmSource;
+
+ @ApiModelProperty("算法用途")
+ private String algorithmUsage;
+
+ @ApiModelProperty("算法精度")
+ private String accuracy;
+
+ @ApiModelProperty("P4推理速度(ms)")
+ private Integer p4InferenceSpeed;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainJobSpecsQueryVO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainJobSpecsQueryVO.java
new file mode 100644
index 0000000..23b0bc1
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainJobSpecsQueryVO.java
@@ -0,0 +1,49 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.vo;
+
+import com.alibaba.fastjson.JSONObject;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * @description: 训练作业规格
+ * @date 2020-05-06
+ */
+@Data
+@Accessors(chain = true)
+public class PtTrainJobSpecsQueryVO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("训练作业规格ID")
+ private Integer id;
+
+ @ApiModelProperty("训练作业规格名称")
+ private String specsName;
+
+ @ApiModelProperty(value = "规格类型(0为CPU, 1为GPU)")
+ private Integer resourcesPoolType;
+
+ @ApiModelProperty(value = "规格信息")
+ private JSONObject specsInfo;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainJobStatisticsMineVO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainJobStatisticsMineVO.java
new file mode 100644
index 0000000..686e39e
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainJobStatisticsMineVO.java
@@ -0,0 +1,42 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @description: 我的训练任务统计
+ * @date: 2020-07-15
+ */
+@Data
+@ApiModel(description = "我的训练任务统计结果")
+public class PtTrainJobStatisticsMineVO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("运行中的任务")
+ private Integer runJobCount;
+
+ @ApiModelProperty("已经完成的任务")
+ private Integer finishJobCount;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainJobStopVO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainJobStopVO.java
new file mode 100644
index 0000000..f05900e
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainJobStopVO.java
@@ -0,0 +1,40 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @description: 返回停止训练任务结果
+ * @date: 2020-04-28
+ */
+@Data
+public class PtTrainJobStopVO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("trainID,如果只传递trainID,代表停止该trainID下的所有job")
+ private Long trainId;
+
+ @ApiModelProperty("训练作业jobID")
+ private Long id;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainLogQueryVO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainLogQueryVO.java
new file mode 100644
index 0000000..2409a48
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainLogQueryVO.java
@@ -0,0 +1,50 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.util.List;
+
+/**
+ * @description: 训练日志 查询VO
+ * @date 2020-05-08
+ */
+@Data
+@Accessors(chain = true)
+public class PtTrainLogQueryVO {
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("log内容")
+ private List content;
+
+ @ApiModelProperty(value = "任务名称")
+ private String jobName;
+
+ @ApiModelProperty(value = "起始行")
+ private Integer startLine;
+
+ @ApiModelProperty(value = "结束行")
+ private Integer endLine;
+
+ @ApiModelProperty(value = "lines")
+ private Integer lines;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainParamQueryVO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainParamQueryVO.java
new file mode 100644
index 0000000..0db9ef8
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainParamQueryVO.java
@@ -0,0 +1,86 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.vo;
+
+import com.alibaba.fastjson.JSONObject;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.dubhe.base.BaseVO;
+
+import java.io.Serializable;
+
+/**
+ * @description: 任务参数查询返回查询结果
+ * @date: 2020-04-27
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class PtTrainParamQueryVO extends BaseVO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("任务参数ID")
+ private Long id;
+
+ @ApiModelProperty("任务参数名称")
+ private String paramName;
+
+ @ApiModelProperty("描述")
+ private String description;
+
+ @ApiModelProperty("镜像名称")
+ private String imageName;
+
+ @ApiModelProperty(value = "镜像Project")
+ private String imageNameProject;
+
+ @ApiModelProperty(value = "镜像版本")
+ private String imageTag;
+
+ @ApiModelProperty("算法ID")
+ private Long algorithmId;
+
+ @ApiModelProperty("运行命令,输入长度不能超过128个字符")
+ private String runCommand;
+
+ @ApiModelProperty("算法名称")
+ private String algorithmName;
+
+ @ApiModelProperty("算法来源(1为我的算法,2为预置算法)")
+ private Integer algorithmSource;
+
+ @ApiModelProperty("数据来源路径")
+ private String dataSourcePath;
+
+ @ApiModelProperty("数据来源名称")
+ private String dataSourceName;
+
+ @ApiModelProperty("运行参数(算法来源为我的算法时为调优参数,算法来源为预置算法时为运行参数)")
+ private JSONObject runParams;
+
+ @ApiModelProperty("规格ID")
+ private Integer trainJobSpecsId;
+
+ @ApiModelProperty("类型(0为CPU,1为GPU)")
+ private Integer resourcesPoolType;
+
+ @ApiModelProperty("节点个数")
+ private Integer resourcesPoolNode;
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainVO.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainVO.java
new file mode 100644
index 0000000..910632e
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/domain/vo/PtTrainVO.java
@@ -0,0 +1,66 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.domain.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+/**
+ * @description: 训练查询结果
+ * @date 2020-04-27
+ */
+@Data
+@Accessors(chain = true)
+public class PtTrainVO implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty("训练作业jobID")
+ private Long jobId;
+
+ @ApiModelProperty("训练作业ID")
+ private Long trainId;
+
+ @ApiModelProperty("训练作业名")
+ private String trainName;
+
+ @ApiModelProperty("训练作业jobName")
+ private String jobName;
+
+ @ApiModelProperty("训练作业版本数")
+ private Integer versionNum;
+
+ @ApiModelProperty("训练时长")
+ private String runtime;
+
+ @ApiModelProperty("训练作业job状态, 0为待处理,1为运行中,2为运行完成,3为失败,4为停止,5为未知,6为删除,7为创建失败")
+ private Integer trainStatus;
+
+ @ApiModelProperty("创建时间")
+ private Timestamp createTime;
+
+ @ApiModelProperty("数据来源路径")
+ private String dataSourcePath;
+
+ @ApiModelProperty("数据来源名称")
+ private String dataSourceName;
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/enums/HarborResourceEnum.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/enums/HarborResourceEnum.java
new file mode 100644
index 0000000..445f5d2
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/enums/HarborResourceEnum.java
@@ -0,0 +1,51 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+package org.dubhe.enums;
+
+/**
+ * @description harbor镜像来源枚举
+ * @date 2020-07-16
+ */
+public enum HarborResourceEnum {
+
+ NOTEBOOK(0, "notebook预置"),
+ TRAIN(1, "train预置"),
+ TRAIN_SYNC(2, "train同步镜像");
+
+ /**
+ * 编码
+ */
+ private Integer code;
+
+ /**
+ * 描述
+ */
+ private String description;
+
+ HarborResourceEnum(Integer code, String description) {
+ this.code = code;
+ this.description = description;
+ }
+
+ public Integer getCode() {
+ return code;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/enums/ImageSourceEnum.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/enums/ImageSourceEnum.java
new file mode 100644
index 0000000..471bf71
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/enums/ImageSourceEnum.java
@@ -0,0 +1,50 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+package org.dubhe.enums;
+
+/**
+ * @description 镜像来源枚举类
+ * @date 2020-07-15
+ */
+public enum ImageSourceEnum {
+ MINE(0, "我的镜像"),
+ PRE(1, "预置镜像");
+
+
+ /**
+ * 编码
+ */
+ private Integer code;
+
+ /**
+ * 描述
+ */
+ private String description;
+
+ ImageSourceEnum(int code, String description) {
+ this.code = code;
+ this.description = description;
+ }
+
+ public Integer getCode() {
+ return code;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/enums/ImageStateEnum.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/enums/ImageStateEnum.java
new file mode 100644
index 0000000..127e747
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/enums/ImageStateEnum.java
@@ -0,0 +1,53 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.enums;
+
+/**
+ * @description 镜像运行状态枚举
+ * @date 2020-07-15
+ **/
+public enum ImageStateEnum {
+
+ MAKING(0, "制作中"),
+ SUCCESS(1, "制作成功"),
+ FAIL(2, "制作失败");
+
+
+ /**
+ * 编码
+ */
+ private Integer code;
+
+ /**
+ * 描述
+ */
+ private String description;
+
+ ImageStateEnum(int code, String description) {
+ this.code = code;
+ this.description = description;
+ }
+
+ public Integer getCode() {
+ return code;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/enums/NoteBookStatusEnum.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/enums/NoteBookStatusEnum.java
new file mode 100644
index 0000000..9ccc3f7
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/enums/NoteBookStatusEnum.java
@@ -0,0 +1,153 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.enums;
+
+
+import org.dubhe.base.MagicNumConstant;
+import org.dubhe.k8s.enums.PodPhaseEnum;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @description notebook 状态枚举
+ * @create 2020-4-28
+ */
+public enum NoteBookStatusEnum {
+ /**
+ * 运行
+ */
+ RUN(0, "运行中", 0),
+ /**
+ * 停止
+ */
+ STOP(1, "停止", 0),
+ /**
+ * 删除
+ */
+ DELETE(2, "删除", 0),
+ /**
+ * 启动中
+ */
+ STARTING(3, "启动中", 1),
+ /**
+ * 停止中
+ */
+ STOPPING(4, "停止中", 1),
+ /**
+ * 删除中
+ */
+ DELETING(5, "删除中", 1),
+ /**
+ * 运行异常
+ */
+ ERROR(6, "运行异常", 0);
+ /**
+ * 编码
+ */
+ private Integer code;
+ /**
+ * 描述
+ */
+ private String description;
+ /**
+ * 删除标识
+ */
+ private Integer deleteType;
+
+ public Integer getCode() {
+ return code;
+ }
+
+ public void setCode(Integer code) {
+ this.code = code;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Integer getDeleteType() {
+ return deleteType;
+ }
+
+ public void setDeleteType(Integer deleteType) {
+ this.deleteType = deleteType;
+ }
+
+ NoteBookStatusEnum(int code, String description, int deleteType) {
+ this.code = code;
+ this.description = description;
+ this.deleteType = deleteType;
+ }
+
+ public static String getDescription(Integer code) {
+ if (code != null) {
+ for (NoteBookStatusEnum en : NoteBookStatusEnum.values()) {
+ if (en.getCode().equals(code)) {
+ return en.getDescription();
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * k8s状态转换成NoteBook状态
+ * 当查询不到k8s状态时即为删除
+ *
+ * @param bizPodPhase
+ * @return
+ */
+ public static NoteBookStatusEnum convert(String bizPodPhase) {
+ if (bizPodPhase == null
+ || PodPhaseEnum.DELETED.getPhase().equals(bizPodPhase)
+ || PodPhaseEnum.FAILED.getPhase().equals(bizPodPhase)) {
+ return STOP;
+ } else if (PodPhaseEnum.PENDING.getPhase().equals(bizPodPhase)) {
+ return STARTING;
+ } else if (PodPhaseEnum.RUNNING.getPhase().equals(bizPodPhase)) {
+ return RUN;
+ } else if (PodPhaseEnum.SUCCEEDED.getPhase().equals(bizPodPhase)) {
+ return STOPPING;
+ } else {
+ return ERROR;
+ }
+ }
+
+
+ /**
+ * 查找可以删除的状态集合
+ *
+ * @return List
+ */
+ public static List getCanDeleteStatus() {
+ List list = new ArrayList<>();
+ for (NoteBookStatusEnum en : NoteBookStatusEnum.values()) {
+ if (en.getDeleteType().equals(MagicNumConstant.ONE)) {
+ list.add(en.getCode());
+ }
+ }
+ return list;
+ }
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/enums/ResourcesPoolTypeEnum.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/enums/ResourcesPoolTypeEnum.java
new file mode 100644
index 0000000..32a7640
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/enums/ResourcesPoolTypeEnum.java
@@ -0,0 +1,53 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+package org.dubhe.enums;
+
+/**
+ *@description 规格类型
+ *@date: 2020-07-15
+
+ */
+public enum ResourcesPoolTypeEnum {
+
+ CPU(0, "CPU"),
+ GPU(1, "GPU");
+
+
+ /**
+ * 编码
+ */
+ private Integer code;
+
+ /**
+ * 描述
+ */
+ private String description;
+
+ ResourcesPoolTypeEnum(int code, String description) {
+ this.code = code;
+ this.description = description;
+ }
+
+ public Integer getCode() {
+ return code;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/ForwardController.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/ForwardController.java
new file mode 100644
index 0000000..0043e36
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/ForwardController.java
@@ -0,0 +1,126 @@
+/** Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.rest;
+
+import cn.hutool.core.util.StrUtil;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.client.RestTemplate;
+
+import javax.servlet.http.HttpServletRequest;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ * @description 代理转发
+ * @date 2020-06-23
+ */
+
+@RestController
+public class ForwardController {
+ @Value("${dubhe-proxy.visual.keyword}")
+ private String visual;
+ @Value("${dubhe-proxy.visual.server}")
+ private String visualServer;
+ @Value("${dubhe-proxy.visual.port}")
+ private String visualPort;
+ @Value("${dubhe-proxy.refine.keyword}")
+ private String refine;
+ @Value("${dubhe-proxy.refine.server}")
+ private String refineServer;
+ @Value("${dubhe-proxy.refine.port}")
+ private String refinePort;
+
+ RestTemplate restTemplate = new RestTemplate();
+
+ /**
+ * 根据不同的请求拼上对应的转发路径
+ *
+ * @param request http请求
+ * @return URI 用于restTemplate的请求路径
+ **/
+ private URI getURI(HttpServletRequest request) throws URISyntaxException {
+ String requestURI = request.getRequestURI();
+ String server = null;
+ String prefix = "";
+ int port = 0;
+ if (requestURI.startsWith(StrUtil.SLASH + visual)) {
+ prefix = visual;
+ server = visualServer;
+ port = Integer.parseInt(visualPort);
+ } else if (requestURI.startsWith(StrUtil.SLASH + refine)) {
+ prefix = refine;
+ server = refineServer;
+ port = Integer.parseInt(refinePort);
+ }
+
+ return new URI("http", null, server, port, requestURI.substring(prefix.length() + 1), request.getQueryString(), null);
+ }
+
+ /**
+ * 获取请求中的Cookie
+ *
+ * @param request http请求
+ * @return HttpHeaders 用于restTemplate的header
+ **/
+ private HttpHeaders getHeader(HttpServletRequest request) {
+ String cookie = request.getHeader("Cookie");
+ HttpHeaders httpHeaders = new HttpHeaders();
+ if (null != cookie) {
+ httpHeaders.set("Cookie", cookie);
+ }
+ return httpHeaders;
+ }
+
+ /**
+ * 转发get请求
+ *
+ * @param request http请求
+ * @return ResponseEntity 返回给前端的响应实体
+ **/
+ @GetMapping({StrUtil.SLASH + "${dubhe-proxy.visual.keyword}" + StrUtil.SLASH + "**", StrUtil.SLASH + "${dubhe-proxy.refine.keyword}" + StrUtil.SLASH + "**"})
+ @ResponseBody
+ public ResponseEntity mirrorRest(HttpServletRequest request) throws URISyntaxException {
+ URI uri = getURI(request);
+ HttpHeaders httpHeaders = getHeader(request);
+ ResponseEntity responseEntity =
+ restTemplate.exchange(uri, HttpMethod.GET, new HttpEntity(httpHeaders), String.class);
+ return responseEntity;
+ }
+
+ /**
+ * 转发get请求
+ *
+ * @param request http请求
+ * @param method 请求方法
+ * @param body 请求体
+ * @return ResponseEntity 返回给前端的响应实体
+ **/
+ @RequestMapping({StrUtil.SLASH + "${dubhe-proxy.visual.keyword}" + StrUtil.SLASH + "**", StrUtil.SLASH + "${dubhe-proxy.refine.keyword}" + StrUtil.SLASH + "**"})
+ @ResponseBody
+ public ResponseEntity mirrorRest(HttpMethod method, HttpServletRequest request, @RequestBody String body) throws URISyntaxException {
+ URI uri = getURI(request);
+ HttpHeaders httpHeaders = getHeader(request);
+ ResponseEntity responseEntity =
+ restTemplate.exchange(uri, method, new HttpEntity(body, httpHeaders), String.class);
+ return responseEntity;
+ }
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/K8sCallbackPodController.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/K8sCallbackPodController.java
new file mode 100644
index 0000000..87f05f4
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/K8sCallbackPodController.java
@@ -0,0 +1,82 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.rest;
+
+import javax.annotation.Resource;
+
+import org.dubhe.base.DataResponseBody;
+import org.dubhe.factory.DataResponseFactory;
+import org.dubhe.dto.callback.AlgorithmK8sPodCallbackCreateDTO;
+import org.dubhe.dto.callback.NotebookK8sPodCallbackCreateDTO;
+import org.dubhe.service.PodCallbackAsyncService;
+import org.dubhe.utils.K8sCallBackTool;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+
+/**
+ * @description k8s Pod 异步回调处理类
+ *
+ * @date 2020-05-28
+ */
+@Api(tags = "k8s回调:Pod")
+@RestController
+@RequestMapping("/api/k8s/callback/pod")
+public class K8sCallbackPodController {
+
+ @Resource(name = "noteBookAsyncServiceImpl")
+ private PodCallbackAsyncService noteBookAsyncService;
+ @Resource(name = "algorithmAsyncServiceImpl")
+ private PodCallbackAsyncService algorithmAsyncServiceImpl;
+
+ /**
+ * notebook异步回调
+ *
+ * @param k8sToken
+ * @param k8sPodCallbackReq
+ * @return
+ */
+ @PostMapping(value = "/notebook")
+ @ApiOperation("模型管理 pod 回调")
+ public DataResponseBody notebookPodCallBack(@ApiParam(type = "head") @RequestHeader(name= K8sCallBackTool.K8S_CALLBACK_TOKEN) String k8sToken
+ ,@Validated @RequestBody NotebookK8sPodCallbackCreateDTO k8sPodCallbackReq) {
+ noteBookAsyncService.podCallBack(k8sPodCallbackReq);
+ return DataResponseFactory.success("notebook正在异步处理pod中。");
+ }
+
+
+ /**
+ * algorithm异步回调
+ *
+ * @param k8sToken
+ * @param k8sPodCallbackReq
+ * @return
+ */
+ @PostMapping(value = "/algorithm")
+ @ApiOperation("算法管理 pod 回调")
+ public DataResponseBody notebookPodCallBack(@ApiParam(type = "head") @RequestHeader(name= K8sCallBackTool.K8S_CALLBACK_TOKEN) String k8sToken
+ ,@Validated @RequestBody AlgorithmK8sPodCallbackCreateDTO k8sPodCallbackReq) {
+ algorithmAsyncServiceImpl.podCallBack(k8sPodCallbackReq);
+ return DataResponseFactory.success("算法管理异步回调处理方法中");
+ }
+
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/NoteBookController.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/NoteBookController.java
new file mode 100644
index 0000000..1076cc7
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/NoteBookController.java
@@ -0,0 +1,163 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.rest;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.*;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.dubhe.base.DataResponseBody;
+import org.dubhe.base.ResponseCode;
+import org.dubhe.constant.Permissions;
+import org.dubhe.domain.entity.NoteBook;
+import org.dubhe.domain.dto.NoteBookListQueryDTO;
+import org.dubhe.domain.dto.SourceNoteBookDTO;
+import org.dubhe.domain.dto.NoteBookCreateDTO;
+import org.dubhe.enums.BizNfsEnum;
+import org.dubhe.factory.DataResponseFactory;
+import org.dubhe.service.NoteBookService;
+import org.dubhe.utils.NotebookUtil;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @description notebook controller
+ * @date 2020-04-27
+ */
+@Api(tags = "模型开发:Notebook")
+@RestController
+@RequestMapping("/api/{version}/notebook")
+public class NoteBookController {
+
+ @Autowired
+ private NoteBookService noteBookService;
+
+ @ApiOperation("新增加notebook")
+ @PostMapping(value = "/notebooks")
+ @RequiresPermissions(Permissions.DEVELOPMENT_NOTEBOOK)
+ public DataResponseBody createNoteBook(@Validated @RequestBody NoteBookCreateDTO noteBookCreateDTO) {
+ long userId = NotebookUtil.getCurUserId();
+ NoteBook noteBook = new NoteBook();
+ BeanUtils.copyProperties(noteBookCreateDTO, noteBook);
+ noteBook.setCreateUserId(userId);
+ noteBook.setUserId(userId);
+ noteBook.setCreateResource(BizNfsEnum.NOTEBOOK.getCreateResource());
+ return new DataResponseBody(noteBookService.createNoteBook(noteBook));
+ }
+
+ @ApiOperation("查询notebook")
+ @GetMapping(value = "/notebooks")
+ @RequiresPermissions(Permissions.DEVELOPMENT_NOTEBOOK)
+ public DataResponseBody getNoteBookList(Page page, NoteBookListQueryDTO noteBookListQueryDTO) {
+ noteBookListQueryDTO.setUserId(NotebookUtil.getCurUserId());
+ return new DataResponseBody(noteBookService.getNoteBookList(page, noteBookListQueryDTO));
+ }
+
+ @ApiOperation("异步批量删除notebook")
+ @DeleteMapping
+ @RequiresPermissions(Permissions.DEVELOPMENT_NOTEBOOK)
+ public DataResponseBody deleteNoteBook(@RequestBody Set noteBookIds) {
+ List noteBookList = noteBookService.validateDeleteNoteBook(noteBookIds);
+ noteBookService.deleteNoteBooks(noteBookList);
+ return new DataResponseBody(ResponseCode.SUCCESS, "正在异步删除NoteBook中..");
+ }
+
+ @ApiOperation("启动notebook")
+ @PutMapping(value = "/start")
+ @RequiresPermissions(Permissions.DEVELOPMENT_NOTEBOOK)
+ public DataResponseBody startNotebook(@RequestParam(required = true) Long noteBookId) {
+ String resultInfo = noteBookService.startNoteBook(noteBookId);
+ return new DataResponseBody(
+ NotebookUtil.validateFailedInfo(resultInfo) ? ResponseCode.ERROR : ResponseCode.SUCCESS
+ , resultInfo);
+ }
+
+ @ApiOperation("停止notebook")
+ @PutMapping(value = "/stop")
+ @RequiresPermissions(Permissions.DEVELOPMENT_NOTEBOOK)
+ public DataResponseBody stopNotebook(@RequestParam(required = true) Long noteBookId) {
+ String resultInfo = noteBookService.stopNoteBook(noteBookId);
+ return new DataResponseBody(
+ NotebookUtil.validateFailedInfo(resultInfo) ? ResponseCode.ERROR : ResponseCode.SUCCESS
+ , resultInfo);
+ }
+
+
+ @ApiOperation("开启notebook")
+ @GetMapping(value = "/{id}")
+ @RequiresPermissions(Permissions.DEVELOPMENT_NOTEBOOK)
+ public DataResponseBody openNotebook(@PathVariable(name = "id", required = true) Long noteBookId) {
+ return DataResponseFactory.success("获取成功", noteBookService.openNoteBook(noteBookId));
+ }
+
+
+ @ApiOperation("第三方业务创建notebook")
+ @PostMapping(value = "/create/{source}")
+ @RequiresPermissions(Permissions.DEVELOPMENT_NOTEBOOK)
+ public DataResponseBody createByThirdParty(@PathVariable int source, @Validated @RequestBody SourceNoteBookDTO sourceNoteBookDTO) {
+ BizNfsEnum bizNfsEnum = BizNfsEnum.getByCreateResource(source);
+ if (bizNfsEnum == null || BizNfsEnum.NOTEBOOK == bizNfsEnum) {
+ return new DataResponseBody(ResponseCode.BADREQUEST, "不支持该渠道创建Notebook!");
+ }
+ sourceNoteBookDTO.setCurUserId(NotebookUtil.getCurUserId());
+ return DataResponseFactory.success("操作成功", noteBookService.createNoteBookByThirdParty(bizNfsEnum, sourceNoteBookDTO));
+ }
+
+ @ApiOperation("获取编辑地址")
+ @GetMapping(value = "/{id}/get-address")
+ @RequiresPermissions(Permissions.DEVELOPMENT_NOTEBOOK)
+ public DataResponseBody getAddress(@PathVariable(name = "id", required = true) Long noteBookId) {
+ return new DataResponseBody(noteBookService.getAddress(noteBookId));
+ }
+
+ @ApiOperation("获取状态")
+ @GetMapping(value = "/status")
+ @RequiresPermissions(Permissions.DEVELOPMENT_NOTEBOOK)
+ public DataResponseBody getNoteBookStatus() {
+ return new DataResponseBody(noteBookService.getNoteBookStatus());
+ }
+
+
+ @ApiOperation("获取正在运行的notebook数量")
+ @GetMapping(value = "/run-number")
+ @RequiresPermissions(Permissions.DEVELOPMENT_NOTEBOOK)
+ public DataResponseBody getNoteBookRunNumber() {
+ return new DataResponseBody(noteBookService.getNoteBookRunNumber(NotebookUtil.getCurUserId()));
+ }
+
+
+ @ApiOperation("获取notebook模板")
+ @GetMapping(value = "/notebook-model")
+ @RequiresPermissions(Permissions.DEVELOPMENT_NOTEBOOK)
+ public DataResponseBody getNoteBookModel() {
+ return new DataResponseBody(noteBookService.getNoteBookModel());
+ }
+
+
+ @ApiOperation("获取notebook详情")
+ @PostMapping(value = "/detail")
+ @RequiresPermissions(Permissions.DEVELOPMENT_NOTEBOOK)
+ public DataResponseBody getNotebookDetail(@RequestBody Set noteBookIds) {
+ return new DataResponseBody(noteBookService.getNotebookDetail(noteBookIds));
+ }
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtDatasetController.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtDatasetController.java
new file mode 100644
index 0000000..486e34c
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtDatasetController.java
@@ -0,0 +1,89 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.rest;
+
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.dubhe.base.DataResponseBody;
+import org.dubhe.domain.PtDataset;
+import org.dubhe.domain.dto.PtDatasetQueryCriteria;
+import org.dubhe.service.PtDatasetService;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import springfox.documentation.annotations.ApiIgnore;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @description dataset管理
+ * @date 2020-03-17
+ */
+@Api(tags = "dataset管理")
+@ApiIgnore
+@RestController
+@RequestMapping("/api/{version}/pt_dataset")
+public class PtDatasetController {
+
+ private final PtDatasetService ptDatasetService;
+
+ public PtDatasetController(PtDatasetService ptDatasetService) {
+ this.ptDatasetService = ptDatasetService;
+ }
+
+
+ @ApiOperation("导出数据")
+ @GetMapping(value = "/download")
+ @PreAuthorize("@el.check('ptDataset:list')")
+ public void download(HttpServletResponse response, PtDatasetQueryCriteria criteria) throws IOException {
+ ptDatasetService.download(ptDatasetService.queryAll(criteria), response);
+ }
+
+ @GetMapping
+ @ApiOperation("查询dataset")
+ @PreAuthorize("@el.check('ptDataset:list')")
+ public DataResponseBody getPtDatasets(PtDatasetQueryCriteria criteria, Page page) {
+ return new DataResponseBody(ptDatasetService.queryAll(criteria, page));
+ }
+
+ @PostMapping
+ @ApiOperation("新增dataset")
+ @PreAuthorize("@el.check('ptDataset:add')")
+ public DataResponseBody create(@Validated @RequestBody PtDataset resources) {
+ return new DataResponseBody(ptDatasetService.create(resources));
+ }
+
+ @PutMapping
+ @ApiOperation("修改dataset")
+ @PreAuthorize("@el.check('ptDataset:edit')")
+ public DataResponseBody update(@Validated @RequestBody PtDataset resources) {
+ ptDatasetService.update(resources);
+ return new DataResponseBody();
+ }
+
+ @ApiOperation("删除dataset")
+ @PreAuthorize("@el.check('ptDataset:del')")
+ @DeleteMapping
+ public DataResponseBody deleteAll(@RequestBody Long[] ids) {
+ ptDatasetService.deleteAll(ids);
+ return new DataResponseBody();
+ }
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtDevEnvsController.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtDevEnvsController.java
new file mode 100644
index 0000000..620d167
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtDevEnvsController.java
@@ -0,0 +1,88 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.rest;
+
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.dubhe.base.DataResponseBody;
+import org.dubhe.domain.PtDevEnvs;
+import org.dubhe.domain.dto.PtDevEnvsQueryCriteria;
+import org.dubhe.service.PtDevEnvsService;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import springfox.documentation.annotations.ApiIgnore;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @description devEnvs管理
+ * @date 2020-03-17
+ */
+@Api(tags = "devEnvs管理")
+@ApiIgnore
+@RestController
+@RequestMapping("/api/{version}/pt_ev_envs")
+public class PtDevEnvsController {
+
+ private final PtDevEnvsService ptDevEnvsService;
+
+ public PtDevEnvsController(PtDevEnvsService ptDevEnvsService) {
+ this.ptDevEnvsService = ptDevEnvsService;
+ }
+
+ @ApiOperation("导出数据")
+ @GetMapping(value = "/download")
+ @PreAuthorize("@el.check('ptDevEnvs:list')")
+ public void download(HttpServletResponse response, PtDevEnvsQueryCriteria criteria) throws IOException {
+ ptDevEnvsService.download(ptDevEnvsService.queryAll(criteria), response);
+ }
+
+ @GetMapping
+ @ApiOperation("查询devEnvs")
+ @PreAuthorize("@el.check('ptDevEnvs:list')")
+ public DataResponseBody getPtDevEnvss(PtDevEnvsQueryCriteria criteria, Page page) {
+ return new DataResponseBody(ptDevEnvsService.queryAll(criteria, page));
+ }
+
+ @PostMapping
+ @ApiOperation("新增devEnvs")
+ @PreAuthorize("@el.check('ptDevEnvs:add')")
+ public DataResponseBody create(@Validated @RequestBody PtDevEnvs resources) {
+ return new DataResponseBody(ptDevEnvsService.create(resources));
+ }
+
+ @PutMapping
+ @ApiOperation("修改devEnvs")
+ @PreAuthorize("@el.check('ptDevEnvs:edit')")
+ public DataResponseBody update(@Validated @RequestBody PtDevEnvs resources) {
+ ptDevEnvsService.update(resources);
+ return new DataResponseBody();
+ }
+
+ @ApiOperation("删除devEnvs")
+ @PreAuthorize("@el.check('ptDevEnvs:del')")
+ @DeleteMapping
+ public DataResponseBody deleteAll(@RequestBody Long[] ids) {
+ ptDevEnvsService.deleteAll(ids);
+ return new DataResponseBody();
+ }
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtImageController.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtImageController.java
new file mode 100644
index 0000000..792b32d
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtImageController.java
@@ -0,0 +1,74 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.rest;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.dubhe.annotation.ApiVersion;
+import org.dubhe.base.DataResponseBody;
+import org.dubhe.constant.Permissions;
+import org.dubhe.domain.dto.PtImageQueryDTO;
+import org.dubhe.domain.dto.PtImageUploadDTO;
+import org.dubhe.service.PtImageService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @description 镜像
+ * @date 2020-04-27
+ */
+@Api(tags = "镜像:镜像管理")
+@RestController
+@ApiVersion(1)
+@RequestMapping("/api/{version}/ptImage")
+public class PtImageController {
+
+ @Autowired
+ private PtImageService ptImageService;
+
+ @GetMapping("/info")
+ @ApiOperation("查询镜像")
+ @RequiresPermissions(Permissions.TRAINING_IMAGE)
+ public DataResponseBody getImage(PtImageQueryDTO ptImageQueryDTO) {
+ return new DataResponseBody(ptImageService.getImage(ptImageQueryDTO));
+ }
+
+ @ApiOperation("通过projectName查询镜像")
+ @GetMapping
+ @RequiresPermissions(Permissions.TRAINING_IMAGE)
+ public DataResponseBody getTagsByImageName(@RequestParam String imageName) {
+ return new DataResponseBody(ptImageService.searchImages(imageName));
+ }
+
+ @PostMapping("uploadImage")
+ @ApiOperation("上传镜像包到harbor")
+ @RequiresPermissions(Permissions.TRAINING_IMAGE)
+ public DataResponseBody uploadImage(@Validated @RequestBody PtImageUploadDTO ptImageUploadDTO) {
+ ptImageService.uploadImage(ptImageUploadDTO);
+ return new DataResponseBody();
+ }
+
+ @GetMapping("/project")
+ @ApiOperation("查询镜像project列表")
+ @RequiresPermissions(Permissions.TRAINING_IMAGE)
+ public DataResponseBody getHarborProjectList() {
+ return new DataResponseBody(ptImageService.getHarborProjectList());
+ }
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtStorageController.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtStorageController.java
new file mode 100644
index 0000000..408e28a
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtStorageController.java
@@ -0,0 +1,87 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.rest;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.dubhe.base.DataResponseBody;
+import org.dubhe.domain.PtStorage;
+import org.dubhe.domain.dto.PtStorageQueryCriteria;
+import org.dubhe.service.PtStorageService;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import springfox.documentation.annotations.ApiIgnore;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @description storage管理
+ * @date 2020-03-17
+ */
+@Api(tags = "storage管理")
+@ApiIgnore
+@RestController
+@RequestMapping("/api/{version}/pt_storage")
+public class PtStorageController {
+
+ private final PtStorageService ptStorageService;
+
+ public PtStorageController(PtStorageService ptStorageService) {
+ this.ptStorageService = ptStorageService;
+ }
+
+ @ApiOperation("导出数据")
+ @GetMapping(value = "/download")
+ @PreAuthorize("@el.check('ptStorage:list')")
+ public void download(HttpServletResponse response, PtStorageQueryCriteria criteria) throws IOException {
+ ptStorageService.download(ptStorageService.queryAll(criteria), response);
+ }
+
+ @GetMapping
+ @ApiOperation("查询storage")
+ @PreAuthorize("@el.check('ptStorage:list')")
+ public DataResponseBody getPtStorages(PtStorageQueryCriteria criteria, Page page) {
+ return new DataResponseBody(ptStorageService.queryAll(criteria, page));
+ }
+
+ @PostMapping
+ @ApiOperation("新增storage")
+ @PreAuthorize("@el.check('ptStorage:add')")
+ public DataResponseBody create(@Validated @RequestBody PtStorage resources) {
+ return new DataResponseBody(ptStorageService.create(resources));
+ }
+
+ @PutMapping
+ @ApiOperation("修改storage")
+ @PreAuthorize("@el.check('ptStorage:edit')")
+ public DataResponseBody update(@Validated @RequestBody PtStorage resources) {
+ ptStorageService.update(resources);
+ return new DataResponseBody();
+ }
+
+ @ApiOperation("删除storage")
+ @PreAuthorize("@el.check('ptStorage:del')")
+ @DeleteMapping
+ public DataResponseBody deleteAll(@RequestBody Long[] ids) {
+ ptStorageService.deleteAll(ids);
+ return new DataResponseBody();
+ }
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtTrainAlgorithmController.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtTrainAlgorithmController.java
new file mode 100644
index 0000000..8f17cbd
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtTrainAlgorithmController.java
@@ -0,0 +1,84 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.rest;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.dubhe.annotation.ApiVersion;
+import org.dubhe.base.DataResponseBody;
+import org.dubhe.constant.Permissions;
+import org.dubhe.domain.dto.PtTrainAlgorithmCreateDTO;
+import org.dubhe.domain.dto.PtTrainAlgorithmDeleteDTO;
+import org.dubhe.domain.dto.PtTrainAlgorithmQueryDTO;
+import org.dubhe.domain.dto.PtTrainAlgorithmUpdateDTO;
+import org.dubhe.service.PtTrainAlgorithmService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @description 训练算法
+ * @date 2020-04-27
+ */
+@Api(tags = "训练:算法管理")
+@RestController
+@ApiVersion(1)
+@RequestMapping("/api/{version}/algorithm")
+public class PtTrainAlgorithmController {
+
+ @Autowired
+ private PtTrainAlgorithmService ptTrainAlgorithmService;
+
+ @GetMapping
+ @ApiOperation("查询算法")
+ @RequiresPermissions(Permissions.DEVELOPMENT_ALGORITHM)
+ public DataResponseBody getAlgorithms(@Validated PtTrainAlgorithmQueryDTO ptTrainAlgorithmQueryDTO) {
+ return new DataResponseBody(ptTrainAlgorithmService.queryAll(ptTrainAlgorithmQueryDTO));
+ }
+
+ @GetMapping("/myAlgorithmCount")
+ @ApiOperation("查询当前用户的算法个数")
+ @RequiresPermissions(Permissions.DEVELOPMENT_ALGORITHM)
+ public DataResponseBody getAlgorithmCount() {
+ return new DataResponseBody(ptTrainAlgorithmService.getAlgorithmCount());
+ }
+
+ @PostMapping
+ @ApiOperation("新增算法")
+ @RequiresPermissions(Permissions.DEVELOPMENT_ALGORITHM)
+ public DataResponseBody create(@Validated @RequestBody PtTrainAlgorithmCreateDTO ptTrainAlgorithmCreateDTO) {
+ return new DataResponseBody(ptTrainAlgorithmService.create(ptTrainAlgorithmCreateDTO));
+ }
+
+ @PutMapping
+ @ApiOperation("修改算法")
+ @RequiresPermissions(Permissions.DEVELOPMENT_ALGORITHM)
+ public DataResponseBody update(@Validated @RequestBody PtTrainAlgorithmUpdateDTO ptTrainAlgorithmUpdateDTO) {
+ return new DataResponseBody(ptTrainAlgorithmService.update(ptTrainAlgorithmUpdateDTO));
+ }
+
+ @DeleteMapping
+ @ApiOperation("删除算法")
+ @RequiresPermissions(Permissions.DEVELOPMENT_ALGORITHM)
+ public DataResponseBody deleteAll(@Validated @RequestBody PtTrainAlgorithmDeleteDTO ptTrainAlgorithmDeleteDTO) {
+ ptTrainAlgorithmService.deleteAll(ptTrainAlgorithmDeleteDTO);
+ return new DataResponseBody();
+ }
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtTrainAlgorithmUsageController.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtTrainAlgorithmUsageController.java
new file mode 100644
index 0000000..928dc31
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtTrainAlgorithmUsageController.java
@@ -0,0 +1,85 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.rest;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.dubhe.annotation.ApiVersion;
+import org.dubhe.base.DataResponseBody;
+import org.dubhe.constant.Permissions;
+import org.dubhe.constant.UserAuxiliaryInfoConstant;
+import org.dubhe.domain.dto.PtTrainAlgorithmUsageDeleteDTO;
+import org.dubhe.domain.dto.PtTrainAlgorithmUsageCreateDTO;
+import org.dubhe.domain.dto.PtTrainAlgorithmUsageQueryDTO;
+import org.dubhe.domain.dto.PtTrainAlgorithmUsageUpdateDTO;
+import org.dubhe.factory.DataResponseFactory;
+import org.dubhe.service.PtTrainAlgorithmUsageService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @description 算法用途管理
+ * @date 2020-06-19
+ */
+@Api(tags = "训练:算法用途管理")
+@RestController
+@ApiVersion(1)
+@RequestMapping("/api/{version}/algorithmUsage")
+public class PtTrainAlgorithmUsageController {
+
+ @Autowired
+ private PtTrainAlgorithmUsageService ptTrainAlgorithmUsageService;
+
+ @GetMapping
+ @ApiOperation("算法用途列表展示")
+ @RequiresPermissions(Permissions.DEVELOPMENT_ALGORITHM)
+ public DataResponseBody queryAll(@Validated PtTrainAlgorithmUsageQueryDTO ptTrainAlgorithmUsageQueryDTO) {
+ ptTrainAlgorithmUsageQueryDTO.setType(UserAuxiliaryInfoConstant.ALGORITHM_USAGE);
+ return DataResponseFactory
+ .success(ptTrainAlgorithmUsageService.queryAll(ptTrainAlgorithmUsageQueryDTO));
+ }
+
+ @PostMapping
+ @ApiOperation("新增算法用途")
+ @RequiresPermissions(Permissions.DEVELOPMENT_ALGORITHM)
+ public DataResponseBody create(
+ @Validated @RequestBody PtTrainAlgorithmUsageCreateDTO ptTrainAlgorithmUsageCreateDTO) {
+ ptTrainAlgorithmUsageCreateDTO.setType(UserAuxiliaryInfoConstant.ALGORITHM_USAGE);
+ return DataResponseFactory.success(ptTrainAlgorithmUsageService.create(ptTrainAlgorithmUsageCreateDTO));
+ }
+
+ @DeleteMapping
+ @ApiOperation("删除算法用途")
+ @RequiresPermissions(Permissions.DEVELOPMENT_ALGORITHM)
+ public DataResponseBody deleteAll(@Validated @RequestBody PtTrainAlgorithmUsageDeleteDTO ptTrainAlgorithmUsageDeleteDTO) {
+ ptTrainAlgorithmUsageService.deleteAll(ptTrainAlgorithmUsageDeleteDTO);
+ return new DataResponseBody();
+ }
+
+ @PutMapping
+ @ApiOperation("修改算法用途")
+ @RequiresPermissions(Permissions.DEVELOPMENT_ALGORITHM)
+ public DataResponseBody update(
+ @Validated @RequestBody PtTrainAlgorithmUsageUpdateDTO ptTrainAlgorithmUsageUpdateDTO) {
+ ptTrainAlgorithmUsageService.update(ptTrainAlgorithmUsageUpdateDTO);
+ return new DataResponseBody();
+ }
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtTrainJobController.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtTrainJobController.java
new file mode 100644
index 0000000..04f025e
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtTrainJobController.java
@@ -0,0 +1,135 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.rest;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.shiro.authz.annotation.Logical;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.dubhe.annotation.ApiVersion;
+import org.dubhe.base.DataResponseBody;
+import org.dubhe.constant.Permissions;
+import org.dubhe.domain.dto.*;
+import org.dubhe.service.PtTrainJobService;
+import org.dubhe.service.PtTrainJobSpecsService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+
+/**
+ * @description 训练作业job
+ * @date 2020-04-27
+ */
+@Api(tags = "训练:任务管理")
+@RestController
+@ApiVersion(1)
+@RequestMapping("/api/{version}/trainJob")
+public class PtTrainJobController {
+
+ @Autowired
+ private PtTrainJobService ptTrainJobService;
+
+ @Autowired
+ private PtTrainJobSpecsService ptTrainJobSpecsService;
+
+ @GetMapping
+ @ApiOperation("作业列表展示")
+ @RequiresPermissions(Permissions.TRAINING_JOB)
+ public DataResponseBody getTrainJob(@Validated PtTrainQueryDTO ptTrainQueryDTO) {
+ return new DataResponseBody(ptTrainJobService.getTrainJob(ptTrainQueryDTO));
+ }
+
+ @GetMapping("/trainJobSpecs")
+ @ApiOperation("规格展示")
+ @RequiresPermissions(Permissions.TRAINING_JOB)
+ public DataResponseBody getTrainJobSpecs(@Validated PtTrainJobSpecsQueryDTO ptTrainJobSpecsQueryDTO) {
+ return new DataResponseBody(ptTrainJobSpecsService.getTrainJobSpecs(ptTrainJobSpecsQueryDTO));
+ }
+
+ @GetMapping("/jobDetail")
+ @ApiOperation("根据jobId查询训练任务详情")
+ @RequiresPermissions(Permissions.TRAINING_JOB)
+ public DataResponseBody getTrainJobDetail(@Validated PtTrainJobDetailQueryDTO ptTrainJobDetailQueryDTO) {
+ return new DataResponseBody(ptTrainJobService.getTrainJobDetail(ptTrainJobDetailQueryDTO));
+ }
+
+ @GetMapping("/mine")
+ @ApiOperation(value = "我的训练任务统计", notes = "运行中的任务:PENDDING,RUNNING;完成的任务:其他状态")
+ @RequiresPermissions(Permissions.TRAINING_JOB)
+ public DataResponseBody statisticsMine() {
+ return new DataResponseBody(ptTrainJobService.statisticsMine());
+ }
+
+ @GetMapping("/trainJobVersionDetail")
+ @ApiOperation("作业不同版本任务列表展示")
+ @RequiresPermissions(Permissions.TRAINING_JOB)
+ public DataResponseBody getTrainJobVersion(@Validated PtTrainJobVersionQueryDTO ptTrainJobVersionQueryDTO) {
+ return new DataResponseBody(ptTrainJobService.getTrainJobVersion(ptTrainJobVersionQueryDTO));
+ }
+
+ @GetMapping("/dataSourceStatus")
+ @ApiOperation("数据集状态展示")
+ @RequiresPermissions(value = {Permissions.TRAINING_JOB, Permissions.DATA}, logical = Logical.OR)
+ public DataResponseBody getTrainDataSourceStatus(@Validated PtTrainDataSourceStatusQueryDTO ptTrainDataSourceStatusQueryDTO) {
+ return new DataResponseBody(ptTrainJobService.getTrainDataSourceStatus(ptTrainDataSourceStatusQueryDTO));
+ }
+
+ @PostMapping
+ @ApiOperation("创建训练任务")
+ @RequiresPermissions(Permissions.TRAINING_JOB)
+ public DataResponseBody createTrainJob(@Validated @RequestBody PtTrainJobCreateDTO ptTrainJobCreateDTO) {
+ return new DataResponseBody(ptTrainJobService.createTrainJobVersion(ptTrainJobCreateDTO));
+ }
+
+ @PutMapping
+ @ApiOperation("修改训练任务")
+ @RequiresPermissions(Permissions.TRAINING_JOB)
+ public DataResponseBody updateTrainJob(@Validated @RequestBody PtTrainJobUpdateDTO ptTrainJobUpdateDTO) {
+ return new DataResponseBody(ptTrainJobService.updateTrainJob(ptTrainJobUpdateDTO));
+ }
+
+ @DeleteMapping
+ @ApiOperation("删除训练任务")
+ @RequiresPermissions(Permissions.TRAINING_JOB)
+ public DataResponseBody deleteTrainJob(@Validated @RequestBody PtTrainJobDeleteDTO ptTrainJobDeleteDTO) {
+ return new DataResponseBody(ptTrainJobService.deleteTrainJob(ptTrainJobDeleteDTO));
+ }
+
+ @PostMapping("/stop")
+ @ApiOperation("停止训练任务")
+ @RequiresPermissions(Permissions.TRAINING_JOB)
+ public DataResponseBody stopTrainJob(@Validated @RequestBody PtTrainJobStopDTO ptTrainJobStopDTO) {
+ return new DataResponseBody(ptTrainJobService.stopTrainJob(ptTrainJobStopDTO));
+ }
+
+ @PostMapping("/resume")
+ @ApiOperation("恢复训练任务")
+ @RequiresPermissions(Permissions.TRAINING_JOB)
+ public DataResponseBody resumeTrainJob(@Validated @RequestBody PtTrainJobResumeDTO ptTrainJobResumeDTO) {
+ ptTrainJobService.resumeTrainJob(ptTrainJobResumeDTO);
+ return new DataResponseBody();
+ }
+
+ @GetMapping("/grafanaUrl/{jobId}")
+ @ApiOperation("获取job在grafana监控的地址")
+ @RequiresPermissions(Permissions.TRAINING_JOB)
+ public DataResponseBody getGrafanaUrl( @PathVariable Long jobId) {
+ return new DataResponseBody(ptTrainJobService.getGrafanaUrl(jobId));
+ }
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtTrainLogController.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtTrainLogController.java
new file mode 100644
index 0000000..add7226
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtTrainLogController.java
@@ -0,0 +1,67 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.rest;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.dubhe.annotation.ApiVersion;
+import org.dubhe.base.DataResponseBody;
+import org.dubhe.base.MagicNumConstant;
+import org.dubhe.constant.Permissions;
+import org.dubhe.domain.dto.PtTrainLogQueryDTO;
+import org.dubhe.domain.vo.PtTrainLogQueryVO;
+import org.dubhe.service.PtTrainLogService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @description 训练日志 控制器入口
+ * @date 2020-05-08
+ */
+@Api(tags = "训练:训练日志")
+@RestController
+@ApiVersion(1)
+@RequestMapping("/api/{version}/trainLog")
+public class PtTrainLogController {
+
+ @Autowired
+ private PtTrainLogService ptTrainLogService;
+
+ @GetMapping
+ @ApiOperation("训练日志查询")
+ @RequiresPermissions(Permissions.TRAINING_JOB)
+ public DataResponseBody getTrainLog(@Validated PtTrainLogQueryDTO ptTrainLogQueryDTO) {
+ return new DataResponseBody(ptTrainLogService.queryTrainLog(ptTrainLogQueryDTO));
+ }
+
+ @GetMapping("/download")
+ @ApiOperation("训练日志下载")
+ @RequiresPermissions(Permissions.TRAINING_JOB)
+ public DataResponseBody downLoadTrainLog(@Validated PtTrainLogQueryDTO ptTrainLogQueryDTO) {
+
+ ptTrainLogQueryDTO.setStartLine(MagicNumConstant.ONE).setLines(MagicNumConstant.MILLION);
+
+ PtTrainLogQueryVO ptTrainLogQueryVO = ptTrainLogService.queryTrainLog(ptTrainLogQueryDTO);
+ return new DataResponseBody(ptTrainLogService.getTrainLogString(ptTrainLogQueryVO.getContent()));
+ }
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtTrainParamController.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtTrainParamController.java
new file mode 100644
index 0000000..7b75ae9
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/rest/PtTrainParamController.java
@@ -0,0 +1,77 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.rest;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.dubhe.annotation.ApiVersion;
+import org.dubhe.base.DataResponseBody;
+import org.dubhe.constant.Permissions;
+import org.dubhe.domain.dto.PtTrainParamCreateDTO;
+import org.dubhe.domain.dto.PtTrainParamDeleteDTO;
+import org.dubhe.domain.dto.PtTrainParamQueryDTO;
+import org.dubhe.domain.dto.PtTrainParamUpdateDTO;
+import org.dubhe.service.PtTrainParamService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @description 任务参数
+ * @date 2020-04-27
+ */
+@Api(tags = "训练:任务参数管理")
+@RestController
+@ApiVersion(1)
+@RequestMapping("/api/{version}/trainParams")
+public class PtTrainParamController {
+
+ @Autowired
+ private PtTrainParamService ptTrainParamService;
+
+ @GetMapping
+ @ApiOperation("任务参数列表展示")
+ @RequiresPermissions(Permissions.TRAINING_JOB)
+ public DataResponseBody getTrainParam(@Validated PtTrainParamQueryDTO ptTrainParamQueryDTO) {
+ return new DataResponseBody(ptTrainParamService.getTrainParam(ptTrainParamQueryDTO));
+ }
+
+ @PostMapping
+ @ApiOperation("保存任务参数")
+ @RequiresPermissions(Permissions.TRAINING_JOB)
+ public DataResponseBody createTrainParam(@Validated @RequestBody PtTrainParamCreateDTO ptTrainParamCreateDTO) {
+ return new DataResponseBody(ptTrainParamService.createTrainParam(ptTrainParamCreateDTO));
+ }
+
+ @PutMapping
+ @ApiOperation("修改任务参数")
+ @RequiresPermissions(Permissions.TRAINING_JOB)
+ public DataResponseBody updateTrainParam(@Validated @RequestBody PtTrainParamUpdateDTO ptTrainParamUpdateDTO) {
+ return new DataResponseBody(ptTrainParamService.updateTrainParam(ptTrainParamUpdateDTO));
+ }
+
+ @DeleteMapping
+ @ApiOperation("删除任务参数")
+ @RequiresPermissions(Permissions.TRAINING_JOB)
+ public DataResponseBody deleteTrainParam(@Validated @RequestBody PtTrainParamDeleteDTO ptTrainParamDeleteDTO) {
+ ptTrainParamService.deleteTrainParam(ptTrainParamDeleteDTO);
+ return new DataResponseBody();
+ }
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/NoteBookService.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/NoteBookService.java
new file mode 100644
index 0000000..abfe52d
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/NoteBookService.java
@@ -0,0 +1,207 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.service;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.dubhe.domain.entity.NoteBook;
+import org.dubhe.domain.entity.NoteBookModel;
+import org.dubhe.domain.dto.*;
+import org.dubhe.domain.vo.NoteBookVO;
+import org.dubhe.enums.BizNfsEnum;
+import org.dubhe.enums.NoteBookStatusEnum;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @description notebook服务接口
+ * @date 2020-04-28
+ */
+public interface NoteBookService {
+ /**
+ * 分页查询所有notebook记录
+ *
+ * @param page
+ * @param noteBookListQueryDTO
+ * @return Map
+ */
+ Map getNoteBookList(Page page, NoteBookListQueryDTO noteBookListQueryDTO);
+
+ /**
+ * 查询所有notebook记录
+ *
+ * @param page
+ * @param noteBookQueryDTO
+ * @return List
+ */
+ List getList(Page page, NoteBookQueryDTO noteBookQueryDTO);
+
+ /**
+ * 新增加notebook
+ *
+ * @param noteBook
+ * @return NoteBookVO
+ */
+ NoteBookVO createNoteBook(NoteBook noteBook);
+
+ /**
+ * 验证notebook是否可删除
+ *
+ * @param noteBookIds
+ * @return List
+ */
+ List validateDeleteNoteBook(Set noteBookIds);
+
+ /**
+ * 删除notebook异步方法
+ *
+ * @param noteBookList
+ */
+ void deleteNoteBooks(List noteBookList);
+
+
+ /**
+ * 启动notebook
+ *
+ * @param noteBookId
+ * @return String
+ */
+ String startNoteBook(Long noteBookId);
+
+ /**
+ * 停止notebook
+ *
+ * @param noteBookId
+ * @return String
+ */
+ String stopNoteBook(Long noteBookId);
+
+ /**
+ * update by ID
+ *
+ * @param noteBook
+ * @return noteBook
+ */
+ NoteBook updateById(NoteBook noteBook);
+
+ /**
+ * 打开notebook
+ *
+ * @param noteBookId
+ * @return String
+ */
+ String openNoteBook(Long noteBookId);
+
+ /**
+ * 获取notebook可访问URL
+ *
+ * @param noteBook
+ * @return String
+ */
+ String getJupyterUrl(NoteBook noteBook);
+
+ /**
+ * 查询notebook在K8s对应的状态
+ *
+ * @param noteBook
+ * @return NoteBookStatusEnum
+ */
+ NoteBookStatusEnum getStatus(NoteBook noteBook);
+
+ /**
+ * 第三方创建notebook
+ *
+ * @param bizNfsEnum
+ * @param sourceNoteBookDTO
+ * @return NoteBookDTO
+ */
+ NoteBookVO createNoteBookByThirdParty(BizNfsEnum bizNfsEnum, SourceNoteBookDTO sourceNoteBookDTO);
+
+ /**
+ * 获取编辑地址
+ *
+ * @param noteBookId
+ * @return String
+ */
+ String getAddress(Long noteBookId);
+
+ /**
+ * 删除PVC
+ *
+ * @param noteBook
+ * @return String
+ */
+ String deletePvc(NoteBook noteBook);
+
+ /**
+ * 获取状态编码
+ *
+ * @return List
+ */
+ List getNoteBookStatus();
+
+ /**
+ * 获取正在运行的notebook数量
+ *
+ * @param curUserId
+ * @return int
+ */
+ int getNoteBookRunNumber(long curUserId);
+
+ /**
+ * 获取notebook模板
+ *
+ * @return Map>
+ */
+ Map> getNoteBookModel();
+
+ /**
+ * 刷新notebook对象状态
+ *
+ * @param statusEnum
+ * @param noteBook
+ * @return true 无需更新
+ */
+ boolean refreshNoteBookStatus(NoteBookStatusEnum statusEnum, NoteBook noteBook);
+
+ /**
+ * 根据notebook id更新训练id
+ *
+ * @param noteBookId
+ * @param algorithmId
+ * @return boolean
+ */
+ boolean updateTrainIdByNoteBookId(Long noteBookId, Long algorithmId);
+
+ /**
+ * 根据ID查询notebook详情
+ *
+ * @param noteBookIds
+ * @return List
+ */
+ List getNotebookDetail(Set noteBookIds);
+
+ /**
+ * 获取已经运行却没有URL的notebook
+ *
+ * @param page
+ * @return List
+ */
+ List getRunNotUrlList(Page page);
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PodCallbackAsyncService.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PodCallbackAsyncService.java
new file mode 100644
index 0000000..6fd353f
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PodCallbackAsyncService.java
@@ -0,0 +1,35 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.service;
+
+import org.dubhe.dto.callback.BaseK8sPodCallbackCreateDTO;
+import org.springframework.scheduling.annotation.Async;
+
+/**
+ * @description Pod 异步回调处理接口
+ * @date 2020-05-28
+ */
+public interface PodCallbackAsyncService {
+
+ /**
+ * pod 异步回调
+ * @param k8sPodCallbackCreateDTO
+ */
+ @Async
+ void podCallBack (R k8sPodCallbackCreateDTO);
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtDatasetService.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtDatasetService.java
new file mode 100644
index 0000000..2fed740
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtDatasetService.java
@@ -0,0 +1,91 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.service;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.dubhe.domain.PtDataset;
+import org.dubhe.domain.dto.PtDatasetDTO;
+import org.dubhe.domain.dto.PtDatasetQueryCriteria;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @description 查询数据
+ * @date 2020-03-17
+ */
+public interface PtDatasetService {
+
+ /**
+ * 查询数据分页
+ *
+ * @param criteria 条件
+ * @param page 分页参数
+ * @return Map
+ */
+ Map queryAll(PtDatasetQueryCriteria criteria, Page page);
+
+ /**
+ * 查询所有数据不分页
+ *
+ * @param criteria 条件参数
+ * @return List
+ */
+ List queryAll(PtDatasetQueryCriteria criteria);
+
+ /**
+ * 根据ID查询
+ *
+ * @param id ID
+ * @return PtDatasetDto
+ */
+ PtDatasetDTO findById(Long id);
+
+ /**
+ * 创建
+ *
+ * @param resources /
+ * @return PtDatasetDto
+ */
+ PtDatasetDTO create(PtDataset resources);
+
+ /**
+ * 编辑
+ *
+ * @param resources /
+ */
+ void update(PtDataset resources);
+
+ /**
+ * 多选删除
+ *
+ * @param ids /
+ */
+ void deleteAll(Long[] ids);
+
+ /**
+ * 导出数据
+ *
+ * @param all 待导出的数据
+ * @param response /
+ * @throws IOException /
+ */
+ void download(List all, HttpServletResponse response) throws IOException;
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtDevEnvsService.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtDevEnvsService.java
new file mode 100644
index 0000000..4eaa17d
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtDevEnvsService.java
@@ -0,0 +1,91 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.service;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.dubhe.domain.PtDevEnvs;
+import org.dubhe.domain.dto.PtDevEnvsDTO;
+import org.dubhe.domain.dto.PtDevEnvsQueryCriteria;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @description 查询数据
+ * @date 2020-03-17
+ */
+public interface PtDevEnvsService {
+
+ /**
+ * 查询数据分页
+ *
+ * @param criteria 条件
+ * @param page 分页参数
+ * @return Map
+ */
+ Map queryAll(PtDevEnvsQueryCriteria criteria, Page page);
+
+ /**
+ * 查询所有数据不分页
+ *
+ * @param criteria 条件参数
+ * @return List
+ */
+ List queryAll(PtDevEnvsQueryCriteria criteria);
+
+ /**
+ * 根据ID查询
+ *
+ * @param id ID
+ * @return PtDevEnvsDto
+ */
+ PtDevEnvsDTO findById(Long id);
+
+ /**
+ * 创建
+ *
+ * @param resources /
+ * @return PtDevEnvsDto
+ */
+ PtDevEnvsDTO create(PtDevEnvs resources);
+
+ /**
+ * 编辑
+ *
+ * @param resources /
+ */
+ void update(PtDevEnvs resources);
+
+ /**
+ * 多选删除
+ *
+ * @param ids /
+ */
+ void deleteAll(Long[] ids);
+
+ /**
+ * 导出数据
+ *
+ * @param all 待导出的数据
+ * @param response /
+ * @throws IOException /
+ */
+ void download(List all, HttpServletResponse response) throws IOException;
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtImageService.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtImageService.java
new file mode 100644
index 0000000..f549ffd
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtImageService.java
@@ -0,0 +1,71 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.service;
+
+import org.dubhe.domain.dto.PtImageQueryDTO;
+import org.dubhe.domain.dto.PtImageUploadDTO;
+import org.dubhe.domain.entity.HarborProject;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @description 镜像服务service
+ * @date 2020-06-22
+ */
+public interface PtImageService {
+
+ /**
+ * 查询镜像
+ *
+ * @param ptImageQueryDTO 查询条件
+ * @return Map 镜像列表分页信息
+ **/
+ Map getImage(PtImageQueryDTO ptImageQueryDTO);
+
+
+ /**
+ * 上传镜像到harbor
+ *
+ * @param ptImageUploadDTO 上传条件
+ */
+ void uploadImage(PtImageUploadDTO ptImageUploadDTO);
+
+
+ /**
+ * 定时到harbor同步imageName
+ */
+ void harborImageNameSync();
+
+
+ /**
+ * 通过imageName查询所含镜像版本信息
+ *
+ * @param imageName 镜像名
+ * @return List 镜像集合
+ */
+ List searchImages(String imageName);
+
+
+ /**
+ * 查询harbor镜像列表
+ *
+ * @return List harbor镜像集合
+ **/
+ List getHarborProjectList();
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtStorageService.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtStorageService.java
new file mode 100644
index 0000000..ebbf862
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtStorageService.java
@@ -0,0 +1,92 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.service;
+
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.dubhe.domain.PtStorage;
+import org.dubhe.domain.dto.PtStorageDTO;
+import org.dubhe.domain.dto.PtStorageQueryCriteria;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @description 查询数据
+ * @date 2020-03-17
+ */
+public interface PtStorageService {
+
+ /**
+ * 查询数据分页
+ *
+ * @param criteria 条件
+ * @param page 分页参数
+ * @return Map
+ */
+ Map queryAll(PtStorageQueryCriteria criteria, Page page);
+
+ /**
+ * 查询所有数据不分页
+ *
+ * @param criteria 条件参数
+ * @return List
+ */
+ List queryAll(PtStorageQueryCriteria criteria);
+
+ /**
+ * 根据ID查询
+ *
+ * @param id ID
+ * @return PtStorageDto
+ */
+ PtStorageDTO findById(Long id);
+
+ /**
+ * 创建
+ *
+ * @param resources /
+ * @return PtStorageDto
+ */
+ PtStorageDTO create(PtStorage resources);
+
+ /**
+ * 编辑
+ *
+ * @param resources /
+ */
+ void update(PtStorage resources);
+
+ /**
+ * 多选删除
+ *
+ * @param ids /
+ */
+ void deleteAll(Long[] ids);
+
+ /**
+ * 导出数据
+ *
+ * @param all 待导出的数据
+ * @param response /
+ * @throws IOException /
+ */
+ void download(List all, HttpServletResponse response) throws IOException;
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtTrainAlgorithmService.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtTrainAlgorithmService.java
new file mode 100644
index 0000000..62e4d07
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtTrainAlgorithmService.java
@@ -0,0 +1,71 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.service;
+
+import org.dubhe.domain.dto.PtTrainAlgorithmCreateDTO;
+import org.dubhe.domain.dto.PtTrainAlgorithmDeleteDTO;
+import org.dubhe.domain.dto.PtTrainAlgorithmQueryDTO;
+import org.dubhe.domain.dto.PtTrainAlgorithmUpdateDTO;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @description 训练算法 服务类
+ * @date 2020-04-27
+ */
+public interface PtTrainAlgorithmService {
+
+ /**
+ * 查询数据分页
+ *
+ * @param criteria 分页参数条件
+ * @return Map map
+ */
+ Map queryAll(PtTrainAlgorithmQueryDTO criteria);
+
+ /**
+ * 新增算法
+ *
+ * @param resources 新增算法条件
+ * @return PtTrainAlgorithmCreateVO 新建训练算法
+ */
+ List create(PtTrainAlgorithmCreateDTO resources);
+
+ /**
+ * 修改算法
+ *
+ * @param resources 修改算法条件
+ * @return PtTrainAlgorithmUpdateVO 修改训练算法
+ */
+ List update(PtTrainAlgorithmUpdateDTO resources);
+
+ /**
+ * 删除算法
+ *
+ * @param ptTrainAlgorithmDeleteDTO 删除算法条件
+ */
+ void deleteAll(PtTrainAlgorithmDeleteDTO ptTrainAlgorithmDeleteDTO);
+
+ /**
+ * 查询当前用户的算法个数
+ */
+ Map getAlgorithmCount();
+
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtTrainAlgorithmUsageService.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtTrainAlgorithmUsageService.java
new file mode 100644
index 0000000..ac8c2d3
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtTrainAlgorithmUsageService.java
@@ -0,0 +1,62 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.service;
+
+import org.dubhe.domain.dto.PtTrainAlgorithmUsageDeleteDTO;
+import org.dubhe.domain.dto.PtTrainAlgorithmUsageCreateDTO;
+import org.dubhe.domain.dto.PtTrainAlgorithmUsageQueryDTO;
+import org.dubhe.domain.dto.PtTrainAlgorithmUsageUpdateDTO;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @description 算法用途 服务类
+ * @date 2020-06-23
+ */
+public interface PtTrainAlgorithmUsageService {
+
+ /**
+ * 查询算法用途
+ *
+ * @param ptTrainAlgorithmUsageQueryDTO 查询算法用途参数
+ */
+ Map queryAll(PtTrainAlgorithmUsageQueryDTO ptTrainAlgorithmUsageQueryDTO);
+
+ /**
+ * 新增算法用途
+ *
+ * @param ptTrainAlgorithmUsageCreateDTO 新增算法用途参数
+ */
+ List create(PtTrainAlgorithmUsageCreateDTO ptTrainAlgorithmUsageCreateDTO);
+
+ /**
+ * 删除算法用途
+ *
+ * @param ptTrainAlgorithmUsageDeleteDTO 删除算法用途参数
+ */
+ void deleteAll(PtTrainAlgorithmUsageDeleteDTO ptTrainAlgorithmUsageDeleteDTO);
+
+ /**
+ * 更新算法用途
+ *
+ * @param ptTrainAlgorithmUsageUpdateDTO 更新算法用途参数
+ */
+ void update(PtTrainAlgorithmUsageUpdateDTO ptTrainAlgorithmUsageUpdateDTO);
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtTrainJobService.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtTrainJobService.java
new file mode 100644
index 0000000..d42cb19
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtTrainJobService.java
@@ -0,0 +1,125 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.service;
+
+import org.dubhe.domain.dto.*;
+import org.dubhe.domain.vo.*;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @description 训练作业job 服务类
+ * @date 2020-04-27
+ */
+public interface PtTrainJobService {
+
+
+ /**
+ * 作业列表展示
+ *
+ * @param ptTrainQueryDTO 查询作业列表参数
+ * @return Map 作业列表分页数据
+ **/
+ Map getTrainJob(PtTrainQueryDTO ptTrainQueryDTO);
+
+
+ /**
+ * 作业不同版本job列表展示
+ *
+ * @param ptTrainJobVersionQueryDTO 查询作业不同版本job列表参数
+ * @return List 训练版本查询详情集合
+ **/
+ List getTrainJobVersion(PtTrainJobVersionQueryDTO ptTrainJobVersionQueryDTO);
+
+
+ /**
+ * 创建训练job
+ *
+ * @param ptTrainJobCreateDTO 创建训练job参数
+ * @return List id集合
+ */
+ List createTrainJobVersion(PtTrainJobCreateDTO ptTrainJobCreateDTO);
+
+
+ /**
+ * 修改训练job
+ *
+ * @param ptTrainJobUpdateDTO 修改训练job参数
+ * @return List id集合
+ **/
+ List updateTrainJob(PtTrainJobUpdateDTO ptTrainJobUpdateDTO);
+
+
+ /**
+ * 删除训练job
+ *
+ * @param ptTrainJobDeleteDTO 删除训练job参数
+ * @return PtTrainJobDeleteVO 返回删除训练任务结果
+ **/
+ PtTrainJobDeleteVO deleteTrainJob(PtTrainJobDeleteDTO ptTrainJobDeleteDTO);
+
+
+ /**
+ * 停止训练job
+ *
+ * @param ptTrainJobStopDTO 停止训练job参数
+ * @return PtTrainJobStopVO 停止训练任务结果
+ **/
+ PtTrainJobStopVO stopTrainJob(PtTrainJobStopDTO ptTrainJobStopDTO);
+
+
+ /**
+ * 查询训练作业job状态
+ *
+ * @param ptTrainDataSourceStatusQueryDTO 查询训练作业job状态参数
+ * @return HashedMap 数据集路径-是否可以删除 的map集合
+ **/
+ Map getTrainDataSourceStatus(PtTrainDataSourceStatusQueryDTO ptTrainDataSourceStatusQueryDTO);
+
+
+ /**
+ * 我的训练任务统计
+ *
+ * @return PtTrainJobStatisticsMineVO 统计信息
+ **/
+ PtTrainJobStatisticsMineVO statisticsMine();
+
+ /**
+ * 根据jobId查询训练任务详情查询
+ *
+ * @param ptTrainJobDetailQueryDTO 根据jobId查询训练任务详情查询条件
+ * @return PtTrainQueryJobDetailVO 根据jobId查询训练任务详情返回结果
+ */
+ PtTrainJobDetailQueryVO getTrainJobDetail(PtTrainJobDetailQueryDTO ptTrainJobDetailQueryDTO);
+
+ /**
+ * 恢复训练
+ *
+ * @param ptTrainJobResumeDTO 恢复训练请求参数
+ */
+ void resumeTrainJob(PtTrainJobResumeDTO ptTrainJobResumeDTO);
+
+ /**
+ * 获取job在grafana监控的地址
+ *
+ * @param jobId 任务ID
+ * @return PtJobMetricsGrafanaVO Pod Metrics Grafana url
+ */
+ PtJobMetricsGrafanaVO getGrafanaUrl(Long jobId);
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtTrainJobSpecsService.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtTrainJobSpecsService.java
new file mode 100644
index 0000000..ca069b1
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtTrainJobSpecsService.java
@@ -0,0 +1,39 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.service;
+
+import org.dubhe.domain.dto.PtTrainJobSpecsQueryDTO;
+import org.dubhe.domain.vo.PtTrainJobSpecsQueryVO;
+
+import java.util.List;
+
+/**
+ * @description 训练作业规格服务类
+ * @date 2020-05-06
+ */
+public interface PtTrainJobSpecsService {
+
+
+ /**
+ * 查询规格表
+ *
+ * @param ptTrainJobSpecsQueryDTO 查询规格表参数
+ * @return List list
+ **/
+ List getTrainJobSpecs(PtTrainJobSpecsQueryDTO ptTrainJobSpecsQueryDTO);
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtTrainLogService.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtTrainLogService.java
new file mode 100644
index 0000000..b4abf6d
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtTrainLogService.java
@@ -0,0 +1,46 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.service;
+
+import java.util.List;
+
+import org.dubhe.domain.dto.PtTrainLogQueryDTO;
+import org.dubhe.domain.vo.PtTrainLogQueryVO;
+
+/**
+ * @description 训练日志服务类
+ * @date 2020-05-08
+ */
+public interface PtTrainLogService {
+
+ /**
+ * 查询训练任务运行日志
+ *
+ * @param ptTrainLogQueryDTO 训练日志查询
+ * @return PtTrainLogQueryVO 返回训练日志查询
+ **/
+ PtTrainLogQueryVO queryTrainLog(PtTrainLogQueryDTO ptTrainLogQueryDTO);
+
+ /**
+ *
+ * 字符串换行
+ * @param content 个数
+ * @return String 字符串
+ */
+ String getTrainLogString(List content);
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtTrainParamService.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtTrainParamService.java
new file mode 100644
index 0000000..232b22a
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/PtTrainParamService.java
@@ -0,0 +1,65 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.service;
+
+import org.dubhe.domain.dto.PtTrainParamCreateDTO;
+import org.dubhe.domain.dto.PtTrainParamDeleteDTO;
+import org.dubhe.domain.dto.PtTrainParamQueryDTO;
+import org.dubhe.domain.dto.PtTrainParamUpdateDTO;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @description 任务参数 服务类
+ * @date 2020-04-27
+ */
+public interface PtTrainParamService {
+
+ /**
+ * 任务参数列表展示
+ *
+ * @param ptTrainParamQueryDTO 任务参数列表展示条件
+ * @return Map 任务参数列表分页数据
+ **/
+ Map getTrainParam(PtTrainParamQueryDTO ptTrainParamQueryDTO);
+
+ /**
+ * 保存任务参数
+ *
+ * @param ptTrainParamCreateDTO 保存任务参数条件
+ * @return List 保存任务参数id集合
+ **/
+ List createTrainParam(PtTrainParamCreateDTO ptTrainParamCreateDTO);
+
+ /**
+ * 修改任务参数
+ *
+ * @param ptTrainParamUpdateDTO 修改任务参数条件
+ * @return List 修改任务参数id集合
+ **/
+ List updateTrainParam(PtTrainParamUpdateDTO ptTrainParamUpdateDTO);
+
+ /**
+ * 删除任务参数
+ *
+ * @param ptTrainParamDeleteDTO 删除任务参数条件
+ **/
+ void deleteTrainParam(PtTrainParamDeleteDTO ptTrainParamDeleteDTO);
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/abstracts/AbstractPodCallback.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/abstracts/AbstractPodCallback.java
new file mode 100644
index 0000000..612816b
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/abstracts/AbstractPodCallback.java
@@ -0,0 +1,82 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.service.abstracts;
+
+import org.dubhe.dto.callback.BaseK8sPodCallbackCreateDTO;
+import org.dubhe.enums.LogEnum;
+import org.dubhe.service.PodCallbackAsyncService;
+import org.dubhe.utils.K8sCallBackTool;
+import org.dubhe.utils.LogUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * @description pod 异步回调抽象处理类
+ * @date 2020-05-29
+ */
+public abstract class AbstractPodCallback implements PodCallbackAsyncService {
+
+ @Autowired
+ private K8sCallBackTool k8sCallBackTool;
+
+ /**
+ * 公共 失败重试策略
+ *
+ * @param k8sPodCallbackCreateDTO
+ * @param
+ */
+ @Override
+ public void podCallBack(R k8sPodCallbackCreateDTO) {
+ int tryTime = 1;
+ while (!doCallback(tryTime,k8sPodCallbackCreateDTO)){
+ if (k8sCallBackTool.continueRetry(++tryTime)){
+ // 继续重试 tryTime重试次数+1
+ try {
+ Thread.sleep(tryTime * 1000);
+ continue;
+ } catch (InterruptedException e) {
+ LogUtil.error(LogEnum.NOTE_BOOK,"AbstractPodCallback podCallBack InterruptedException", e);
+ // Restore interrupted state...
+ Thread.currentThread().interrupt();
+ }
+ }else {
+ // 重试超限 tryTime重试次数+1未尝试,因此需要tryTime重试次数-1
+ callbackFailed(--tryTime,k8sPodCallbackCreateDTO);
+ break;
+ }
+ }
+ }
+
+ /**
+ * pod 异步回调具体实现处理类
+ * @param times 第n次处理
+ * @param k8sPodCallbackCreateDTO k8s回调实体类
+ * @param BaseK8sPodCallbackReq k8s回调基类
+ * @return true:处理成功 false:处理失败
+ */
+ public abstract boolean doCallback(int times,R k8sPodCallbackCreateDTO);
+
+
+ /**
+ * pod 异步回调具体实现处理类
+ * @param retryTimes 总处理次数
+ * @param k8sPodCallbackCreateDTO k8s回调实体类
+ * @param BaseK8sPodCallbackReq k8s回调基类
+ */
+ public abstract void callbackFailed(int retryTimes, R k8sPodCallbackCreateDTO);
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/convert/NoteBookConvert.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/convert/NoteBookConvert.java
new file mode 100644
index 0000000..4c1cef1
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/convert/NoteBookConvert.java
@@ -0,0 +1,32 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.service.convert;
+
+import org.dubhe.base.BaseConvert;
+import org.dubhe.domain.entity.NoteBook;
+import org.dubhe.domain.vo.NoteBookVO;
+import org.mapstruct.Mapper;
+import org.mapstruct.ReportingPolicy;
+
+/**
+ * @description notebook 转化器
+ * @create 2020-04-28
+ */
+@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
+public interface NoteBookConvert extends BaseConvert {
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/convert/PtDatasetConvert.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/convert/PtDatasetConvert.java
new file mode 100644
index 0000000..87c986d
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/convert/PtDatasetConvert.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.service.convert;
+
+import org.dubhe.base.BaseConvert;
+import org.dubhe.domain.PtDataset;
+import org.dubhe.domain.dto.PtDatasetDTO;
+import org.mapstruct.Mapper;
+import org.mapstruct.ReportingPolicy;
+
+/**
+ * @description 数据集
+ * @date 2020-03-17
+ */
+@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
+public interface PtDatasetConvert extends BaseConvert {
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/convert/PtDevEnvsConvert.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/convert/PtDevEnvsConvert.java
new file mode 100644
index 0000000..81f7688
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/convert/PtDevEnvsConvert.java
@@ -0,0 +1,34 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.service.convert;
+
+
+import org.dubhe.base.BaseConvert;
+import org.dubhe.domain.PtDevEnvs;
+import org.dubhe.domain.dto.PtDevEnvsDTO;
+import org.mapstruct.Mapper;
+import org.mapstruct.ReportingPolicy;
+
+/**
+ * @description 开发环境
+ * @date 2020-03-17
+ */
+@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
+public interface PtDevEnvsConvert extends BaseConvert {
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/convert/PtImageConvert.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/convert/PtImageConvert.java
new file mode 100644
index 0000000..8cbd6af
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/convert/PtImageConvert.java
@@ -0,0 +1,34 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.service.convert;
+
+
+import org.dubhe.base.BaseConvert;
+import org.dubhe.domain.entity.PtImage;
+import org.dubhe.domain.dto.PtImageDTO;
+import org.mapstruct.Mapper;
+import org.mapstruct.ReportingPolicy;
+
+/**
+ * @description 镜像
+ * @date 2020-03-17
+ */
+@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
+public interface PtImageConvert extends BaseConvert {
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/convert/PtJupyterResourceConvert.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/convert/PtJupyterResourceConvert.java
new file mode 100644
index 0000000..9c371e8
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/convert/PtJupyterResourceConvert.java
@@ -0,0 +1,66 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.service.convert;
+
+import org.dubhe.base.MagicNumConstant;
+import org.dubhe.enums.BizEnum;
+import org.dubhe.k8s.domain.bo.PtJupyterResourceBO;
+import org.dubhe.domain.entity.NoteBook;
+import org.dubhe.utils.K8sNameTool;
+
+/**
+ * @description PtJupyterResourceBO 转换器
+ * @date 2020-04-30
+ */
+public class PtJupyterResourceConvert {
+
+ private PtJupyterResourceConvert(){
+
+ }
+
+ /**
+ * NoteBook 转换为 PtJupyterResourceBO
+ *
+ * @param noteBook
+ * @return PtJupyterResourceBO
+ */
+ public static PtJupyterResourceBO toPtJupyterResourceBo(NoteBook noteBook,K8sNameTool k8sNameTool){
+ if (noteBook == null){
+ return null;
+ }
+ PtJupyterResourceBO bo = new PtJupyterResourceBO();
+ bo.setNamespace(noteBook.getK8sNamespace())
+ .setName(noteBook.getK8sResourceName())
+ .setCpuNum(noteBook.getCpuNum()* MagicNumConstant.ONE_THOUSAND)
+ .setGpuNum(noteBook.getGpuNum()< MagicNumConstant.ONE?null:noteBook.getGpuNum())
+ .setMemNum(noteBook.getMemNum()* MagicNumConstant.ONE_THOUSAND_TWENTY_FOUR)
+ .setImage(noteBook.getK8sImageName())
+ .setWorkspaceDir(k8sNameTool.getAbsoluteNfsPath(noteBook.getK8sPvcPath()))
+ .setWorkspaceMountPath(noteBook.getK8sMountPath())
+ // request和limit先一致
+ .setWorkspaceRequest(noteBook.getDiskMemNum()*MagicNumConstant.ONE_THOUSAND_TWENTY_FOUR+"Mi")
+ .setWorkspaceLimit(noteBook.getDiskMemNum()*MagicNumConstant.ONE_THOUSAND_TWENTY_FOUR+"Mi")
+ .setBusinessLabel(k8sNameTool.getPodLabel(BizEnum.NOTEBOOK))
+ .setDatasetDir(k8sNameTool.getAbsoluteNfsPath(noteBook.getDataSourcePath()))
+ .setDatasetMountPath(k8sNameTool.getDatasetPath())
+ .setDatasetReadOnly(true)
+ ;
+ return bo;
+ }
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/convert/PtStorageConvert.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/convert/PtStorageConvert.java
new file mode 100644
index 0000000..4b39370
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/convert/PtStorageConvert.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.service.convert;
+
+
+import org.dubhe.base.BaseConvert;
+import org.dubhe.domain.PtStorage;
+import org.dubhe.domain.dto.PtStorageDTO;
+import org.mapstruct.Mapper;
+import org.mapstruct.ReportingPolicy;
+
+/**
+ * @description 存储类转化
+ * @date 2020-03-17
+ */
+@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
+public interface PtStorageConvert extends BaseConvert {
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/convert/PtTrainJobConvert.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/convert/PtTrainJobConvert.java
new file mode 100644
index 0000000..433c3af
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/convert/PtTrainJobConvert.java
@@ -0,0 +1,34 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.service.convert;
+
+
+import org.dubhe.base.BaseConvert;
+import org.dubhe.domain.entity.PtTrainJob;
+import org.dubhe.domain.dto.PtTrainJobDTO;
+import org.mapstruct.Mapper;
+import org.mapstruct.ReportingPolicy;
+
+/**
+ * @description 训练任务转化
+ * @date 2020-03-17
+ */
+@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
+public interface PtTrainJobConvert extends BaseConvert {
+
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/impl/AlgorithmAsyncServiceImpl.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/impl/AlgorithmAsyncServiceImpl.java
new file mode 100644
index 0000000..34fb1ae
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/impl/AlgorithmAsyncServiceImpl.java
@@ -0,0 +1,121 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.dubhe.base.MagicNumConstant;
+import org.dubhe.enums.TrainJobStatusEnum;
+import org.dubhe.dao.PtTrainJobMapper;
+import org.dubhe.domain.entity.PtTrainJob;
+import org.dubhe.dto.callback.AlgorithmK8sPodCallbackCreateDTO;
+import org.dubhe.dto.callback.BaseK8sPodCallbackCreateDTO;
+import org.dubhe.enums.LogEnum;
+import org.dubhe.service.PodCallbackAsyncService;
+import org.dubhe.service.abstracts.AbstractPodCallback;
+import org.dubhe.utils.K8sNameTool;
+import org.dubhe.utils.LogUtil;
+import org.dubhe.utils.TrainUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @description 训练任务回调
+ * @date 2020-06-03
+ */
+@Service(value = "algorithmAsyncServiceImpl")
+public class AlgorithmAsyncServiceImpl extends AbstractPodCallback implements PodCallbackAsyncService {
+
+ @Autowired
+ private PtTrainJobMapper ptTrainJobMapper;
+ @Autowired
+ private K8sNameTool k8sNameTool;
+
+ /**
+ * pod 异步回调具体实现处理类
+ *
+ * @param times 第n次处理
+ * @param k8sPodCallbackCreateDTO k8s回调实体类
+ * @param BaseK8sPodCallbackReq k8s回调基类
+ * @return boolean true:处理成功 false:处理失败
+ */
+ @Override
+ public boolean doCallback(int times, R k8sPodCallbackCreateDTO) {
+ // 强制转型
+ AlgorithmK8sPodCallbackCreateDTO req = (AlgorithmK8sPodCallbackCreateDTO) k8sPodCallbackCreateDTO;
+ LogUtil.info(LogEnum.BIZ_TRAIN, "Thread {} try {} time.Request: {}", Thread.currentThread(), times, req.toString());
+ // 根据namespace和podName找到job
+ QueryWrapper queryTrainJonWrapper = new QueryWrapper<>();
+ Long userId = k8sNameTool.getUserIdFromNameSpace(req.getNamespace());
+ String podName = req.getPodName();
+ if (null == podName || podName.length() <= MagicNumConstant.SIX) {
+ LogUtil.error(LogEnum.BIZ_TRAIN, "podName={} too short", podName);
+ return false;
+ }
+ String k8sJobName = podName.substring(MagicNumConstant.ZERO, podName.length() - MagicNumConstant.SIX);
+ queryTrainJonWrapper.eq("k8s_job_name", k8sJobName).
+ eq("create_user_id", userId);
+ PtTrainJob ptTrainJob = ptTrainJobMapper.selectOne(queryTrainJonWrapper);
+ if (null == ptTrainJob) {
+ LogUtil.error(LogEnum.BIZ_TRAIN, "k8s_job_name={} not found", k8sJobName);
+ return false;
+ }
+ String phase = req.getPhase();
+ // 对于当前状态为结束状态或上报状态为删除的任务不做处理
+ if (TrainJobStatusEnum.isEnd(ptTrainJob.getTrainStatus()) || TrainJobStatusEnum.DELETED.getMessage().equalsIgnoreCase(phase)) {
+ return true;
+ }
+ PtTrainJob updatePtTrainJob = new PtTrainJob();
+
+ // 更新job运行时间和状态
+ updatePtTrainJob.setId(ptTrainJob.getId())
+ .setTrainStatus(TrainJobStatusEnum.get(phase).getStatus());
+ // 如果上报状态是结束状态并没指定过运行时间,则更新运行时间
+ if (TrainJobStatusEnum.isEnd(phase) && "".equals(ptTrainJob.getRuntime())) {
+ long timeDelta = System.currentTimeMillis() - ptTrainJob.getCreateTime().getTime();
+ String runTime = String.format(TrainUtil.RUNTIME,
+ TimeUnit.MILLISECONDS.toHours(timeDelta),
+ TimeUnit.MILLISECONDS.toMinutes(timeDelta) % TimeUnit.HOURS.toMinutes(1),
+ TimeUnit.MILLISECONDS.toSeconds(timeDelta) % TimeUnit.MINUTES.toSeconds(1)
+ );
+ updatePtTrainJob.setRuntime(runTime);
+ }
+ int updateResult = ptTrainJobMapper.updateById(updatePtTrainJob);
+ if (updateResult < 1) {
+ LogUtil.error(LogEnum.BIZ_TRAIN, "update trainJob_id={} failed, phase={}", ptTrainJob.getId(), req.getPhase());
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * pod 异步回调具体实现处理类
+ *
+ * @param retryTimes 总处理次数
+ * @param k8sPodCallbackCreateDTO k8s回调实体类
+ * @param BaseK8sPodCallbackReq k8s回调基类
+ */
+ @Override
+ public void callbackFailed(int retryTimes, R k8sPodCallbackCreateDTO) {
+ // 强制转型
+ AlgorithmK8sPodCallbackCreateDTO req = (AlgorithmK8sPodCallbackCreateDTO) k8sPodCallbackCreateDTO;
+ LogUtil.info(LogEnum.BIZ_TRAIN, "Thread {}try {} times FAILED! if you want to storage or send failed msg,please impl this.. Request: {}", Thread.currentThread(), retryTimes, req.toString());
+ }
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/impl/NoteBookAsyncServiceImpl.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/impl/NoteBookAsyncServiceImpl.java
new file mode 100644
index 0000000..146c63b
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/impl/NoteBookAsyncServiceImpl.java
@@ -0,0 +1,80 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.service.impl;
+
+import org.dubhe.dao.NoteBookMapper;
+import org.dubhe.domain.entity.NoteBook;
+import org.dubhe.enums.LogEnum;
+import org.dubhe.enums.NoteBookStatusEnum;
+import org.dubhe.dto.callback.BaseK8sPodCallbackCreateDTO;
+import org.dubhe.dto.callback.NotebookK8sPodCallbackCreateDTO;
+import org.dubhe.service.NoteBookService;
+import org.dubhe.service.PodCallbackAsyncService;
+import org.dubhe.service.abstracts.AbstractPodCallback;
+import org.dubhe.utils.LogUtil;
+import org.dubhe.utils.NotebookUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * @description 异步刪除接口实现
+ * @date 2020-05-28
+ */
+@Service(value = "noteBookAsyncServiceImpl")
+public class NoteBookAsyncServiceImpl extends AbstractPodCallback implements PodCallbackAsyncService {
+
+ @Autowired
+ private NoteBookService noteBookService;
+
+ @Autowired
+ private NoteBookMapper noteBookMapper;
+
+
+ @Override
+ public boolean doCallback(int times, R k8sPodCallbackCreateDTO) {
+ try {
+ // 强制转型
+ NotebookK8sPodCallbackCreateDTO req = (NotebookK8sPodCallbackCreateDTO) k8sPodCallbackCreateDTO;
+ LogUtil.info(LogEnum.NOTE_BOOK, "NoteBookAsyncServiceImpl try {} time.Request: {}", times, req.toString());
+ NoteBook notebook = noteBookMapper.findByNamespaceAndResourceName(req.getNamespace(), req.getResourceName(),NoteBookStatusEnum.DELETE.getCode());
+ if (notebook == null) {
+ LogUtil.warn(LogEnum.NOTE_BOOK, "Cannot find notebook! Request: {}", Thread.currentThread(), times, req.toString());
+ return true;
+ }
+ NoteBookStatusEnum statusEnum = NoteBookStatusEnum.convert(k8sPodCallbackCreateDTO.getPhase());
+ if (noteBookService.refreshNoteBookStatus(statusEnum, notebook)) {
+ return true;
+ }
+ notebook.setK8sStatusCode(req.getPhase());
+ notebook.setK8sStatusInfo(NotebookUtil.getK8sStatusInfo(req.getMessages()));
+ noteBookService.updateById(notebook);
+ return true;
+ } catch (Exception e) {
+ LogUtil.error(LogEnum.NOTE_BOOK, "NoteBook doCallback error!", e);
+ return false;
+ }
+ }
+
+ @Override
+ public void callbackFailed(int retryTimes, R k8sPodCallbackCreateDTO) {
+ // 强制转型
+ NotebookK8sPodCallbackCreateDTO req = (NotebookK8sPodCallbackCreateDTO) k8sPodCallbackCreateDTO;
+ LogUtil.info(LogEnum.NOTE_BOOK, "Thread {}try {} times FAILED! if you want to storage or send failed msg,please impl this.. Request: {}", Thread.currentThread(), retryTimes, req.toString());
+ // 目前利用定时补偿补充处理,无需做callbackFailed
+ }
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/impl/NoteBookServiceImpl.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/impl/NoteBookServiceImpl.java
new file mode 100644
index 0000000..0537a24
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/impl/NoteBookServiceImpl.java
@@ -0,0 +1,739 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.service.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.RandomUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.commons.lang3.StringUtils;
+import org.dubhe.base.MagicNumConstant;
+import org.dubhe.constant.SymbolConstant;
+import org.dubhe.dao.NoteBookMapper;
+import org.dubhe.dao.NoteBookModelMapper;
+import org.dubhe.domain.dto.NoteBookListQueryDTO;
+import org.dubhe.domain.dto.NoteBookQueryDTO;
+import org.dubhe.domain.dto.NoteBookStatusDTO;
+import org.dubhe.domain.dto.SourceNoteBookDTO;
+import org.dubhe.domain.entity.NoteBook;
+import org.dubhe.domain.entity.NoteBookModel;
+import org.dubhe.domain.vo.NoteBookVO;
+import org.dubhe.enums.BizEnum;
+import org.dubhe.enums.BizNfsEnum;
+import org.dubhe.enums.LogEnum;
+import org.dubhe.enums.NoteBookStatusEnum;
+import org.dubhe.exception.NotebookBizException;
+import org.dubhe.harbor.api.HarborApi;
+import org.dubhe.k8s.api.PodApi;
+import org.dubhe.k8s.api.JupyterResourceApi;
+import org.dubhe.k8s.api.NamespaceApi;
+import org.dubhe.k8s.domain.PtBaseResult;
+import org.dubhe.k8s.domain.resource.BizNamespace;
+import org.dubhe.k8s.domain.resource.BizPod;
+import org.dubhe.k8s.domain.vo.PtJupyterDeployVO;
+import org.dubhe.k8s.enums.K8sResponseEnum;
+import org.dubhe.service.HarborProjectService;
+import org.dubhe.service.NoteBookService;
+import org.dubhe.service.convert.NoteBookConvert;
+import org.dubhe.service.convert.PtJupyterResourceConvert;
+import org.dubhe.utils.HttpUtils;
+import org.dubhe.utils.K8sNameTool;
+import org.dubhe.utils.LogUtil;
+import org.dubhe.utils.NotebookUtil;
+import org.dubhe.utils.NumberUtil;
+import org.dubhe.utils.PageUtil;
+import org.dubhe.utils.WrapperHelp;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * @description notebook服务实现
+ * @date 2020-04-28
+ */
+@Service
+public class NoteBookServiceImpl implements NoteBookService {
+
+ @Autowired
+ private NoteBookMapper noteBookMapper;
+
+ @Autowired
+ private NoteBookModelMapper noteBookModelMapper;
+
+ @Autowired
+ private NoteBookConvert noteBookConvert;
+
+ @Autowired
+ private JupyterResourceApi jupyterResourceApi;
+
+ @Autowired
+ private PodApi podApi;
+
+ @Autowired
+ private NamespaceApi namespaceApi;
+
+ @Autowired
+ private K8sNameTool k8sNameTool;
+
+ @Autowired
+ private HarborApi harborApi;
+
+ @Autowired
+ private HarborProjectService harborProjectService;
+
+ private static final String BLANK = SymbolConstant.BLANK;
+
+ /**
+ * 分页查询所有 notebook 记录
+ *
+ * @param page
+ * @param noteBookListQueryDTO
+ * @return Map
+ */
+ @Override
+ public Map getNoteBookList(Page page, NoteBookListQueryDTO noteBookListQueryDTO) {
+ IPage noteBookPage = noteBookMapper.selectPage(page, WrapperHelp.getWrapper(noteBookListQueryDTO)
+ .ne(true, "status", NoteBookStatusEnum.DELETE.getCode())
+ .ne(true, "deleted", NoteBookStatusEnum.STOP.getCode())
+ .orderBy(true, false, "id"));
+ return PageUtil.toPage(noteBookPage, noteBookConvert::toDto);
+ }
+
+ /**
+ * 查询所有 notebook 记录
+ *
+ * @param page
+ * @param noteBookQueryDTO
+ * @return List
+ */
+ @Override
+ public List getList(Page page, NoteBookQueryDTO noteBookQueryDTO) {
+ return noteBookMapper.selectPage(page, WrapperHelp.getWrapper(noteBookQueryDTO)).getRecords();
+ }
+
+ /**
+ * 获取镜像路径
+ *
+ * @param bizEnum
+ * @return String
+ */
+ private String getDefaultImage(BizEnum bizEnum) {
+ if (bizEnum == null) {
+ throw new NotebookBizException("业务模块未识别!无法获取默认镜像。");
+ }
+ List projectList = harborProjectService.getHarborProjects(bizEnum.getCreateResource());
+ if (CollUtil.isEmpty(projectList)) {
+ throw new NotebookBizException("此模块" + bizEnum.getBizName() + "未配置Project!无法获取默认镜像。");
+ }
+ List imageList = harborApi.searchImageNames(projectList);
+ if (CollUtil.isEmpty(imageList)) {
+ throw new NotebookBizException("此模块" + bizEnum.getBizName() + "未配置镜像!");
+ }
+ return imageList.get(MagicNumConstant.ZERO);
+ }
+
+ /**
+ * 新增加 notebook
+ *
+ * @param noteBook
+ * @return NoteBookVO
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public NoteBookVO createNoteBook(NoteBook noteBook) {
+ if (noteBookMapper.findByNameAndUserId(noteBook.getNoteBookName(), noteBook.getCreateUserId(),NoteBookStatusEnum.DELETE.getCode()) != null) {
+ throw new NotebookBizException("Notebook名称已使用过!请重新提交。");
+ }
+ if (StringUtils.isEmpty(noteBook.getName())) {
+ noteBook.setName(k8sNameTool.getK8sName());
+ }
+ noteBook.setK8sNamespace(k8sNameTool.generateNameSpace(noteBook.getCreateUserId()));
+ noteBook.setK8sResourceName(k8sNameTool.generateResourceName(BizEnum.NOTEBOOK, noteBook.getName()));
+ if (StringUtils.isBlank(noteBook.getK8sPvcPath())) {
+ //20200618 修改为 使用训练路劲
+ noteBook.setK8sPvcPath(k8sNameTool.getNfsPath(BizNfsEnum.ALGORITHM, noteBook.getCreateUserId()));
+ }
+ noteBook.setK8sMountPath(NotebookUtil.getK8sMountPath());
+ if (start(noteBook)) {
+ noteBook.setStatus(NoteBookStatusEnum.STARTING.getCode());
+ } else {
+ noteBook.setStatus(NoteBookStatusEnum.STOP.getCode());
+ }
+ noteBookMapper.insert(noteBook);
+ return noteBookConvert.toDto(noteBook);
+ }
+
+ /**
+ * 初始化namespace
+ *
+ * @param noteBook
+ * @param labels
+ * @return boolean
+ */
+ private boolean initNameSpace(NoteBook noteBook, Map labels) {
+ try {
+ BizNamespace result = namespaceApi.create(noteBook.getK8sNamespace(), labels);
+ noteBook.setK8sStatusCode(result.getCode() == null ? BLANK : result.getCode());
+ noteBook.setK8sStatusInfo(NotebookUtil.getK8sStatusInfo(result));
+ return (HttpUtils.isSuccess(result.getCode())
+ || K8sResponseEnum.EXISTS.getCode().equals(result.getCode()));
+ } catch (Exception e) {
+ LogUtil.error(LogEnum.NOTE_BOOK, "createNoteBook调用jupyterResourceApi.createWithPvc异常!", e);
+ noteBook.setK8sStatusCode(BLANK);
+ noteBook.setK8sStatusInfo(NotebookUtil.getK8sStatusInfo(e));
+ return false;
+ }
+ }
+
+ /**
+ * 验证 notebook 是否可删除
+ *
+ * @param noteBookIds
+ * @return List
+ */
+ @Override
+ public List validateDeleteNoteBook(Set noteBookIds) {
+ for (Long noteBookId : noteBookIds) {
+ NumberUtil.isNumber(noteBookId);
+ }
+ List deleteTypeList = NoteBookStatusEnum.getCanDeleteStatus();
+ List noteBookList = noteBookMapper.selectBatchIds(noteBookIds);
+ for (NoteBook noteBook : noteBookList) {
+ if (deleteTypeList.contains(noteBook.getStatus())) {
+ throw new NotebookBizException("不可删除正在运行的notebook!");
+ }
+ }
+ return noteBookList;
+ }
+
+ /**
+ * 删除notebook异步方法
+ *
+ * @param noteBookList
+ */
+ @Override
+ @Async
+ @Transactional(rollbackFor = Exception.class)
+ public void deleteNoteBooks(List noteBookList) {
+ if (CollUtil.isNotEmpty(noteBookList)) {
+ for (NoteBook noteBook : noteBookList) {
+ if (noteBook.getStatus().equals(NoteBookStatusEnum.STOP.getCode())) {
+ deleteNoteBook(noteBook);
+ }
+ }
+ }
+ }
+
+ /**
+ * 删除notebook实现逻辑
+ *
+ * @param noteBook
+ * @return String
+ */
+ private String deleteNoteBook(NoteBook noteBook) {
+ if (noteBook == null) {
+ throw new NotebookBizException(NotebookUtil.NOTEBOOK_NOT_EXISTS);
+ }
+ String returnStr;
+ NoteBookStatusEnum statusEnum = getStatus(noteBook);
+ if (NoteBookStatusEnum.STOP == statusEnum) {
+ noteBook.setK8sStatusCode(BLANK);
+ noteBook.setK8sStatusInfo(BLANK);
+ noteBook.setUrl(BLANK);
+ returnStr = this.deletePvc(noteBook);
+ } else {
+ try {
+ PtBaseResult result = jupyterResourceApi.delete(noteBook.getK8sNamespace(), noteBook.getK8sResourceName());
+ noteBook.setK8sStatusCode(result.getCode() == null ? BLANK : result.getCode());
+ noteBook.setK8sStatusInfo(NotebookUtil.getK8sStatusInfo(result));
+ if (HttpUtils.isSuccess(result.getCode())) {
+ noteBook.setStatus(NoteBookStatusEnum.DELETING.getCode());
+ // 添加超时时间点
+ noteBook.setLastOperationTimeout(NotebookUtil.getTimeoutSecondLong());
+ noteBook.setUrl(BLANK);
+ returnStr = NoteBookStatusEnum.DELETING.getDescription();
+ } else if (K8sResponseEnum.REPEAT.getCode().equals(result.getCode())) {
+ // 重复提交停止指令,无需再次停止,直接删除PVC文件
+ noteBook.setUrl(BLANK);
+ returnStr = deletePvc(noteBook);
+ } else {
+ // 其他失败编码 -> 删除失败,保留原状态
+ returnStr = "删除失败";
+ }
+ } catch (Exception e) {
+ LogUtil.error(LogEnum.NOTE_BOOK, "deleteNoteBook调用jupyterResourceApi.delete异常!", e);
+ noteBook.setK8sStatusCode(BLANK);
+ noteBook.setK8sStatusInfo(NotebookUtil.getK8sStatusInfo(e));
+ returnStr = "删除失败";
+ }
+ }
+ this.updateById(noteBook);
+ return returnStr;
+ }
+
+ /**
+ * 启动notebook
+ *
+ * @param noteBookId
+ * @return String
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public String startNoteBook(Long noteBookId) {
+ NumberUtil.isNumber(noteBookId);
+ NoteBook noteBook = noteBookMapper.selectById(noteBookId);
+ return startNoteBook(noteBook);
+ }
+
+ /**
+ * 具体启动notebook实现
+ *
+ * @param noteBook
+ * @return String
+ */
+ private String startNoteBook(NoteBook noteBook) {
+ if (noteBook == null) {
+ throw new NotebookBizException(NotebookUtil.NOTEBOOK_NOT_EXISTS);
+ }
+ if (NoteBookStatusEnum.RUN.getCode().equals(noteBook.getStatus())) {
+ return "notebook " + NoteBookStatusEnum.RUN.getDescription();
+ } else if (NoteBookStatusEnum.STARTING.getCode().equals(noteBook.getStatus())) {
+ return "notebook " + NoteBookStatusEnum.STARTING.getDescription();
+ } else if (!NoteBookStatusEnum.STOP.getCode().equals(noteBook.getStatus())) {
+ throw new NotebookBizException("notebook【" + noteBook.getName() + "】当前状态:" + NoteBookStatusEnum.getDescription(noteBook.getStatus()) + ",无法再次启动。");
+ }
+ String returnStr;
+ if (start(noteBook)) {
+ noteBook.setStatus(NoteBookStatusEnum.STARTING.getCode());
+ returnStr = NoteBookStatusEnum.STARTING.getDescription();
+ } else {
+ // 重启notebook状态沿用历史状态
+ returnStr = "启动" + NotebookUtil.FAILED;
+ }
+ this.updateById(noteBook);
+ return returnStr;
+ }
+
+ /**
+ * 更新notebook
+ *
+ * @param noteBook
+ * @return NoteBook
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public NoteBook updateById(NoteBook noteBook) {
+ noteBook.setUpdateTime(null);
+ noteBook.setUpdateUserId(NotebookUtil.getCurUserId());
+ noteBookMapper.updateById(noteBook);
+ return noteBook;
+ }
+
+ /**
+ * 启动notebook
+ *
+ * @param noteBook
+ * @return true 启动成功;false 启动失败
+ */
+ private boolean start(NoteBook noteBook) {
+ // 添加启动时间
+ noteBook.setLastStartTime(new Date());
+ // 添加超时时间点
+ noteBook.setLastOperationTimeout(NotebookUtil.getTimeoutSecondLong());
+ if (initNameSpace(noteBook, null)) {
+ try {
+ //20200618 修改为 创建时不创建PVC
+ PtJupyterDeployVO result = jupyterResourceApi.create(PtJupyterResourceConvert.toPtJupyterResourceBo(noteBook, k8sNameTool));
+ noteBook.setK8sStatusCode(result.getCode() == null ? BLANK : result.getCode());
+ noteBook.setK8sStatusInfo(NotebookUtil.getK8sStatusInfo(result));
+ return HttpUtils.isSuccess(result.getCode());
+ } catch (Exception e) {
+ LogUtil.error(LogEnum.NOTE_BOOK, "notebook调用jupyterResourceApi.createWithPvc异常!", e);
+ noteBook.setK8sStatusCode(BLANK);
+ noteBook.setK8sStatusInfo(NotebookUtil.getK8sStatusInfo(e));
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * 停止notebook
+ *
+ * @param noteBookId
+ * @return String
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public String stopNoteBook(Long noteBookId) {
+ NumberUtil.isNumber(noteBookId);
+ NoteBook noteBook = noteBookMapper.selectById(noteBookId);
+ if (noteBook == null) {
+ throw new NotebookBizException(NotebookUtil.NOTEBOOK_NOT_EXISTS);
+ }
+ if (!NoteBookStatusEnum.RUN.getCode().equals(noteBook.getStatus())) {
+ throw new NotebookBizException("notebook正在运行,不能停止");
+ }
+ String returnStr;
+ NoteBookStatusEnum statusEnum = getStatus(noteBook);
+ if (NoteBookStatusEnum.STOP == statusEnum) {
+ noteBook.setK8sStatusCode(BLANK);
+ noteBook.setK8sStatusInfo(BLANK);
+ noteBook.setUrl(BLANK);
+ returnStr = "已停止";
+ } else {
+ try {
+ PtBaseResult result = jupyterResourceApi.delete(noteBook.getK8sNamespace(), noteBook.getK8sResourceName());
+ noteBook.setK8sStatusCode(result.getCode() == null ? BLANK : result.getCode());
+ noteBook.setK8sStatusInfo(NotebookUtil.getK8sStatusInfo(result));
+ if (HttpUtils.isSuccess(result.getCode())) {
+ noteBook.setStatus(NoteBookStatusEnum.STOPPING.getCode());
+ // 添加超时时间点
+ noteBook.setLastOperationTimeout(NotebookUtil.getTimeoutSecondLong());
+ noteBook.setUrl(BLANK);
+ returnStr = NoteBookStatusEnum.STOPPING.getDescription();
+ } else if (K8sResponseEnum.REPEAT.getCode().equals(result.getCode())) {
+ // 重复提交停止指令,无需再次停止,直接标记停止
+ noteBook.setStatus(NoteBookStatusEnum.STOP.getCode());
+ noteBook.setUrl(BLANK);
+ returnStr = NoteBookStatusEnum.STOP.getDescription();
+ } else {
+ // 其他失败编码 -> 停止失败,保留原状态
+ returnStr = "停止" + NotebookUtil.FAILED;
+ }
+ } catch (Exception e) {
+ LogUtil.error(LogEnum.NOTE_BOOK, "停止notebook调用jupyterResourceApi.delete异常!", e);
+ noteBook.setK8sStatusCode(BLANK);
+ noteBook.setK8sStatusInfo(NotebookUtil.getK8sStatusInfo(e));
+ returnStr = "停止" + NotebookUtil.FAILED;
+ }
+ }
+ this.updateById(noteBook);
+ return returnStr;
+ }
+
+ /**
+ * 开启notebook
+ *
+ * @param noteBookId
+ * @return String
+ */
+ @Override
+ public String openNoteBook(Long noteBookId) {
+ NumberUtil.isNumber(noteBookId);
+ NoteBook noteBook = noteBookMapper.selectById(noteBookId);
+ if (noteBook == null) {
+ throw new NotebookBizException(NotebookUtil.NOTEBOOK_NOT_EXISTS);
+ } else if (NoteBookStatusEnum.RUN.getCode().equals(noteBook.getStatus())) {
+ if (NotebookUtil.checkUrlContainsToken(noteBook.getUrl())) {
+ return noteBook.getUrl();
+ } else {
+ // 补偿:已启动notebook获取可访问地址
+ String jupyterUrlWithToken = this.getJupyterUrl(noteBook);
+ if (NotebookUtil.checkUrlContainsToken(jupyterUrlWithToken)) {
+ noteBook.setUrl(jupyterUrlWithToken);
+ this.updateById(noteBook);
+ return noteBook.getUrl();
+ } else {
+ throw new NotebookBizException("notebook已启动 获取URL失败!");
+ }
+ }
+ } else {
+ throw new NotebookBizException("notebook 尚未启动成功,无法打开。");
+ }
+ }
+
+ /**
+ * 获取jupyter 地址
+ *
+ * @param noteBook
+ * @return String
+ */
+ @Override
+ public String getJupyterUrl(NoteBook noteBook) {
+ try {
+ return podApi.getUrlByResourceName(noteBook.getK8sNamespace(), noteBook.getK8sResourceName());
+ } catch (Exception e) {
+ LogUtil.error(LogEnum.NOTE_BOOK, "notebook nameSpace:{} resourceName:{} 获取URL失败!", noteBook.getK8sNamespace(), noteBook.getK8sResourceName(), e);
+ noteBook.setK8sStatusCode(BLANK);
+ noteBook.setK8sStatusInfo(NotebookUtil.getK8sStatusInfo(e));
+ return null;
+ }
+ }
+
+ /**
+ * 获取notebook状态
+ *
+ * @param noteBook
+ * @return NoteBookStatusEnum
+ */
+ @Override
+ public NoteBookStatusEnum getStatus(NoteBook noteBook) {
+ try {
+ BizPod result = podApi.getWithResourceName(noteBook.getK8sNamespace(), noteBook.getK8sResourceName());
+ noteBook.setK8sStatusCode(result.getCode() == null ? BLANK : result.getCode());
+ noteBook.setK8sStatusInfo(NotebookUtil.getK8sStatusInfo(result));
+ if (K8sResponseEnum.NOT_FOUND.getCode().equals(result.getCode())) {
+ // 结果不存在当已停止
+ return NoteBookStatusEnum.STOP;
+ } else if (!HttpUtils.isSuccess(result.getCode())) {
+ LogUtil.warn(LogEnum.NOTE_BOOK, "notebook nameSpace:{} resourceName:{} 查询失败!", noteBook.getK8sNamespace(), noteBook.getK8sResourceName());
+ return null;
+ }
+ return NoteBookStatusEnum.convert(result.getPhase());
+ } catch (Exception e) {
+ LogUtil.error(LogEnum.NOTE_BOOK, "notebook nameSpace:{} resourceName:{} 查询异常!", noteBook.getK8sNamespace(), noteBook.getK8sResourceName(), e);
+ noteBook.setK8sStatusCode(BLANK);
+ noteBook.setK8sStatusInfo(NotebookUtil.getK8sStatusInfo(e));
+ return null;
+ }
+ }
+
+ /**
+ * 第三方创建notebook
+ *
+ * @param bizNfsEnum
+ * @param sourceNoteBookDTO
+ * @return NoteBookVO
+ */
+ @Override
+ public NoteBookVO createNoteBookByThirdParty(BizNfsEnum bizNfsEnum, SourceNoteBookDTO sourceNoteBookDTO) {
+ String k8sPvcPath = sourceNoteBookDTO.getSourceFilePath();
+ NoteBook noteBook = noteBookMapper.selectOne(WrapperHelp.getWrapper(new NoteBookQueryDTO(
+ NoteBookStatusEnum.DELETE.getCode(),
+ k8sPvcPath,
+ sourceNoteBookDTO.getCurUserId())
+ ));
+ if (noteBook == null) {
+ return this.createNoteBook(initSourceReqNoteBook(bizNfsEnum, sourceNoteBookDTO, k8sPvcPath));
+ } else {
+ if (!NoteBookStatusEnum.RUN.getCode().equals(noteBook.getStatus())) {
+ this.startNoteBook(noteBook);
+ }
+ return noteBookConvert.toDto(noteBook);
+ }
+ }
+
+ /**
+ * 初始化第三方请求的notebook
+ *
+ * @param bizNfsEnum
+ * @param sourceNoteBookDTO
+ * @param k8sPvcPath
+ * @return NoteBook
+ */
+ private NoteBook initSourceReqNoteBook(BizNfsEnum bizNfsEnum, SourceNoteBookDTO sourceNoteBookDTO, String k8sPvcPath) {
+ NoteBook noteBook = new NoteBook();
+ noteBook.setCreateUserId(sourceNoteBookDTO.getCurUserId());
+ noteBook.setUserId(sourceNoteBookDTO.getCurUserId());
+ noteBook.setCreateResource(bizNfsEnum.getCreateResource());
+ noteBook.setDescription(bizNfsEnum.getBizName());
+ noteBook.setName(k8sNameTool.getK8sName());
+ String notebookName = NotebookUtil.generateName(bizNfsEnum, sourceNoteBookDTO.getSourceId());
+ if (noteBookMapper.findByNameAndUserId(notebookName, noteBook.getCreateUserId(),NoteBookStatusEnum.DELETE.getCode()) != null) {
+ // 重名随机符号拼接
+ notebookName += RandomUtil.randomString(MagicNumConstant.TWO);
+ }
+
+ noteBook.setNoteBookName(notebookName);
+ noteBook.setCpuNum(MagicNumConstant.ONE);
+ noteBook.setGpuNum(MagicNumConstant.ZERO);
+ noteBook.setMemNum(MagicNumConstant.ONE);
+ noteBook.setDiskMemNum(MagicNumConstant.ONE);
+ noteBook.setAlgorithmId(sourceNoteBookDTO.getSourceId());
+
+ noteBook.setK8sPvcPath(k8sPvcPath);
+ noteBook.setK8sImageName(getDefaultImage(BizEnum.NOTEBOOK));
+ return noteBook;
+ }
+
+ /**
+ * 获取地址
+ *
+ * @param noteBookId
+ * @return String
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public String getAddress(Long noteBookId) {
+ NumberUtil.isNumber(noteBookId);
+ NoteBook noteBook = noteBookMapper.selectById(noteBookId);
+ if (noteBook == null) {
+ throw new NotebookBizException(NotebookUtil.NOTEBOOK_NOT_EXISTS);
+ } else if (NoteBookStatusEnum.RUN.getCode().equals(noteBook.getStatus())) {
+ if (NotebookUtil.checkUrlContainsToken(noteBook.getUrl())) {
+ return noteBook.getUrl();
+ } else {
+ // 补偿:已启动notebook获取可访问地址
+ String jupyterUrlWithToken = this.getJupyterUrl(noteBook);
+ if (NotebookUtil.checkUrlContainsToken(jupyterUrlWithToken)) {
+ noteBook.setUrl(jupyterUrlWithToken);
+ this.updateById(noteBook);
+ return noteBook.getUrl();
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * 删除PVC
+ *
+ * @param noteBook
+ * @return String
+ */
+ @Override
+ public String deletePvc(NoteBook noteBook) {
+ noteBook.setStatus(NoteBookStatusEnum.DELETE.getCode());
+ noteBook.setDeleted(MagicNumConstant.ONE);
+ return NoteBookStatusEnum.DELETE.getDescription();
+ }
+
+ /**
+ * 获取notebook所有状态
+ *
+ * @return List
+ */
+ @Override
+ public List getNoteBookStatus() {
+ List noteBookStatusDtoList = new ArrayList<>();
+ for (NoteBookStatusEnum noteBookStatusEnum : NoteBookStatusEnum.values()) {
+ if (noteBookStatusEnum != NoteBookStatusEnum.DELETE) {
+ NoteBookStatusDTO noteBookStatusDTO = new NoteBookStatusDTO();
+ noteBookStatusDTO.setStatusCode(noteBookStatusEnum.getCode());
+ noteBookStatusDTO.setStatusName(noteBookStatusEnum.getDescription());
+ noteBookStatusDtoList.add(noteBookStatusDTO);
+ }
+ }
+ return noteBookStatusDtoList;
+ }
+
+ /**
+ * 获取正在运行的notebook数量
+ *
+ * @param curUserId
+ * @return int
+ */
+ @Override
+ public int getNoteBookRunNumber(long curUserId) {
+ return noteBookMapper.selectRunNoteBookNum(curUserId,NoteBookStatusEnum.RUN.getCode());
+ }
+
+ /**
+ * 获取notebook配置的模式数据
+ *
+ * @return Map>
+ */
+ @Override
+ public Map> getNoteBookModel() {
+ List noteBookModelList = noteBookModelMapper.selectAllNoteBookModel();
+ return CollUtil.isEmpty(noteBookModelList) ?
+ new HashMap<>(MagicNumConstant.EIGHT) :
+ noteBookModelList.stream().collect(Collectors.groupingBy(NoteBookModel::getModelType));
+ }
+
+ /**
+ * 刷新notebook状态
+ *
+ * @param statusEnum
+ * @param noteBook
+ * @return boolean
+ */
+ @Override
+ public boolean refreshNoteBookStatus(NoteBookStatusEnum statusEnum, NoteBook noteBook) {
+ if (NoteBookStatusEnum.RUN == statusEnum) {
+ if (NoteBookStatusEnum.STARTING.getCode().equals(noteBook.getStatus())) {
+ // append jupyter url+token
+ noteBook.setUrl(this.getJupyterUrl(noteBook));
+ // 仅启动中可切换为启动状态
+ noteBook.setStatus(statusEnum.getCode());
+ } else {
+ return true;
+ }
+ } else if (NoteBookStatusEnum.STOP == statusEnum) {
+ if (NoteBookStatusEnum.DELETING.getCode().equals(noteBook.getStatus())) {
+ this.deletePvc(noteBook);
+ // deletePVC方法内部已设置状态,无需这边设置
+ } else {
+ noteBook.setStatus(statusEnum.getCode());
+ }
+ noteBook.setUrl(BLANK);
+ }
+ return false;
+ }
+
+ /**
+ * 支持双向更新,如果不为0 ,则是绑定关联关系,反之解除绑定关系
+ *
+ * @param noteBookId
+ * @param algorithmId
+ * @return boolean
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public boolean updateTrainIdByNoteBookId(Long noteBookId, Long algorithmId) {
+ if (noteBookId != null) {
+ NumberUtil.isNumber(noteBookId);
+ NoteBook noteBook = noteBookMapper.selectById(noteBookId);
+ if (noteBook != null) {
+ noteBook.setAlgorithmId(algorithmId == null ? MagicNumConstant.ZERO : algorithmId);
+ noteBookMapper.updateById(noteBook);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * 获取notebook详情
+ *
+ * @param noteBookIds
+ * @return List
+ */
+ @Override
+ public List getNotebookDetail(Set noteBookIds) {
+ QueryWrapper queryWrapper = new QueryWrapper<>();
+ queryWrapper.in("id",noteBookIds);
+ queryWrapper.eq("user_id",NotebookUtil.getCurUserId());
+ queryWrapper.ne("status",NoteBookStatusEnum.DELETE.getCode());
+ List noteBookList = noteBookMapper.selectList(queryWrapper);
+ return noteBookConvert.toDto(noteBookList);
+ }
+
+ /**
+ * 获取正在运行却没有URL的notebook
+ *
+ * @param page
+ * @return List
+ */
+ @Override
+ public List getRunNotUrlList(Page page) {
+ return noteBookMapper.selectRunNotUrlList(page,NoteBookStatusEnum.RUN.getCode());
+ }
+}
diff --git a/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/impl/PtDatasetServiceImpl.java b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/impl/PtDatasetServiceImpl.java
new file mode 100644
index 0000000..28fcced
--- /dev/null
+++ b/dubhe-server/dubhe-admin/src/main/java/org/dubhe/service/impl/PtDatasetServiceImpl.java
@@ -0,0 +1,122 @@
+/**
+ * Copyright 2020 Zhejiang Lab. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =============================================================
+ */
+
+package org.dubhe.service.impl;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.dubhe.dao.PtDatasetMapper;
+import org.dubhe.domain.PtDataset;
+import org.dubhe.domain.dto.PtDatasetDTO;
+import org.dubhe.domain.dto.PtDatasetQueryCriteria;
+import org.dubhe.service.PtDatasetService;
+import org.dubhe.service.convert.PtDatasetConvert;
+import org.dubhe.utils.FileUtil;
+import org.dubhe.utils.PageUtil;
+import org.dubhe.utils.StringUtils;
+import org.dubhe.utils.WrapperHelp;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.CacheConfig;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @description 数据集管理
+ * @date 2020-03-17
+ */
+@Service
+@CacheConfig(cacheNames = "ptDataset")
+@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
+public class PtDatasetServiceImpl implements PtDatasetService {
+
+ @Autowired
+ private PtDatasetMapper ptDatasetMapper;
+ @Autowired
+ private PtDatasetConvert ptDatasetConvert;
+
+
+ @Override
+ @Cacheable
+ public Map queryAll(PtDatasetQueryCriteria criteria, Page page) {
+ IPage ptDatasets = ptDatasetMapper.selectPage(page, WrapperHelp.getWrapper(criteria));
+ return PageUtil.toPage(ptDatasets, ptDatasetConvert::toDto);
+ }
+
+ @Override
+ @Cacheable
+ public List queryAll(PtDatasetQueryCriteria criteria) {
+ return ptDatasetConvert.toDto(ptDatasetMapper.selectList(WrapperHelp.getWrapper(criteria)));
+ }
+
+ @Override
+ @Cacheable(key = "#p0")
+ public PtDatasetDTO findById(Long id) {
+ PtDataset ptDataset = ptDatasetMapper.selectById(id);
+ return ptDatasetConvert.toDto(ptDataset);
+ }
+
+ @Override
+ @CacheEvict(allEntries = true)
+ @Transactional(rollbackFor = Exception.class)
+ public PtDatasetDTO create(PtDataset resources) {
+ ptDatasetMapper.insert(resources);
+ return ptDatasetConvert.toDto(resources);
+ }
+
+ @Override
+ @CacheEvict(allEntries = true)
+ @Transactional(rollbackFor = Exception.class)
+ public void update(PtDataset resources) {
+ PtDataset ptDataset = ptDatasetMapper.selectById(resources.getId());
+ ptDataset.copy(resources);
+ ptDatasetMapper.updateById(ptDataset);
+ }
+
+ @Override
+ @CacheEvict(allEntries = true)
+ public void deleteAll(Long[] ids) {
+ for (Long id : ids) {
+ ptDatasetMapper.deleteById(id);
+ }
+ }
+
+ @Override
+ public void download(List all, HttpServletResponse response) throws IOException {
+ List