@@ -36,7 +36,7 @@ Thumbs.db | |||
target/ | |||
output/ | |||
*.jar | |||
!/dubhe-dcm/lib/dcm4che-core-5.19.1.jar | |||
!/dubhe-data-dcm/lib/dcm4che-core-5.19.1.jar | |||
!.mvn/wrapper/* | |||
*.war | |||
*.zip | |||
@@ -48,6 +48,4 @@ output/ | |||
.project | |||
.classpath | |||
logs/ | |||
/dubhe-k8s/src/main/resources/kubeconfig | |||
*.log | |||
/dubhe-admin/kubeconfig | |||
*.log |
@@ -1,5 +1,4 @@ | |||
# type: subject | |||
# type:feat增加新功能;fix修复错误;docs修改文档;style修改样式;refactor代码重构;test增加测试模块,不涉及生产环境的代码;chore更新核心模块,包配置文件,不涉及生产环境的代码 | |||
# subject: 一两句话简述提交原因,与下方详细描述间隔一行 | |||
@@ -1,62 +1,5 @@ | |||
FROM docker | |||
FROM harbor.dubhe.ai/dubhe/docker-in-docker-java8-ssh:v3 | |||
RUN apk add ffmpeg | |||
ENV LANG=C.UTF-8 | |||
#更换为aliyun源 | |||
RUN echo "http://mirrors.aliyun.com/alpine/latest-stable/community" > /etc/apk/repositories | |||
RUN echo "http://mirrors.aliyun.com/alpine/latest-stable/main" >> /etc/apk/repositories | |||
#update apk bash vim wget curl net-tools sshpass | |||
RUN apk update \ | |||
&& apk upgrade \ | |||
&& apk --no-cache add ca-certificates \ | |||
&& apk add bash \ | |||
bash-doc \ | |||
bash-completion \ | |||
vim \ | |||
wget \ | |||
curl \ | |||
net-tools \ | |||
sshpass \ | |||
&& rm -rf /var/cache/apk/* \ | |||
&& /bin/bash | |||
#setup glibc | |||
RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.32-r0/glibc-2.32-r0.apk | |||
RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.32-r0/glibc-bin-2.32-r0.apk | |||
RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.32-r0/glibc-i18n-2.32-r0.apk | |||
RUN apk add --no-cache --virtual=.build-dependencies wget ca-certificates && \ | |||
echo \ | |||
"-----BEGIN PUBLIC KEY-----\ | |||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApZ2u1KJKUu/fW4A25y9m\ | |||
y70AGEa/J3Wi5ibNVGNn1gT1r0VfgeWd0pUybS4UmcHdiNzxJPgoWQhV2SSW1JYu\ | |||
tOqKZF5QSN6X937PTUpNBjUvLtTQ1ve1fp39uf/lEXPpFpOPL88LKnDBgbh7wkCp\ | |||
m2KzLVGChf83MS0ShL6G9EQIAUxLm99VpgRjwqTQ/KfzGtpke1wqws4au0Ab4qPY\ | |||
KXvMLSPLUp7cfulWvhmZSegr5AdhNw5KNizPqCJT8ZrGvgHypXyiFvvAH5YRtSsc\ | |||
Zvo9GI2e2MaZyo9/lvb+LbLEJZKEQckqRj4P26gmASrZEPStwc+yqy1ShHLA0j6m\ | |||
1QIDAQAB\ | |||
-----END PUBLIC KEY-----" | sed 's/ */\n/g' > "/etc/apk/keys/sgerrand.rsa.pub" | |||
RUN apk add glibc-2.32-r0.apk | |||
RUN apk add glibc-bin-2.32-r0.apk | |||
RUN apk add glibc-i18n-2.32-r0.apk | |||
RUN rm -rf *.apk | |||
#setup date | |||
RUN apk add tzdata | |||
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime | |||
#安装jdk | |||
RUN wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz" | |||
RUN tar xzf jdk-8u141-linux-x64.tar.gz -C /usr/local/ | |||
ENV JAVA_HOME /usr/local/jdk1.8.0_141 | |||
ENV PATH ${PATH}:${JAVA_HOME}/bin | |||
ENV CLASSPATH $JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar | |||
#设置到nfs-host-ip的免密登录 | |||
RUN ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa >/dev/null 2>&1 && \ | |||
#让连接新主机时,不进行公钥确认 | |||
echo "StrictHostKeyChecking no">>/etc/ssh/ssh_config && \ | |||
#发送公钥到目标服务器 | |||
sshpass -p nfs-host-pwd ssh-copy-id -p 22 -i ~/.ssh/id_rsa.pub nfs-host-user@nfs-host-ip | |||
COPY dubhe-admin/target/dubhe-admin-1.0-exec.jar /dubhe/ | |||
COPY dubhe-task/target/dubhe-task-1.0.jar /dubhe/ | |||
COPY dubhe-serving-gateway/target/dubhe-serving-gateway.jar /dubhe/ | |||
COPY */target/*-exec.jar /dubhe/ | |||
CMD ["bash", "-c","exec java $JVM_PARAM -Dspring.security.strategy=MODE_INHERITABLETHREADLOCAL -jar -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 /dubhe/$JAR_BALL"] |
@@ -1,211 +0,0 @@ | |||
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 |
@@ -1,108 +1,64 @@ | |||
# 之江天枢-服务端 | |||
# Spring Cloud | |||
## 微服务框架核心组件 | |||
Nacos + Fegin + Gateway + (Spring Security + JWT + OAuth2) | |||
**之江天枢一站式人工智能开源平台**(简称:**之江天枢**),包括海量数据处理、交互式模型构建(包含Notebook和模型可视化)、AI模型高效训练。多维度产品形态满足从开发者到大型企业的不同需求,将提升人工智能技术的研发效率、扩大算法模型的应用范围,进一步构建人工智能生态“朋友圈”。 | |||
数据库连接池 Druid | |||
## 源码部署 | |||
需要额外部署 Mysql Nacos | |||
### 准备环境 | |||
安装如下软件环境。 | |||
- OpenJDK:1.8+ | |||
- Redis: 5.0+ | |||
- Maven: 3.0+ | |||
- MYSQL: 5.7.0+ | |||
## 初始化配置 | |||
### Mysql | |||
### 下载源码 | |||
``` bash | |||
git clone https://codeup.teambition.com/zhejianglab/dubhe-server.git | |||
# 进入项目根目录 | |||
cd dubhe-server | |||
``` | |||
初始化sql位置 /sql | |||
### 创建DB | |||
在MySQL中依次执行如下sql文件 | |||
``` | |||
sql/v1/00-Dubhe-DB.sql | |||
sql/v1/01-Dubhe-DDL.sql | |||
sql/v1/02-Dubhe-DML.sql | |||
``` | |||
**地址:** 127.0.0.1:3306 | |||
**用户名:** test **密码:** test | |||
### 配置 | |||
根据实际情况修改如下配置文件。 | |||
``` | |||
dubhe-admin/src/main/resources/config/application-prod.yml | |||
``` | |||
### Nacos | |||
### 构建 | |||
``` bash | |||
# 构建,生成的 jar 包位于 ./dubhe-admin/target/dubhe-admin-1.0.jar | |||
mvn clean compile package | |||
``` | |||
**如何部署:** https://nacos.io/zh-cn/docs/quick-start.html | |||
### 启动 | |||
``` bash | |||
# 指定启动环境为 prod | |||
## admin模块 | |||
java -jar ./dubhe-admin/target/dubhe-admin-1.0-exec.jar --spring.profiles.active=prod | |||
配置中心配置参考 /yaml | |||
## task模块 | |||
java -jar ./dubhe-task/target/dubhe-task-1.0.jar --spring.profiles.active=prod | |||
**配置规则:** ${prefix}-${spring.profiles.active}.${file-extension} | |||
## serving gateway模块 | |||
java -jar ./dubhe-serving-gateway/target/dubhe-serving-gateway.jar --spring.profiles.active=prod | |||
``` | |||
**详见:** https://nacos.io/zh-cn/docs/quick-start-spring-cloud.html | |||
**地址:** http://127.0.0.1:8848/nacos/#/login | |||
**用户名:** nacos **密码:** nacos | |||
## 本地开发 | |||
开发人员进行开发自测时,请使用以自己名字命名的namespace进行测试,不要使用dev或者test | |||
### 必要条件: | |||
导入maven项目,下载所需的依赖包 | |||
mysql下创建数据库dubhe,初始化数据脚本 | |||
安装redis | |||
### 启动: | |||
mvn spring-boot:run | |||
### swagger | |||
默认开启,若需要关闭,手动配置swagger.enabled: false | |||
## 代码结构: | |||
**各模块swagger访问地址:** http://{IP}:{port}/doc.html | |||
**可通过swagger统一的网关访问地址:** http://{gateway IP}:{gateway port}/doc.html查看基于gateway路由配置的后台rest服务 | |||
### OAuth2 | |||
授权token获取样例: | |||
*POST* http://localhost:8866/oauth/token?grant_type=password&username=admin&client_id=dubhe-client&client_secret=dubhe-secret&password=123456&scope=all | |||
请求资源时在header添加: | |||
Authorization: 'Bearer '+${access_token} | |||
测试服务提供者配置中心动态获取配置样例: | |||
header 添加-> Authorization:'Bearer '+${access_token} | |||
*GET* http://localhost:8860/config/get | |||
刷新token样例: | |||
*POST* http://localhost:8866/oauth/token?grant_type=refresh_token&client_id=dubhe-client&client_secret=dubhe-secret&scope=all&refresh_token=${refresh_token} | |||
### Admin | |||
登录接口 | |||
```$xslt | |||
url: | |||
*POST* http://localhost:8870/auth/login | |||
param: | |||
{"username":"admin","password":"RBb2Czac2HBI9XNj4ZLF1QcTytOe5pN1vHZHYuAVgSAPRcYbndn/4zGDxKdXS1j0sLsDsKZLUojEXFnYHpsKxA==","code":"jggg","uuid":"validate_codeea991a3cb8ea47cca05744a47ad17a37"} | |||
``` | |||
├── common 公共模块 | |||
├── dubhe-admin 开发与训练模块 | |||
│ ├── src | |||
│ │ └── main | |||
│ │ ├── java | |||
│ │ │ └── org | |||
│ │ │ └── dubhe | |||
│ │ │ ├── AppRun.java | |||
│ │ │ ├── domain 实体对象 | |||
│ │ │ ├── repository 数据库层 | |||
│ │ │ ├── rest 控制层 | |||
│ │ │ └── service 服务层 | |||
│ │ │ ├── dto 数据传输对象 | |||
│ │ │ ├── impl 服务实现 | |||
│ │ │ └── mapper 对象转化 | |||
│ │ └── resources 配置文件 | |||
├── dubhe-data 数据处理模块 | |||
├── dubhe-model 模型管理模块 | |||
├── dubhe-system 系统管理 | |||
├── dubhe-task 定时任务模块 | |||
├── dubhe-serving 云端serving模块 | |||
├── dubhe-serving-gateway 云端serving gateway网关模块 | |||
``` | |||
## 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 | |||
@@ -1,120 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
xmlns="http://maven.apache.org/POM/4.0.0" | |||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||
<parent> | |||
<artifactId>dubheplatform</artifactId> | |||
<groupId>zhejianglab</groupId> | |||
<version>1.0</version> | |||
</parent> | |||
<modelVersion>4.0.0</modelVersion> | |||
<properties> | |||
<hutool.version>5.0.6</hutool.version> | |||
<minio.version>7.0.2</minio.version> | |||
<aspectjweaver.version>1.8.9</aspectjweaver.version> | |||
</properties> | |||
<artifactId>common</artifactId> | |||
<name>公共模块</name> | |||
<dependencies> | |||
<!--工具包--> | |||
<dependency> | |||
<groupId>cn.hutool</groupId> | |||
<artifactId>hutool-all</artifactId> | |||
<version>${hutool.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>com.google.guava</groupId> | |||
<artifactId>guava</artifactId> | |||
<version>21.0</version> | |||
</dependency> | |||
<!-- shiro --> | |||
<dependency> | |||
<groupId>org.apache.shiro</groupId> | |||
<artifactId>shiro-spring</artifactId> | |||
<version>${shiro.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>com.auth0</groupId> | |||
<artifactId>java-jwt</artifactId> | |||
<version>${jwt.version}</version> | |||
<exclusions> | |||
<exclusion> | |||
<groupId>*</groupId> | |||
<artifactId>*</artifactId> | |||
</exclusion> | |||
</exclusions> | |||
</dependency> | |||
<dependency> | |||
<groupId>io.minio</groupId> | |||
<artifactId>minio</artifactId> | |||
<version>${minio.version}</version> | |||
</dependency> | |||
<!-- aspect --> | |||
<dependency> | |||
<groupId>org.aspectj</groupId> | |||
<artifactId>aspectjweaver</artifactId> | |||
<version>${aspectjweaver.version}</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>javax.xml.bind</groupId> | |||
<artifactId>jaxb-api</artifactId> | |||
<version>2.3.0</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>com.sun.xml.bind</groupId> | |||
<artifactId>jaxb-impl</artifactId> | |||
<version>2.3.0</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>com.sun.xml.bind</groupId> | |||
<artifactId>jaxb-core</artifactId> | |||
<version>2.3.0</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-io</groupId> | |||
<artifactId>commons-io</artifactId> | |||
<version>1.3.2</version> | |||
<scope>compile</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>net.lingala.zip4j</groupId> | |||
<artifactId>zip4j</artifactId> | |||
<version>1.3.2</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.commons</groupId> | |||
<artifactId>commons-compress</artifactId> | |||
<version>1.20</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>com.github.whvcse</groupId> | |||
<artifactId>easy-captcha</artifactId> | |||
</dependency> | |||
</dependencies> | |||
<build> | |||
<plugins> | |||
<plugin> | |||
<groupId>org.springframework.boot</groupId> | |||
<artifactId>spring-boot-maven-plugin</artifactId> | |||
</plugin> | |||
<!-- 跳过单元测试 --> | |||
<plugin> | |||
<groupId>org.apache.maven.plugins</groupId> | |||
<artifactId>maven-surefire-plugin</artifactId> | |||
<configuration> | |||
<skipTests>true</skipTests> | |||
</configuration> | |||
</plugin> | |||
</plugins> | |||
<resources> | |||
<resource> | |||
<filtering>true</filtering> | |||
<directory>src/main/resources</directory> | |||
</resource> | |||
</resources> | |||
</build> | |||
</project> |
@@ -1,32 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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; | |||
} |
@@ -1,41 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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; | |||
/** | |||
* @description 数据权限注解 | |||
* @date 2020-09-24 | |||
*/ | |||
import java.lang.annotation.*; | |||
@Target({ElementType.METHOD, ElementType.TYPE}) | |||
@Retention(RetentionPolicy.RUNTIME) | |||
@Documented | |||
public @interface DataPermission { | |||
/** | |||
* 只在类的注解上使用,代表方法的数据权限类型 | |||
* @return | |||
*/ | |||
String permission() default ""; | |||
/** | |||
* 不需要数据权限的方法名 | |||
* @return | |||
*/ | |||
String[] ignoresMethod() default {}; | |||
} |
@@ -1,47 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 org.dubhe.enums.DatasetTypeEnum; | |||
import java.lang.annotation.ElementType; | |||
import java.lang.annotation.Retention; | |||
import java.lang.annotation.RetentionPolicy; | |||
import java.lang.annotation.Target; | |||
/** | |||
* @description 数据权限方法注解 | |||
* @date 2020-09-24 | |||
*/ | |||
@Target(ElementType.METHOD) | |||
@Retention(RetentionPolicy.RUNTIME) | |||
public @interface DataPermissionMethod { | |||
/** | |||
* 是否需要拦截标识 true: 不拦截 false: 拦截 | |||
* | |||
* @return 拦截标识 | |||
*/ | |||
boolean interceptFlag() default false; | |||
/** | |||
* 数据类型 | |||
* | |||
* @return 数据集类型 | |||
*/ | |||
DatasetTypeEnum dataType() default DatasetTypeEnum.PRIVATE; | |||
} |
@@ -1,88 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 javax.validation.Constraint; | |||
import javax.validation.ConstraintValidator; | |||
import javax.validation.ConstraintValidatorContext; | |||
import javax.validation.Payload; | |||
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; | |||
/** | |||
* @description 接口枚举类检测标注类 | |||
* @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<EnumValue, Object> { | |||
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); | |||
} | |||
} | |||
} | |||
} |
@@ -1,66 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 javax.validation.Constraint; | |||
import javax.validation.ConstraintValidator; | |||
import javax.validation.ConstraintValidatorContext; | |||
import javax.validation.Payload; | |||
import java.lang.annotation.*; | |||
import java.util.Arrays; | |||
/** | |||
* @description 自定义状态校验注解(传入值是否在指定状态范围内) | |||
* @date 2020-09-18 | |||
*/ | |||
@Target({ElementType.FIELD, ElementType.PARAMETER}) | |||
@Retention(RetentionPolicy.RUNTIME) | |||
@Constraint(validatedBy = FlagValidator.Validator.class) | |||
@Documented | |||
public @interface FlagValidator { | |||
String[] value() default {}; | |||
String message() default "flag value is invalid"; | |||
Class<?>[] groups() default {}; | |||
Class<? extends Payload>[] payload() default {}; | |||
/** | |||
* @description 校验传入值是否在默认值范围校验逻辑 | |||
* @date 2020-09-18 | |||
*/ | |||
class Validator implements ConstraintValidator<FlagValidator, Integer> { | |||
private String[] values; | |||
@Override | |||
public void initialize(FlagValidator flagValidator) { | |||
this.values = flagValidator.value(); | |||
} | |||
@Override | |||
public boolean isValid(Integer value, ConstraintValidatorContext constraintValidatorContext) { | |||
if (value == null) { | |||
//当状态为空时,使用默认值 | |||
return false; | |||
} | |||
return Arrays.stream(values).anyMatch(value::equals); | |||
} | |||
} | |||
} |
@@ -1,23 +0,0 @@ | |||
/** | |||
* 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 { | |||
} |
@@ -1,68 +0,0 @@ | |||
/** | |||
* 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 | |||
} | |||
} | |||
@@ -1,33 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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; | |||
} |
@@ -1,87 +0,0 @@ | |||
/** | |||
* 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 lombok.extern.slf4j.Slf4j; | |||
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 java.util.UUID; | |||
/** | |||
* @description 日志切面 | |||
* @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() ") | |||
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.LOG_ASPECT, "uri:{},input:{},==>begin", joinPoint.getSignature(), param); | |||
long start = System.currentTimeMillis(); | |||
Object result = ((ProceedingJoinPoint) joinPoint).proceed(); | |||
long end = System.currentTimeMillis(); | |||
LogUtil.info(LogEnum.LOG_ASPECT, "uri:{},output:{},proc_time:{},<==end", joinPoint.getSignature().toString(), | |||
result, end - start); | |||
return result; | |||
} | |||
} |
@@ -1,116 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.aspect; | |||
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.aspectj.lang.reflect.MethodSignature; | |||
import org.dubhe.annotation.DataPermissionMethod; | |||
import org.dubhe.base.BaseService; | |||
import org.dubhe.base.DataContext; | |||
import org.dubhe.domain.dto.CommonPermissionDataDTO; | |||
import org.dubhe.enums.DatasetTypeEnum; | |||
import org.dubhe.enums.LogEnum; | |||
import org.dubhe.utils.JwtUtils; | |||
import org.dubhe.utils.LogUtil; | |||
import org.springframework.stereotype.Component; | |||
import java.lang.reflect.Method; | |||
import java.util.HashSet; | |||
import java.util.Objects; | |||
import java.util.Set; | |||
/** | |||
* @description 数据权限切面 | |||
* @date 2020-09-24 | |||
*/ | |||
@Aspect | |||
@Component | |||
public class PermissionAspect { | |||
/** | |||
* 公共数据的有用户ID | |||
*/ | |||
public static final Long PUBLIC_DATA_USER_ID = 0L; | |||
/** | |||
* 基于注解的切面方法 | |||
*/ | |||
@Pointcut("@annotation(org.dubhe.annotation.DataPermissionMethod)") | |||
private void cutMethod() { | |||
} | |||
/** | |||
*环绕通知 | |||
* @param joinPoint 切入参数对象 | |||
* @return 返回方法结果集 | |||
* @throws Throwable | |||
*/ | |||
@Around("cutMethod()") | |||
public Object around(ProceedingJoinPoint joinPoint) throws Throwable { | |||
// 获取方法传入参数 | |||
Object[] params = joinPoint.getArgs(); | |||
DataPermissionMethod dataPermissionMethod = getDeclaredAnnotation(joinPoint); | |||
if (!Objects.isNull(JwtUtils.getCurrentUserDto()) && !Objects.isNull(dataPermissionMethod)) { | |||
Set<Long> ids = new HashSet<>(); | |||
ids.add(JwtUtils.getCurrentUserDto().getId()); | |||
CommonPermissionDataDTO commonPermissionDataDTO = CommonPermissionDataDTO.builder().type(dataPermissionMethod.interceptFlag()).resourceUserIds(ids).build(); | |||
if (DatasetTypeEnum.PUBLIC.equals(dataPermissionMethod.dataType())) { | |||
ids.add(PUBLIC_DATA_USER_ID); | |||
commonPermissionDataDTO.setResourceUserIds(ids); | |||
} | |||
DataContext.set(commonPermissionDataDTO); | |||
} | |||
// 执行源方法 | |||
try { | |||
return joinPoint.proceed(params); | |||
} finally { | |||
// 模拟进行验证 | |||
BaseService.removeContext(); | |||
} | |||
} | |||
/** | |||
* 获取方法中声明的注解 | |||
* | |||
* @param joinPoint 切入参数对象 | |||
* @return DataPermissionMethod 方法注解类型 | |||
*/ | |||
public DataPermissionMethod getDeclaredAnnotation(ProceedingJoinPoint joinPoint){ | |||
// 获取方法名 | |||
String methodName = joinPoint.getSignature().getName(); | |||
// 反射获取目标类 | |||
Class<?> targetClass = joinPoint.getTarget().getClass(); | |||
// 拿到方法对应的参数类型 | |||
Class<?>[] parameterTypes = ((MethodSignature) joinPoint.getSignature()).getParameterTypes(); | |||
// 根据类、方法、参数类型(重载)获取到方法的具体信息 | |||
Method objMethod = null; | |||
try { | |||
objMethod = targetClass.getMethod(methodName, parameterTypes); | |||
} catch (NoSuchMethodException e) { | |||
LogUtil.error(LogEnum.BIZ_DATASET,"获取注解方法参数异常 error:{}",e); | |||
} | |||
// 拿到方法定义的注解信息 | |||
DataPermissionMethod annotation = objMethod.getDeclaredAnnotation(DataPermissionMethod.class); | |||
// 返回 | |||
return annotation; | |||
} | |||
} |
@@ -1,58 +0,0 @@ | |||
/** | |||
* 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<D, E> { | |||
/** | |||
* DTO转Entity | |||
* | |||
* @param dto / | |||
* @return / | |||
*/ | |||
E toEntity(D dto); | |||
/** | |||
* Entity转DTO | |||
* | |||
* @param entity / | |||
* @return / | |||
*/ | |||
D toDto(E entity); | |||
/** | |||
* DTO集合转Entity集合 | |||
* | |||
* @param dtoList / | |||
* @return / | |||
*/ | |||
List<E> toEntity(List<D> dtoList); | |||
/** | |||
* Entity集合转DTO集合 | |||
* | |||
* @param entityList / | |||
* @return / | |||
*/ | |||
List<D> toDto(List<E> entityList); | |||
} |
@@ -1,48 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 + | |||
'}'; | |||
} | |||
} |
@@ -1,76 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 { | |||
} | |||
} |
@@ -1,44 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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; | |||
} |
@@ -1,77 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 org.dubhe.constant.PermissionConstant; | |||
import org.dubhe.domain.dto.UserDTO; | |||
import org.dubhe.domain.entity.Role; | |||
import org.dubhe.exception.BaseErrorCode; | |||
import org.dubhe.exception.BusinessException; | |||
import org.dubhe.utils.JwtUtils; | |||
import org.springframework.util.CollectionUtils; | |||
import java.util.List; | |||
import java.util.Objects; | |||
import java.util.stream.Collectors; | |||
/** | |||
* @description 服务层基础数据公共方法类 | |||
* @date 2020-03-27 | |||
*/ | |||
public class BaseService { | |||
private BaseService (){} | |||
/** | |||
* 校验是否具有管理员权限 | |||
*/ | |||
public static void checkAdminPermission() { | |||
if(!isAdmin()){ | |||
throw new BusinessException(BaseErrorCode.DATASET_ADMIN_PERMISSION_ERROR); | |||
} | |||
} | |||
/** | |||
* 校验是否是管理管理员 | |||
* | |||
* @return 校验标识 | |||
*/ | |||
public static Boolean isAdmin() { | |||
UserDTO currentUserDto = JwtUtils.getCurrentUserDto(); | |||
if (currentUserDto != null && !CollectionUtils.isEmpty(currentUserDto.getRoles())) { | |||
List<Role> roles = currentUserDto.getRoles(); | |||
List<Role> roleList = roles.stream(). | |||
filter(a -> a.getId().compareTo(PermissionConstant.ADMIN_USER_ID) == 0) | |||
.collect(Collectors.toList()); | |||
if (!CollectionUtils.isEmpty(roleList)) { | |||
return true; | |||
} | |||
} | |||
return false; | |||
} | |||
/** | |||
* 清除本地线程数据权限数据 | |||
*/ | |||
public static void removeContext(){ | |||
if( !Objects.isNull(DataContext.get())){ | |||
DataContext.remove(); | |||
} | |||
} | |||
} |
@@ -1,46 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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; | |||
} |
@@ -1,62 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 org.dubhe.domain.dto.CommonPermissionDataDTO; | |||
/** | |||
* @description 共享上下文数据集信息 | |||
* @date 2020-04-10 | |||
*/ | |||
public class DataContext { | |||
/** | |||
* 私有化构造参数 | |||
*/ | |||
private DataContext() { | |||
} | |||
private static final ThreadLocal<CommonPermissionDataDTO> CONTEXT = new ThreadLocal<>(); | |||
/** | |||
* 存放数据集信息 | |||
* | |||
* @param datasetVO | |||
*/ | |||
public static void set(CommonPermissionDataDTO datasetVO) { | |||
CONTEXT.set(datasetVO); | |||
} | |||
/** | |||
* 获取用户信息 | |||
* | |||
* @return | |||
*/ | |||
public static CommonPermissionDataDTO get() { | |||
return CONTEXT.get(); | |||
} | |||
/** | |||
* 清除当前线程内引用,防止内存泄漏 | |||
*/ | |||
public static void remove() { | |||
CONTEXT.remove(); | |||
} | |||
} |
@@ -1,76 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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<T> 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"); | |||
} | |||
} |
@@ -1,101 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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-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 THOUSAND_LONG = 1000L; | |||
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() { | |||
} | |||
} |
@@ -1,62 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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-08 | |||
*/ | |||
@Data | |||
@Accessors(chain = true) | |||
public class PageQueryBase<T> { | |||
@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<T> toPage() { | |||
Page<T> 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; | |||
} | |||
} |
@@ -1,33 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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; | |||
} |
@@ -1,44 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 org.dubhe.enums.LogEnum; | |||
import org.dubhe.utils.LogUtil; | |||
/** | |||
* @description 定时任务处理器, 主要做日志标识 | |||
* @date 2020-08-13 | |||
*/ | |||
public class ScheduleTaskHandler { | |||
public static void process(Handler handler) { | |||
LogUtil.startScheduleTrace(); | |||
try { | |||
handler.run(); | |||
} catch (Exception e) { | |||
LogUtil.error(LogEnum.BIZ_SYS, "There is something wrong in schedule task handler :{}", e); | |||
} finally { | |||
LogUtil.cleanTrace(); | |||
} | |||
} | |||
public interface Handler { | |||
void run(); | |||
} | |||
} |
@@ -1,56 +0,0 @@ | |||
/** | |||
* 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); | |||
} | |||
} |
@@ -1,44 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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; | |||
} |
@@ -1,44 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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()); | |||
} | |||
} |
@@ -1,92 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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-06-10 | |||
*/ | |||
@Component | |||
public class MetaHandlerConfig implements MetaObjectHandler { | |||
/** | |||
* 新增数据执行 | |||
* | |||
* @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); | |||
} | |||
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.ORIGIN_USER_ID, metaObject))) { | |||
this.setFieldValByName(StringConstant.ORIGIN_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(); | |||
} | |||
} |
@@ -1,43 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 org.dubhe.interceptor.PaginationInterceptor; | |||
import org.springframework.context.annotation.Bean; | |||
import org.springframework.context.annotation.Configuration; | |||
import org.springframework.transaction.annotation.EnableTransactionManagement; | |||
/** | |||
* @description mybatis plus拦截器 | |||
* @date 2020-06-10 | |||
*/ | |||
@EnableTransactionManagement | |||
@Configuration | |||
public class MybatisPlusConfig { | |||
/** | |||
* 注入 MybatisPlus 分页拦截器 | |||
* | |||
* @return 自定义MybatisPlus分页拦截器 | |||
*/ | |||
@Bean | |||
public PaginationInterceptor paginationInterceptor() { | |||
PaginationInterceptor paginationInterceptor = new PaginationInterceptor(); | |||
return paginationInterceptor; | |||
} | |||
} | |||
@@ -1,41 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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; | |||
} |
@@ -1,62 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.boot.context.properties.ConfigurationProperties; | |||
import org.springframework.stereotype.Component; | |||
/** | |||
* @description 垃圾回收机制配置常量 | |||
* @date 2020-09-21 | |||
*/ | |||
@Data | |||
@Component | |||
@ConfigurationProperties(prefix = "recycle.timeout") | |||
public class RecycleConfig { | |||
/** | |||
* 回收无效文件的默认有效时长 | |||
*/ | |||
private Integer date; | |||
/** | |||
* 用户上传文件至临时路径下后文件最大有效时长,以小时为单位 | |||
*/ | |||
private Integer fileValid; | |||
/** | |||
* 用户删除某一算法后,其算法文件最大有效时长,以天为单位 | |||
*/ | |||
private Integer algorithmValid; | |||
/** | |||
* 用户删除某一模型后,其模型文件最大有效时长,以天为单位 | |||
*/ | |||
private Integer modelValid; | |||
/** | |||
* 用户删除训练任务后,其训练管理文件最大有效时长,以天为单位 | |||
*/ | |||
private Integer trainValid; | |||
/** | |||
* 删除服务器无效文件(大文件) | |||
* 示例:rsync --delete-before -d /空目录 /需要回收的源目录 | |||
*/ | |||
public static final String DEL_COMMAND = "ssh %s@%s \"mkdir -p %s; rsync --delete-before -d %s %s; rmdir %s %s\""; | |||
} |
@@ -1,214 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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<Object> fastJsonRedisSerializer = new FastJsonRedisSerializer<>(Object.class); | |||
RedisCacheConfiguration configuration = RedisCacheConfiguration.defaultCacheConfig(); | |||
configuration = configuration.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(fastJsonRedisSerializer)).entryTtl(Duration.ofHours(2)); | |||
return configuration; | |||
} | |||
@SuppressWarnings("all") | |||
@Bean(name = "redisTemplate") | |||
@ConditionalOnMissingBean(name = "redisTemplate") | |||
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) { | |||
RedisTemplate<Object, Object> template = new RedisTemplate<>(); | |||
//序列化 | |||
FastJsonRedisSerializer<Object> fastJsonRedisSerializer = new FastJsonRedisSerializer<>(Object.class); | |||
// value值的序列化采用fastJsonRedisSerializer | |||
template.setValueSerializer(fastJsonRedisSerializer); | |||
template.setHashValueSerializer(fastJsonRedisSerializer); | |||
// 全局开启AutoType,这里方便开发,使用全局的方式 | |||
ParserConfig.getGlobalInstance().setAutoTypeSupport(true); | |||
// 建议使用这种方式,小范围指定白名单 | |||
// ParserConfig.getGlobalInstance().addAccept("org.dubhe.domain"); | |||
// key的序列化采用StringRedisSerializer | |||
template.setKeySerializer(new StringRedisSerializer()); | |||
template.setHashKeySerializer(new StringRedisSerializer()); | |||
template.setConnectionFactory(redisConnectionFactory); | |||
return template; | |||
} | |||
/** | |||
* 自定义缓存key生成策略,默认将使用该策略 | |||
*/ | |||
@Bean | |||
@Override | |||
public KeyGenerator keyGenerator() { | |||
return (target, method, params) -> { | |||
Map<String, Object> container = new HashMap<>(3); | |||
Class<?> targetClassClass = target.getClass(); | |||
// 类地址 | |||
container.put("class", targetClassClass.toGenericString()); | |||
// 方法名称 | |||
container.put("methodName", method.getName()); | |||
// 包名称 | |||
container.put("package", targetClassClass.getPackage()); | |||
// 参数列表 | |||
for (int i = 0; i < params.length; i++) { | |||
container.put(String.valueOf(i), params[i]); | |||
} | |||
// 转为JSON字符串 | |||
String jsonString = JSON.toJSONString(container); | |||
// 做SHA256 Hash计算,得到一个SHA256摘要作为Key | |||
return DigestUtils.sha256Hex(jsonString); | |||
}; | |||
} | |||
@Bean | |||
@Override | |||
public CacheErrorHandler errorHandler() { | |||
// 异常处理,当Redis发生异常时,打印日志,但是程序正常走 | |||
log.info("初始化 -> [{}]", "Redis CacheErrorHandler"); | |||
return new CacheErrorHandler() { | |||
@Override | |||
public void handleCacheGetError(RuntimeException e, Cache cache, Object key) { | |||
log.error("Redis occur handleCacheGetError:key -> [{}]", key, e); | |||
} | |||
@Override | |||
public void handleCachePutError(RuntimeException e, Cache cache, Object key, Object value) { | |||
log.error("Redis occur handleCachePutError:key -> [{}];value -> [{}]", key, value, e); | |||
} | |||
@Override | |||
public void handleCacheEvictError(RuntimeException e, Cache cache, Object key) { | |||
log.error("Redis occur handleCacheEvictError:key -> [{}]", key, e); | |||
} | |||
@Override | |||
public void handleCacheClearError(RuntimeException e, Cache cache) { | |||
log.error("Redis occur handleCacheClearError:", e); | |||
} | |||
}; | |||
} | |||
} | |||
/** | |||
* Value 序列化 | |||
* | |||
* @param <T> | |||
*/ | |||
class FastJsonRedisSerializer<T> implements RedisSerializer<T> { | |||
private Class<T> clazz; | |||
FastJsonRedisSerializer(Class<T> clazz) { | |||
super(); | |||
this.clazz = clazz; | |||
} | |||
@Override | |||
public byte[] serialize(T t) { | |||
if (t == null) { | |||
return new byte[0]; | |||
} | |||
return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(StandardCharsets.UTF_8); | |||
} | |||
@Override | |||
public T deserialize(byte[] bytes) { | |||
if (bytes == null || bytes.length <= 0) { | |||
return null; | |||
} | |||
String str = new String(bytes, StandardCharsets.UTF_8); | |||
return JSON.parseObject(str, clazz); | |||
} | |||
} | |||
/** | |||
* 重写序列化器 | |||
* | |||
*/ | |||
class StringRedisSerializer implements RedisSerializer<Object> { | |||
private final Charset charset; | |||
StringRedisSerializer() { | |||
this(StandardCharsets.UTF_8); | |||
} | |||
private StringRedisSerializer(Charset charset) { | |||
Assert.notNull(charset, "Charset must not be null!"); | |||
this.charset = charset; | |||
} | |||
@Override | |||
public String deserialize(byte[] bytes) { | |||
return (bytes == null ? null : new String(bytes, charset)); | |||
} | |||
@Override | |||
public byte[] serialize(Object object) { | |||
String string = JSON.toJSONString(object); | |||
if (StringUtils.isBlank(string)) { | |||
return null; | |||
} | |||
string = string.replace("\"", ""); | |||
return string.getBytes(charset); | |||
} | |||
} |
@@ -1,70 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 org.springframework.context.annotation.PropertySource; | |||
import org.springframework.context.i18n.LocaleContextHolder; | |||
import java.util.HashMap; | |||
import java.util.Locale; | |||
import java.util.Map; | |||
import java.util.ResourceBundle; | |||
/** | |||
* @description 加载配置 | |||
* @date 2020-03-15 | |||
*/ | |||
@PropertySource(value = {"classpath:config/thirdParty.properties", "classpath:i18n/messages*.properties"}) | |||
public final class Resources { | |||
/** | |||
* 第三方登录配置 | |||
*/ | |||
public static final ResourceBundle THIRDPARTY = ResourceBundle.getBundle("config/thirdParty"); | |||
/** | |||
* 国际化信息 | |||
*/ | |||
private static final Map<String, ResourceBundle> MESSAGES = new HashMap<String, ResourceBundle>(); | |||
/** | |||
* 国际化信息 | |||
*/ | |||
public static String getMessage(String key, Object... params) { | |||
Locale locale = LocaleContextHolder.getLocale(); | |||
ResourceBundle message = MESSAGES.get(locale.getLanguage()); | |||
if (message == null) { | |||
synchronized (MESSAGES) { | |||
message = MESSAGES.get(locale.getLanguage()); | |||
if (message == null) { | |||
message = ResourceBundle.getBundle("i18n/messages", locale); | |||
MESSAGES.put(locale.getLanguage(), message); | |||
} | |||
} | |||
} | |||
if (params != null && params.length > 0) { | |||
return String.format(message.getString(key), params); | |||
} | |||
return message.getString(key); | |||
} | |||
/** | |||
* 清除国际化信息 | |||
*/ | |||
public static void flushMessage() { | |||
MESSAGES.clear(); | |||
} | |||
} |
@@ -1,36 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 org.springframework.context.annotation.Configuration; | |||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | |||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; | |||
/** | |||
* @description 关闭Security | |||
* @date 2020-03-25 | |||
*/ | |||
@Configuration | |||
public class SecurityConfig extends WebSecurityConfigurerAdapter { | |||
@Override | |||
protected void configure(HttpSecurity http) throws Exception { | |||
http.authorizeRequests().antMatchers("/**").permitAll().and().csrf().disable(); | |||
} | |||
} |
@@ -1,138 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.classmate.TypeResolver; | |||
import com.google.common.base.Predicates; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import org.springframework.beans.factory.annotation.Value; | |||
import org.springframework.context.annotation.Bean; | |||
import org.springframework.context.annotation.Configuration; | |||
import org.springframework.core.Ordered; | |||
import org.springframework.data.domain.Pageable; | |||
import springfox.documentation.builders.ApiInfoBuilder; | |||
import springfox.documentation.builders.ParameterBuilder; | |||
import springfox.documentation.builders.PathSelectors; | |||
import springfox.documentation.schema.AlternateTypeRule; | |||
import springfox.documentation.schema.AlternateTypeRuleConvention; | |||
import springfox.documentation.schema.ModelRef; | |||
import springfox.documentation.service.ApiInfo; | |||
import springfox.documentation.service.Parameter; | |||
import springfox.documentation.spi.DocumentationType; | |||
import springfox.documentation.spring.web.plugins.Docket; | |||
import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||
import java.sql.Timestamp; | |||
import java.util.ArrayList; | |||
import java.util.Date; | |||
import java.util.List; | |||
import static com.google.common.collect.Lists.newArrayList; | |||
import static springfox.documentation.schema.AlternateTypeRules.newRule; | |||
/** | |||
* @description api页面 /swagger-ui.html | |||
* @date 2020-03-25 | |||
*/ | |||
@Configuration | |||
@EnableSwagger2 | |||
public class SwaggerConfig { | |||
@Value("${jwt.header}") | |||
private String tokenHeader; | |||
@Value("${jwt.token-start-with}") | |||
private String tokenStartWith; | |||
@Value("${swagger.enabled}") | |||
private Boolean enabled; | |||
@Value("${server.rest-version}") | |||
private String restVersion; | |||
@Bean | |||
@SuppressWarnings("all") | |||
public Docket createRestApi() { | |||
List<Parameter> pars = new ArrayList<>(); | |||
pars.add(new ParameterBuilder().name(tokenHeader).description("token") | |||
.modelRef(new ModelRef("string")) | |||
.parameterType("header") | |||
.defaultValue(tokenStartWith + " ") | |||
.required(true) | |||
.build()); | |||
pars.add(new ParameterBuilder().name("version").description("版本") | |||
.modelRef(new ModelRef("string")) | |||
.parameterType("path") | |||
.defaultValue(restVersion) | |||
.required(false) | |||
.build()); | |||
return new Docket(DocumentationType.SWAGGER_2) | |||
.enable(enabled) | |||
.apiInfo(apiInfo()) | |||
.select() | |||
.paths(Predicates.not(PathSelectors.regex("/error.*"))) | |||
.build().directModelSubstitute(Timestamp.class, Date.class) | |||
.globalOperationParameters(pars); | |||
} | |||
private ApiInfo apiInfo() { | |||
return new ApiInfoBuilder() | |||
.title("之江天枢一站式人工智能开源平台") | |||
.version("1.0") | |||
.build(); | |||
} | |||
} | |||
/** | |||
* 将Pageable转换展示在swagger中 | |||
*/ | |||
@Configuration | |||
class SwaggerDataConfig { | |||
@Bean | |||
public AlternateTypeRuleConvention pageableConvention(final TypeResolver resolver) { | |||
return new AlternateTypeRuleConvention() { | |||
@Override | |||
public int getOrder() { | |||
return Ordered.HIGHEST_PRECEDENCE; | |||
} | |||
@Override | |||
public List<AlternateTypeRule> rules() { | |||
return newArrayList(newRule(resolver.resolve(Pageable.class), resolver.resolve(Page.class))); | |||
} | |||
}; | |||
} | |||
@ApiModel | |||
@Data | |||
private static class Page { | |||
@ApiModelProperty("页码 (0..N)") | |||
private Integer page; | |||
@ApiModelProperty("每页显示的数目") | |||
private Integer size; | |||
@ApiModelProperty("以下列格式排序标准:property[,asc | desc]。 默认排序顺序为升序。 支持多种排序条件:如:id,asc") | |||
private List<String> sort; | |||
} | |||
} |
@@ -1,39 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.boot.context.properties.ConfigurationProperties; | |||
import org.springframework.stereotype.Component; | |||
/** | |||
* @description harbor相关配置 | |||
* @date 2020-07-17 | |||
*/ | |||
@Data | |||
@Component | |||
@ConfigurationProperties(prefix = "harbor") | |||
public class TrainHarborConfig { | |||
private String address; | |||
private String username; | |||
private String password; | |||
private String modelName; | |||
} |
@@ -1,107 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.boot.context.properties.ConfigurationProperties; | |||
import org.springframework.stereotype.Component; | |||
/** | |||
* @description 训练常量 | |||
* @date 2020-05-12 | |||
*/ | |||
@Component | |||
@Data | |||
@ConfigurationProperties(prefix = "train-job") | |||
public class TrainJobConfig { | |||
private String namespace; | |||
private String versionLabel; | |||
private String separator; | |||
private String podName; | |||
private String pythonFormat; | |||
private String manage; | |||
private String outPath; | |||
private String logPath; | |||
private String visualizedLogPath; | |||
private String dockerDatasetPath; | |||
private String dockerTrainPath; | |||
private String dockerOutPath; | |||
private String dockerLogPath; | |||
private String dockerDataset; | |||
private String dockerModelPath; | |||
private String dockerTeacherModelPath; | |||
private String dockerTeacherModelKey; | |||
private String dockerStudentModelKey; | |||
private String dockerStudentModelPath; | |||
private String atlasAnaconda; | |||
private String atlasPythonioencoding; | |||
private String dockerValDatasetPath; | |||
private String loadValDatasetKey; | |||
private String dockerVisualizedLogPath; | |||
private String loadPath; | |||
private String loadKey; | |||
private String eight; | |||
private String plusEight; | |||
private String nodeIps; | |||
private String nodeNum; | |||
private String gpuNumPerNode; | |||
public static final String TRAIN_ID = "trainId"; | |||
public static final String TRAIN_VERSION = "trainVersion"; | |||
public static final String RUN_TIME = "runtime"; | |||
public static final String TRAIN_STATUS = "trainStatus"; | |||
public static final String CREATE_TIME = "createTime"; | |||
public static final String ALGORITHM_NAME = "algorithmName"; | |||
} |
@@ -1,79 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 org.dubhe.enums.LogEnum; | |||
import org.dubhe.utils.LogUtil; | |||
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; | |||
import org.springframework.beans.factory.annotation.Value; | |||
import org.springframework.context.annotation.Bean; | |||
import org.springframework.context.annotation.Configuration; | |||
import org.springframework.scheduling.annotation.AsyncConfigurer; | |||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | |||
import java.util.concurrent.Executor; | |||
import java.util.concurrent.ThreadPoolExecutor; | |||
/** | |||
* @description 线程池配置类 | |||
* @date 2020-07-17 | |||
*/ | |||
@Configuration | |||
public class TrainPoolConfig implements AsyncConfigurer { | |||
@Value("${basepool.corePoolSize:40}") | |||
private Integer corePoolSize; | |||
@Value("${basepool.maximumPoolSize:60}") | |||
private Integer maximumPoolSize; | |||
@Value("${basepool.keepAliveTime:120}") | |||
private Integer keepAliveTime; | |||
@Value("${basepool.blockQueueSize:20}") | |||
private Integer blockQueueSize; | |||
/** | |||
* 训练任务异步处理线程池 | |||
* @return Executor 线程实例 | |||
*/ | |||
@Bean("trainExecutor") | |||
@Override | |||
public Executor getAsyncExecutor() { | |||
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor(); | |||
//核心线程数 | |||
taskExecutor.setCorePoolSize(corePoolSize); | |||
taskExecutor.setAllowCoreThreadTimeOut(true); | |||
//最大线程数 | |||
taskExecutor.setMaxPoolSize(maximumPoolSize); | |||
//超时时间 | |||
taskExecutor.setKeepAliveSeconds(keepAliveTime); | |||
//配置队列大小 | |||
taskExecutor.setQueueCapacity(blockQueueSize); | |||
//配置线程池前缀 | |||
taskExecutor.setThreadNamePrefix("async-train-"); | |||
//拒绝策略 | |||
taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy()); | |||
taskExecutor.initialize(); | |||
return taskExecutor; | |||
} | |||
@Override | |||
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() { | |||
LogUtil.error(LogEnum.BIZ_TRAIN, "开始捕获训练管理异步任务异常信息-----》》》"); | |||
return (ex, method, params) -> { | |||
LogUtil.error(LogEnum.BIZ_TRAIN, "训练管理方法名{}的异步任务执行失败,参数信息:{},异常信息:{}", method.getName(), params, ex); | |||
}; | |||
} | |||
} |
@@ -1,50 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 org.dubhe.interceptor.K8sCallBackPodInterceptor; | |||
import org.dubhe.utils.K8sCallBackTool; | |||
import org.springframework.context.annotation.Configuration; | |||
import org.springframework.web.servlet.config.annotation.InterceptorRegistration; | |||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; | |||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | |||
import javax.annotation.Resource; | |||
/** | |||
* @description Web Mvc Config | |||
* | |||
* @date 2020-05-28 | |||
*/ | |||
@Configuration | |||
public class WebMvcConfig implements WebMvcConfigurer { | |||
@Resource | |||
private K8sCallBackPodInterceptor k8sCallBackPodInterceptor; | |||
@Override | |||
public void addInterceptors(InterceptorRegistry registry) { | |||
InterceptorRegistration registration = registry.addInterceptor(k8sCallBackPodInterceptor); | |||
// 拦截配置 | |||
registration.addPathPatterns(K8sCallBackTool.getK8sCallbackPaths()); | |||
} | |||
} |
@@ -1,35 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 org.dubhe.handle.CustomRequestMappingHandlerMapping; | |||
import org.springframework.boot.SpringBootConfiguration; | |||
import org.springframework.boot.autoconfigure.web.servlet.WebMvcRegistrations; | |||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; | |||
/** | |||
* @description API版本控制 | |||
* @date 2020-04-06 | |||
*/ | |||
@SpringBootConfiguration | |||
public class WebMvcRegistrationsConfig implements WebMvcRegistrations { | |||
@Override | |||
public RequestMappingHandlerMapping getRequestMappingHandlerMapping() { | |||
return new CustomRequestMappingHandlerMapping(); | |||
} | |||
} |
@@ -1,46 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.constant; | |||
import lombok.Getter; | |||
/** | |||
* @description 算法枚举类 | |||
* @date 2020-05-12 | |||
*/ | |||
@Getter | |||
public enum AlgorithmSourceEnum { | |||
/** | |||
* MINE 算法来源 我的算法 | |||
*/ | |||
MINE(1, "MINE"), | |||
/** | |||
* PRE 算法来源 预置算法 | |||
*/ | |||
PRE(2,"PRE"); | |||
private Integer status; | |||
private String message; | |||
AlgorithmSourceEnum(Integer status, String message) { | |||
this.status = status; | |||
this.message = message; | |||
} | |||
} |
@@ -1,37 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.constant; | |||
/** | |||
* @description 状态机异常量类 | |||
* @date 2020-09-01 | |||
*/ | |||
public class ErrorMessageConstant { | |||
private ErrorMessageConstant(){} | |||
/** | |||
* 数据状态异常信息 | |||
*/ | |||
public static final String FILE_CHANGE_ERR_MESSAGE = "当前文件状态不可变更"; | |||
/** | |||
* 数据状态异常信息 | |||
*/ | |||
public static final String DATASET_CHANGE_ERR_MESSAGE = "当前数据集状态不可变更"; | |||
} |
@@ -1,128 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.constant; | |||
import lombok.Data; | |||
import org.springframework.stereotype.Component; | |||
/** | |||
* @description 模型优化常量 | |||
* @date 2020-05-25 | |||
*/ | |||
@Component | |||
@Data | |||
public class ModelOptConstant { | |||
/** | |||
* 模型优化任务结果字典 | |||
*/ | |||
public static final String TASK_RESULT_DICT_NAME = "opt_result"; | |||
/** | |||
* 数据集挂载路径 | |||
*/ | |||
public static final String DATASET_MOUNT_PATH = "/usr/local/dataset"; | |||
/** | |||
*算法挂载路径 | |||
*/ | |||
public static final String ALGORITHM_MOUNT_PATH = "/usr/local/algorithm"; | |||
/** | |||
*输入模型挂载路径 | |||
*/ | |||
public static final String INPUT_MODEL_BEFORE_MOUNT_PATH = "/usr/local/input/model"; | |||
/** | |||
*输出日志挂载路径 | |||
*/ | |||
public static final String OUTPUT_LOG_MOUNT_PATH = "/usr/local/output/log"; | |||
/** | |||
*压缩前评估结果挂载路径 | |||
*/ | |||
public static final String OUTPUT_RESULT_BEFORE_MOUNT_PATH = "/usr/local/output/result/before"; | |||
/** | |||
*输出模型挂载路径 | |||
*/ | |||
public static final String OUTPUT_MODEL_MOUNT_PATH = "/usr/local/output/model"; | |||
/** | |||
*压缩后评估结果挂载路径 | |||
*/ | |||
public static final String OUTPUT_RESULT_AFTER_MOUNT_PATH = "/usr/local/output/result/after"; | |||
/** | |||
* 使用的CPU配额 | |||
*/ | |||
public static final int CPU_NUM = 2048; | |||
/** | |||
* 使用的GPU配额 | |||
*/ | |||
public static final int GPU_NUM = 1; | |||
/** | |||
* 使用的内存配额 | |||
*/ | |||
public static final int MEMORY_NUM = 8000; | |||
/** | |||
* CNN剪枝算法启动命令 | |||
*/ | |||
public static final String OPT_START_SLIMMING_COMMAND = "cd /usr/local/algorithm && python run.py --prune_method=%s --model=%s --data_type=%s --dataset_dir=%s --model_save_dir=%s --log_dir=%s --before_result_dir=%s --after_result_dir=%s"; | |||
/** | |||
* 量化算法启动命令 | |||
*/ | |||
public static final String OPT_START_QUANTIFY_COMMAND = "cd /usr/local/algorithm && python3 of_cnn_evaluate.py --model=%s --model_load_dir=%s --val_data_dir=%s --log_dir=%s --result_dir=%s --use_tensorrt=False --use_int8_online=False && python3 of_cnn_evaluate.py --model=%s --model_load_dir=%s --val_data_dir=%s --log_dir=%s --result_dir=%s --use_tensorrt=True --use_int8_online=True"; | |||
/** | |||
* 非内置运行命令 | |||
*/ | |||
public static final String MY_OPT_COMMAND = "cd %s && %s"; | |||
/** | |||
* 模型优化结果日志路径 | |||
*/ | |||
public static final String OPTIMIZE_LOG = "/log"; | |||
/** | |||
* 模型优化结果保存模型路径 | |||
*/ | |||
public static final String OPTIMIZE_MODEL = "/model"; | |||
/** | |||
* 模型优化结果保存优化前模型评估参数 | |||
*/ | |||
public static final String OPTIMIZE_JSON_BEFORE = "/before"; | |||
/** | |||
* 模型优化结果保存优化后模型评估参数 | |||
*/ | |||
public static final String OPTIMIZE_JSON_AFTER = "/after"; | |||
/** | |||
* 模型优化结果JSON文件名称 | |||
*/ | |||
public static final String OPTIMIZE_JSON_NAME = "/results_eval.json"; | |||
/** | |||
* 我的压缩算法根路径 | |||
*/ | |||
public static final String MY_OPT_ALGORITHM_ROOT_PATH = "/model-opt/myAlgorithms/"; | |||
/** | |||
* 我的数据集 | |||
*/ | |||
public static final String MY_OPT_DATASET_ROOT_PATH = "/model-opt/myDataset/"; | |||
/** | |||
* 算法准确度名称 | |||
*/ | |||
public static final String ACCURACY = "accuracy"; | |||
/** | |||
* 复制模型后缀文件夹名称 | |||
*/ | |||
public static final String COPY_MODEL_POSTFIX = "/model"; | |||
/** | |||
* 基于神经元权重剪枝 | |||
*/ | |||
public static final String NEURONAL_PRUNING = "基于神经元权重剪枝"; | |||
} |
@@ -1,127 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.constant; | |||
import lombok.Getter; | |||
import org.dubhe.exception.ErrorCode; | |||
/** | |||
* @description 模型优化错误码 | |||
* @date 2020-05-22 | |||
*/ | |||
@Getter | |||
public enum ModelOptErrorEnum implements ErrorCode { | |||
/** | |||
* 该模型优化任务不存在 | |||
*/ | |||
MODEL_OPT_TASK_ABSENT(1400, "该模型优化任务不存在"), | |||
/** | |||
* 该模型优化任务实例不存在 | |||
*/ | |||
MODEL_OPT_TASK_INSTANCE_ABSENT(1401, "该模型优化任务实例不存在"), | |||
/** | |||
* 模型优化任务实例创建失败 | |||
*/ | |||
MODEL_OPT_TASK_INSTANCE_CREATE_FAILED(1402, "模型优化任务实例创建失败"), | |||
/** | |||
* 模型优化任务名称已存在 | |||
*/ | |||
MODEL_OPT_TASK_NAME_EXIST(1403, "模型优化任务名称已存在"), | |||
/** | |||
* 该任务已存在等待或进行中的实例 | |||
*/ | |||
MODEL_OPT_TASK_INSTANCE_EXIST(1404, "该任务已存在等待或进行中的实例"), | |||
/** | |||
* 请先取消等待或进行中的实例 | |||
*/ | |||
MODEL_OPT_TASK_DELETE_ERROR(1405, "请先取消等待或进行中的实例"), | |||
/** | |||
* 请先添加模型优化结果字典 | |||
*/ | |||
MODEL_OPT_TASK_RESULT_DICT_EMPTY(1406, "请先添加模型优化结果字典"), | |||
/** | |||
* 模型压缩算法不存在 | |||
*/ | |||
MODEL_OPT_ALGORITHM_NOT_EXIST(1407, "模型压缩算法不存在"), | |||
/** | |||
* 任务未完成,不能下载 | |||
*/ | |||
MODEL_OPT_TASK_UNFINISHED(1408, "任务未完成,不能下载"), | |||
/** | |||
* 数据集不存在,请选择正确的数据集 | |||
*/ | |||
MODEL_OPT_DATASET_ABSENT(1409, "数据集不存在,请选择正确的数据集"), | |||
/** | |||
* 当前状态不能进行此操作 | |||
*/ | |||
MODEL_OPT_TASK_INSTANCE_STATUS_ERROR(1410, "当前状态不能进行此操作"), | |||
/** | |||
* 模型不存在 | |||
*/ | |||
MODEL_OPT_MODEL_NOT_EXIST(1411, "模型不存在"), | |||
/** | |||
* 请先登录 | |||
*/ | |||
NO_USER_LOGGED_IN(1412, "请先登录"), | |||
/** | |||
* 当前用户无此操作权限 | |||
*/ | |||
NO_PERMISSION(1413, "当前用户无此操作权限"), | |||
/** | |||
* 内部错误 | |||
*/ | |||
INTERNAL_SERVER_ERROR(1414, "内部错误"), | |||
/** | |||
* 字典参数不存在,请先添加字典 | |||
*/ | |||
PARAM_DICT_NOT_EXIST(1415, "字典参数不存在,请先添加字典"), | |||
/** | |||
* 无可用镜像,请先在字典中配置镜像 | |||
*/ | |||
IMAGES_DICT_NOT_EXIST(1416, "无可用镜像,请先在字典中配置镜像"), | |||
/** | |||
* 容器启动失败 | |||
*/ | |||
CONTAINER_START_FAILED(1417, "容器启动失败"), | |||
/** | |||
* 数据集名称已存在 | |||
*/ | |||
DATASET_NAME_EXIST(1418, "数据集名称已存在"); | |||
private Integer code; | |||
private String msg; | |||
ModelOptErrorEnum(Integer code, String msg) { | |||
this.code = code; | |||
this.msg = msg; | |||
} | |||
} |
@@ -1,46 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.constant; | |||
import lombok.Getter; | |||
/** | |||
* @description 模型优化常量 | |||
* @date 2020-05-22 | |||
*/ | |||
@Getter | |||
public enum ModelOptInstanceStatusEnum { | |||
/** | |||
* 模型优化任务状态 | |||
*/ | |||
WAITING("-1", "等待中"), | |||
RUNNING("0", "进行中"), | |||
COMPLETED("1", "已完成"), | |||
CANCELED("2", "已取消"), | |||
EXEC_FAILED("3", "执行失败"), | |||
; | |||
private String value; | |||
private String msg; | |||
ModelOptInstanceStatusEnum(String value, String msg) { | |||
this.value = value; | |||
this.msg = msg; | |||
} | |||
} |
@@ -1,48 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.constant; | |||
/** | |||
* @description 数字常量 | |||
* @date 2020-06-09 | |||
*/ | |||
public class NumberConstant { | |||
public final static int NUMBER_0 = 0; | |||
public final static int NUMBER_1 = 1; | |||
public final static int NUMBER_2 = 2; | |||
public final static int NUMBER_3 = 3; | |||
public final static int NUMBER_4 = 4; | |||
public final static int NUMBER_5 = 5; | |||
public final static int NUMBER_6 = 6; | |||
public final static int NUMBER_8 = 8; | |||
public final static int NUMBER_10 = 10; | |||
public final static int NUMBER_25 = 25; | |||
public final static int NUMBER_30 = 30; | |||
public final static int NUMBER_50 = 50; | |||
public final static int NUMBER_60 = 60; | |||
public final static int NUMBER_1024 = 1024; | |||
public final static int NUMBER_1000 = 1000; | |||
public final static int NUMBER_100 = 100; | |||
public final static int HOUR_SECOND = 60 * 60; | |||
public final static int DAY_SECOND = 60 * 60 * 24; | |||
public final static int WEEK_SECOND = 60 * 60 * 24 * 7; | |||
public final static int MAX_PAGE_SIZE = 2000; | |||
public final static int MAX_MESSAGE_LENGTH = 1024 * 1024 * 1024; | |||
} |
@@ -1,41 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.constant; | |||
import lombok.Data; | |||
import org.springframework.stereotype.Component; | |||
/** | |||
* @description 权限常量 | |||
* @date 2020-05-25 | |||
*/ | |||
@Component | |||
@Data | |||
public class PermissionConstant { | |||
/** | |||
* 超级用户 | |||
*/ | |||
public static final long ADMIN_USER_ID = 1L; | |||
/** | |||
* 数据集模块类型 | |||
*/ | |||
public static final Integer RESOURCE_DATA_MODEL = 1; | |||
} |
@@ -1,74 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.constant; | |||
/** | |||
* @description 权限标识,对应 menu 表中的 permission 字段 | |||
* @date 2020-05-14 | |||
*/ | |||
public final class Permissions { | |||
/** | |||
* 数据管理 | |||
*/ | |||
public static final String DATA = "data"; | |||
public static final String DATA_DATASET = "data:dataset"; | |||
/** | |||
* 模型开发 | |||
*/ | |||
public static final String DEVELOPMENT = "development"; | |||
public static final String DEVELOPMENT_NOTEBOOK = "development:notebook"; | |||
public static final String DEVELOPMENT_ALGORITHM = "development:algorithm"; | |||
/** | |||
* 训练管理 | |||
*/ | |||
public static final String TRAINING = "training"; | |||
public static final String TRAINING_IMAGE = "training:image"; | |||
public static final String TRAINING_JOB = "training:job"; | |||
/** | |||
* 模型管理 | |||
*/ | |||
public static final String MODEL = "model"; | |||
public static final String MODEL_MODEL = "model:model"; | |||
public static final String MODEL_OPTIMIZE = "model:optimize"; | |||
/** | |||
* 控制台 | |||
*/ | |||
public static final String SYSTEM = "system"; | |||
public static final String SYSTEM_USER = "system:user"; | |||
public static final String SYSTEM_ROLE = "system:role"; | |||
public static final String SYSTEM_MENU = "system:menu"; | |||
public static final String SYSTEM_DICT = "system:dict"; | |||
public static final String SYSTEM_NODE = "system:node"; | |||
public static final String SYSTEM_LOG = "system:log"; | |||
public static final String SYSTEM_TEAM = "system:team"; | |||
/** | |||
* 云端Serving | |||
*/ | |||
public static final String SERVING = "serving"; | |||
public static final String SERVING_DEPLOYMENT = "serving:deployment"; | |||
public static final String SERVING_BATCH = "serving:batch"; | |||
private Permissions() { | |||
} | |||
} |
@@ -1,48 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.constant; | |||
import org.dubhe.base.MagicNumConstant; | |||
/** | |||
* @description redis 常量 | |||
* @date 2020-12-17 | |||
*/ | |||
public class RedisConstants { | |||
/** | |||
* 分布式锁过期时间 | |||
*/ | |||
public static final Long DELAY_CUD_RESOURCE_EXPIRE_TIME = MagicNumConstant.TEN_LONG; | |||
/** | |||
* 分布式锁 | |||
*/ | |||
public static final String DELAY_CUD_RESOURCE_KEY = "k8sclient:task:k8s_delay_cud_resource"; | |||
/** | |||
* 延时启动队列 | |||
*/ | |||
public static final String DELAY_APPLY_ZSET_KEY = "k8sclient:task:delay_apply_zset"; | |||
/** | |||
* 延时停止队列 | |||
*/ | |||
public static final String DELAY_STOP_ZSET_KEY = "k8sclient:task:delay_stop_zset"; | |||
/** | |||
* 延时队列值 | |||
*/ | |||
public static final String DELAY_ZSET_VALUE = "%s__%s"; | |||
} |
@@ -1,83 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.constant; | |||
import java.util.regex.Pattern; | |||
/** | |||
* @description 字符串constant | |||
* @date 2020-05-14 | |||
*/ | |||
public final class StringConstant { | |||
public static final String MSIE = "MSIE"; | |||
public static final String MOZILLA = "Mozilla"; | |||
public static final String REQUEST_METHOD_GET = "GET"; | |||
/** | |||
* 字母、数字、英文横杠和下划线匹配 | |||
*/ | |||
public static final String REGEXP = "^[a-zA-Z0-9\\-\\_\\u4e00-\\u9fa5]+$"; | |||
/** | |||
* 整数匹配 | |||
*/ | |||
public static final Pattern PATTERN_NUM = Pattern.compile("^[-\\+]?[\\d]*$"); | |||
/** | |||
* 公共字段 | |||
*/ | |||
public static final String CREATE_TIME = "createTime"; | |||
public static final String UPDATE_TIME = "updateTime"; | |||
public static final String UPDATE_USER_ID = "updateUserId"; | |||
public static final String CREATE_USER_ID = "createUserId"; | |||
public static final String ORIGIN_USER_ID = "originUserId"; | |||
public static final String DELETED = "deleted"; | |||
public static final String UTF8 = "utf-8"; | |||
public static final String JSON_REQUEST = "application/json"; | |||
public static final String K8S_CALLBACK_URI = "/api/k8s/callback/pod"; | |||
public static final String K8S_CALLBACK_PATH_DEPLOYMENT = "/api/k8s/callback/deployment"; | |||
public static final String MULTIPART = "multipart/form-data"; | |||
/** | |||
* 分页内容 | |||
*/ | |||
public static final String RESULT = "result"; | |||
/** | |||
* 排序规则 | |||
*/ | |||
public static final String SORT_ASC = "asc"; | |||
public static final String SORT_DESC = "desc"; | |||
public static final String QUERY = "query"; | |||
public static final String NGINX_LOWERCASE = "nginx"; | |||
public static final String TRUE_LOWERCASE = "true"; | |||
public static final String GRPC_CAPITALIZE = "GRPC"; | |||
/** | |||
* 测试环境 | |||
*/ | |||
public static final String PROFILE_ACTIVE_TEST = "test"; | |||
private StringConstant() { | |||
} | |||
} |
@@ -1,54 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.constant; | |||
/** | |||
* @description 符号常量 | |||
* @date 2020-5-29 | |||
*/ | |||
public class SymbolConstant { | |||
public static final String SLASH = "/"; | |||
public static final String COMMA = ","; | |||
public static final String COLON = ":"; | |||
public static final String LINEBREAK = "\n"; | |||
public static final String BLANK = ""; | |||
public static final String QUESTION = "?"; | |||
public static final String ZERO = "0"; | |||
public static final String DOT = "."; | |||
public static final String TOKEN = "token"; | |||
public static final String GET = "get"; | |||
public static final String SET = "set"; | |||
public static final String HTTP = "http"; | |||
public static final String GRPC = "grpc"; | |||
public static final String BRACKETS = "{}"; | |||
public static final String BACKSLASH = "\\"; | |||
public static final String BACKSLASH_MARK= "\\\""; | |||
public static final String DOUBLE_MARK= "\"\""; | |||
public static final String MARK= "\""; | |||
public static final String FLAG_EQUAL = "="; | |||
public static final String LEFT_PARENTHESIS = "["; | |||
public static final String RIGHT_PARENTHESIS = "]"; | |||
public static final String APOSTROPHE = "'"; | |||
public static final String HYPHEN = "-"; | |||
public static final String EVENT_SEPARATOR = "&&"; | |||
public static final String POST = "POST"; | |||
private SymbolConstant() { | |||
} | |||
} |
@@ -1,47 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.constant; | |||
import lombok.Data; | |||
import org.springframework.beans.factory.annotation.Value; | |||
import org.springframework.stereotype.Component; | |||
/** | |||
* @description 算法常量 | |||
* @date 2020-06-02 | |||
*/ | |||
@Data | |||
@Component | |||
public class TrainAlgorithmConstant { | |||
@Value("${train-algorithm.is-train-out}") | |||
private Boolean isTrainOut; | |||
@Value("${train-algorithm.is-train-log}") | |||
private Boolean isTrainLog; | |||
@Value("${train-algorithm.is-visualized-log}") | |||
private Boolean isVisualizedLog; | |||
@Value("${train-algorithm.algorithm-source}") | |||
private Integer algorithmSource; | |||
@Value("${train-algorithm.fork}") | |||
private Boolean fork; | |||
} |
@@ -1,33 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.constant; | |||
import lombok.Data; | |||
/** | |||
* @description 算法用途 | |||
* @date 2020-06-23 | |||
*/ | |||
@Data | |||
public class UserAuxiliaryInfoConstant { | |||
public static final String ALGORITHM_USAGE ="algorithem_usage"; | |||
} |
@@ -1,52 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.AllArgsConstructor; | |||
import lombok.Builder; | |||
import lombok.Data; | |||
import lombok.NoArgsConstructor; | |||
import java.io.Serializable; | |||
import java.util.Set; | |||
/** | |||
* @description 公共权限信息DTO | |||
* @date 2020-09-24 | |||
*/ | |||
@AllArgsConstructor | |||
@NoArgsConstructor | |||
@Builder | |||
@Data | |||
public class CommonPermissionDataDTO implements Serializable { | |||
/** | |||
* 资源拥有者ID | |||
*/ | |||
private Long id; | |||
/** | |||
* 公共类型 | |||
*/ | |||
private Boolean type; | |||
/** | |||
* 资源所属用户ids | |||
*/ | |||
private Set<Long> resourceUserIds; | |||
} |
@@ -1,65 +0,0 @@ | |||
/** | |||
* 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.domain.dto; | |||
import com.fasterxml.jackson.annotation.JsonIgnore; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import org.dubhe.domain.entity.Role; | |||
import org.dubhe.domain.entity.UserAvatar; | |||
import java.io.Serializable; | |||
import java.sql.Timestamp; | |||
import java.util.Date; | |||
import java.util.List; | |||
/** | |||
* @description 用户信息 | |||
* @date 2020-06-29 | |||
*/ | |||
@Data | |||
public class UserDTO implements Serializable { | |||
@ApiModelProperty(hidden = true) | |||
private Long id; | |||
private String username; | |||
private String nickName; | |||
private String sex; | |||
private String email; | |||
private String phone; | |||
private Boolean enabled; | |||
private String remark; | |||
@JsonIgnore | |||
private String password; | |||
private Date lastPasswordResetTime; | |||
private Timestamp createTime; | |||
private List<Role> roles; | |||
private UserAvatar userAvatar; | |||
} |
@@ -1,59 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 cn.hutool.core.date.DateUtil; | |||
import com.alibaba.fastjson.annotation.JSONField; | |||
import lombok.Data; | |||
import lombok.experimental.Accessors; | |||
import org.dubhe.base.MagicNumConstant; | |||
import java.io.Serializable; | |||
/** | |||
* @description 日志对象封装类 | |||
* @date 2020-06-29 | |||
*/ | |||
@Data | |||
@Accessors(chain = true) | |||
public class LogInfo implements Serializable { | |||
private static final long serialVersionUID = 5250395474667395607L; | |||
@JSONField(ordinal = MagicNumConstant.ONE) | |||
private String traceId; | |||
@JSONField(ordinal = MagicNumConstant.TWO) | |||
private String type; | |||
@JSONField(ordinal = MagicNumConstant.THREE) | |||
private String level; | |||
@JSONField(ordinal = MagicNumConstant.FOUR) | |||
private String location; | |||
@JSONField(ordinal = MagicNumConstant.FIVE) | |||
private String time = DateUtil.now(); | |||
@JSONField(ordinal = MagicNumConstant.SIX) | |||
private Object info; | |||
public void setInfo(Object info) { | |||
this.info = info; | |||
} | |||
} |
@@ -1,117 +0,0 @@ | |||
/** | |||
* 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.domain.entity; | |||
import com.baomidou.mybatisplus.annotation.*; | |||
import lombok.AllArgsConstructor; | |||
import lombok.Builder; | |||
import lombok.Data; | |||
import lombok.NoArgsConstructor; | |||
import org.dubhe.base.BaseEntity; | |||
import javax.validation.constraints.NotBlank; | |||
import java.io.Serializable; | |||
import java.util.Objects; | |||
/** | |||
* @description 菜单实体 | |||
* @date 2020-06-29 | |||
*/ | |||
@Data | |||
@Builder | |||
@AllArgsConstructor | |||
@NoArgsConstructor | |||
@TableName("menu") | |||
public class Menu extends BaseEntity implements Serializable { | |||
private static final long serialVersionUID = 3100515433018008777L; | |||
@TableId(value = "id", type = IdType.AUTO) | |||
private Long id; | |||
@NotBlank | |||
private String name; | |||
@TableField(value = "sort") | |||
private Long sort = 999L; | |||
@TableField(value = "path") | |||
private String path; | |||
@TableField(value = "component") | |||
private String component; | |||
/** | |||
* 类型,目录、菜单、按钮 | |||
*/ | |||
@TableField(value = "type") | |||
private Integer type; | |||
/** | |||
* 权限 | |||
*/ | |||
@TableField(value = "permission") | |||
private String permission; | |||
@TableField(value = "component_name") | |||
private String componentName; | |||
@TableField(value = "icon") | |||
private String icon; | |||
/** | |||
* 布局类型 | |||
*/ | |||
@TableField(value = "layout") | |||
private String layout; | |||
@TableField(value = "cache") | |||
private Boolean cache; | |||
@TableField(value = "hidden") | |||
private Boolean hidden; | |||
/** | |||
* 上级菜单ID | |||
*/ | |||
@TableField(value = "pid") | |||
private Long pid; | |||
@TableField(value = "deleted",fill = FieldFill.INSERT) | |||
private Boolean deleted; | |||
@Override | |||
public boolean equals(Object o) { | |||
if (this == o) { | |||
return true; | |||
} | |||
if (o == null || getClass() != o.getClass()) { | |||
return false; | |||
} | |||
Menu menu = (Menu) o; | |||
return Objects.equals(id, menu.id); | |||
} | |||
@Override | |||
public int hashCode() { | |||
return Objects.hash(id); | |||
} | |||
public @interface Update { | |||
} | |||
} |
@@ -1,82 +0,0 @@ | |||
/** | |||
* 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.domain.entity; | |||
import com.baomidou.mybatisplus.annotation.*; | |||
import lombok.AllArgsConstructor; | |||
import lombok.Builder; | |||
import lombok.Data; | |||
import lombok.NoArgsConstructor; | |||
import org.dubhe.base.BaseEntity; | |||
import java.io.Serializable; | |||
import java.util.Objects; | |||
import java.util.Set; | |||
/** | |||
* @description 角色实体 | |||
* @date 2020-06-29 | |||
*/ | |||
@Data | |||
@Builder | |||
@AllArgsConstructor | |||
@NoArgsConstructor | |||
@TableName("role") | |||
public class Role extends BaseEntity implements Serializable { | |||
private static final long serialVersionUID = -812009584744832371L; | |||
@TableId(value = "id", type = IdType.AUTO) | |||
private Long id; | |||
@TableField(value = "name") | |||
private String name; | |||
/** | |||
* 权限 | |||
*/ | |||
@TableField(value = "permission") | |||
private String permission; | |||
@TableField(value = "remark") | |||
private String remark; | |||
@TableField(exist = false) | |||
private Set<Menu> menus; | |||
@TableField(value = "deleted",fill = FieldFill.INSERT) | |||
private Boolean deleted = false; | |||
@Override | |||
public boolean equals(Object o) { | |||
if (this == o) { | |||
return true; | |||
} | |||
if (o == null || getClass() != o.getClass()) { | |||
return false; | |||
} | |||
Role role = (Role) o; | |||
return Objects.equals(id, role.id); | |||
} | |||
@Override | |||
public int hashCode() { | |||
return Objects.hash(id); | |||
} | |||
public @interface Update { | |||
} | |||
} |
@@ -1,49 +0,0 @@ | |||
/** | |||
* 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.domain.entity; | |||
import com.baomidou.mybatisplus.annotation.TableField; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import lombok.AllArgsConstructor; | |||
import lombok.Builder; | |||
import lombok.Data; | |||
import lombok.NoArgsConstructor; | |||
import java.io.Serializable; | |||
/** | |||
* @description 角色菜单关系实体 | |||
* @date 2020-06-29 | |||
*/ | |||
@Data | |||
@Builder | |||
@AllArgsConstructor | |||
@NoArgsConstructor | |||
@TableName("roles_menus") | |||
public class RoleMenu implements Serializable { | |||
private static final long serialVersionUID = -6296866205797727963L; | |||
@TableField(value = "menu_id") | |||
private Long menuId; | |||
@TableField(value = "role_id") | |||
private Long roleId; | |||
} |
@@ -1,85 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.AllArgsConstructor; | |||
import lombok.Builder; | |||
import lombok.Data; | |||
import lombok.NoArgsConstructor; | |||
import javax.validation.constraints.NotBlank; | |||
import javax.validation.constraints.NotNull; | |||
import java.sql.Timestamp; | |||
import java.util.List; | |||
import java.util.Objects; | |||
/** | |||
* @description 团队实体 | |||
* @date 2020-06-29 | |||
*/ | |||
@TableName("team") | |||
@Data | |||
@Builder | |||
@NoArgsConstructor | |||
@AllArgsConstructor | |||
public class Team { | |||
@TableId(value = "id", type = IdType.AUTO) | |||
@NotNull(groups = Update.class) | |||
private Long id; | |||
@TableField(value = "name") | |||
@NotBlank | |||
private String name; | |||
@TableField(value = "enabled") | |||
@NotNull | |||
private Boolean enabled; | |||
/** | |||
* 团队成员 | |||
*/ | |||
@TableField(exist = false) | |||
private List<User> teamUserList; | |||
@TableField(value = "create_time") | |||
private Timestamp createTime; | |||
@Override | |||
public boolean equals(Object o) { | |||
if (this == o) { | |||
return true; | |||
} | |||
if (o == null || getClass() != o.getClass()) { | |||
return false; | |||
} | |||
Team dept = (Team) o; | |||
return Objects.equals(id, dept.id) && | |||
Objects.equals(name, dept.name); | |||
} | |||
@Override | |||
public int hashCode() { | |||
return Objects.hash(id, name); | |||
} | |||
public @interface Update { | |||
} | |||
} |
@@ -1,58 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 javax.validation.constraints.NotNull; | |||
import java.io.Serializable; | |||
/** | |||
* @description 团队用户关系实体 | |||
* @date 2020-06-29 | |||
*/ | |||
@Data | |||
@TableName("teams_users_roles") | |||
public class TeamUserRole implements Serializable { | |||
@TableId(value = "id", type = IdType.AUTO) | |||
@NotNull() | |||
private Long id; | |||
/** | |||
* 团队 | |||
*/ | |||
@TableField(exist = false) | |||
private Team team; | |||
/** | |||
* 用户 | |||
*/ | |||
@TableField(exist = false) | |||
private User user; | |||
/** | |||
* 角色 | |||
*/ | |||
@TableField(exist = false) | |||
private Role role; | |||
} |
@@ -1,126 +0,0 @@ | |||
/** | |||
* 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.domain.entity; | |||
import com.baomidou.mybatisplus.annotation.*; | |||
import lombok.AllArgsConstructor; | |||
import lombok.Builder; | |||
import lombok.Data; | |||
import lombok.NoArgsConstructor; | |||
import org.dubhe.base.BaseEntity; | |||
import javax.validation.constraints.NotBlank; | |||
import javax.validation.constraints.NotEmpty; | |||
import javax.validation.constraints.NotNull; | |||
import java.io.Serializable; | |||
import java.util.Date; | |||
import java.util.List; | |||
import java.util.Objects; | |||
/** | |||
* @description 用户实体 | |||
* @date 2020-06-29 | |||
*/ | |||
@Data | |||
@TableName("user") | |||
@Builder | |||
@NoArgsConstructor | |||
@AllArgsConstructor | |||
public class User extends BaseEntity implements Serializable { | |||
private static final long serialVersionUID = -3836401769559845765L; | |||
@TableId(value = "id", type = IdType.AUTO) | |||
@NotNull(groups = Update.class) | |||
private Long id; | |||
@NotBlank | |||
@TableField(value = "username") | |||
private String username; | |||
/** | |||
* 用户昵称 | |||
*/ | |||
@TableField(value = "nick_name") | |||
@NotBlank | |||
private String nickName; | |||
/** | |||
* 性别 | |||
*/ | |||
@TableField(value = "sex") | |||
private String sex; | |||
@NotBlank | |||
@TableField(value = "email") | |||
private String email; | |||
@NotBlank | |||
@TableField(value = "phone") | |||
private String phone; | |||
@NotNull | |||
@TableField(value = "enabled") | |||
private Boolean enabled; | |||
@TableField(value = "password") | |||
private String password; | |||
@TableField(value = "last_password_reset_time") | |||
private Date lastPasswordResetTime; | |||
@TableField(value = "remark") | |||
private String remark; | |||
@TableField(value = "avatar_id") | |||
private Long avatarId; | |||
@TableField(exist = false) | |||
private UserAvatar userAvatar; | |||
@NotEmpty | |||
@TableField(exist = false) | |||
private List<Role> roles; | |||
@TableField(value = "deleted",fill = FieldFill.INSERT) | |||
private Boolean deleted = false; | |||
@Override | |||
public boolean equals(Object o) { | |||
if (this == o) { | |||
return true; | |||
} | |||
if (o == null || getClass() != o.getClass()) { | |||
return false; | |||
} | |||
User user = (User) o; | |||
return Objects.equals(id, user.id) && | |||
Objects.equals(username, user.username); | |||
} | |||
@Override | |||
public int hashCode() { | |||
return Objects.hash(id, username); | |||
} | |||
public @interface Update { | |||
} | |||
} |
@@ -1,58 +0,0 @@ | |||
/** | |||
* 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.domain.entity; | |||
import cn.hutool.core.util.ObjectUtil; | |||
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.NoArgsConstructor; | |||
import org.dubhe.base.BaseEntity; | |||
import java.io.Serializable; | |||
/** | |||
* @description 用户头像实体 | |||
* @date 2020-06-29 | |||
*/ | |||
@Data | |||
@NoArgsConstructor | |||
@TableName("user_avatar") | |||
public class UserAvatar extends BaseEntity implements Serializable { | |||
@TableId(value = "id", type = IdType.AUTO) | |||
private Long id; | |||
@TableField(value = "real_name") | |||
private String realName; | |||
@TableField(value = "path") | |||
private String path; | |||
@TableField(value = "size") | |||
private String size; | |||
public UserAvatar(UserAvatar userAvatar, String realName, String path, String size) { | |||
this.id = ObjectUtil.isNotEmpty(userAvatar) ? userAvatar.getId() : null; | |||
this.realName = realName; | |||
this.path = path; | |||
this.size = size; | |||
} | |||
} |
@@ -1,47 +0,0 @@ | |||
/** | |||
* 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.domain.entity; | |||
import com.baomidou.mybatisplus.annotation.TableField; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import lombok.AllArgsConstructor; | |||
import lombok.Builder; | |||
import lombok.Data; | |||
import lombok.NoArgsConstructor; | |||
import java.io.Serializable; | |||
/** | |||
* @description 用户角色关系实体 | |||
* @date 2020-06-29 | |||
*/ | |||
@Data | |||
@Builder | |||
@AllArgsConstructor | |||
@NoArgsConstructor | |||
@TableName("users_roles") | |||
public class UserRole implements Serializable { | |||
private static final long serialVersionUID = -6296866205797727963L; | |||
@TableField(value = "user_id") | |||
private Long userId; | |||
@TableField(value = "role_id") | |||
private Long roleId; | |||
} |
@@ -1,73 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.dto; | |||
import lombok.Data; | |||
/** | |||
* @description 全局请求日志信息 | |||
* @date 2020-08-13 | |||
*/ | |||
@Data | |||
public class GlobalRequestRecordDTO { | |||
/** | |||
* 客户主机地址 | |||
*/ | |||
private String clientHost; | |||
/** | |||
* 请求地址 | |||
*/ | |||
private String uri; | |||
/** | |||
* 授权信息 | |||
*/ | |||
private String authorization; | |||
/** | |||
* 用户名 | |||
*/ | |||
private String username; | |||
/** | |||
* form参数 | |||
*/ | |||
private String params; | |||
/** | |||
* 返回值类型 | |||
*/ | |||
private String contentType; | |||
/** | |||
* 返回状态 | |||
*/ | |||
private Integer status; | |||
/** | |||
* 时间耗费 | |||
*/ | |||
private Long timeCost; | |||
/** | |||
* 请求方式 | |||
*/ | |||
private String method; | |||
/** | |||
* 请求体body参数 | |||
*/ | |||
private String requestBody; | |||
/** | |||
* 返回值json数据 | |||
*/ | |||
private String responseBody; | |||
} |
@@ -1,49 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.dto; | |||
import lombok.*; | |||
import org.springframework.stereotype.Component; | |||
/** | |||
* @description 执行状态机切换请求体 | |||
* @date 2020-08-27 | |||
*/ | |||
@Component | |||
@Data | |||
@Builder | |||
@ToString | |||
@NoArgsConstructor | |||
@AllArgsConstructor | |||
public class StateChangeDTO { | |||
/** | |||
* 业务参数 eg: id | |||
*/ | |||
private Object[] objectParam; | |||
/** | |||
* 状态机类型 eg:dataStateMachine | |||
*/ | |||
private String stateMachineType; | |||
/** | |||
* 状态机执行事件 | |||
*/ | |||
private String eventMethodName; | |||
} |
@@ -1,35 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.dto.callback; | |||
import io.swagger.annotations.ApiModel; | |||
import lombok.Data; | |||
/** | |||
* @descripton 个性化参数实现 与 个性化参数个性化校验 | |||
* | |||
* @date 2020-05-28 | |||
*/ | |||
@ApiModel(description = "k8s pod异步回调Algorithm") | |||
@Data | |||
public class AlgorithmK8sPodCallbackCreateDTO extends BaseK8sPodCallbackCreateDTO { | |||
@Override | |||
public String toString() { | |||
return super.toString(); | |||
} | |||
} |
@@ -1,33 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.dto.callback; | |||
import io.swagger.annotations.ApiModel; | |||
import lombok.Data; | |||
/** | |||
* @descripton k8s方异步回调统一汇总类,即不管什么业务所有请求参数都放在这个类中 | |||
* | |||
* @date 2020-05-28 | |||
*/ | |||
@ApiModel(description = "k8s方 pod异步回调汇总类") | |||
@Data | |||
public class AllK8sPodCallbackCreateDTO extends BaseK8sPodCallbackCreateDTO{ | |||
} |
@@ -1,82 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.dto.callback; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import javax.validation.constraints.NotBlank; | |||
import javax.validation.constraints.NotNull; | |||
/** | |||
* @descripton 统一通用参数实现与校验 | |||
* @date 2020-11-26 | |||
*/ | |||
@ApiModel(description = "k8s deployment异步回调基类") | |||
@Data | |||
public class BaseK8sDeploymentCallbackCreateDTO { | |||
@ApiModelProperty(required = true, value = "k8s namespace") | |||
@NotBlank(message = "namespace 不能为空!") | |||
private String namespace; | |||
@ApiModelProperty(required = true, value = "k8s resource name") | |||
@NotBlank(message = "resourceName 不能为空!") | |||
private String resourceName; | |||
@ApiModelProperty(required = true, value = "k8s deployment name") | |||
@NotBlank(message = "deployment 不能为空!") | |||
private String deploymentName; | |||
/** | |||
* deployment已 Running的pod数 | |||
*/ | |||
@ApiModelProperty(required = true, value = "k8s deployment readyReplicas") | |||
@NotNull(message = "readyReplicas 不能为空!") | |||
private Integer readyReplicas; | |||
/** | |||
* deployment总pod数 | |||
*/ | |||
@ApiModelProperty(required = true, value = "k8s deployment replicas") | |||
@NotNull(message = "replicas 不能为空!") | |||
private Integer replicas; | |||
public BaseK8sDeploymentCallbackCreateDTO() { | |||
} | |||
public BaseK8sDeploymentCallbackCreateDTO(String namespace, String resourceName, String deploymentName, Integer readyReplicas, Integer replicas) { | |||
this.namespace = namespace; | |||
this.resourceName = resourceName; | |||
this.deploymentName = deploymentName; | |||
this.readyReplicas = readyReplicas; | |||
this.replicas = replicas; | |||
} | |||
@Override | |||
public String toString() { | |||
return "BaseK8sDeploymentCallbackCreateDTO{" + | |||
"namespace='" + namespace + '\'' + | |||
", resourceName='" + resourceName + '\'' + | |||
", deploymentName='" + deploymentName + '\'' + | |||
", readyReplicas='" + readyReplicas + '\'' + | |||
", replicas='" + replicas + '\'' + | |||
'}'; | |||
} | |||
} |
@@ -1,88 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.dto.callback; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import javax.validation.constraints.NotEmpty; | |||
/** | |||
* @descripton 统一通用参数实现与校验 | |||
* | |||
* @date 2020-05-28 | |||
*/ | |||
@ApiModel(description = "k8s pod异步回调基类") | |||
@Data | |||
public class BaseK8sPodCallbackCreateDTO { | |||
@ApiModelProperty(required = true,value = "k8s namespace") | |||
@NotEmpty(message = "namespace 不能为空!") | |||
private String namespace; | |||
@ApiModelProperty(required = true,value = "k8s resource name") | |||
@NotEmpty(message = "resourceName 不能为空!") | |||
private String resourceName; | |||
@ApiModelProperty(required = true,value = "k8s pod name") | |||
@NotEmpty(message = "podName 不能为空!") | |||
private String podName; | |||
@ApiModelProperty(required = true,value = "k8s pod parent type") | |||
@NotEmpty(message = "podParentType 不能为空!") | |||
private String podParentType; | |||
@ApiModelProperty(required = true,value = "k8s pod parent name") | |||
@NotEmpty(message = "podParentName 不能为空!") | |||
private String podParentName; | |||
@ApiModelProperty(value = "k8s pod phase",notes = "对应PodPhaseEnum") | |||
@NotEmpty(message = "phase 不能为空!") | |||
private String phase; | |||
@ApiModelProperty(value = "k8s pod containerStatuses state") | |||
private String messages; | |||
public BaseK8sPodCallbackCreateDTO(){ | |||
} | |||
public BaseK8sPodCallbackCreateDTO(String namespace,String resourceName,String podName,String podParentType,String podParentName,String phase,String messages){ | |||
this.namespace = namespace; | |||
this.resourceName = resourceName; | |||
this.podName = podName; | |||
this.podParentType = podParentType; | |||
this.podParentName = podParentName; | |||
this.phase = phase; | |||
this.messages = messages; | |||
} | |||
@Override | |||
public String toString() { | |||
return "BaseK8sPodCallbackReq{" + | |||
"namespace='" + namespace + '\'' + | |||
", resourceName='" + resourceName + '\'' + | |||
", podName='" + podName + '\'' + | |||
", podParentType='" + podParentType + '\'' + | |||
", podParentName='" + podParentName + '\'' + | |||
", phase='" + phase + '\'' + | |||
", messages=" + messages + | |||
'}'; | |||
} | |||
} |
@@ -1,35 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.dto.callback; | |||
import io.swagger.annotations.ApiModel; | |||
import lombok.Data; | |||
/** | |||
* @description k8s pod异步回调云端serving | |||
* @date 2020-11-27 | |||
*/ | |||
@ApiModel(description = "k8s pod异步回调云端serving") | |||
@Data | |||
public class BatchServingK8sPodCallbackCreateDTO extends BaseK8sPodCallbackCreateDTO { | |||
@Override | |||
public String toString() { | |||
return super.toString(); | |||
} | |||
} |
@@ -1,30 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.dto.callback; | |||
import io.swagger.annotations.ApiModel; | |||
import lombok.Data; | |||
/** | |||
* @description 模型优化自定义回调参数类 | |||
* @date 2020-06-03 | |||
*/ | |||
@ApiModel(description = "k8s pod异步回调Algorithm") | |||
@Data | |||
public class ModelOptK8sPodCallbackCreateDTO extends BaseK8sPodCallbackCreateDTO { | |||
} |
@@ -1,36 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.dto.callback; | |||
import io.swagger.annotations.ApiModel; | |||
import lombok.Data; | |||
/** | |||
* @descripton k8s pod异步回调Notebook | |||
* | |||
* @date 2020-05-28 | |||
*/ | |||
@ApiModel(description = "k8s pod异步回调Notebook") | |||
@Data | |||
public class NotebookK8sPodCallbackCreateDTO extends BaseK8sPodCallbackCreateDTO { | |||
@Override | |||
public String toString() { | |||
return super.toString(); | |||
} | |||
} |
@@ -1,34 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.dto.callback; | |||
import io.swagger.annotations.ApiModel; | |||
import lombok.Data; | |||
/** | |||
* @description k8s deployment异步回调云端serving | |||
* @date 2020-09-16 | |||
*/ | |||
@ApiModel(description = "k8s deployment异步回调云端serving") | |||
@Data | |||
public class ServingK8sDeploymentCallbackCreateDTO extends BaseK8sDeploymentCallbackCreateDTO { | |||
@Override | |||
public String toString() { | |||
return super.toString(); | |||
} | |||
} |
@@ -1,114 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 lombok.Getter; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
/** | |||
* @description 业务模块 | |||
* @date 2020-05-25 | |||
*/ | |||
@Getter | |||
public enum BizEnum { | |||
/** | |||
* 模型开发 | |||
*/ | |||
NOTEBOOK("模型开发", "notebook", 0), | |||
/** | |||
* 算法管理 | |||
*/ | |||
ALGORITHM("算法管理", "algorithm", 1), | |||
/** | |||
* 模型管理 | |||
*/ | |||
MODEL("模型管理", "model", 2), | |||
/** | |||
* 训练管理 | |||
*/ | |||
TRAIN("训练管理", "train", 3), | |||
/** | |||
* 云端Serving-在线服务 | |||
*/ | |||
SERVING("云端Serving", "serving", 4), | |||
/** | |||
* 批量服务 | |||
*/ | |||
BATCH_SERVING("批量服务", "batchserving", 5), | |||
/** | |||
* 模型优化 | |||
*/ | |||
MODEL_OPT("模型优化管理","modelopt",6), | |||
; | |||
/** | |||
* 业务模块名称 | |||
*/ | |||
private String bizName; | |||
/** | |||
* 业务模块名称 | |||
*/ | |||
private String bizCode; | |||
/** | |||
* 业务源代号 | |||
*/ | |||
private Integer createResource; | |||
BizEnum(String bizName, String bizCode, Integer createResource) { | |||
this.createResource = createResource; | |||
this.bizName = bizName; | |||
this.bizCode = bizCode; | |||
} | |||
private static final Map<Integer, BizEnum> RESOURCE_ENUM_MAP = new HashMap<Integer, BizEnum>() { | |||
{ | |||
for (BizEnum enums : BizEnum.values()) { | |||
put(enums.getCreateResource(), enums); | |||
} | |||
} | |||
}; | |||
/** | |||
* 根据createResource获取BizEnum | |||
* @param createResource 业务源代号 | |||
* @return 枚举对象 | |||
*/ | |||
public static BizEnum getByCreateResource(int createResource) { | |||
return RESOURCE_ENUM_MAP.get(createResource); | |||
} | |||
/** | |||
* 根据createResource获取code | |||
* | |||
* @param createResource 业务源代号 | |||
* @return String 业务模块名称 | |||
*/ | |||
public static String getCodeByResource(Integer createResource) { | |||
for (BizEnum enums : BizEnum.values()) { | |||
if (enums.getCreateResource().equals(createResource)) { | |||
return enums.getBizCode(); | |||
} | |||
} | |||
return null; | |||
} | |||
} |
@@ -1,99 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 java.util.HashMap; | |||
import java.util.Map; | |||
/** | |||
* @description 业务NFS路径枚举 | |||
* @date 2020-05-13 | |||
*/ | |||
public enum BizNfsEnum { | |||
/** | |||
* 模型开发 NFS 路径命名 | |||
*/ | |||
NOTEBOOK(BizEnum.NOTEBOOK, "notebook"), | |||
/** | |||
* 算法管理 NFS 路径命名 | |||
*/ | |||
ALGORITHM(BizEnum.ALGORITHM, "algorithm-manage"), | |||
/** | |||
* 模型管理 NFS 路径命名 | |||
*/ | |||
MODEL(BizEnum.MODEL, "model"), | |||
/** | |||
* 模型优化 NFS 路径命名 | |||
*/ | |||
MODEL_OPT(BizEnum.MODEL_OPT, "model-opt"), | |||
; | |||
BizNfsEnum(BizEnum bizEnum, String bizNfsPath) { | |||
this.bizEnum = bizEnum; | |||
this.bizNfsPath = bizNfsPath; | |||
} | |||
/** | |||
* 业务模块 | |||
*/ | |||
private BizEnum bizEnum; | |||
/** | |||
* 业务模块nfs路径 | |||
*/ | |||
private String bizNfsPath; | |||
private static final Map<Integer, BizNfsEnum> RESOURCE_ENUM_MAP = new HashMap<Integer, BizNfsEnum>() { | |||
{ | |||
for (BizNfsEnum enums : BizNfsEnum.values()) { | |||
put(enums.getCreateResource(), enums); | |||
} | |||
} | |||
}; | |||
/** | |||
* 根据createResource获取BizNfsEnum | |||
* | |||
* @param createResource | |||
* @return | |||
*/ | |||
public static BizNfsEnum getByCreateResource(int createResource) { | |||
return RESOURCE_ENUM_MAP.get(createResource); | |||
} | |||
public String getBizName() { | |||
return bizEnum == null ? null : bizEnum.getBizName(); | |||
} | |||
public Integer getCreateResource() { | |||
return bizEnum == null ? null : bizEnum.getCreateResource(); | |||
} | |||
public String getBizNfsPath() { | |||
return bizNfsPath; | |||
} | |||
public BizEnum getBizEnum() { | |||
return bizEnum; | |||
} | |||
public String getBizCode() { | |||
return bizEnum == null ? null : bizEnum.getBizCode(); | |||
} | |||
} |
@@ -1,65 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 lombok.Getter; | |||
/** | |||
* @description 数据集类型 | |||
* @date 2020-05-21 | |||
*/ | |||
@Getter | |||
public enum DatasetTypeEnum { | |||
/** | |||
* 私有数据 | |||
*/ | |||
PRIVATE(0, "私有数据"), | |||
/** | |||
* 团队数据 | |||
*/ | |||
TEAM(1, "团队数据"), | |||
/** | |||
* 公开数据 | |||
*/ | |||
PUBLIC(2, "公开数据"); | |||
DatasetTypeEnum(Integer value, String msg) { | |||
this.value = value; | |||
this.msg = msg; | |||
} | |||
private Integer value; | |||
private String msg; | |||
/** | |||
* 数据集类型校验 用户web端接口调用时参数校验 | |||
* | |||
* @param value 数据集类型 | |||
* @return | |||
*/ | |||
public static boolean isValid(Integer value) { | |||
for (DatasetTypeEnum datasetTypeEnum : DatasetTypeEnum.values()) { | |||
if (datasetTypeEnum.value.equals(value)) { | |||
return true; | |||
} | |||
} | |||
return false; | |||
} | |||
} |
@@ -1,50 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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; | |||
} | |||
} |
@@ -1,53 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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; | |||
} | |||
} |
@@ -1,92 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 lombok.Getter; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
/** | |||
* @description 镜像项目枚举类 | |||
* @date 2020-12-11 | |||
*/ | |||
@Getter | |||
public enum ImageTypeEnum { | |||
/** | |||
* notebook镜像 | |||
*/ | |||
NOTEBOOK("notebook镜像", "notebook", 0), | |||
/** | |||
* 训练镜像 | |||
*/ | |||
TRAIN("训练镜像", "train", 1); | |||
/** | |||
* 镜像项目名称 | |||
*/ | |||
private String name; | |||
/** | |||
* 镜像项目代码 | |||
*/ | |||
private String code; | |||
/** | |||
* 镜像项目类型 | |||
*/ | |||
private Integer type; | |||
ImageTypeEnum(String name, String code, Integer type) { | |||
this.name = name; | |||
this.code = code; | |||
this.type = type; | |||
} | |||
private static final Map<Integer, ImageTypeEnum> RESOURCE_ENUM_MAP = new HashMap<Integer, ImageTypeEnum>() { | |||
{ | |||
for (ImageTypeEnum enums : ImageTypeEnum.values()) { | |||
put(enums.getType(), enums); | |||
} | |||
} | |||
}; | |||
/** | |||
* 根据type获取ImageTypeEnum | |||
* @param type | |||
* @return 镜像项目枚举对象 | |||
*/ | |||
public static ImageTypeEnum getType(int type) { | |||
return RESOURCE_ENUM_MAP.get(type); | |||
} | |||
/** | |||
* 根据type获取code | |||
* | |||
* @param type 镜像项目类型 | |||
* @return String 镜像项目代码 | |||
*/ | |||
public static String getType(Integer type) { | |||
for (ImageTypeEnum enums : ImageTypeEnum.values()) { | |||
if (enums.getType().equals(type)) { | |||
return enums.getCode(); | |||
} | |||
} | |||
return null; | |||
} | |||
} |
@@ -1,88 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 lombok.Getter; | |||
/** | |||
* @description 日志类型枚举类 | |||
* @date 2020-06-23 | |||
*/ | |||
@Getter | |||
public enum LogEnum { | |||
// 系统报错日志 | |||
SYS_ERR, | |||
// 用户请求日志 | |||
REST_REQ, | |||
//全局请求日志 | |||
GLOBAL_REQ, | |||
// 训练模块 | |||
BIZ_TRAIN, | |||
// 系统模块 | |||
BIZ_SYS, | |||
// 模型模块 | |||
BIZ_MODEL, | |||
// 模型优化 | |||
MODEL_OPT, | |||
// 数据集模块 | |||
BIZ_DATASET, | |||
// k8s模块 | |||
BIZ_K8S, | |||
//note book | |||
NOTE_BOOK, | |||
//NFS UTILS | |||
NFS_UTIL, | |||
//localFileUtil | |||
LOCAL_FILE_UTIL, | |||
//FILE UTILS | |||
FILE_UTIL, | |||
// 云端Serving模块 | |||
SERVING, | |||
//FILE UTILS | |||
UPLOAD_TEMP, | |||
//STATE MACHINE | |||
STATE_MACHINE, | |||
//全局垃圾回收 | |||
GARBAGE_RECYCLE, | |||
//IO UTIL | |||
IO_UTIL, | |||
//DATA_SEQUENCE | |||
DATA_SEQUENCE, | |||
// 日志切面 | |||
LOG_ASPECT, | |||
//镜像 | |||
IMAGE, | |||
//度量 | |||
MEASURE; | |||
; | |||
/** | |||
* 判断日志类型不能为空 | |||
* | |||
* @param logType 日志类型 | |||
* @return boolean 返回类型 | |||
*/ | |||
public static boolean isLogType(LogEnum logType) { | |||
if (logType != null) { | |||
return true; | |||
} | |||
return false; | |||
} | |||
} |
@@ -1,66 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 lombok.Getter; | |||
/** | |||
* @description 模型资源枚举类 | |||
* @date 2020-11-19 | |||
*/ | |||
@Getter | |||
public enum ModelResourceEnum { | |||
/** | |||
* 我的模型 | |||
*/ | |||
MINE(0, "我的模型"), | |||
/** | |||
* 预置模型 | |||
*/ | |||
PRESET(1, "预置模型"), | |||
/** | |||
* 炼知模型 | |||
*/ | |||
ATLAS(2, "炼知模型"); | |||
private Integer type; | |||
private String description; | |||
ModelResourceEnum(Integer type, String description) { | |||
this.type = type; | |||
this.description = description; | |||
} | |||
/** | |||
* 根据类型获取枚举类对象 | |||
* | |||
* @param type 类型 | |||
* @return 枚举类对象 | |||
*/ | |||
public static ModelResourceEnum getType(Integer type) { | |||
for (ModelResourceEnum modelResourceEnum : values()) { | |||
if (modelResourceEnum.getType().compareTo(type) == 0) { | |||
//获取指定的枚举 | |||
return modelResourceEnum; | |||
} | |||
} | |||
return null; | |||
} | |||
} |
@@ -1,72 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 lombok.Getter; | |||
import lombok.ToString; | |||
/** | |||
* @Description 操作类型枚举 | |||
* @Date 2020-08-24 | |||
*/ | |||
@ToString | |||
@Getter | |||
public enum OperationTypeEnum { | |||
/** | |||
* SELECT 查询类型 | |||
*/ | |||
SELECT("select", "查询"), | |||
/** | |||
* UPDATE 修改类型 | |||
*/ | |||
UPDATE("update", "修改"), | |||
/** | |||
* DELETE 删除类型 | |||
*/ | |||
DELETE("delete", "删除"), | |||
/** | |||
* LIMIT 禁止操作类型 | |||
*/ | |||
LIMIT("limit", "禁止操作"), | |||
/** | |||
* INSERT 新增类型 | |||
*/ | |||
INSERT("insert", "新增类型"), | |||
; | |||
/** | |||
* 操作类型值 | |||
*/ | |||
private String type; | |||
/** | |||
* 操作类型备注 | |||
*/ | |||
private String desc; | |||
OperationTypeEnum(String type, String desc) { | |||
this.type = type; | |||
this.desc = desc; | |||
} | |||
} |
@@ -1,64 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 lombok.Getter; | |||
import java.util.HashSet; | |||
import java.util.Set; | |||
/** | |||
* @description 资源回收枚举类 | |||
* @date 2020-10-10 | |||
*/ | |||
@Getter | |||
public enum RecycleResourceEnum { | |||
/** | |||
* 数据集文件回收 | |||
*/ | |||
DATASET_RECYCLE_FILE("datasetRecycleFile", "数据集文件回收"), | |||
/** | |||
* 医学数据集文件回收 | |||
*/ | |||
DATAMEDICINE_RECYCLE_FILE("dataMedicineRecycleFile", "数据集文件回收"), | |||
/** | |||
* 数据集版本文件回收 | |||
*/ | |||
DATASET_RECYCLE_VERSION_FILE("datasetRecycleVersionFile", "数据集版本文件回收"), | |||
/** | |||
* 云端Serving输入文件回收 | |||
*/ | |||
SERVING_RECYCLE_FILE("servingRecycleFile", "云端Serving文件回收"), | |||
; | |||
private String className; | |||
private String message; | |||
RecycleResourceEnum(String className, String message) { | |||
this.className = className; | |||
this.message = message; | |||
} | |||
} |
@@ -1,95 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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-06-01 | |||
*/ | |||
public enum SwitchEnum { | |||
/** | |||
* OFF 否 | |||
*/ | |||
OFF(0, "否"), | |||
/** | |||
* ON 否 | |||
*/ | |||
ON(1, "是"), | |||
; | |||
private Integer value; | |||
private String desc; | |||
SwitchEnum(Integer value, String desc) { | |||
this.value = value; | |||
this.desc = desc; | |||
} | |||
public Integer getValue() { | |||
return this.value; | |||
} | |||
public String getDesc() { | |||
return desc; | |||
} | |||
public void setDesc(String desc) { | |||
this.desc = desc; | |||
} | |||
public static SwitchEnum getEnumValue(Integer value) { | |||
switch (value) { | |||
case 0: | |||
return OFF; | |||
case 1: | |||
return ON; | |||
default: | |||
return OFF; | |||
} | |||
} | |||
public static Boolean getBooleanValue(Integer value) { | |||
switch (value) { | |||
case 1: | |||
return true; | |||
case 0: | |||
return false; | |||
default: | |||
return false; | |||
} | |||
} | |||
public static boolean isExist(Integer value) { | |||
for (SwitchEnum itm : SwitchEnum.values()) { | |||
if (value.compareTo(itm.getValue()) == 0) { | |||
return true; | |||
} | |||
} | |||
return false; | |||
} | |||
@Override | |||
public String toString() { | |||
return "[" + this.value + "]" + this.desc; | |||
} | |||
} |
@@ -1,149 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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 lombok.Getter; | |||
import java.util.HashSet; | |||
import java.util.Set; | |||
/** | |||
* @description 训练任务枚举类 | |||
* @date 2020-04-27 | |||
*/ | |||
@Getter | |||
public enum TrainJobStatusEnum { | |||
/** | |||
* PENDING | |||
*/ | |||
PENDING(0, "PENDING"), | |||
/** | |||
* RUNNING | |||
*/ | |||
RUNNING(1, "RUNNING"), | |||
/** | |||
* SUCCEEDED | |||
*/ | |||
SUCCEEDED(2, "SUCCEEDED"), | |||
/** | |||
* FAILED | |||
*/ | |||
FAILED(3, "FAILED"), | |||
/** | |||
* STOP | |||
*/ | |||
STOP(4, "STOP"), | |||
/** | |||
* UNKNOWN | |||
*/ | |||
UNKNOWN(5, "UNKNOWN"), | |||
/** | |||
* DELETED | |||
*/ | |||
DELETED(6, "DELETED"), | |||
/** | |||
* CREATE_FAILED | |||
*/ | |||
CREATE_FAILED(7, "CREATE_FAILED"); | |||
private Integer status; | |||
private String message; | |||
TrainJobStatusEnum(Integer status, String message) { | |||
this.status = status; | |||
this.message = message; | |||
} | |||
/** | |||
* 根据信息获取枚举类对象 | |||
* | |||
* @param msg 信息 | |||
* @return 枚举类对象 | |||
*/ | |||
public static TrainJobStatusEnum getByMessage(String msg) { | |||
for (TrainJobStatusEnum statusEnum : values()) { | |||
if (statusEnum.message.equalsIgnoreCase(msg)) { | |||
return statusEnum; | |||
} | |||
} | |||
return UNKNOWN; | |||
} | |||
/** | |||
* 回调状态转换 若是DELETED则转换为STOP,避免状态不统一 | |||
* @param phase k8s pod phase | |||
* @return | |||
*/ | |||
public static TrainJobStatusEnum transferStatus(String phase) { | |||
TrainJobStatusEnum enums = getByMessage(phase); | |||
if (enums != DELETED) { | |||
return enums; | |||
} | |||
return STOP; | |||
} | |||
/** | |||
* 根据状态获取枚举类对象 | |||
* | |||
* @param status 状态 | |||
* @return 枚举类对象 | |||
*/ | |||
public static TrainJobStatusEnum getByStatus(Integer status) { | |||
for (TrainJobStatusEnum statusEnum : values()) { | |||
if (statusEnum.status.equals(status)) { | |||
return statusEnum; | |||
} | |||
} | |||
return UNKNOWN; | |||
} | |||
/** | |||
* 结束状态枚举集合 | |||
*/ | |||
public static final Set<TrainJobStatusEnum> END_TRAIN_JOB_STATUS; | |||
static { | |||
END_TRAIN_JOB_STATUS = new HashSet<>(); | |||
END_TRAIN_JOB_STATUS.add(SUCCEEDED); | |||
END_TRAIN_JOB_STATUS.add(FAILED); | |||
END_TRAIN_JOB_STATUS.add(STOP); | |||
END_TRAIN_JOB_STATUS.add(CREATE_FAILED); | |||
END_TRAIN_JOB_STATUS.add(DELETED); | |||
} | |||
public static boolean isEnd(String msg) { | |||
return END_TRAIN_JOB_STATUS.contains(getByMessage(msg)); | |||
} | |||
public static boolean isEnd(Integer status) { | |||
return END_TRAIN_JOB_STATUS.contains(getByStatus(status)); | |||
} | |||
public static boolean checkStopStatus(Integer num) { | |||
return isEnd(num); | |||
} | |||
public static boolean checkRunStatus(Integer num) { | |||
return PENDING.getStatus().equals(num) || | |||
RUNNING.getStatus().equals(num); | |||
} | |||
} |
@@ -1,70 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.exception; | |||
import lombok.Getter; | |||
/** | |||
* @description 通用异常code | |||
* @date 2020-03-26 | |||
*/ | |||
@Getter | |||
public enum BaseErrorCode implements ErrorCode { | |||
/** | |||
* undefined error | |||
*/ | |||
UNDEFINED(10000, "操作成功!"), | |||
ERROR(10001, "操作失败!"), | |||
ERROR_SYSTEM(10002, "系统繁忙!"), | |||
UNAUTHORIZED(401, "无权访问!"), | |||
/** | |||
* system 模块异常码 | |||
*/ | |||
SYSTEM_USERNAME_ALREADY_EXISTS(20000, "账号已存在!"), | |||
SYSTEM_CODE_ALREADY_EXISTS(20001, "Code already exists!"), | |||
SYSTEM_USER_IS_NOT_EXISTS(20002, "用户不存在!"), | |||
SYSTEM_USER_ALREADY_REGISTER(20003, "账号已注册!"), | |||
SYSTEM_USER_REGISTER_EMAIL_INFO_EXPIRED(20004, "邮箱验证码已过期!"), | |||
SYSTEM_USER_EMAIL_ALREADY_EXISTS(20004, "该邮箱已被注册!"), | |||
SYSTEM_USER_EMAIL_PASSWORD_ERROR(20005, "邮件密码错误!"), | |||
SYSTEM_USER_EMAIL_CODE_CANNOT_EXCEED_TIMES(20006, "邮件发送不能超过三次!"), | |||
SYSTEM_USER_EMAIL_OR_CODE_ERROR(20007, "邮箱地址或验证码错误、请重新输入!"), | |||
SYSTEM_USER_IS_LOCKED(20008, "用户已锁定!"), | |||
SYSTEM_USER_USERNAME_OR_PASSWORD_ERROR(20009, "账号或密码不正确!"), | |||
SYSTEM_USER_USERNAME_IS_LOCKED(20010, "账号已锁定,6小时后解锁!"), | |||
SYSTEM_USER_CANNOT_UPDATE_ADMIN(20011, "仅超级管理员可操作!"), | |||
SYSTEM_USER_TOKEN_INFO_IS_NULL(20012, "登录信息不存在!"), | |||
SYSTEM_USER_EMAIL_NOT_EXISTS(20013, "该邮箱未注册!"), | |||
SYSTEM_USER_CANNOT_DELETE(20014, "系统默认用户不可删除!"), | |||
SYSTEM_ROLE_CANNOT_DELETE(20015, "系统默认角色不可删除!"), | |||
DATASET_ADMIN_PERMISSION_ERROR(1310,"无此权限,请联系管理员"), | |||
; | |||
Integer code; | |||
String msg; | |||
BaseErrorCode(Integer code, String msg) { | |||
this.code = code; | |||
this.msg = msg; | |||
} | |||
} |
@@ -1,72 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.exception; | |||
import lombok.Getter; | |||
import org.dubhe.base.DataResponseBody; | |||
import org.dubhe.base.ResponseCode; | |||
/** | |||
* @description 业务异常 | |||
* @date 2020-03-13 | |||
*/ | |||
@Getter | |||
public class BusinessException extends RuntimeException { | |||
private DataResponseBody responseBody; | |||
public BusinessException(String msg) { | |||
super(msg); | |||
this.responseBody = new DataResponseBody(ResponseCode.BADREQUEST, msg); | |||
} | |||
public BusinessException(String msg, Throwable cause) { | |||
super(msg,cause); | |||
this.responseBody = new DataResponseBody(ResponseCode.BADREQUEST, msg); | |||
} | |||
public BusinessException(Throwable cause) { | |||
super(cause); | |||
this.responseBody = new DataResponseBody(ResponseCode.BADREQUEST); | |||
} | |||
public BusinessException(Integer code, String msg, String info, Throwable cause) { | |||
super(msg,cause); | |||
if (info == null) { | |||
this.responseBody = new DataResponseBody(code, msg); | |||
} else { | |||
this.responseBody = new DataResponseBody(code, msg + ":" + info); | |||
} | |||
} | |||
public BusinessException(ErrorCode errorCode, Throwable cause) { | |||
this(errorCode.getCode(), errorCode.getMsg(), null, cause); | |||
} | |||
public BusinessException(ErrorCode errorCode, String info, Throwable cause) { | |||
this(errorCode.getCode(), errorCode.getMsg(), info, cause); | |||
} | |||
public BusinessException(ErrorCode errorCode) { | |||
this(errorCode, null); | |||
} | |||
public BusinessException(Integer code,String msg) { | |||
this.responseBody = new DataResponseBody(code, msg); | |||
} | |||
} |
@@ -1,48 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.exception; | |||
import lombok.Getter; | |||
import org.dubhe.base.DataResponseBody; | |||
import org.dubhe.base.ResponseCode; | |||
/** | |||
* @description 验证码异常 | |||
* @date 2020-02-23 | |||
*/ | |||
@Getter | |||
public class CaptchaException extends RuntimeException { | |||
private static final long serialVersionUID = 1L; | |||
private DataResponseBody responseBody; | |||
private Throwable cause; | |||
public CaptchaException(String msg) { | |||
this.responseBody = new DataResponseBody(ResponseCode.BADREQUEST, msg); | |||
} | |||
public CaptchaException(String msg, Throwable cause) { | |||
this.cause = cause; | |||
this.responseBody = new DataResponseBody(ResponseCode.BADREQUEST, msg); | |||
} | |||
public CaptchaException(Throwable cause) { | |||
this.cause = cause; | |||
this.responseBody = new DataResponseBody(ResponseCode.BADREQUEST); | |||
} | |||
} |
@@ -1,42 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.exception; | |||
import lombok.Getter; | |||
/** | |||
* @description 获取序列异常 | |||
* @date 2020-09-23 | |||
*/ | |||
@Getter | |||
public class DataSequenceException extends BusinessException { | |||
private static final long serialVersionUID = 1L; | |||
public DataSequenceException(String msg) { | |||
super(msg); | |||
} | |||
public DataSequenceException(String msg, Throwable cause) { | |||
super(msg,cause); | |||
} | |||
public DataSequenceException(Throwable cause) { | |||
super(cause); | |||
} | |||
} |
@@ -1,48 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.exception; | |||
import lombok.Getter; | |||
import org.dubhe.base.DataResponseBody; | |||
import org.dubhe.base.ResponseCode; | |||
/** | |||
* @Description docker 异常 | |||
* @Date 2020-6-6 | |||
**/ | |||
@Getter | |||
public class DockerBizException extends RuntimeException { | |||
private static final long serialVersionUID = 1L; | |||
private DataResponseBody responseBody; | |||
private Throwable cause; | |||
public DockerBizException(String msg) { | |||
this.responseBody = new DataResponseBody(ResponseCode.DOCKER_ERROR, msg); | |||
} | |||
public DockerBizException(String msg, Throwable cause) { | |||
this.cause = cause; | |||
this.responseBody = new DataResponseBody(ResponseCode.DOCKER_ERROR, msg); | |||
} | |||
public DockerBizException(Throwable cause) { | |||
this.cause = cause; | |||
this.responseBody = new DataResponseBody(ResponseCode.DOCKER_ERROR); | |||
} | |||
} |
@@ -1,39 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.exception; | |||
/** | |||
* @description 异常code | |||
* @date 2020-03-26 | |||
*/ | |||
public interface ErrorCode { | |||
/** | |||
* 错误码 | |||
* @return code | |||
*/ | |||
Integer getCode(); | |||
/** | |||
* error info | |||
* @return | |||
*/ | |||
String getMsg(); | |||
} |
@@ -1,44 +0,0 @@ | |||
/** | |||
* 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.exception; | |||
import lombok.Getter; | |||
import org.dubhe.base.DataResponseBody; | |||
import org.dubhe.base.ResponseCode; | |||
/** | |||
* @description 登录异常 | |||
* @date 2020-02-23 | |||
*/ | |||
@Getter | |||
public class LoginException extends RuntimeException { | |||
private DataResponseBody responseBody; | |||
private Throwable cause; | |||
public LoginException(String msg) { | |||
this.responseBody = new DataResponseBody(ResponseCode.BADREQUEST, msg); | |||
} | |||
public LoginException(String msg, Throwable cause) { | |||
this.cause = cause; | |||
this.responseBody = new DataResponseBody(ResponseCode.BADREQUEST, msg); | |||
} | |||
public LoginException(Throwable cause) { | |||
this.cause = cause; | |||
this.responseBody = new DataResponseBody(ResponseCode.BADREQUEST); | |||
} | |||
} |
@@ -1,42 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.exception; | |||
import lombok.Getter; | |||
/** | |||
* Description : NFS utils 工具异常 | |||
* | |||
* @date 15.06.2020 | |||
*/ | |||
@Getter | |||
public class NfsBizException extends BusinessException { | |||
private static final long serialVersionUID = 1L; | |||
public NfsBizException(Throwable cause){ | |||
super(cause); | |||
} | |||
public NfsBizException(String msg){ | |||
super(msg); | |||
} | |||
} |
@@ -1,44 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.exception; | |||
import lombok.Getter; | |||
/** | |||
* @description Notebook 业务处理异常 | |||
* @date 2020.04.27 | |||
*/ | |||
@Getter | |||
public class NotebookBizException extends BusinessException{ | |||
private static final long serialVersionUID = 1L; | |||
public NotebookBizException(String msg) { | |||
super(msg); | |||
} | |||
public NotebookBizException(String msg, Throwable cause) { | |||
super(msg,cause); | |||
} | |||
public NotebookBizException(Throwable cause) { | |||
super(cause); | |||
} | |||
} |
@@ -1,48 +0,0 @@ | |||
/** | |||
* Copyright 2020 Tianshu AI Platform. 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.exception; | |||
import lombok.Getter; | |||
/** | |||
* @description 状态机异常类 | |||
* @date 2020-08-27 | |||
*/ | |||
@Getter | |||
public class StateMachineException extends BusinessException { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 自定义状态机异常(抛出异常堆栈信息) | |||
* | |||
* @param cause | |||
*/ | |||
public StateMachineException(Throwable cause){ | |||
super(cause); | |||
} | |||
/** | |||
* 自定义状态机异常(抛出异常信息) | |||
* | |||
* @param msg | |||
*/ | |||
public StateMachineException(String msg){ | |||
super(msg); | |||
} | |||
} |