| @@ -13,7 +13,7 @@ show_help() { | |||
| echo | |||
| echo "Options:" | |||
| echo " -b Branch to deploy, default is master" | |||
| echo " -s Service to deploy (manage-front, manage, front, all, default is manage-front)" | |||
| echo " -s Service to deploy (manage-front, manage, front, all, system, default is manage-front)" | |||
| echo " -h Show this help message" | |||
| } | |||
| @@ -54,7 +54,7 @@ compile_front() { | |||
| # 编译前端 | |||
| docker run -v ${baseDir}:${baseDir} \ | |||
| -e http_proxy=http://172.20.32.253:3128 -e https_proxy=http://172.20.32.253:3128 \ | |||
| 172.20.32.187/ci4s/node:16.16.0 ${baseDir}/k8s/build-node.sh | |||
| 172.20.32.187/tempimagefile/node:18.16.0 ${baseDir}/k8s/build-node.sh | |||
| if [ $? -ne 0 ]; then | |||
| echo "编译失败,请检查代码!" | |||
| exit 1 | |||
| @@ -80,13 +80,45 @@ compile_java() { | |||
| fi | |||
| # 复制jar包 | |||
| cp -rf ${baseDir}/ruoyi-modules/management-platform/target/management-platform.jar ${baseDir}/k8s/dockerfiles/jar/management-platform.jar | |||
| if [ $? -ne 0 ]; then | |||
| echo "复制jar包失败,请检查代码!" | |||
| exit 1 | |||
| if [ "$param" == "manage-front" ] || [ "$param" == "manage" ]; then | |||
| cp -rf ${baseDir}/ruoyi-modules/management-platform/target/management-platform.jar ${baseDir}/k8s/dockerfiles/jar/management-platform.jar | |||
| if [ $? -ne 0 ]; then | |||
| echo "复制jar包失败,请检查代码!" | |||
| exit 1 | |||
| fi | |||
| fi | |||
| if [ "$param" == "gateway" ]; then | |||
| cp -rf ${baseDir}/ruoyi-gateway/target/ruoyi-gateway.jar ${baseDir}/k8s/dockerfiles/jar/ruoyi-gateway.jar | |||
| if [ $? -ne 0 ]; then | |||
| echo "复制jar包失败,请检查代码!" | |||
| exit 1 | |||
| fi | |||
| fi | |||
| if [ "$param" == "auth" ]; then | |||
| cp -rf ${baseDir}/ruoyi-auth/target/ruoyi-auth.jar ${baseDir}/k8s/dockerfiles/jar/ruoyi-auth.jar | |||
| if [ $? -ne 0 ]; then | |||
| echo "复制jar包失败,请检查代码!" | |||
| exit 1 | |||
| fi | |||
| fi | |||
| if [ "$param" == "system" ]; then | |||
| cp -rf ${baseDir}/ruoyi-modules/ruoyi-system/target/ruoyi-modules-system.jar ${baseDir}/k8s/dockerfiles/jar/ruoyi-modules-system.jar | |||
| if [ $? -ne 0 ]; then | |||
| echo "复制jar包失败,请检查代码!" | |||
| exit 1 | |||
| fi | |||
| fi | |||
| if [ "$param" == "all" ]; then | |||
| cp -rf ${baseDir}/ruoyi-modules/management-platform/target/management-platform.jar ${baseDir}/k8s/dockerfiles/jar/management-platform.jar | |||
| if [ $? -ne 0 ]; then | |||
| echo "复制jar包失败,请检查代码!" | |||
| exit 1 | |||
| fi | |||
| cp -rf ${baseDir}/ruoyi-modules/ruoyi-system/target/ruoyi-modules-system.jar ${baseDir}/k8s/dockerfiles/jar/ruoyi-modules-system.jar | |||
| if [ $? -ne 0 ]; then | |||
| echo "复制jar包失败,请检查代码!" | |||
| @@ -19,7 +19,7 @@ show_help() { | |||
| echo | |||
| echo "Options:" | |||
| echo " -b Branch to deploy, default: master" | |||
| echo " -s Service to deploy (manage-front, manage, front, all, default: manage-front)" | |||
| echo " -s Service to deploy (manage-front, manage, front, all, system default: manage-front)" | |||
| echo " -e Environment (e.g., dev, test, default: dev)" | |||
| echo " -h Show this help message" | |||
| } | |||
| @@ -61,7 +61,7 @@ if [[ ! " ${valid_services[@]} " =~ " $service " ]]; then | |||
| exit 1 | |||
| fi | |||
| valid_envs=("dev" "test") | |||
| valid_envs=("dev" "test" "test1") | |||
| if [[ ! " ${valid_envs[@]} " =~ " $env " ]]; then | |||
| echo "Invalid environment: $env" >&2 | |||
| echo "Valid environments are: ${valid_envs[*]}" | |||
| @@ -10,7 +10,7 @@ show_help() { | |||
| echo "Usage: $0 [-s service] [-e environment]" | |||
| echo | |||
| echo "Options:" | |||
| echo " -s Service to deploy (manage-front, manage, front, all default: manage-front)" | |||
| echo " -s Service to deploy (manage-front, manage, front, all, system default: manage-front)" | |||
| echo " -e Environment (e.g., dev, test, default: dev)" | |||
| echo " -h Show this help message" | |||
| } | |||
| @@ -34,7 +34,7 @@ if [[ ! " ${valid_services[@]} " =~ " $service " ]]; then | |||
| exit 1 | |||
| fi | |||
| valid_envs=("dev" "test") | |||
| valid_envs=("dev" "test" "test1") | |||
| if [[ ! " ${valid_envs[@]} " =~ " $env " ]]; then | |||
| echo "Invalid environment: $env" >&2 | |||
| echo "Valid environments are: ${valid_envs[*]}" | |||
| @@ -43,9 +43,11 @@ fi | |||
| # 根据环境设置 IP 地址 | |||
| if [ "$env" == "dev" ]; then | |||
| remote_ip="172.20.32.181" | |||
| remote_ip="172.20.32.197" | |||
| elif [ "$env" == "test" ]; then | |||
| remote_ip="172.20.32.185" | |||
| elif [ "$env" == "test1" ]; then | |||
| remote_ip="172.20.32.235" | |||
| else | |||
| echo "Invalid environment - $env" | |||
| exit 1 | |||
| @@ -29,11 +29,25 @@ http { | |||
| location /label-studio/ { | |||
| # rewrite ^/label-studio/(.*)$ /$1 break; | |||
| proxy_pass http://label-studio-service.argo.svc:8080/projects/; | |||
| proxy_pass http://label-studio-service.argo.svc:9000/projects/; | |||
| proxy_hide_header X-Frame-Options; | |||
| add_header X-Frame-Options ALLOWALL; | |||
| } | |||
| location /minio/ { | |||
| # rewrite ^/label-studio/(.*)$ /$1 break; | |||
| proxy_pass http://juicefs-s3-gateway.juicefs.svc:9000/; | |||
| proxy_hide_header X-Frame-Options; | |||
| add_header X-Frame-Options ALLOWALL; | |||
| } | |||
| location /neo4j/ { | |||
| # rewrite ^/label-studio/(.*)$ /$1 break; | |||
| proxy_pass http://172.20.20.88:7474/; | |||
| proxy_hide_header X-Frame-Options; | |||
| add_header X-Frame-Options ALLOWALL; | |||
| } | |||
| location / { | |||
| rewrite ^/prod-api/(.*)$ /$1 break; | |||
| root /home/ruoyi/projects/ruoyi-ui; | |||
| @@ -1,36 +0,0 @@ | |||
| apiVersion: apps/v1 | |||
| kind: Deployment | |||
| metadata: | |||
| name: ci4s-gen-deployment | |||
| namespace: ci4s-test | |||
| spec: | |||
| replicas: 1 | |||
| selector: | |||
| matchLabels: | |||
| app: ci4s-gen | |||
| template: | |||
| metadata: | |||
| labels: | |||
| app: ci4s-gen | |||
| spec: | |||
| containers: | |||
| - name: ci4s-gen | |||
| image: ci4s-gen:v1.0 | |||
| ports: | |||
| - containerPort: 9202 | |||
| --- | |||
| apiVersion: v1 | |||
| kind: Service | |||
| metadata: | |||
| name: ci4s-gen-service | |||
| namespace: ci4s-test | |||
| spec: | |||
| type: NodePort | |||
| ports: | |||
| - port: 9202 | |||
| nodePort: 31211 | |||
| protocol: TCP | |||
| selector: | |||
| app: ci4s-gen | |||
| @@ -1,36 +0,0 @@ | |||
| apiVersion: apps/v1 | |||
| kind: Deployment | |||
| metadata: | |||
| name: ci4s-visual-deployment | |||
| namespace: ci4s-test | |||
| spec: | |||
| replicas: 1 | |||
| selector: | |||
| matchLabels: | |||
| app: ci4s-visual | |||
| template: | |||
| metadata: | |||
| labels: | |||
| app: ci4s-visual | |||
| spec: | |||
| containers: | |||
| - name: ci4s-visual | |||
| image: ci4s-visual:v1.0 | |||
| ports: | |||
| - containerPort: 9100 | |||
| --- | |||
| apiVersion: v1 | |||
| kind: Service | |||
| metadata: | |||
| name: ci4s-visual-service | |||
| namespace: ci4s-test | |||
| spec: | |||
| type: NodePort | |||
| ports: | |||
| - port: 9100 | |||
| nodePort: 31212 | |||
| protocol: TCP | |||
| selector: | |||
| app: ci4s-visual | |||
| @@ -1,36 +0,0 @@ | |||
| apiVersion: apps/v1 | |||
| kind: Deployment | |||
| metadata: | |||
| name: ci4s-front-deployment | |||
| namespace: argo | |||
| spec: | |||
| replicas: 1 | |||
| selector: | |||
| matchLabels: | |||
| app: ci4s-front | |||
| template: | |||
| metadata: | |||
| labels: | |||
| app: ci4s-front | |||
| spec: | |||
| containers: | |||
| - name: ci4s-front | |||
| image: 172.20.32.187/ci4s/ci4s-front:20240401 | |||
| ports: | |||
| - containerPort: 8000 | |||
| --- | |||
| apiVersion: v1 | |||
| kind: Service | |||
| metadata: | |||
| name: ci4s-front-service | |||
| namespace: argo | |||
| spec: | |||
| type: NodePort | |||
| ports: | |||
| - port: 8000 | |||
| nodePort: 31213 | |||
| protocol: TCP | |||
| selector: | |||
| app: ci4s-front | |||
| @@ -1,62 +0,0 @@ | |||
| apiVersion: apps/v1 | |||
| kind: Deployment | |||
| metadata: | |||
| namespace: argo | |||
| name: nacos-ci4s | |||
| labels: | |||
| app: nacos-ci4s | |||
| spec: | |||
| replicas: 1 | |||
| selector: | |||
| matchLabels: | |||
| app: nacos-ci4s | |||
| template: | |||
| metadata: | |||
| labels: | |||
| app: nacos-ci4s | |||
| spec: | |||
| containers: | |||
| - name: nacos-ci4s | |||
| image: nacos/nacos-server:v2.2.0 | |||
| env: | |||
| - name: SPRING_DATASOURCE_PLATFORM | |||
| value: mysql | |||
| - name: MODE | |||
| value: standalone | |||
| - name: MYSQL_SERVICE_HOST | |||
| value: mysql.argo.svc | |||
| - name: MYSQL_SERVICE_PORT | |||
| value: "3306" | |||
| - name: MYSQL_SERVICE_DB_NAME | |||
| value: nacos-ci4s-config | |||
| - name: MYSQL_SERVICE_USER | |||
| value: root | |||
| - name: MYSQL_SERVICE_PASSWORD | |||
| value: qazxc123456. | |||
| ports: | |||
| - containerPort: 8848 | |||
| - containerPort: 9848 | |||
| restartPolicy: Always | |||
| --- | |||
| apiVersion: v1 | |||
| kind: Service | |||
| metadata: | |||
| namespace: argo | |||
| name: nacos-ci4s | |||
| labels: | |||
| app: nacos-ci4s | |||
| spec: | |||
| type: NodePort | |||
| selector: | |||
| app: nacos-ci4s | |||
| ports: | |||
| - port: 8848 | |||
| targetPort: 8848 | |||
| nodePort: 31203 | |||
| name: web | |||
| - port: 9848 | |||
| targetPort: 9848 | |||
| nodePort: 31204 | |||
| name: podsa | |||
| @@ -1,36 +0,0 @@ | |||
| apiVersion: apps/v1 | |||
| kind: Deployment | |||
| metadata: | |||
| name: ci4s-gateway-deployment | |||
| namespace: argo | |||
| spec: | |||
| replicas: 1 | |||
| selector: | |||
| matchLabels: | |||
| app: ci4s-gateway | |||
| template: | |||
| metadata: | |||
| labels: | |||
| app: ci4s-gateway | |||
| spec: | |||
| containers: | |||
| - name: ci4s-gateway | |||
| image: 172.20.32.187/ci4s/ci4s-gateway:20240401 | |||
| ports: | |||
| - containerPort: 8082 | |||
| --- | |||
| apiVersion: v1 | |||
| kind: Service | |||
| metadata: | |||
| name: ci4s-gateway-service | |||
| namespace: argo | |||
| spec: | |||
| type: NodePort | |||
| ports: | |||
| - port: 8082 | |||
| nodePort: 31205 | |||
| protocol: TCP | |||
| selector: | |||
| app: ci4s-gateway | |||
| @@ -1,36 +0,0 @@ | |||
| apiVersion: apps/v1 | |||
| kind: Deployment | |||
| metadata: | |||
| name: ci4s-auth-deployment | |||
| namespace: argo | |||
| spec: | |||
| replicas: 1 | |||
| selector: | |||
| matchLabels: | |||
| app: ci4s-auth | |||
| template: | |||
| metadata: | |||
| labels: | |||
| app: ci4s-auth | |||
| spec: | |||
| containers: | |||
| - name: ci4s-auth | |||
| image: 172.20.32.187/ci4s/ci4s-auth:20240401 | |||
| ports: | |||
| - containerPort: 9200 | |||
| --- | |||
| apiVersion: v1 | |||
| kind: Service | |||
| metadata: | |||
| name: ci4s-auth-service | |||
| namespace: argo | |||
| spec: | |||
| type: NodePort | |||
| ports: | |||
| - port: 9200 | |||
| nodePort: 31206 | |||
| protocol: TCP | |||
| selector: | |||
| app: ci4s-auth | |||
| @@ -1,36 +0,0 @@ | |||
| apiVersion: apps/v1 | |||
| kind: Deployment | |||
| metadata: | |||
| name: ci4s-system-deployment | |||
| namespace: argo | |||
| spec: | |||
| replicas: 1 | |||
| selector: | |||
| matchLabels: | |||
| app: ci4s-system | |||
| template: | |||
| metadata: | |||
| labels: | |||
| app: ci4s-system | |||
| spec: | |||
| containers: | |||
| - name: ci4s-system | |||
| image: 172.20.32.187/ci4s/ci4s-system:20240401 | |||
| ports: | |||
| - containerPort: 9201 | |||
| --- | |||
| apiVersion: v1 | |||
| kind: Service | |||
| metadata: | |||
| name: ci4s-system-service | |||
| namespace: argo | |||
| spec: | |||
| type: NodePort | |||
| ports: | |||
| - port: 9201 | |||
| nodePort: 31207 | |||
| protocol: TCP | |||
| selector: | |||
| app: ci4s-system | |||
| @@ -1,44 +0,0 @@ | |||
| apiVersion: apps/v1 | |||
| kind: Deployment | |||
| metadata: | |||
| name: ci4s-management-platform-deployment | |||
| namespace: argo | |||
| spec: | |||
| replicas: 1 | |||
| selector: | |||
| matchLabels: | |||
| app: ci4s-management-platform | |||
| template: | |||
| metadata: | |||
| labels: | |||
| app: ci4s-management-platform | |||
| spec: | |||
| containers: | |||
| - name: ci4s-management-platform | |||
| image: 172.20.32.187/ci4s/managent:20240401 | |||
| ports: | |||
| - containerPort: 9213 | |||
| volumeMounts: | |||
| - name: resource | |||
| mountPath: /home/resource/ | |||
| volumes: | |||
| - name: resource | |||
| hostPath: | |||
| path: /home/resource/ | |||
| type: DirectoryOrCreate | |||
| --- | |||
| apiVersion: v1 | |||
| kind: Service | |||
| metadata: | |||
| name: ci4s-management-platform-service | |||
| namespace: argo | |||
| spec: | |||
| type: NodePort | |||
| ports: | |||
| - port: 9213 | |||
| nodePort: 31208 | |||
| protocol: TCP | |||
| selector: | |||
| app: ci4s-management-platform | |||
| @@ -1,36 +0,0 @@ | |||
| apiVersion: apps/v1 | |||
| kind: Deployment | |||
| metadata: | |||
| name: ci4s-file-deployment | |||
| namespace: ci4s-test | |||
| spec: | |||
| replicas: 1 | |||
| selector: | |||
| matchLabels: | |||
| app: ci4s-file | |||
| template: | |||
| metadata: | |||
| labels: | |||
| app: ci4s-file | |||
| spec: | |||
| containers: | |||
| - name: ci4s-file | |||
| image: ci4s-file:v1.0 | |||
| ports: | |||
| - containerPort: 9300 | |||
| --- | |||
| apiVersion: v1 | |||
| kind: Service | |||
| metadata: | |||
| name: ci4s-file-service | |||
| namespace: ci4s-test | |||
| spec: | |||
| type: NodePort | |||
| ports: | |||
| - port: 9300 | |||
| nodePort: 31209 | |||
| protocol: TCP | |||
| selector: | |||
| app: ci4s-file | |||
| @@ -1,36 +0,0 @@ | |||
| apiVersion: apps/v1 | |||
| kind: Deployment | |||
| metadata: | |||
| name: ci4s-job-deployment | |||
| namespace: ci4s-test | |||
| spec: | |||
| replicas: 1 | |||
| selector: | |||
| matchLabels: | |||
| app: ci4s-job | |||
| template: | |||
| metadata: | |||
| labels: | |||
| app: ci4s-job | |||
| spec: | |||
| containers: | |||
| - name: ci4s-job | |||
| image: ci4s-job:v1.0 | |||
| ports: | |||
| - containerPort: 9203 | |||
| --- | |||
| apiVersion: v1 | |||
| kind: Service | |||
| metadata: | |||
| name: ci4s-job-service | |||
| namespace: ci4s-test | |||
| spec: | |||
| type: NodePort | |||
| ports: | |||
| - port: 9203 | |||
| nodePort: 31210 | |||
| protocol: TCP | |||
| selector: | |||
| app: ci4s-job | |||
| @@ -1,36 +0,0 @@ | |||
| apiVersion: apps/v1 | |||
| kind: Deployment | |||
| metadata: | |||
| name: ci4s-front-deployment | |||
| namespace: argo | |||
| spec: | |||
| replicas: 1 | |||
| selector: | |||
| matchLabels: | |||
| app: ci4s-front | |||
| template: | |||
| metadata: | |||
| labels: | |||
| app: ci4s-front | |||
| spec: | |||
| containers: | |||
| - name: ci4s-front | |||
| image: 172.20.32.187/ci4s/ci4s-front:202406120836 | |||
| ports: | |||
| - containerPort: 8000 | |||
| --- | |||
| apiVersion: v1 | |||
| kind: Service | |||
| metadata: | |||
| name: ci4s-front-service | |||
| namespace: argo | |||
| spec: | |||
| type: NodePort | |||
| ports: | |||
| - port: 8000 | |||
| nodePort: 31213 | |||
| protocol: TCP | |||
| selector: | |||
| app: ci4s-front | |||
| @@ -1,53 +0,0 @@ | |||
| apiVersion: apps/v1 | |||
| kind: Deployment | |||
| metadata: | |||
| name: ci4s-management-platform-deployment | |||
| namespace: argo | |||
| spec: | |||
| replicas: 1 | |||
| selector: | |||
| matchLabels: | |||
| app: ci4s-management-platform | |||
| template: | |||
| metadata: | |||
| labels: | |||
| app: ci4s-management-platform | |||
| spec: | |||
| containers: | |||
| - name: ci4s-management-platform | |||
| image: 172.20.32.187/ci4s/ci4s-managent:202409201355 | |||
| env: | |||
| - name: TZ | |||
| value: Asia/Shanghai | |||
| - name: JAVA_TOOL_OPTIONS | |||
| value: "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=*:5005" | |||
| ports: | |||
| - containerPort: 9213 | |||
| volumeMounts: | |||
| - name: resource-volume | |||
| mountPath: /home/resource/ | |||
| volumes: | |||
| - name: resource-volume | |||
| persistentVolumeClaim: | |||
| claimName: platform-data-pvc-nfs | |||
| --- | |||
| apiVersion: v1 | |||
| kind: Service | |||
| metadata: | |||
| name: ci4s-management-platform-service | |||
| namespace: argo | |||
| spec: | |||
| type: NodePort | |||
| ports: | |||
| - name: http | |||
| port: 9213 | |||
| nodePort: 31208 | |||
| protocol: TCP | |||
| - name: debug | |||
| nodePort: 34567 | |||
| port: 5005 | |||
| protocol: TCP | |||
| targetPort: 5005 | |||
| selector: | |||
| app: ci4s-management-platform | |||
| @@ -0,0 +1,43 @@ | |||
| apiVersion: apps/v1 | |||
| kind: Deployment | |||
| metadata: | |||
| name: ci4s-oauth2-authenticator-deployment | |||
| namespace: argo | |||
| spec: | |||
| replicas: 1 | |||
| selector: | |||
| matchLabels: | |||
| app: ci4s-oauth2-authenticator | |||
| template: | |||
| metadata: | |||
| labels: | |||
| app: ci4s-oauth2-authenticator | |||
| spec: | |||
| containers: | |||
| - name: ci4s-oauth2-authenticator | |||
| image: 172.20.32.187/ci4s/spring-oauth2-authenticator:latest | |||
| env: | |||
| - name: DB_URL | |||
| value: mysql.argo.svc:3306 | |||
| - name: DB_USERNAME | |||
| value: root | |||
| - name: DB_PASSWORD | |||
| value: qazxc123456. | |||
| ports: | |||
| - containerPort: 8080 | |||
| --- | |||
| apiVersion: v1 | |||
| kind: Service | |||
| metadata: | |||
| name: ci4s-oauth2-authenticator-service | |||
| namespace: argo | |||
| spec: | |||
| type: NodePort | |||
| ports: | |||
| - name: http | |||
| port: 8080 | |||
| nodePort: 31080 | |||
| protocol: TCP | |||
| selector: | |||
| app: ci4s-oauth2-authenticator | |||
| @@ -17,7 +17,7 @@ spec: | |||
| spec: | |||
| containers: | |||
| - name: nacos-ci4s | |||
| image: nacos/nacos-server:v2.2.0 | |||
| image: 172.20.32.187/ci4s/nacos-server:v2.2.0 | |||
| env: | |||
| - name: SPRING_DATASOURCE_PLATFORM | |||
| value: mysql | |||
| @@ -38,8 +38,8 @@ spec: | |||
| - containerPort: 9848 | |||
| - containerPort: 9849 | |||
| initContainers: | |||
| - name: init-mydb | |||
| image: busybox:1.31 | |||
| - name: init-mydb-check | |||
| image: 172.20.32.187/ci4s/busybox:1.31 | |||
| command: [ 'sh', '-c', 'nc -zv mysql.argo.svc 3306' ] | |||
| restartPolicy: Always | |||
| @@ -18,7 +18,11 @@ spec: | |||
| image: ${k8s-6system-image} | |||
| ports: | |||
| - containerPort: 9201 | |||
| env: | |||
| - name: TZ | |||
| value: Asia/Shanghai | |||
| - name: JAVA_TOOL_OPTIONS | |||
| value: "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=*:5005" | |||
| --- | |||
| apiVersion: v1 | |||
| kind: Service | |||
| @@ -28,9 +32,15 @@ metadata: | |||
| spec: | |||
| type: NodePort | |||
| ports: | |||
| - port: 9201 | |||
| - name: http | |||
| port: 9201 | |||
| nodePort: 31207 | |||
| protocol: TCP | |||
| - name: debug | |||
| nodePort: 31220 | |||
| port: 5005 | |||
| protocol: TCP | |||
| targetPort: 5005 | |||
| selector: | |||
| app: ci4s-system | |||
| @@ -16,6 +16,8 @@ spec: | |||
| containers: | |||
| - name: ci4s-management-platform | |||
| image: ${k8s-7management-image} | |||
| securityContext: | |||
| privileged: true | |||
| env: | |||
| - name: TZ | |||
| value: Asia/Shanghai | |||
| @@ -27,10 +29,30 @@ spec: | |||
| - name: resource-volume | |||
| mountPath: /home/resource/ | |||
| subPath: mini-model-platform-data | |||
| mountPropagation: Bidirectional | |||
| volumes: | |||
| - name: resource-volume | |||
| hostPath: | |||
| path: /platform-data | |||
| initContainers: | |||
| - name: init-fs-check | |||
| image: 172.20.32.187/ci4s/ci4s-managent:202502141722 | |||
| securityContext: | |||
| privileged: true | |||
| volumeMounts: | |||
| - name: resource-volume | |||
| mountPath: /home/resource/ | |||
| subPath: mini-model-platform-data | |||
| mountPropagation: Bidirectional | |||
| command: [ "/bin/sh", "-c" ] | |||
| args: | |||
| - | | |||
| mounted=$(findmnt /home/resource/ | grep 'fuse.juicefs') | |||
| if [ -z "$mounted" ]; then | |||
| echo "/platform-data not mounted"; | |||
| exit 1 | |||
| fi | |||
| restartPolicy: Always | |||
| --- | |||
| apiVersion: v1 | |||
| kind: Service | |||
| @@ -0,0 +1,68 @@ | |||
| apiVersion: rbac.authorization.k8s.io/v1 | |||
| kind: Role | |||
| metadata: | |||
| name: custom-workflow | |||
| namespace: argo | |||
| rules: | |||
| - apiGroups: | |||
| - argoproj.io | |||
| resources: | |||
| - workflows | |||
| verbs: | |||
| - create | |||
| - get | |||
| - list | |||
| - watch | |||
| - update | |||
| - patch | |||
| - delete | |||
| - apiGroups: | |||
| - "" | |||
| resources: | |||
| - pods | |||
| - services | |||
| verbs: | |||
| - get | |||
| - list | |||
| - watch | |||
| - create | |||
| - update | |||
| - patch | |||
| - delete | |||
| - apiGroups: | |||
| - "" | |||
| resources: | |||
| - pods/exec | |||
| verbs: | |||
| - create | |||
| - get | |||
| - list | |||
| - watch | |||
| - update | |||
| - patch | |||
| - delete | |||
| - apiGroups: | |||
| - "apps" | |||
| resources: | |||
| - deployments | |||
| verbs: | |||
| - get | |||
| - list | |||
| - watch | |||
| - create | |||
| - update | |||
| - patch | |||
| - delete | |||
| --- | |||
| apiVersion: rbac.authorization.k8s.io/v1 | |||
| kind: RoleBinding | |||
| metadata: | |||
| name: custom-workflow-default | |||
| roleRef: | |||
| apiGroup: rbac.authorization.k8s.io | |||
| kind: Role | |||
| name: custom-workflow | |||
| subjects: | |||
| - kind: ServiceAccount | |||
| name: default | |||
| @@ -22,7 +22,13 @@ | |||
| <groupId>com.ruoyi</groupId> | |||
| <artifactId>ruoyi-common-core</artifactId> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.alibaba</groupId> | |||
| <artifactId>easyexcel-core</artifactId> | |||
| <version>3.3.2</version> | |||
| <scope>compile</scope> | |||
| </dependency> | |||
| </dependencies> | |||
| </project> | |||
| @@ -0,0 +1,21 @@ | |||
| package com.ruoyi.system.api; | |||
| import com.ruoyi.common.core.constant.ServiceNameConstants; | |||
| import com.ruoyi.common.core.web.domain.AjaxResult; | |||
| import com.ruoyi.system.api.domain.SysUser; | |||
| import com.ruoyi.system.api.factory.RemoteAuthFallbackFactory; | |||
| import org.springframework.cloud.openfeign.FeignClient; | |||
| import org.springframework.validation.annotation.Validated; | |||
| import org.springframework.web.bind.annotation.PostMapping; | |||
| import org.springframework.web.bind.annotation.PutMapping; | |||
| import org.springframework.web.bind.annotation.RequestBody; | |||
| @FeignClient(contextId = "remoteAuthService", value = ServiceNameConstants.AUTH_SERVICE, fallbackFactory = RemoteAuthFallbackFactory.class) | |||
| public interface RemoteAuthService { | |||
| @PostMapping("/oauth2") | |||
| public AjaxResult add(@Validated @RequestBody SysUser user); | |||
| @PutMapping("/oauth2") | |||
| public AjaxResult edit(@Validated @RequestBody SysUser user); | |||
| } | |||
| @@ -0,0 +1,30 @@ | |||
| package com.ruoyi.system.api; | |||
| import com.ruoyi.common.core.constant.ServiceNameConstants; | |||
| import com.ruoyi.common.core.web.domain.GenericsAjaxResult; | |||
| import com.ruoyi.system.api.domain.SysUser; | |||
| import com.ruoyi.system.api.factory.RemoteMmpFallbackFactory; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.springframework.cloud.openfeign.FeignClient; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @FeignClient(contextId = "remoteMmpService", value = ServiceNameConstants.MANAGEMENT_SERVICE, fallbackFactory = RemoteMmpFallbackFactory.class) | |||
| public interface RemoteMmpService { | |||
| @GetMapping("/gitLink/login") | |||
| public GenericsAjaxResult<String> gitLinkLogin(@RequestParam("username") String username, @RequestParam("password") String password); | |||
| @PostMapping("/gitLink/createGitLinkUser") | |||
| public GenericsAjaxResult<String> createGitLinkUser(@RequestBody SysUser sysUser) throws Exception; | |||
| @PostMapping("/gitLink/resetPwd") | |||
| public GenericsAjaxResult<String> resetPwd(@RequestBody SysUser sysUser) throws Exception; | |||
| @PutMapping("/gitLink/resetEmail") | |||
| public GenericsAjaxResult<String> resetEmail(@RequestBody SysUser sysUser) throws Exception; | |||
| @PutMapping("/gitLink/resetPhoneNum") | |||
| public GenericsAjaxResult<String> resetPhoneNum(@RequestBody SysUser sysUser) throws Exception; | |||
| @DeleteMapping("/gitLink/deleteGitLinkUser") | |||
| public GenericsAjaxResult<String> deleteGitLinkUser(@RequestBody SysUser sysUser) throws Exception; | |||
| } | |||
| @@ -1,11 +1,7 @@ | |||
| package com.ruoyi.system.api; | |||
| import org.springframework.cloud.openfeign.FeignClient; | |||
| import org.springframework.web.bind.annotation.GetMapping; | |||
| import org.springframework.web.bind.annotation.PathVariable; | |||
| import org.springframework.web.bind.annotation.PostMapping; | |||
| import org.springframework.web.bind.annotation.RequestBody; | |||
| import org.springframework.web.bind.annotation.RequestHeader; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import com.ruoyi.common.core.constant.SecurityConstants; | |||
| import com.ruoyi.common.core.constant.ServiceNameConstants; | |||
| import com.ruoyi.common.core.domain.R; | |||
| @@ -0,0 +1,77 @@ | |||
| package com.ruoyi.system.api.constant; | |||
| public class Constant { | |||
| public final static int Image_Type_Pub = 1; // 公共镜像 | |||
| public final static int Image_Type_Pri = 0; // 私有镜像 | |||
| public final static int Code_Repo_Pub = 1; // 代码仓库可见性-公开 | |||
| public final static int Code_Repo_Pri = 0; // 代码仓库可见性-私有 | |||
| public final static int State_valid = 1; // 有效 | |||
| public final static int State_invalid = 0; // 无效 | |||
| public final static int State_building = 2; //创建中 | |||
| public final static int State_failed = 3; //运行失败 | |||
| public final static int Used_State_used = 1; // 已占用 | |||
| public final static int Used_State_unused = 0; // 未占用 | |||
| public final static String Computing_Resource_CPU = "CPU"; // 计算资源_CPU | |||
| public final static String Computing_Resource_GPU = "GPU"; // 计算资源_GPU | |||
| public final static int Git_Category_Id = 39; | |||
| public final static String Topic_Dataset = "dataset"; | |||
| public final static String Topic_model = "model"; | |||
| public final static String Item_Public = "public"; | |||
| public final static String Source_Auto_Export = "auto_export"; | |||
| public final static String Source_Hand_Export = "hand_export"; | |||
| public final static String Source_Add = "add"; | |||
| public final static String Building = "building"; | |||
| public final static String Running = "Running"; | |||
| public final static String Failed = "Failed"; | |||
| public final static String Pending = "Pending"; | |||
| public final static String Terminated = "Terminated"; | |||
| public final static String Init = "Init"; | |||
| public final static String Stopped = "Stopped"; | |||
| public final static String Succeeded = "Succeeded"; | |||
| public final static String Error = "Error"; | |||
| public final static String Unknown = "Unknown"; | |||
| public final static String Available = "available"; | |||
| public final static String Type_Train = "train"; | |||
| public final static String Type_Evaluate = "evaluate"; | |||
| public final static String AutoMl_Classification = "classification"; | |||
| public final static String Asset_Type_Dataset = "dataset"; | |||
| public final static String Asset_Type_Model = "model"; | |||
| public final static String Asset_Type_Image = "image"; | |||
| public final static String Asset_Type_Code = "code"; | |||
| public final static String Asset_Type_Service = "service"; | |||
| // 任务类型 | |||
| public final static String TaskType_Dev = "dev_environment"; | |||
| public final static String TaskType_Workflow = "workflow"; | |||
| public final static String TaskType_Ray = "ray"; | |||
| public final static String TaskType_ActiveLearn = "active_learn"; | |||
| public final static String TaskType_Service = "service"; | |||
| public final static String TaskType_ML = "machine_learn"; | |||
| public final static String TaskType_TextClassification = "text_classification"; | |||
| public final static String ML_CSV = "auto_ml"; | |||
| public final static String ML_TextClassification = "text_classification"; | |||
| public final static String ML_VideoClassification = "video_classification"; | |||
| public final static String DelFlag = "2"; | |||
| public final static String Code = "123123"; | |||
| public final static String Sex_Men = "0"; | |||
| } | |||
| @@ -1,11 +1,13 @@ | |||
| package com.ruoyi.system.api.domain; | |||
| import com.ruoyi.common.core.annotation.Excel; | |||
| import com.ruoyi.common.core.annotation.Excel.ColumnType; | |||
| import com.ruoyi.common.core.annotation.Excel.Type; | |||
| import com.ruoyi.common.core.annotation.Excels; | |||
| import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | |||
| import com.alibaba.excel.annotation.ExcelProperty; | |||
| import com.alibaba.excel.annotation.write.style.ContentStyle; | |||
| import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum; | |||
| import com.alibaba.excel.enums.poi.VerticalAlignmentEnum; | |||
| import com.ruoyi.common.core.web.domain.BaseEntity; | |||
| import com.ruoyi.common.core.xss.Xss; | |||
| import com.ruoyi.system.api.constant.Constant; | |||
| import org.apache.commons.lang3.builder.ToStringBuilder; | |||
| import org.apache.commons.lang3.builder.ToStringStyle; | |||
| @@ -20,51 +22,56 @@ import java.util.List; | |||
| * | |||
| * @author ruoyi | |||
| */ | |||
| @ExcelIgnoreUnannotated | |||
| @ContentStyle(horizontalAlignment = HorizontalAlignmentEnum.CENTER, | |||
| verticalAlignment = VerticalAlignmentEnum.CENTER) | |||
| public class SysUser extends BaseEntity { | |||
| private static final long serialVersionUID = 1L; | |||
| /** | |||
| * 用户ID | |||
| */ | |||
| @Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号") | |||
| @ExcelProperty(value = "用户序号", order = 1) | |||
| private Long userId; | |||
| /** | |||
| * 部门ID | |||
| */ | |||
| @Excel(name = "部门编号", type = Type.IMPORT) | |||
| @ExcelProperty(value = "部门编号", order = 2) | |||
| private Long deptId; | |||
| /** | |||
| * 用户账号 | |||
| */ | |||
| @Excel(name = "登录名称") | |||
| @ExcelProperty(value = "登录名称", order = 3) | |||
| private String userName; | |||
| /** | |||
| * 用户昵称 | |||
| */ | |||
| @Excel(name = "用户名称") | |||
| @ExcelProperty(value = "用户名称", order = 4) | |||
| private String nickName; | |||
| /** | |||
| * 用户邮箱 | |||
| */ | |||
| @Excel(name = "用户邮箱") | |||
| @ExcelProperty(value = "邮箱", order = 4) | |||
| private String email; | |||
| /** | |||
| * 手机号码 | |||
| */ | |||
| @Excel(name = "手机号码") | |||
| @ExcelProperty(value = "手机号码", order = 5) | |||
| private String phonenumber; | |||
| /** | |||
| * 用户性别 | |||
| */ | |||
| @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知") | |||
| private String sex; | |||
| @ExcelProperty(value = "性别", order = 6) | |||
| private String sexName; | |||
| /** | |||
| * 用户头像 | |||
| */ | |||
| @@ -75,10 +82,11 @@ public class SysUser extends BaseEntity { | |||
| */ | |||
| private String password; | |||
| private String originPassword; | |||
| /** | |||
| * 帐号状态(0正常 1停用) | |||
| */ | |||
| @Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用") | |||
| private String status; | |||
| /** | |||
| @@ -89,22 +97,24 @@ public class SysUser extends BaseEntity { | |||
| /** | |||
| * 最后登录IP | |||
| */ | |||
| @Excel(name = "最后登录IP", type = Type.EXPORT) | |||
| @ExcelProperty(value = "最后登录IP", order = 7) | |||
| private String loginIp; | |||
| /** | |||
| * 最后登录时间 | |||
| */ | |||
| @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT) | |||
| // @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT) | |||
| @ExcelProperty(value = "最后登录时间", order = 8) | |||
| private Date loginDate; | |||
| /** | |||
| * 部门对象 | |||
| */ | |||
| @Excels({ | |||
| @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT), | |||
| @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT) | |||
| }) | |||
| // @Excels({ | |||
| // @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT), | |||
| // @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT) | |||
| // }) | |||
| // @ExcelProperty(value = "部门", order = 4) | |||
| private SysDept dept; | |||
| /** | |||
| @@ -127,9 +137,7 @@ public class SysUser extends BaseEntity { | |||
| */ | |||
| private Long roleId; | |||
| private String gitLinkUsername; | |||
| private String gitLinkPassword; | |||
| private Float credit; | |||
| public SysUser() { | |||
| @@ -211,6 +219,18 @@ public class SysUser extends BaseEntity { | |||
| this.sex = sex; | |||
| } | |||
| public String getSexName() { | |||
| if (Constant.Sex_Men.equals(this.sex)) { | |||
| return "男"; | |||
| } else { | |||
| return "女"; | |||
| } | |||
| } | |||
| public void setSexName(String sexName) { | |||
| this.sexName = sexName; | |||
| } | |||
| public String getAvatar() { | |||
| return avatar; | |||
| } | |||
| @@ -227,6 +247,14 @@ public class SysUser extends BaseEntity { | |||
| this.password = password; | |||
| } | |||
| public String getOriginPassword() { | |||
| return originPassword; | |||
| } | |||
| public void setOriginPassword(String originPassword) { | |||
| this.originPassword = originPassword; | |||
| } | |||
| public String getStatus() { | |||
| return status; | |||
| } | |||
| @@ -299,20 +327,12 @@ public class SysUser extends BaseEntity { | |||
| this.roleId = roleId; | |||
| } | |||
| public void setGitLinkUsername(String gitLinkUsername) { | |||
| this.gitLinkUsername = gitLinkUsername; | |||
| } | |||
| public String getGitLinkUsername() { | |||
| return gitLinkUsername; | |||
| } | |||
| public void setGitLinkPassword(String gitLinkPassword) { | |||
| this.gitLinkPassword = gitLinkPassword; | |||
| public void setCredit(Float credit) { | |||
| this.credit = credit; | |||
| } | |||
| public String getGitLinkPassword() { | |||
| return gitLinkPassword; | |||
| public Float getCredit() { | |||
| return credit; | |||
| } | |||
| @Override | |||
| @@ -327,6 +347,7 @@ public class SysUser extends BaseEntity { | |||
| .append("sex", getSex()) | |||
| .append("avatar", getAvatar()) | |||
| .append("password", getPassword()) | |||
| .append("originPassword", getOriginPassword()) | |||
| .append("status", getStatus()) | |||
| .append("delFlag", getDelFlag()) | |||
| .append("loginIp", getLoginIp()) | |||
| @@ -337,8 +358,7 @@ public class SysUser extends BaseEntity { | |||
| .append("updateTime", getUpdateTime()) | |||
| .append("remark", getRemark()) | |||
| .append("dept", getDept()) | |||
| .append("gitLinkUsername", getGitLinkUsername()) | |||
| .append("gitLinkPassword", getGitLinkPassword()) | |||
| .append("credit", getCredit()) | |||
| .toString(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,30 @@ | |||
| package com.ruoyi.system.api.factory; | |||
| import com.ruoyi.common.core.web.domain.AjaxResult; | |||
| import com.ruoyi.system.api.RemoteAuthService; | |||
| import com.ruoyi.system.api.domain.SysUser; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.cloud.openfeign.FallbackFactory; | |||
| import org.springframework.stereotype.Component; | |||
| @Component | |||
| public class RemoteAuthFallbackFactory implements FallbackFactory<RemoteAuthService> { | |||
| private static final Logger log = LoggerFactory.getLogger(RemoteAuthFallbackFactory.class); | |||
| @Override | |||
| public RemoteAuthService create(Throwable throwable) { | |||
| log.error("Auth服务调用失败:{}", throwable.getMessage()); | |||
| return new RemoteAuthService() { | |||
| @Override | |||
| public AjaxResult add(SysUser user) { | |||
| return AjaxResult.error("新增Oauth2用户失败"); | |||
| } | |||
| @Override | |||
| public AjaxResult edit(SysUser user) { | |||
| return AjaxResult.error("更新Oauth2用户失败"); | |||
| } | |||
| }; | |||
| } | |||
| } | |||
| @@ -0,0 +1,51 @@ | |||
| package com.ruoyi.system.api.factory; | |||
| import com.ruoyi.common.core.web.domain.GenericsAjaxResult; | |||
| import com.ruoyi.system.api.RemoteMmpService; | |||
| import com.ruoyi.system.api.domain.SysUser; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.cloud.openfeign.FallbackFactory; | |||
| import org.springframework.stereotype.Component; | |||
| @Component | |||
| public class RemoteMmpFallbackFactory implements FallbackFactory<RemoteMmpService> { | |||
| private static final Logger log = LoggerFactory.getLogger(RemoteMmpFallbackFactory.class); | |||
| @Override | |||
| public RemoteMmpService create(Throwable throwable) { | |||
| log.error("管理平台服务调用失败:{}", throwable.getMessage()); | |||
| return new RemoteMmpService() { | |||
| @Override | |||
| public GenericsAjaxResult<String> gitLinkLogin(String username, String password) { | |||
| return GenericsAjaxResult.error("刷新gitLink登录信息失败"); | |||
| } | |||
| @Override | |||
| public GenericsAjaxResult<String> createGitLinkUser(SysUser sysUser) throws Exception { | |||
| throw new Exception("新增gitLink用户失败:" + throwable.getMessage()); | |||
| } | |||
| @Override | |||
| public GenericsAjaxResult<String> resetPwd(SysUser sysUser) throws Exception { | |||
| throw new Exception("修改gitLink用户密码失败:" + throwable.getMessage()); | |||
| } | |||
| @Override | |||
| public GenericsAjaxResult<String> resetEmail(SysUser sysUser) throws Exception { | |||
| throw new Exception("修改gitLink用户邮箱失败:" + throwable.getMessage()); | |||
| } | |||
| @Override | |||
| public GenericsAjaxResult<String> resetPhoneNum(SysUser sysUser) throws Exception { | |||
| throw new Exception("修改gitLink用户手机号失败:" + throwable.getMessage()); | |||
| } | |||
| @Override | |||
| public GenericsAjaxResult<String> deleteGitLinkUser(SysUser sysUser) throws Exception { | |||
| throw new Exception("删除gitLink用户失败:" + throwable.getMessage()); | |||
| } | |||
| }; | |||
| } | |||
| } | |||
| @@ -1,3 +1,5 @@ | |||
| com.ruoyi.system.api.factory.RemoteUserFallbackFactory | |||
| com.ruoyi.system.api.factory.RemoteLogFallbackFactory | |||
| com.ruoyi.system.api.factory.RemoteFileFallbackFactory | |||
| com.ruoyi.system.api.factory.RemoteMmpFallbackFactory | |||
| com.ruoyi.system.api.factory.RemoteAuthFallbackFactory | |||
| @@ -51,9 +51,32 @@ | |||
| <groupId>com.ruoyi</groupId> | |||
| <artifactId>ruoyi-common-security</artifactId> | |||
| </dependency> | |||
| <!-- Mysql Connector --> | |||
| <dependency> | |||
| <groupId>com.mysql</groupId> | |||
| <artifactId>mysql-connector-j</artifactId> | |||
| </dependency> | |||
| <!-- RuoYi Common DataSource --> | |||
| <dependency> | |||
| <groupId>com.ruoyi</groupId> | |||
| <artifactId>ruoyi-common-datasource</artifactId> | |||
| </dependency> | |||
| <!-- RuoYi Common DataScope --> | |||
| <dependency> | |||
| <groupId>com.ruoyi</groupId> | |||
| <artifactId>ruoyi-common-datascope</artifactId> | |||
| </dependency> | |||
| <!-- RuoYi Common Log --> | |||
| <dependency> | |||
| <groupId>com.ruoyi</groupId> | |||
| <artifactId>ruoyi-common-log</artifactId> | |||
| </dependency> | |||
| </dependencies> | |||
| <build> | |||
| <finalName>${project.artifactId}</finalName> | |||
| <plugins> | |||
| @@ -1,5 +1,6 @@ | |||
| package com.ruoyi.auth; | |||
| import com.ruoyi.common.security.annotation.EnableCustomConfig; | |||
| import org.springframework.boot.SpringApplication; | |||
| import org.springframework.boot.autoconfigure.SpringBootApplication; | |||
| import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; | |||
| @@ -10,6 +11,7 @@ import com.ruoyi.common.security.annotation.EnableRyFeignClients; | |||
| * | |||
| * @author ruoyi | |||
| */ | |||
| @EnableCustomConfig | |||
| @EnableRyFeignClients | |||
| @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class }) | |||
| public class RuoYiAuthApplication | |||
| @@ -0,0 +1,26 @@ | |||
| package com.ruoyi.auth.controller; | |||
| import com.ruoyi.auth.service.Oauth2Service; | |||
| import com.ruoyi.common.core.web.controller.BaseController; | |||
| import com.ruoyi.common.core.web.domain.AjaxResult; | |||
| import com.ruoyi.system.api.domain.SysUser; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.validation.annotation.Validated; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("/oauth2") | |||
| public class Oauth2Controller extends BaseController { | |||
| @Autowired | |||
| private Oauth2Service oauth2Service; | |||
| @PostMapping | |||
| public AjaxResult add(@Validated @RequestBody SysUser user) { | |||
| return toAjax(oauth2Service.insertOauth2User(user)); | |||
| } | |||
| @PutMapping | |||
| public AjaxResult edit(@Validated @RequestBody SysUser user) { | |||
| return toAjax(oauth2Service.updateOauth2User(user)); | |||
| } | |||
| } | |||
| @@ -0,0 +1,37 @@ | |||
| package com.ruoyi.auth.domain; | |||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | |||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | |||
| import lombok.Data; | |||
| import java.util.Date; | |||
| @Data | |||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | |||
| public class OauthAccount { | |||
| private Long id; | |||
| private String clientId; | |||
| private String username; | |||
| private String password; | |||
| private String mobile; | |||
| private String email; | |||
| private Integer enabled; | |||
| private Integer accountNonExpired; | |||
| private Integer credentialsNonExpired; | |||
| private Integer accountNonLocked; | |||
| private Integer accountNonDeleted; | |||
| private Date createdTime; | |||
| private Date updatedTime; | |||
| } | |||
| @@ -0,0 +1,10 @@ | |||
| package com.ruoyi.auth.mapper; | |||
| import com.ruoyi.auth.domain.OauthAccount; | |||
| import org.apache.ibatis.annotations.Param; | |||
| public interface Oauth2Mapper { | |||
| int insertOauth2User(@Param("oauthAccount")OauthAccount oauthAccount); | |||
| int updateOauth2User(@Param("oauthAccount")OauthAccount oauthAccount); | |||
| } | |||
| @@ -0,0 +1,45 @@ | |||
| package com.ruoyi.auth.service; | |||
| import com.ruoyi.auth.domain.OauthAccount; | |||
| import com.ruoyi.auth.mapper.Oauth2Mapper; | |||
| import com.ruoyi.common.core.utils.StringUtils; | |||
| import com.ruoyi.system.api.constant.Constant; | |||
| import com.ruoyi.system.api.domain.SysUser; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.beans.factory.annotation.Value; | |||
| import org.springframework.stereotype.Component; | |||
| @Component | |||
| public class Oauth2Service { | |||
| @Value("${oauth2.client-id}") | |||
| String clientId; | |||
| @Autowired | |||
| private Oauth2Mapper oauth2Mapper; | |||
| public int insertOauth2User(SysUser user) { | |||
| OauthAccount oauthAccount = new OauthAccount(); | |||
| oauthAccount.setClientId(clientId); | |||
| oauthAccount.setUsername(user.getUserName()); | |||
| oauthAccount.setPassword(user.getPassword()); | |||
| oauthAccount.setMobile(user.getPhonenumber()); | |||
| oauthAccount.setEmail(user.getEmail()); | |||
| oauthAccount.setEnabled(Constant.State_valid); | |||
| return oauth2Mapper.insertOauth2User(oauthAccount); | |||
| } | |||
| public int updateOauth2User(SysUser user) { | |||
| OauthAccount oauthAccount = new OauthAccount(); | |||
| oauthAccount.setClientId(clientId); | |||
| oauthAccount.setUsername(user.getUserName()); | |||
| if (StringUtils.isNotEmpty(user.getPassword())) { | |||
| oauthAccount.setPassword(user.getPassword()); | |||
| } | |||
| oauthAccount.setMobile(user.getPhonenumber()); | |||
| oauthAccount.setEmail(user.getEmail()); | |||
| if (Constant.DelFlag.equals(user.getDelFlag())) { | |||
| oauthAccount.setEnabled(Constant.State_invalid); | |||
| } | |||
| return oauth2Mapper.updateOauth2User(oauthAccount); | |||
| } | |||
| } | |||
| @@ -1,8 +1,6 @@ | |||
| package com.ruoyi.auth.service; | |||
| import com.ruoyi.auth.form.AccessTokenVo; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Component; | |||
| import com.ruoyi.common.core.constant.CacheConstants; | |||
| import com.ruoyi.common.core.constant.Constants; | |||
| import com.ruoyi.common.core.constant.SecurityConstants; | |||
| @@ -15,18 +13,20 @@ import com.ruoyi.common.core.utils.StringUtils; | |||
| import com.ruoyi.common.core.utils.ip.IpUtils; | |||
| import com.ruoyi.common.redis.service.RedisService; | |||
| import com.ruoyi.common.security.utils.SecurityUtils; | |||
| import com.ruoyi.system.api.RemoteMmpService; | |||
| import com.ruoyi.system.api.RemoteUserService; | |||
| import com.ruoyi.system.api.domain.SysUser; | |||
| import com.ruoyi.system.api.model.LoginUser; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Component; | |||
| /** | |||
| * 登录校验方法 | |||
| * | |||
| * | |||
| * @author ruoyi | |||
| */ | |||
| @Component | |||
| public class SysLoginService | |||
| { | |||
| public class SysLoginService { | |||
| @Autowired | |||
| private RemoteUserService remoteUserService; | |||
| @@ -39,92 +39,82 @@ public class SysLoginService | |||
| @Autowired | |||
| private RedisService redisService; | |||
| @Autowired | |||
| private RemoteMmpService remoteMmpService; | |||
| /** | |||
| * 登录 | |||
| */ | |||
| public LoginUser login(String username, String password) | |||
| { | |||
| public LoginUser login(String username, String password) { | |||
| // 用户名或密码为空 错误 | |||
| if (StringUtils.isAnyBlank(username, password)) | |||
| { | |||
| if (StringUtils.isAnyBlank(username, password)) { | |||
| recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写"); | |||
| throw new ServiceException("用户/密码必须填写"); | |||
| } | |||
| // 密码如果不在指定范围内 错误 | |||
| if (password.length() < UserConstants.PASSWORD_MIN_LENGTH | |||
| || password.length() > UserConstants.PASSWORD_MAX_LENGTH) | |||
| { | |||
| || password.length() > UserConstants.PASSWORD_MAX_LENGTH) { | |||
| recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户密码不在指定范围"); | |||
| throw new ServiceException("用户密码不在指定范围"); | |||
| } | |||
| // 用户名不在指定范围内 错误 | |||
| if (username.length() < UserConstants.USERNAME_MIN_LENGTH | |||
| || username.length() > UserConstants.USERNAME_MAX_LENGTH) | |||
| { | |||
| || username.length() > UserConstants.USERNAME_MAX_LENGTH) { | |||
| recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户名不在指定范围"); | |||
| throw new ServiceException("用户名不在指定范围"); | |||
| } | |||
| // IP黑名单校验 | |||
| String blackStr = Convert.toStr(redisService.getCacheObject(CacheConstants.SYS_LOGIN_BLACKIPLIST)); | |||
| if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr())) | |||
| { | |||
| if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr())) { | |||
| recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "很遗憾,访问IP已被列入系统黑名单"); | |||
| throw new ServiceException("很遗憾,访问IP已被列入系统黑名单"); | |||
| } | |||
| // 查询用户信息 | |||
| R<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER); | |||
| if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) | |||
| { | |||
| if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) { | |||
| recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在"); | |||
| throw new ServiceException("登录用户:" + username + " 不存在"); | |||
| } | |||
| if (R.FAIL == userResult.getCode()) | |||
| { | |||
| if (R.FAIL == userResult.getCode()) { | |||
| throw new ServiceException(userResult.getMsg()); | |||
| } | |||
| LoginUser userInfo = userResult.getData(); | |||
| SysUser user = userResult.getData().getSysUser(); | |||
| if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) | |||
| { | |||
| if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) { | |||
| recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除"); | |||
| throw new ServiceException("对不起,您的账号:" + username + " 已被删除"); | |||
| } | |||
| if (UserStatus.DISABLE.getCode().equals(user.getStatus())) | |||
| { | |||
| if (UserStatus.DISABLE.getCode().equals(user.getStatus())) { | |||
| recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员"); | |||
| throw new ServiceException("对不起,您的账号:" + username + " 已停用"); | |||
| } | |||
| passwordService.validate(user, password); | |||
| remoteMmpService.gitLinkLogin(username, user.getOriginPassword()); | |||
| recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功"); | |||
| return userInfo; | |||
| } | |||
| public void logout(String loginName) | |||
| { | |||
| public void logout(String loginName) { | |||
| recordLogService.recordLogininfor(loginName, Constants.LOGOUT, "退出成功"); | |||
| } | |||
| /** | |||
| * 注册 | |||
| */ | |||
| public void register(String username, String password) | |||
| { | |||
| public void register(String username, String password) { | |||
| // 用户名或密码为空 错误 | |||
| if (StringUtils.isAnyBlank(username, password)) | |||
| { | |||
| if (StringUtils.isAnyBlank(username, password)) { | |||
| throw new ServiceException("用户/密码必须填写"); | |||
| } | |||
| if (username.length() < UserConstants.USERNAME_MIN_LENGTH | |||
| || username.length() > UserConstants.USERNAME_MAX_LENGTH) | |||
| { | |||
| || username.length() > UserConstants.USERNAME_MAX_LENGTH) { | |||
| throw new ServiceException("账户长度必须在2到20个字符之间"); | |||
| } | |||
| if (password.length() < UserConstants.PASSWORD_MIN_LENGTH | |||
| || password.length() > UserConstants.PASSWORD_MAX_LENGTH) | |||
| { | |||
| || password.length() > UserConstants.PASSWORD_MAX_LENGTH) { | |||
| throw new ServiceException("密码长度必须在5到20个字符之间"); | |||
| } | |||
| @@ -135,8 +125,7 @@ public class SysLoginService | |||
| sysUser.setPassword(SecurityUtils.encryptPassword(password)); | |||
| R<?> registerResult = remoteUserService.registerUserInfo(sysUser, SecurityConstants.INNER); | |||
| if (R.FAIL == registerResult.getCode()) | |||
| { | |||
| if (R.FAIL == registerResult.getCode()) { | |||
| throw new ServiceException(registerResult.getMsg()); | |||
| } | |||
| recordLogService.recordLogininfor(username, Constants.REGISTER, "注册成功"); | |||
| @@ -144,52 +133,45 @@ public class SysLoginService | |||
| public LoginUser loginByKey(String username, String key) { | |||
| // 用户名或密码为空 错误 | |||
| if (StringUtils.isAnyBlank(username, key)) | |||
| { | |||
| if (StringUtils.isAnyBlank(username, key)) { | |||
| recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户/key必须填写"); | |||
| throw new ServiceException("用户/key必须填写"); | |||
| } | |||
| // 用户名不在指定范围内 错误 | |||
| if (username.length() < UserConstants.USERNAME_MIN_LENGTH | |||
| || username.length() > UserConstants.USERNAME_MAX_LENGTH) | |||
| { | |||
| || username.length() > UserConstants.USERNAME_MAX_LENGTH) { | |||
| recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户名不在指定范围"); | |||
| throw new ServiceException("用户名不在指定范围"); | |||
| } | |||
| // IP黑名单校验 | |||
| String blackStr = Convert.toStr(redisService.getCacheObject(CacheConstants.SYS_LOGIN_BLACKIPLIST)); | |||
| if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr())) | |||
| { | |||
| if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr())) { | |||
| recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "很遗憾,访问IP已被列入系统黑名单"); | |||
| throw new ServiceException("很遗憾,访问IP已被列入系统黑名单"); | |||
| } | |||
| // 查询用户信息 | |||
| R<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER); | |||
| if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) | |||
| { | |||
| if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) { | |||
| recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在"); | |||
| throw new ServiceException("登录用户:" + username + " 不存在"); | |||
| } | |||
| if (R.FAIL == userResult.getCode()) | |||
| { | |||
| if (R.FAIL == userResult.getCode()) { | |||
| throw new ServiceException(userResult.getMsg()); | |||
| } | |||
| LoginUser userInfo = userResult.getData(); | |||
| SysUser user = userResult.getData().getSysUser(); | |||
| if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) | |||
| { | |||
| if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) { | |||
| recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除"); | |||
| throw new ServiceException("对不起,您的账号:" + username + " 已被删除"); | |||
| } | |||
| if (UserStatus.DISABLE.getCode().equals(user.getStatus())) | |||
| { | |||
| if (UserStatus.DISABLE.getCode().equals(user.getStatus())) { | |||
| recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员"); | |||
| throw new ServiceException("对不起,您的账号:" + username + " 已停用"); | |||
| } | |||
| if (!StringUtils.equals(key,"h1n2x3j4y5@")){ | |||
| if (!StringUtils.equals(key, "h1n2x3j4y5@")) { | |||
| throw new ServiceException("对不起,您的key不正确"); | |||
| } | |||
| return userInfo; | |||
| @@ -200,51 +182,44 @@ public class SysLoginService | |||
| String username = accountInfo.getUsername(); | |||
| // 用户名或密码为空 错误 | |||
| if (StringUtils.isAnyBlank(username)) | |||
| { | |||
| if (StringUtils.isAnyBlank(username)) { | |||
| recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写"); | |||
| throw new ServiceException("用户/密码必须填写"); | |||
| } | |||
| // 用户名不在指定范围内 错误 | |||
| if (username.length() < UserConstants.USERNAME_MIN_LENGTH | |||
| || username.length() > UserConstants.USERNAME_MAX_LENGTH) | |||
| { | |||
| || username.length() > UserConstants.USERNAME_MAX_LENGTH) { | |||
| recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户名不在指定范围"); | |||
| throw new ServiceException("用户名不在指定范围"); | |||
| } | |||
| // IP黑名单校验 | |||
| String blackStr = Convert.toStr(redisService.getCacheObject(CacheConstants.SYS_LOGIN_BLACKIPLIST)); | |||
| if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr())) | |||
| { | |||
| if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr())) { | |||
| recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "很遗憾,访问IP已被列入系统黑名单"); | |||
| throw new ServiceException("很遗憾,访问IP已被列入系统黑名单"); | |||
| } | |||
| // 查询用户信息 | |||
| R<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER); | |||
| if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) | |||
| { | |||
| if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) { | |||
| recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在"); | |||
| throw new ServiceException("登录用户:" + username + " 不存在"); | |||
| // register(username, "123456"); | |||
| // register(username, "123456"); | |||
| // userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER); | |||
| } | |||
| if (R.FAIL == userResult.getCode()) | |||
| { | |||
| if (R.FAIL == userResult.getCode()) { | |||
| throw new ServiceException(userResult.getMsg()); | |||
| } | |||
| LoginUser userInfo = userResult.getData(); | |||
| SysUser user = userResult.getData().getSysUser(); | |||
| if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) | |||
| { | |||
| if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) { | |||
| recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除"); | |||
| throw new ServiceException("对不起,您的账号:" + username + " 已被删除"); | |||
| } | |||
| if (UserStatus.DISABLE.getCode().equals(user.getStatus())) | |||
| { | |||
| if (UserStatus.DISABLE.getCode().equals(user.getStatus())) { | |||
| recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员"); | |||
| throw new ServiceException("对不起,您的账号:" + username + " 已停用"); | |||
| } | |||
| @@ -0,0 +1,31 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.ruoyi.auth.mapper.Oauth2Mapper"> | |||
| <insert id="insertOauth2User" useGeneratedKeys="true" keyProperty="id"> | |||
| insert into oauth_account(client_id, username, password, mobile, email, enabled) | |||
| values (#{oauthAccount.clientId}, #{oauthAccount.username}, #{oauthAccount.password}, #{oauthAccount.mobile}, | |||
| #{oauthAccount.email}, #{oauthAccount.enabled}) | |||
| </insert> | |||
| <update id="updateOauth2User"> | |||
| update oauth_account | |||
| <set> | |||
| <if test="oauthAccount.username != null and oauthAccount.username !=''"> | |||
| username = #{oauthAccount.username}, | |||
| </if> | |||
| <if test="oauthAccount.password != null and oauthAccount.password !=''"> | |||
| password = #{oauthAccount.password}, | |||
| </if> | |||
| <if test="oauthAccount.mobile != null and oauthAccount.mobile !=''"> | |||
| mobile = #{oauthAccount.mobile}, | |||
| </if> | |||
| <if test="oauthAccount.email != null and oauthAccount.email !=''"> | |||
| email = #{oauthAccount.email}, | |||
| </if> | |||
| <if test="oauthAccount.enabled != null"> | |||
| enabled = #{oauthAccount.enabled}, | |||
| </if> | |||
| </set> | |||
| where username = #{oauthAccount.username} and enabled = 1 | |||
| </update> | |||
| </mapper> | |||
| @@ -21,4 +21,6 @@ public class ServiceNameConstants | |||
| * 文件服务的serviceid | |||
| */ | |||
| public static final String FILE_SERVICE = "ruoyi-file"; | |||
| public static final String MANAGEMENT_SERVICE = "management-platform"; | |||
| } | |||
| @@ -257,7 +257,7 @@ public class ExcelUtil<T> | |||
| /** | |||
| * 对excel表单默认第一个索引名转换成list | |||
| * | |||
| * | |||
| * @param is 输入流 | |||
| * @return 转换后集合 | |||
| */ | |||
| @@ -282,7 +282,7 @@ public class ExcelUtil<T> | |||
| /** | |||
| * 对excel表单默认第一个索引名转换成list | |||
| * | |||
| * | |||
| * @param is 输入流 | |||
| * @param titleNum 标题占用行数 | |||
| * @return 转换后集合 | |||
| @@ -294,7 +294,7 @@ public class ExcelUtil<T> | |||
| /** | |||
| * 对excel表单指定表格索引名转换成list | |||
| * | |||
| * | |||
| * @param sheetName 表格索引名 | |||
| * @param titleNum 标题占用行数 | |||
| * @param is 输入流 | |||
| @@ -503,7 +503,7 @@ public class ExcelUtil<T> | |||
| /** | |||
| * 对list数据源将其里面的数据导入到excel表单 | |||
| * | |||
| * | |||
| * @return 结果 | |||
| */ | |||
| public void exportExcel(HttpServletResponse response) | |||
| @@ -565,7 +565,7 @@ public class ExcelUtil<T> | |||
| /** | |||
| * 填充excel数据 | |||
| * | |||
| * | |||
| * @param index 序号 | |||
| * @param row 单元格行 | |||
| */ | |||
| @@ -636,7 +636,7 @@ public class ExcelUtil<T> | |||
| /** | |||
| * 创建表格样式 | |||
| * | |||
| * | |||
| * @param wb 工作薄对象 | |||
| * @return 样式列表 | |||
| */ | |||
| @@ -689,7 +689,7 @@ public class ExcelUtil<T> | |||
| /** | |||
| * 根据Excel注解创建表格头样式 | |||
| * | |||
| * | |||
| * @param wb 工作薄对象 | |||
| * @return 自定义样式列表 | |||
| */ | |||
| @@ -722,7 +722,7 @@ public class ExcelUtil<T> | |||
| /** | |||
| * 根据Excel注解创建表格列样式 | |||
| * | |||
| * | |||
| * @param wb 工作薄对象 | |||
| * @return 自定义样式列表 | |||
| */ | |||
| @@ -784,7 +784,7 @@ public class ExcelUtil<T> | |||
| /** | |||
| * 设置单元格信息 | |||
| * | |||
| * | |||
| * @param value 单元格值 | |||
| * @param attr 注解相关 | |||
| * @param cell 单元格信息 | |||
| @@ -943,7 +943,7 @@ public class ExcelUtil<T> | |||
| /** | |||
| * 设置 POI XSSFSheet 单元格提示或选择框 | |||
| * | |||
| * | |||
| * @param sheet 表单 | |||
| * @param textlist 下拉框显示的内容 | |||
| * @param promptContent 提示内容 | |||
| @@ -953,7 +953,7 @@ public class ExcelUtil<T> | |||
| * @param endCol 结束列 | |||
| */ | |||
| public void setPromptOrValidation(Sheet sheet, String[] textlist, String promptContent, int firstRow, int endRow, | |||
| int firstCol, int endCol) | |||
| int firstCol, int endCol) | |||
| { | |||
| DataValidationHelper helper = sheet.getDataValidationHelper(); | |||
| DataValidationConstraint constraint = textlist.length > 0 ? helper.createExplicitListConstraint(textlist) : helper.createCustomConstraint("DD1"); | |||
| @@ -980,7 +980,7 @@ public class ExcelUtil<T> | |||
| /** | |||
| * 设置某些列的值只能输入预制的数据,显示下拉框(兼容超出一定数量的下拉框). | |||
| * | |||
| * | |||
| * @param sheet 要设置的sheet. | |||
| * @param textlist 下拉框显示的内容 | |||
| * @param promptContent 提示内容 | |||
| @@ -1069,7 +1069,7 @@ public class ExcelUtil<T> | |||
| /** | |||
| * 反向解析值 男=0,女=1,未知=2 | |||
| * | |||
| * | |||
| * @param propertyValue 参数值 | |||
| * @param converterExp 翻译注解 | |||
| * @param separator 分隔符 | |||
| @@ -1311,7 +1311,7 @@ public class ExcelUtil<T> | |||
| /** | |||
| * 创建工作表 | |||
| * | |||
| * | |||
| * @param sheetNo sheet数量 | |||
| * @param index 序号 | |||
| */ | |||
| @@ -1328,7 +1328,7 @@ public class ExcelUtil<T> | |||
| /** | |||
| * 获取单元格值 | |||
| * | |||
| * | |||
| * @param row 获取的行 | |||
| * @param column 获取单元格列号 | |||
| * @return 单元格值 | |||
| @@ -1388,7 +1388,7 @@ public class ExcelUtil<T> | |||
| /** | |||
| * 判断是否是空行 | |||
| * | |||
| * | |||
| * @param row 判断的行 | |||
| * @return | |||
| */ | |||
| @@ -1411,7 +1411,7 @@ public class ExcelUtil<T> | |||
| /** | |||
| * 格式化不同类型的日期对象 | |||
| * | |||
| * | |||
| * @param dateFormat 日期格式 | |||
| * @param val 被格式化的日期对象 | |||
| * @return 格式化后的日期字符 | |||
| @@ -1477,7 +1477,7 @@ public class ExcelUtil<T> | |||
| /** | |||
| * 获取对象的子列表方法 | |||
| * | |||
| * | |||
| * @param name 名称 | |||
| * @param pojoClass 类对象 | |||
| * @return 子列表方法 | |||
| @@ -34,6 +34,11 @@ | |||
| <artifactId>ruoyi-common-redis</artifactId> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>cn.hutool</groupId> | |||
| <artifactId>hutool-all</artifactId> | |||
| <version>5.8.5</version> | |||
| </dependency> | |||
| </dependencies> | |||
| </project> | |||
| @@ -1,66 +1,61 @@ | |||
| package com.ruoyi.common.security.utils; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | |||
| import cn.hutool.crypto.symmetric.AES; | |||
| import com.ruoyi.common.core.constant.SecurityConstants; | |||
| import com.ruoyi.common.core.constant.TokenConstants; | |||
| import com.ruoyi.common.core.context.SecurityContextHolder; | |||
| import com.ruoyi.common.core.utils.ServletUtils; | |||
| import com.ruoyi.common.core.utils.StringUtils; | |||
| import com.ruoyi.system.api.model.LoginUser; | |||
| import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| /** | |||
| * 权限获取工具类 | |||
| * | |||
| * | |||
| * @author ruoyi | |||
| */ | |||
| public class SecurityUtils | |||
| { | |||
| public class SecurityUtils { | |||
| /** | |||
| * 获取用户ID | |||
| */ | |||
| public static Long getUserId() | |||
| { | |||
| public static Long getUserId() { | |||
| return SecurityContextHolder.getUserId(); | |||
| } | |||
| /** | |||
| * 获取用户名称 | |||
| */ | |||
| public static String getUsername() | |||
| { | |||
| public static String getUsername() { | |||
| return SecurityContextHolder.getUserName(); | |||
| } | |||
| /** | |||
| * 获取用户key | |||
| */ | |||
| public static String getUserKey() | |||
| { | |||
| public static String getUserKey() { | |||
| return SecurityContextHolder.getUserKey(); | |||
| } | |||
| /** | |||
| * 获取登录用户信息 | |||
| */ | |||
| public static LoginUser getLoginUser() | |||
| { | |||
| public static LoginUser getLoginUser() { | |||
| return SecurityContextHolder.get(SecurityConstants.LOGIN_USER, LoginUser.class); | |||
| } | |||
| /** | |||
| * 获取请求token | |||
| */ | |||
| public static String getToken() | |||
| { | |||
| public static String getToken() { | |||
| return getToken(ServletUtils.getRequest()); | |||
| } | |||
| /** | |||
| * 根据request获取请求token | |||
| */ | |||
| public static String getToken(HttpServletRequest request) | |||
| { | |||
| public static String getToken(HttpServletRequest request) { | |||
| // 从header获取token标识 | |||
| String token = request.getHeader(TokenConstants.AUTHENTICATION); | |||
| return replaceTokenPrefix(token); | |||
| @@ -69,11 +64,9 @@ public class SecurityUtils | |||
| /** | |||
| * 裁剪token前缀 | |||
| */ | |||
| public static String replaceTokenPrefix(String token) | |||
| { | |||
| public static String replaceTokenPrefix(String token) { | |||
| // 如果前端设置了令牌前缀,则裁剪掉前缀 | |||
| if (StringUtils.isNotEmpty(token) && token.startsWith(TokenConstants.PREFIX)) | |||
| { | |||
| if (StringUtils.isNotEmpty(token) && token.startsWith(TokenConstants.PREFIX)) { | |||
| token = token.replaceFirst(TokenConstants.PREFIX, ""); | |||
| } | |||
| return token; | |||
| @@ -81,12 +74,11 @@ public class SecurityUtils | |||
| /** | |||
| * 是否为管理员 | |||
| * | |||
| * | |||
| * @param userId 用户ID | |||
| * @return 结果 | |||
| */ | |||
| public static boolean isAdmin(Long userId) | |||
| { | |||
| public static boolean isAdmin(Long userId) { | |||
| return userId != null && 1L == userId; | |||
| } | |||
| @@ -96,8 +88,7 @@ public class SecurityUtils | |||
| * @param password 密码 | |||
| * @return 加密字符串 | |||
| */ | |||
| public static String encryptPassword(String password) | |||
| { | |||
| public static String encryptPassword(String password) { | |||
| BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); | |||
| return passwordEncoder.encode(password); | |||
| } | |||
| @@ -105,13 +96,28 @@ public class SecurityUtils | |||
| /** | |||
| * 判断密码是否相同 | |||
| * | |||
| * @param rawPassword 真实密码 | |||
| * @param rawPassword 真实密码 | |||
| * @param encodedPassword 加密后字符 | |||
| * @return 结果 | |||
| */ | |||
| public static boolean matchesPassword(String rawPassword, String encodedPassword) | |||
| { | |||
| public static boolean matchesPassword(String rawPassword, String encodedPassword) { | |||
| BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); | |||
| return passwordEncoder.matches(rawPassword, encodedPassword); | |||
| } | |||
| // AES密钥算法 | |||
| private static final String key = "1234567890abcdef"; | |||
| public static String encrypt(String data) { | |||
| AES aes = new AES(key.getBytes()); | |||
| // 加密 | |||
| return aes.encryptHex(data); | |||
| } | |||
| // 解密 | |||
| public static String decrypt(String data) { | |||
| AES aes = new AES(key.getBytes()); | |||
| return aes.decryptStr(data); | |||
| } | |||
| } | |||
| @@ -1,38 +0,0 @@ | |||
| package com.ruoyi.platform.constant; | |||
| public class Constant { | |||
| public final static int Image_Type_Pub = 1; // 公共镜像 | |||
| public final static int Image_Type_Pri = 0; // 私有镜像 | |||
| public final static int Code_Repo_Pub = 1; // 代码仓库可见性-公开 | |||
| public final static int Code_Repo_Pri = 0; // 代码仓库可见性-私有 | |||
| public final static int State_valid = 1; // 有效 | |||
| public final static int State_invalid = 0; // 无效 | |||
| public final static int State_building = 2; //创建中 | |||
| public final static int State_failed = 3; //运行失败 | |||
| public final static int Used_State_used = 1; // 已占用 | |||
| public final static int Used_State_unused = 0; // 未占用 | |||
| public final static String Computing_Resource_CPU = "CPU"; // 计算资源_CPU | |||
| public final static String Computing_Resource_GPU = "GPU"; // 计算资源_GPU | |||
| public final static int Git_Category_Id = 39; | |||
| public final static String Source_Auto_Export = "auto_export"; | |||
| public final static String Source_Hand_Export = "hand_export"; | |||
| public final static String Source_Add = "add"; | |||
| public final static String Running = "Running"; | |||
| public final static String Failed = "Failed"; | |||
| public final static String Pending = "Pending"; | |||
| public final static String Init = "Init"; | |||
| public final static String Stopped = "Stopped"; | |||
| public final static String Succeeded = "Succeeded"; | |||
| public final static String Type_Train = "train"; | |||
| public final static String Type_Evaluate = "evaluate"; | |||
| } | |||
| @@ -0,0 +1,62 @@ | |||
| package com.ruoyi.platform.controller.activeLearn; | |||
| import com.ruoyi.common.core.web.controller.BaseController; | |||
| import com.ruoyi.common.core.web.domain.GenericsAjaxResult; | |||
| import com.ruoyi.platform.domain.ActiveLearn; | |||
| import com.ruoyi.platform.service.ActiveLearnService; | |||
| import com.ruoyi.platform.vo.ActiveLearnVo; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import org.springframework.data.domain.Page; | |||
| import org.springframework.data.domain.PageRequest; | |||
| import javax.annotation.Resource; | |||
| import java.io.IOException; | |||
| @RestController | |||
| @RequestMapping("activeLearn") | |||
| @Api("主动学习") | |||
| public class ActiveLearnController extends BaseController { | |||
| @Resource | |||
| private ActiveLearnService activeLearnService; | |||
| @GetMapping | |||
| @ApiOperation("分页查询") | |||
| public GenericsAjaxResult<Page<ActiveLearn>> queryByPage(@RequestParam("page") int page, | |||
| @RequestParam("size") int size, | |||
| @RequestParam(value = "name", required = false) String name) { | |||
| PageRequest pageRequest = PageRequest.of(page, size); | |||
| return genericsSuccess(this.activeLearnService.queryByPage(name, pageRequest)); | |||
| } | |||
| @PostMapping | |||
| @ApiOperation("新增主动学习") | |||
| public GenericsAjaxResult<ActiveLearn> addActiveLearn(@RequestBody ActiveLearnVo activeLearnVo) throws Exception { | |||
| return genericsSuccess(this.activeLearnService.save(activeLearnVo)); | |||
| } | |||
| @PutMapping | |||
| @ApiOperation("编辑主动学习") | |||
| public GenericsAjaxResult<String> editActiveLearn(@RequestBody ActiveLearnVo activeLearnVo) throws Exception { | |||
| return genericsSuccess(this.activeLearnService.edit(activeLearnVo)); | |||
| } | |||
| @GetMapping("/getActiveLearnDetail") | |||
| @ApiOperation("获取主动学习详细信息") | |||
| public GenericsAjaxResult<ActiveLearnVo> getActiveLearnDetail(@RequestParam("id") Long id) throws IOException { | |||
| return genericsSuccess(this.activeLearnService.getActiveLearnDetail(id)); | |||
| } | |||
| @DeleteMapping("{id}") | |||
| @ApiOperation("删除主动学习") | |||
| public GenericsAjaxResult<String> deleteActiveLearn(@PathVariable("id") Long id) { | |||
| return genericsSuccess(this.activeLearnService.delete(id)); | |||
| } | |||
| @PostMapping("/run/{id}") | |||
| @ApiOperation("运行主动学习实验") | |||
| public GenericsAjaxResult<String> runActiveLearn(@PathVariable("id") Long id) throws Exception { | |||
| return genericsSuccess(this.activeLearnService.runActiveLearnIns(id)); | |||
| } | |||
| } | |||
| @@ -0,0 +1,68 @@ | |||
| package com.ruoyi.platform.controller.activeLearn; | |||
| import com.ruoyi.common.core.web.controller.BaseController; | |||
| import com.ruoyi.common.core.web.domain.GenericsAjaxResult; | |||
| import com.ruoyi.platform.domain.ActiveLearnIns; | |||
| import com.ruoyi.platform.service.ActiveLearnInsService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import io.swagger.v3.oas.annotations.responses.ApiResponse; | |||
| import org.springframework.data.domain.PageRequest; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import org.springframework.data.domain.Page; | |||
| import javax.annotation.Resource; | |||
| import java.io.IOException; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping("activeLearnIns") | |||
| @Api("主动学习实验实例") | |||
| public class ActiveLearnInsController extends BaseController { | |||
| @Resource | |||
| private ActiveLearnInsService activeLearnInsService; | |||
| @GetMapping | |||
| @ApiOperation("分页查询") | |||
| public GenericsAjaxResult<Page<ActiveLearnIns>> queryByPage(Long activeLearnId, int page, int size) throws IOException { | |||
| PageRequest pageRequest = PageRequest.of(page, size); | |||
| return genericsSuccess(this.activeLearnInsService.queryByPage(activeLearnId, pageRequest)); | |||
| } | |||
| @PostMapping | |||
| @ApiOperation("新增实验实例") | |||
| public GenericsAjaxResult<ActiveLearnIns> add(@RequestBody ActiveLearnIns activeLearnIns) { | |||
| return genericsSuccess(this.activeLearnInsService.insert(activeLearnIns)); | |||
| } | |||
| @DeleteMapping("{id}") | |||
| @ApiOperation("删除实验实例") | |||
| public GenericsAjaxResult<String> deleteById(@PathVariable("id") Long id) { | |||
| return genericsSuccess(this.activeLearnInsService.deleteById(id)); | |||
| } | |||
| @DeleteMapping("batchDelete") | |||
| @ApiOperation("批量删除实验实例") | |||
| public GenericsAjaxResult<String> batchDelete(@RequestBody List<Long> ids) { | |||
| return genericsSuccess(this.activeLearnInsService.batchDelete(ids)); | |||
| } | |||
| @PutMapping("{id}") | |||
| @ApiOperation("终止实验实例") | |||
| public GenericsAjaxResult<Boolean> terminateActiveLearnIns(@PathVariable("id") Long id) throws Exception { | |||
| return genericsSuccess(this.activeLearnInsService.terminateActiveLearnIns(id)); | |||
| } | |||
| @GetMapping("{id}") | |||
| @ApiOperation("查看实验实例详情") | |||
| public GenericsAjaxResult<ActiveLearnIns> getDetailById(@PathVariable("id") Long id) throws Exception { | |||
| return genericsSuccess(this.activeLearnInsService.getDetailById(id)); | |||
| } | |||
| @GetMapping("/getExpMetrics") | |||
| @ApiOperation("获取当前实验的指标对比地址") | |||
| @ApiResponse | |||
| public GenericsAjaxResult<String> getExpMetrics(@RequestParam(value = "experiment_ins_id") String experimentInsId) throws Exception { | |||
| return genericsSuccess(activeLearnInsService.getExpMetrics(experimentInsId)); | |||
| } | |||
| } | |||
| @@ -35,8 +35,8 @@ public class AimController extends BaseController { | |||
| @ApiOperation("获取当前实验的模型推理指标信息") | |||
| @ApiResponse | |||
| public AjaxResult getExpEvaluateInfos(@RequestParam(value = "page") int page, | |||
| @RequestParam(value = "size") int size, | |||
| @PathVariable("experiment_id") Integer experimentId) { | |||
| @RequestParam(value = "size") int size, | |||
| @PathVariable("experiment_id") Integer experimentId) { | |||
| return AjaxResult.success(aimService.getExpInfos(false, experimentId, page, size)); | |||
| } | |||
| @@ -0,0 +1,72 @@ | |||
| package com.ruoyi.platform.controller.autoML; | |||
| import com.ruoyi.common.core.web.controller.BaseController; | |||
| import com.ruoyi.common.core.web.domain.AjaxResult; | |||
| import com.ruoyi.common.core.web.domain.GenericsAjaxResult; | |||
| import com.ruoyi.platform.domain.AutoMl; | |||
| import com.ruoyi.platform.service.AutoMlService; | |||
| import com.ruoyi.platform.vo.AutoMlVo; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.springframework.data.domain.Page; | |||
| import org.springframework.data.domain.PageRequest; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import org.springframework.web.multipart.MultipartFile; | |||
| import javax.annotation.Resource; | |||
| import java.io.IOException; | |||
| @RestController | |||
| @RequestMapping("autoML") | |||
| @Api("自动机器学习") | |||
| public class AutoMlController extends BaseController { | |||
| @Resource | |||
| private AutoMlService autoMlService; | |||
| @GetMapping | |||
| @ApiOperation("分页查询") | |||
| public GenericsAjaxResult<Page<AutoMl>> queryByPage(@RequestParam("page") int page, | |||
| @RequestParam("size") int size, | |||
| @RequestParam(value = "ml_name", required = false) String mlName) { | |||
| PageRequest pageRequest = PageRequest.of(page, size); | |||
| return genericsSuccess(this.autoMlService.queryByPage(mlName, pageRequest)); | |||
| } | |||
| @PostMapping | |||
| @ApiOperation("新增自动机器学习") | |||
| public GenericsAjaxResult<AutoMl> addAutoMl(@RequestBody AutoMlVo autoMlVo) throws Exception { | |||
| return genericsSuccess(this.autoMlService.save(autoMlVo)); | |||
| } | |||
| @PutMapping | |||
| @ApiOperation("编辑自动机器学习") | |||
| public GenericsAjaxResult<String> editAutoMl(@RequestBody AutoMlVo autoMlVo) throws Exception { | |||
| return genericsSuccess(this.autoMlService.edit(autoMlVo)); | |||
| } | |||
| @GetMapping("/getAutoMlDetail") | |||
| @ApiOperation("获取自动机器学习详细信息") | |||
| public GenericsAjaxResult<AutoMlVo> getAutoMlDetail(@RequestParam("id") Long id) throws IOException { | |||
| return genericsSuccess(this.autoMlService.getAutoMlDetail(id)); | |||
| } | |||
| @DeleteMapping("{id}") | |||
| @ApiOperation("删除自动机器学习") | |||
| public GenericsAjaxResult<String> deleteAutoMl(@PathVariable("id") Long id) { | |||
| return genericsSuccess(this.autoMlService.delete(id)); | |||
| } | |||
| @CrossOrigin(origins = "*", allowedHeaders = "*") | |||
| @PostMapping("/upload") | |||
| @ApiOperation(value = "上传数据文件csv", notes = "上传数据文件csv,并将信息存入数据库。") | |||
| public AjaxResult upload(@RequestParam("file") MultipartFile file, @RequestParam("uuid") String uuid) throws Exception { | |||
| return AjaxResult.success(this.autoMlService.upload(file, uuid)); | |||
| } | |||
| @PostMapping("/run/{id}") | |||
| @ApiOperation("运行自动机器学习实验") | |||
| public GenericsAjaxResult<String> runAutoML(@PathVariable("id") Long id) throws Exception { | |||
| return genericsSuccess(this.autoMlService.runAutoMlIns(id)); | |||
| } | |||
| } | |||
| @@ -0,0 +1,61 @@ | |||
| package com.ruoyi.platform.controller.autoML; | |||
| import com.ruoyi.common.core.web.controller.BaseController; | |||
| import com.ruoyi.common.core.web.domain.GenericsAjaxResult; | |||
| import com.ruoyi.platform.domain.AutoMlIns; | |||
| import com.ruoyi.platform.service.AutoMlInsService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.springframework.data.domain.Page; | |||
| import org.springframework.data.domain.PageRequest; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.annotation.Resource; | |||
| import java.io.IOException; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping("autoMLIns") | |||
| @Api("自动机器学习实验实例") | |||
| public class AutoMlInsController extends BaseController { | |||
| @Resource | |||
| private AutoMlInsService autoMLInsService; | |||
| @GetMapping | |||
| @ApiOperation("分页查询") | |||
| public GenericsAjaxResult<Page<AutoMlIns>> queryByPage(AutoMlIns autoMlIns, int page, int size) throws IOException { | |||
| PageRequest pageRequest = PageRequest.of(page, size); | |||
| return genericsSuccess(this.autoMLInsService.queryByPage(autoMlIns, pageRequest)); | |||
| } | |||
| @PostMapping | |||
| @ApiOperation("新增实验实例") | |||
| public GenericsAjaxResult<AutoMlIns> add(@RequestBody AutoMlIns autoMlIns) { | |||
| return genericsSuccess(this.autoMLInsService.insert(autoMlIns)); | |||
| } | |||
| @DeleteMapping("{id}") | |||
| @ApiOperation("删除实验实例") | |||
| public GenericsAjaxResult<String> deleteById(@PathVariable("id") Long id) { | |||
| return genericsSuccess(this.autoMLInsService.removeById(id)); | |||
| } | |||
| @DeleteMapping("batchDelete") | |||
| @ApiOperation("批量删除实验实例") | |||
| public GenericsAjaxResult<String> batchDelete(@RequestBody List<Long> ids) { | |||
| return genericsSuccess(this.autoMLInsService.batchDelete(ids)); | |||
| } | |||
| @PutMapping("{id}") | |||
| @ApiOperation("终止实验实例") | |||
| public GenericsAjaxResult<Boolean> terminateAutoMlIns(@PathVariable("id") Long id) throws Exception { | |||
| return genericsSuccess(this.autoMLInsService.terminateAutoMlIns(id)); | |||
| } | |||
| @GetMapping("{id}") | |||
| @ApiOperation("查看实验实例详情") | |||
| public GenericsAjaxResult<AutoMlIns> getDetailById(@PathVariable("id") Long id) { | |||
| return genericsSuccess(this.autoMLInsService.getDetailById(id)); | |||
| } | |||
| } | |||
| @@ -7,7 +7,6 @@ import com.ruoyi.platform.service.CodeConfigService; | |||
| import io.swagger.annotations.Api; | |||
| import org.springframework.data.domain.Page; | |||
| import org.springframework.data.domain.PageRequest; | |||
| import org.springframework.http.ResponseEntity; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.annotation.Resource; | |||
| @@ -63,7 +62,7 @@ public class CodeConfigController extends BaseController { | |||
| } | |||
| @DeleteMapping("{id}") | |||
| public GenericsAjaxResult<String> delete(@PathVariable("id") Long id) { | |||
| public GenericsAjaxResult<String> delete(@PathVariable("id") Long id) throws Exception { | |||
| return genericsSuccess(this.codeConfigService.removeById(id)); | |||
| } | |||
| } | |||
| @@ -136,12 +136,12 @@ public class DatasetVersionController extends BaseController { | |||
| return genericsSuccess(this.datasetVersionService.deleteDatasetVersion(datasetId, version)); | |||
| } | |||
| @PostMapping("/addDatasetVersionsFromLabel") | |||
| @ApiOperation("从数据标注添加数据集版本") | |||
| public GenericsAjaxResult<?> addDatasetVersionsFromLabel(@RequestBody LabelDatasetVersionVo labelDatasetVersionVo) throws Exception { | |||
| datasetVersionService.addDatasetVersionsFromLabel(labelDatasetVersionVo); | |||
| return GenericsAjaxResult.success(); | |||
| } | |||
| // @PostMapping("/addDatasetVersionsFromLabel") | |||
| // @ApiOperation("从数据标注添加数据集版本") | |||
| // public GenericsAjaxResult<?> addDatasetVersionsFromLabel(@RequestBody LabelDatasetVersionVo labelDatasetVersionVo) throws Exception { | |||
| // datasetVersionService.addDatasetVersionsFromLabel(labelDatasetVersionVo); | |||
| // | |||
| // return GenericsAjaxResult.success(); | |||
| // } | |||
| } | |||
| @@ -3,7 +3,10 @@ package com.ruoyi.platform.controller.dataset; | |||
| import com.ruoyi.common.core.web.domain.AjaxResult; | |||
| import com.ruoyi.platform.domain.Dataset; | |||
| import com.ruoyi.platform.service.NewDatasetService; | |||
| import com.ruoyi.platform.utils.DVCUtils; | |||
| import com.ruoyi.platform.vo.LabelDatasetVersionVo; | |||
| import com.ruoyi.platform.vo.NewDatasetVo; | |||
| import com.ruoyi.platform.vo.QueryModelMetricsVo; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.springframework.core.io.InputStreamResource; | |||
| import org.springframework.data.domain.PageRequest; | |||
| @@ -11,9 +14,13 @@ import org.springframework.http.ResponseEntity; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import org.springframework.web.multipart.MultipartFile; | |||
| import javax.annotation.Nullable; | |||
| import javax.annotation.Resource; | |||
| import java.nio.file.Path; | |||
| import java.nio.file.Paths; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import java.util.Optional; | |||
| @RestController | |||
| @RequestMapping("newdataset") | |||
| @@ -25,6 +32,8 @@ public class NewDatasetFromGitController { | |||
| @Resource | |||
| private NewDatasetService newDatasetService; | |||
| @Resource | |||
| private DVCUtils dvcUtils; | |||
| /** | |||
| * 新增数据集与版本新 | |||
| @@ -53,14 +62,30 @@ public class NewDatasetFromGitController { | |||
| } | |||
| /** | |||
| * 新增数据集与版本新 | |||
| * | |||
| * @param datasetVo 实体 | |||
| * @return 新增结果 | |||
| */ | |||
| @PostMapping("/addVersionFromLabelStudio") | |||
| @ApiOperation("从labelsudio添加版本") | |||
| public AjaxResult addVersionFromLabelStudio(@RequestBody LabelDatasetVersionVo datasetVo) throws Exception { | |||
| return AjaxResult.success(this.newDatasetService.newCreateVersionFromLabelStudio(datasetVo)); | |||
| } | |||
| @GetMapping("/queryDatasets") | |||
| @ApiOperation("数据集广场公开数据集分页查询,根据data_type,data_tag筛选,true公开false私有") | |||
| public AjaxResult queryDatasets(@RequestParam("page") int page, | |||
| @RequestParam("size") int size, | |||
| @RequestParam(value = "is_public") Boolean isPublic, | |||
| public AjaxResult queryDatasets(@RequestParam(value = "page", required = false) @Nullable Integer page, | |||
| @RequestParam(value = "size", required = false) @Nullable Integer size, | |||
| @RequestParam(value = "is_public", required = false) @Nullable Boolean isPublic, | |||
| @RequestParam(value = "data_type", required = false) String dataType, | |||
| @RequestParam(value = "data_tag", required = false) String dataTag, | |||
| @RequestParam(value = "name", required = false) String name) throws Exception { | |||
| page = Optional.ofNullable(page).orElse(0); // 默认 page 为 0 | |||
| size = Optional.ofNullable(size).orElse(10000); // 默认 size 为 10000 | |||
| isPublic = Optional.ofNullable(isPublic).orElse(false); | |||
| PageRequest pageRequest = PageRequest.of(page, size); | |||
| Dataset dataset = new Dataset(); | |||
| dataset.setDataTag(dataTag); | |||
| @@ -85,27 +110,28 @@ public class NewDatasetFromGitController { | |||
| @RequestParam("id") Integer id, | |||
| @RequestParam(value = "owner", required = false) String owner, | |||
| @RequestParam(value = "identifier", required = false) String identifier, | |||
| @RequestParam(value = "version", required = false) String version) throws Exception { | |||
| return AjaxResult.success(this.newDatasetService.getNewDatasetDesc(id, name, identifier, owner, version)); | |||
| @RequestParam(value = "version", required = false) String version, | |||
| @RequestParam(value = "is_public") Boolean isPublic) throws Exception { | |||
| return AjaxResult.success(this.newDatasetService.getNewDatasetDesc(id, name, identifier, owner, version, isPublic)); | |||
| } | |||
| @DeleteMapping("/deleteDataset") | |||
| @ApiOperation(value = "删除数据集") | |||
| public AjaxResult deleteDataset(@RequestParam("id") Integer id, @RequestParam("identifier") String identifier, @RequestParam("owner") String owner) throws Exception { | |||
| this.newDatasetService.deleteDatasetNew(id, identifier, owner); | |||
| public AjaxResult deleteDataset(@RequestParam("id") Integer id, @RequestParam("identifier") String identifier, @RequestParam("owner") String owner, @RequestParam("is_public") Boolean isPublic) throws Exception { | |||
| this.newDatasetService.deleteDatasetNew(id, identifier, owner, isPublic); | |||
| return AjaxResult.success(); | |||
| } | |||
| @DeleteMapping("/deleteDatasetVersion") | |||
| @ApiOperation(value = "删除数据集版本") | |||
| public AjaxResult deleteDatasetVersion(@RequestParam("identifier") String repo, @RequestParam("owner") String owner, @RequestParam("version") String version, | |||
| public AjaxResult deleteDatasetVersion(@RequestParam("id") Integer id, @RequestParam("identifier") String repo, @RequestParam("owner") String owner, @RequestParam("version") String version, | |||
| @RequestParam("relative_paths") String relativePaths) throws Exception { | |||
| // 查询版本,如果是最后一个版本,则不能删除 | |||
| List<Map<String, Object>> versionList = this.newDatasetService.getVersionList(repo, owner); | |||
| if (versionList.size() == 1) { | |||
| return AjaxResult.error("当前数据集只有一个版本,不能删除该版本"); | |||
| } | |||
| this.newDatasetService.deleteDatasetVersionNew(repo, owner, version, relativePaths); | |||
| this.newDatasetService.deleteDatasetVersionNew(id, repo, owner, version, relativePaths); | |||
| return AjaxResult.success(); | |||
| } | |||
| @@ -132,8 +158,8 @@ public class NewDatasetFromGitController { | |||
| */ | |||
| @GetMapping("/downloadAllFiles") | |||
| @ApiOperation(value = "下载同一版本下所有数据集,并打包") | |||
| public ResponseEntity<InputStreamResource> downloadAllDatasetFiles(@RequestParam("name") String name, @RequestParam("identifier") String identifier, @RequestParam("id") Integer id, @RequestParam("version") String version) throws Exception { | |||
| return newDatasetService.downloadAllDatasetFilesNew(name, identifier, id, version); | |||
| public ResponseEntity<InputStreamResource> downloadAllDatasetFiles(@RequestParam("name") String name, @RequestParam("identifier") String identifier, @RequestParam("id") Integer id, @RequestParam("version") String version, @RequestParam("is_public") Boolean isPublic) throws Exception { | |||
| return newDatasetService.downloadAllDatasetFilesNew(name, identifier, id, version, isPublic); | |||
| } | |||
| /** | |||
| @@ -148,4 +174,18 @@ public class NewDatasetFromGitController { | |||
| public ResponseEntity<InputStreamResource> downloadDataset(@RequestParam("url") String url) throws Exception { | |||
| return newDatasetService.downloadDatasetlocal(url); | |||
| } | |||
| @PostMapping("/getVersionsCompare") | |||
| @ApiOperation(value = "获取数据集版本对比") | |||
| public AjaxResult getVersionsCompare(@RequestBody QueryModelMetricsVo querydatasetVo) throws Exception { | |||
| return AjaxResult.success(this.newDatasetService.getVersionsCompare(querydatasetVo)); | |||
| } | |||
| @DeleteMapping("/deleteFile") | |||
| @ApiOperation(value = "删除文件") | |||
| public AjaxResult deleteFile(@RequestParam("url") String url, @RequestParam("fileName") String fileName) { | |||
| Path file = Paths.get(url, System.getProperty("file.separator"), fileName); | |||
| dvcUtils.deletePath(file); | |||
| return AjaxResult.success("删除成功"); | |||
| } | |||
| } | |||
| @@ -61,7 +61,7 @@ public class DevEnvironmentController extends BaseController { | |||
| * @return 新增结果 | |||
| */ | |||
| @PostMapping | |||
| public GenericsAjaxResult<DevEnvironment> add(@RequestBody DevEnvironmentVo devEnvironmentVo) { | |||
| public GenericsAjaxResult<DevEnvironment> add(@RequestBody DevEnvironmentVo devEnvironmentVo) throws Exception { | |||
| return genericsSuccess(this.devEnvironmentService.insert(devEnvironmentVo)); | |||
| } | |||
| @@ -72,7 +72,7 @@ public class DevEnvironmentController extends BaseController { | |||
| * @return 编辑结果 | |||
| */ | |||
| @PutMapping | |||
| public GenericsAjaxResult<DevEnvironment> edit(@RequestBody DevEnvironment devEnvironment) { | |||
| public GenericsAjaxResult<DevEnvironment> edit(@RequestBody DevEnvironment devEnvironment) throws Exception { | |||
| return genericsSuccess(this.devEnvironmentService.update(devEnvironment)); | |||
| } | |||
| @@ -102,7 +102,7 @@ public class ExperimentController extends BaseController { | |||
| * @return 删除是否成功 | |||
| */ | |||
| @DeleteMapping("{id}") | |||
| @ApiOperation("删除流水线") | |||
| @ApiOperation("删除实验") | |||
| public GenericsAjaxResult<String> deleteById(@PathVariable("id") Integer id) throws Exception { | |||
| return genericsSuccess(this.experimentService.removeById(id)); | |||
| } | |||
| @@ -120,7 +120,7 @@ public class ExperimentInsController extends BaseController { | |||
| */ | |||
| @PutMapping("{id}") | |||
| @ApiOperation("终止实验实例") | |||
| public GenericsAjaxResult<Boolean> terminateExperimentIns(@PathVariable("id") Integer id) { | |||
| public GenericsAjaxResult<Boolean> terminateExperimentIns(@PathVariable("id") Integer id) throws Exception { | |||
| return genericsSuccess(this.experimentInsService.terminateExperimentIns(id)); | |||
| } | |||
| @@ -0,0 +1,61 @@ | |||
| package com.ruoyi.platform.controller.git; | |||
| import com.ruoyi.common.core.web.controller.BaseController; | |||
| import com.ruoyi.common.core.web.domain.GenericsAjaxResult; | |||
| import com.ruoyi.platform.service.GitService; | |||
| import com.ruoyi.system.api.domain.SysUser; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.annotation.Resource; | |||
| @RestController | |||
| @RequestMapping("gitLink") | |||
| @Api("gitLink") | |||
| public class GitLinkController extends BaseController { | |||
| @Resource | |||
| private GitService gitService; | |||
| @GetMapping("/login") | |||
| @ApiOperation("刷新giotLink用户信息") | |||
| public GenericsAjaxResult<String> gitLinkLogin(@RequestParam("username") String username, @RequestParam("password") String password) { | |||
| return genericsSuccess(gitService.login(username, password)); | |||
| } | |||
| @PostMapping("/createGitLinkUser") | |||
| @ApiOperation("新增gitLink用户") | |||
| public GenericsAjaxResult<String> createGitLinkUser(@RequestBody SysUser sysUser) throws Exception { | |||
| gitService.createUser(sysUser); | |||
| return GenericsAjaxResult.success("新增成功"); | |||
| } | |||
| @PostMapping("/resetPwd") | |||
| @ApiOperation("更改gitLink用户密码") | |||
| public GenericsAjaxResult<String> resetPwd(@RequestBody SysUser sysUser) throws Exception { | |||
| gitService.resetPwd(sysUser); | |||
| return GenericsAjaxResult.success("修改成功"); | |||
| } | |||
| @PutMapping("/resetEmail") | |||
| @ApiOperation("更改gitLink用户邮箱") | |||
| public GenericsAjaxResult<String> resetEmail(@RequestBody SysUser sysUser) throws Exception { | |||
| gitService.resetEmail(sysUser); | |||
| return GenericsAjaxResult.success("修改成功"); | |||
| } | |||
| @PutMapping("/resetPhoneNum") | |||
| @ApiOperation("更改gitLink用户手机号") | |||
| public GenericsAjaxResult<String> resetPhoneNum(@RequestBody SysUser sysUser) throws Exception { | |||
| gitService.resetPhoneNum(sysUser); | |||
| return GenericsAjaxResult.success("修改成功"); | |||
| } | |||
| @DeleteMapping("/deleteGitLinkUser") | |||
| @ApiOperation("删除gitLink用户") | |||
| public GenericsAjaxResult<String> deleteGitLinkUser(@RequestBody SysUser sysUser) throws Exception { | |||
| gitService.deleteUser(sysUser); | |||
| return GenericsAjaxResult.success("删除成功"); | |||
| } | |||
| } | |||
| @@ -92,7 +92,7 @@ public class ImageController extends BaseController { | |||
| @PostMapping("/addImageAndVersion") | |||
| @ApiOperation("添加镜像和版本") | |||
| public GenericsAjaxResult<String> addImageAndVersion(@RequestBody ImageVo imageVo) throws Exception { | |||
| return genericsSuccess(this.imageService.insertImageAndVersion(imageVo)); | |||
| return this.imageService.insertImageAndVersion(imageVo); | |||
| } | |||
| @@ -115,6 +115,7 @@ public class ImageController extends BaseController { | |||
| * @return 删除是否成功 | |||
| */ | |||
| @DeleteMapping("{id}") | |||
| @ApiOperation("删除镜像") | |||
| public GenericsAjaxResult<String> deleteById(@PathVariable("id") Integer id) throws Exception { | |||
| return genericsSuccess(this.imageService.removeById(id)); | |||
| } | |||
| @@ -131,8 +132,8 @@ public class ImageController extends BaseController { | |||
| @ApiOperation("从本地上传构建镜像") | |||
| public GenericsAjaxResult<Map<String, String>> createImageFromLocal(@RequestParam("name") String imageName, | |||
| @RequestParam("tag") String imageTag, | |||
| @RequestParam("path") String path) throws Exception { | |||
| return genericsSuccess(this.imageService.createImageFromLocal(imageName, imageTag, path)); | |||
| @RequestParam("fileName") String fileName) throws Exception { | |||
| return genericsSuccess(this.imageService.createImageFromLocal(imageName, imageTag, fileName)); | |||
| } | |||
| @@ -150,8 +151,9 @@ public class ImageController extends BaseController { | |||
| @PostMapping("/saveImage") | |||
| @ApiOperation(value = "保存环境为镜像", notes = "docker commit方式保存,并推送到horbor") | |||
| public void saveImage(@RequestBody ImageVo imageVo) { | |||
| public GenericsAjaxResult<String> saveImage(@RequestBody ImageVo imageVo) { | |||
| this.imageService.saveImage(imageVo); | |||
| return genericsSuccess("操作成功"); | |||
| } | |||
| } | |||
| @@ -89,8 +89,8 @@ public class ImageVersionController extends BaseController { | |||
| * @return 删除是否成功 | |||
| */ | |||
| @DeleteMapping("{id}") | |||
| public GenericsAjaxResult<String> deleteById(@PathVariable("id") Integer id) { | |||
| return genericsSuccess(this.imageVersionService.removeById(id)); | |||
| public GenericsAjaxResult<String> deleteById(@PathVariable("id") Integer id) throws Exception { | |||
| return this.imageVersionService.removeById(id); | |||
| } | |||
| } | |||
| @@ -6,9 +6,7 @@ import com.ruoyi.common.core.web.domain.GenericsAjaxResult; | |||
| import com.ruoyi.platform.domain.DevEnvironment; | |||
| import com.ruoyi.platform.service.JupyterService; | |||
| import com.ruoyi.platform.service.NewDatasetService; | |||
| import com.ruoyi.platform.vo.NewDatasetVo; | |||
| import com.ruoyi.platform.vo.PodStatusVo; | |||
| import com.ruoyi.platform.vo.VersionVo; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import io.swagger.v3.oas.annotations.responses.ApiResponse; | |||
| @@ -19,8 +17,6 @@ import java.io.File; | |||
| import java.io.FileInputStream; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping("/jupyter") | |||
| @@ -30,6 +26,7 @@ public class JupyterController extends BaseController { | |||
| private JupyterService jupyterService; | |||
| @Resource | |||
| private NewDatasetService newDatasetService; | |||
| @GetMapping(value = "/getURL") | |||
| @ApiOperation("得到访问地址") | |||
| public GenericsAjaxResult<String> getURL() throws IOException { | |||
| @@ -47,7 +44,7 @@ public class JupyterController extends BaseController { | |||
| @ApiOperation("根据开发环境id启动jupyter pod") | |||
| @ApiResponse | |||
| public GenericsAjaxResult<String> runJupyter(@PathVariable("id") Integer id) throws Exception { | |||
| return genericsSuccess(this.jupyterService.runJupyterService(id)); | |||
| return genericsSuccess(this.jupyterService.runJupyterService(id)); | |||
| } | |||
| @@ -68,7 +65,7 @@ public class JupyterController extends BaseController { | |||
| @ApiOperation("查询jupyter pod状态") | |||
| @ApiResponse | |||
| public GenericsAjaxResult<PodStatusVo> getStatus(DevEnvironment devEnvironment) throws Exception { | |||
| return genericsSuccess(this.jupyterService.getJupyterStatus(devEnvironment)); | |||
| return genericsSuccess(this.jupyterService.getJupyterStatus(devEnvironment)); | |||
| } | |||
| @@ -0,0 +1,61 @@ | |||
| package com.ruoyi.platform.controller.machineLearn; | |||
| import com.ruoyi.common.core.web.controller.BaseController; | |||
| import com.ruoyi.common.core.web.domain.GenericsAjaxResult; | |||
| import com.ruoyi.platform.domain.MachineLearn; | |||
| import com.ruoyi.platform.service.MachineLearnService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.springframework.data.domain.Page; | |||
| import org.springframework.data.domain.PageRequest; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.annotation.Resource; | |||
| @RestController | |||
| @RequestMapping("machineLearn") | |||
| @Api("自动机器学习") | |||
| public class MachineLearnController extends BaseController { | |||
| @Resource | |||
| private MachineLearnService machineLearnService; | |||
| @GetMapping | |||
| @ApiOperation("分页查询") | |||
| public GenericsAjaxResult<Page<MachineLearn>> queryByPage(@RequestParam("page") int page, | |||
| @RequestParam("size") int size, | |||
| @RequestParam(value = "name", required = false) String name, | |||
| @RequestParam(value = "type", required = false) String type) { | |||
| PageRequest pageRequest = PageRequest.of(page, size); | |||
| return genericsSuccess(this.machineLearnService.queryByPage(name, type, pageRequest)); | |||
| } | |||
| @PostMapping | |||
| @ApiOperation("新增自动机器学习") | |||
| public GenericsAjaxResult<MachineLearn> add(@RequestBody MachineLearn machineLearn) { | |||
| return genericsSuccess(this.machineLearnService.add(machineLearn)); | |||
| } | |||
| @PutMapping | |||
| @ApiOperation("编辑自动机器学习") | |||
| public GenericsAjaxResult<String> edit(@RequestBody MachineLearn machineLearn) throws Exception { | |||
| return genericsSuccess(this.machineLearnService.edit(machineLearn)); | |||
| } | |||
| @GetMapping("/getMLDetail") | |||
| @ApiOperation("获取自动机器学习详细信息") | |||
| public GenericsAjaxResult<MachineLearn> getMLDetail(@RequestParam("id") Long id) { | |||
| return genericsSuccess(this.machineLearnService.getMLDetail(id)); | |||
| } | |||
| @DeleteMapping("{id}") | |||
| @ApiOperation("删除自动机器学习") | |||
| public GenericsAjaxResult<String> delete(@PathVariable("id") Long id) { | |||
| return genericsSuccess(this.machineLearnService.delete(id)); | |||
| } | |||
| @PostMapping("/run/{id}") | |||
| @ApiOperation("运行自动机器学习") | |||
| public GenericsAjaxResult<String> runMachineLearn(@PathVariable("id") Long id) throws Exception { | |||
| return genericsSuccess(this.machineLearnService.runMachineLearn(id)); | |||
| } | |||
| } | |||
| @@ -0,0 +1,60 @@ | |||
| package com.ruoyi.platform.controller.machineLearn; | |||
| import com.ruoyi.common.core.web.controller.BaseController; | |||
| import com.ruoyi.common.core.web.domain.GenericsAjaxResult; | |||
| import com.ruoyi.platform.domain.MachineLearnIns; | |||
| import com.ruoyi.platform.service.MachineLearnInsService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import org.springframework.data.domain.Page; | |||
| import org.springframework.data.domain.PageRequest; | |||
| import javax.annotation.Resource; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping("machineLearnIns") | |||
| @Api("自动机器学习实验实例") | |||
| public class MachineLearnInsController extends BaseController { | |||
| @Resource | |||
| private MachineLearnInsService machineLearnInsService; | |||
| @GetMapping | |||
| @ApiOperation("分页查询") | |||
| public GenericsAjaxResult<Page<MachineLearnIns>> queryByPage(Long machineLearnId, int page, int size) { | |||
| PageRequest pageRequest = PageRequest.of(page, size); | |||
| return genericsSuccess(this.machineLearnInsService.queryByPage(machineLearnId, pageRequest)); | |||
| } | |||
| @PostMapping | |||
| @ApiOperation("新增实验实例") | |||
| public GenericsAjaxResult<MachineLearnIns> add(@RequestBody MachineLearnIns machineLearnIns) { | |||
| return genericsSuccess(this.machineLearnInsService.insert(machineLearnIns)); | |||
| } | |||
| @DeleteMapping("{id}") | |||
| @ApiOperation("删除实验实例") | |||
| public GenericsAjaxResult<String> deleteById(@PathVariable("id") Long id) { | |||
| return genericsSuccess(this.machineLearnInsService.removeById(id)); | |||
| } | |||
| @DeleteMapping("batchDelete") | |||
| @ApiOperation("批量删除实验实例") | |||
| public GenericsAjaxResult<String> batchDelete(@RequestBody List<Long> ids) { | |||
| return genericsSuccess(this.machineLearnInsService.batchDelete(ids)); | |||
| } | |||
| @PutMapping("{id}") | |||
| @ApiOperation("终止实验实例") | |||
| public GenericsAjaxResult<Boolean> terminateMLIns(@PathVariable("id") Long id) throws Exception { | |||
| return genericsSuccess(this.machineLearnInsService.terminateMLIns(id)); | |||
| } | |||
| @GetMapping("{id}") | |||
| @ApiOperation("查看实验实例详情") | |||
| public GenericsAjaxResult<MachineLearnIns> getDetailById(@PathVariable("id") Long id) { | |||
| return genericsSuccess(this.machineLearnInsService.getDetailById(id)); | |||
| } | |||
| } | |||
| @@ -23,11 +23,20 @@ public class MinioStorageController { | |||
| @Resource | |||
| private MinioService minioService; | |||
| @GetMapping("/downloadFile") | |||
| @ApiOperation("下载单个文件") | |||
| public ResponseEntity<InputStreamResource> downloadFile(@RequestParam("path") String path) throws Exception { | |||
| String bucketName = path.substring(0, path.indexOf("/")); | |||
| String prefix = path.substring(path.indexOf("/")+1,path.length()); | |||
| return minioService.downloadFile(bucketName, prefix); | |||
| } | |||
| @GetMapping("/download") | |||
| @ApiOperation(value = "minio存储下载", notes = "minio存储下载文件为zip包") | |||
| public ResponseEntity<InputStreamResource> downloadDataset(@RequestParam("path") String path) { | |||
| String bucketName = path.substring(0, path.indexOf("/")); | |||
| String prefix = path.substring(path.indexOf("/")+1,path.length())+"/"; | |||
| String prefix = path.substring(path.indexOf("/")+1,path.length()); | |||
| return minioService.downloadZipFile(bucketName,prefix); | |||
| } | |||
| @@ -1,7 +1,6 @@ | |||
| package com.ruoyi.platform.controller.model; | |||
| import com.ruoyi.common.core.web.domain.AjaxResult; | |||
| import com.ruoyi.platform.domain.ModelDependency1; | |||
| import com.ruoyi.platform.service.ModelsService; | |||
| import com.ruoyi.platform.vo.ModelsVo; | |||
| import com.ruoyi.platform.vo.QueryModelMetricsVo; | |||
| @@ -46,8 +45,8 @@ public class NewModelFromGitController { | |||
| @GetMapping("/downloadAllFiles") | |||
| @ApiOperation(value = "下载同一版本下所有模型,并打包") | |||
| public ResponseEntity<InputStreamResource> downloadAllDatasetFiles(@RequestParam("name") String name, @RequestParam("identifier") String identifier, @RequestParam("id") Integer id, @RequestParam("version") String version) throws Exception { | |||
| return modelsService.downloadAllModelFilesNew(name, identifier, id, version); | |||
| public ResponseEntity<InputStreamResource> downloadAllDatasetFiles(@RequestParam("name") String name, @RequestParam("identifier") String identifier, @RequestParam("id") Integer id, @RequestParam("version") String version, @RequestParam("is_public") Boolean isPublic) throws Exception { | |||
| return modelsService.downloadAllModelFilesNew(name, identifier, id, version, isPublic); | |||
| } | |||
| @GetMapping("/downloadSingleFile") | |||
| @@ -103,8 +102,8 @@ public class NewModelFromGitController { | |||
| @GetMapping("/getModelDetail") | |||
| @ApiOperation(value = "获取模型详细信息") | |||
| public AjaxResult getModelDetail(@RequestParam("id") Integer id, @RequestParam("identifier") String identifier, @RequestParam("owner") String owner, @RequestParam("version") String version) throws Exception { | |||
| return AjaxResult.success(this.modelsService.getModelDetail(id, identifier, owner, version)); | |||
| public AjaxResult getModelDetail(@RequestParam("id") Integer id, @RequestParam("identifier") String identifier, @RequestParam("owner") String owner, @RequestParam("version") String version, @RequestParam("is_public") Boolean isPublic) throws Exception { | |||
| return AjaxResult.success(this.modelsService.getModelDetail(id, identifier, owner, version, isPublic)); | |||
| } | |||
| @GetMapping("/getModelDependencyTree") | |||
| @@ -116,8 +115,8 @@ public class NewModelFromGitController { | |||
| @DeleteMapping("/delete") | |||
| @ApiOperation(value = "删除模型") | |||
| public AjaxResult deleteModel(@RequestParam("id") Integer id, @RequestParam("identifier") String identifier, | |||
| @RequestParam("owner") String owner) throws Exception { | |||
| this.modelsService.deleteModel(id, identifier, owner); | |||
| @RequestParam("owner") String owner, @RequestParam("is_public") Boolean isPublic) throws Exception { | |||
| this.modelsService.deleteModel(id, identifier, owner, isPublic); | |||
| return AjaxResult.success(); | |||
| } | |||
| @@ -133,4 +132,21 @@ public class NewModelFromGitController { | |||
| return AjaxResult.success(); | |||
| } | |||
| @PostMapping("/getVersionsCompare") | |||
| @ApiOperation(value = "获取模型版本对比") | |||
| public AjaxResult getVersionsCompare(@RequestBody QueryModelMetricsVo queryModelMetricsVo) throws Exception { | |||
| return AjaxResult.success(this.modelsService.getVersionsCompare(queryModelMetricsVo)); | |||
| } | |||
| @PostMapping("/praise/{id}") | |||
| @ApiOperation(value = "点赞一个项目") | |||
| public AjaxResult praise(@PathVariable("id") Integer id) throws Exception { | |||
| return AjaxResult.success(this.modelsService.praise(id)); | |||
| } | |||
| @DeleteMapping("/unpraise/{id}") | |||
| @ApiOperation(value = "取消点赞一个项目") | |||
| public AjaxResult unpraise(@PathVariable("id") Integer id) throws Exception { | |||
| return AjaxResult.success(this.modelsService.unpraise(id)); | |||
| } | |||
| } | |||
| @@ -0,0 +1,62 @@ | |||
| package com.ruoyi.platform.controller.ray; | |||
| import com.ruoyi.common.core.web.controller.BaseController; | |||
| import com.ruoyi.common.core.web.domain.GenericsAjaxResult; | |||
| import com.ruoyi.platform.domain.Ray; | |||
| import com.ruoyi.platform.service.RayService; | |||
| import com.ruoyi.platform.vo.RayVo; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.springframework.data.domain.Page; | |||
| import org.springframework.data.domain.PageRequest; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.annotation.Resource; | |||
| import java.io.IOException; | |||
| @RestController | |||
| @RequestMapping("ray") | |||
| @Api("自动超参数寻优") | |||
| public class RayController extends BaseController { | |||
| @Resource | |||
| private RayService rayService; | |||
| @GetMapping | |||
| @ApiOperation("分页查询") | |||
| public GenericsAjaxResult<Page<Ray>> queryByPage(@RequestParam("page") int page, | |||
| @RequestParam("size") int size, | |||
| @RequestParam(value = "name", required = false) String name) { | |||
| PageRequest pageRequest = PageRequest.of(page, size); | |||
| return genericsSuccess(this.rayService.queryByPage(name, pageRequest)); | |||
| } | |||
| @PostMapping | |||
| @ApiOperation("新增自动超参数寻优") | |||
| public GenericsAjaxResult<Ray> addRay(@RequestBody RayVo rayVo) throws Exception { | |||
| return genericsSuccess(this.rayService.save(rayVo)); | |||
| } | |||
| @PutMapping | |||
| @ApiOperation("编辑自动超参数寻优") | |||
| public GenericsAjaxResult<String> editRay(@RequestBody RayVo rayVo) throws Exception{ | |||
| return genericsSuccess(this.rayService.edit(rayVo)); | |||
| } | |||
| @GetMapping("/getRayDetail") | |||
| @ApiOperation("获取自动超参数寻优详细信息") | |||
| public GenericsAjaxResult<RayVo> getRayDetail(@RequestParam("id") Long id) throws IOException { | |||
| return genericsSuccess(this.rayService.getRayDetail(id)); | |||
| } | |||
| @DeleteMapping("{id}") | |||
| @ApiOperation("删除自动超参数寻优") | |||
| public GenericsAjaxResult<String> deleteRay(@PathVariable("id") Long id) { | |||
| return genericsSuccess(this.rayService.delete(id)); | |||
| } | |||
| @PostMapping("/run/{id}") | |||
| @ApiOperation("运行自动超参数寻优实验") | |||
| public GenericsAjaxResult<String> runRay(@PathVariable("id") Long id) throws Exception { | |||
| return genericsSuccess(this.rayService.runRayIns(id)); | |||
| } | |||
| } | |||
| @@ -0,0 +1,68 @@ | |||
| package com.ruoyi.platform.controller.ray; | |||
| import com.ruoyi.common.core.web.controller.BaseController; | |||
| import com.ruoyi.common.core.web.domain.GenericsAjaxResult; | |||
| import com.ruoyi.platform.domain.RayIns; | |||
| import com.ruoyi.platform.service.RayInsService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import io.swagger.v3.oas.annotations.responses.ApiResponse; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import org.springframework.data.domain.Page; | |||
| import org.springframework.data.domain.PageRequest; | |||
| import javax.annotation.Resource; | |||
| import java.io.IOException; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping("rayIns") | |||
| @Api("自动超参数寻优实验实例") | |||
| public class RayInsController extends BaseController { | |||
| @Resource | |||
| private RayInsService rayInsService; | |||
| @GetMapping | |||
| @ApiOperation("分页查询") | |||
| public GenericsAjaxResult<Page<RayIns>> queryByPage(Long rayId, int page, int size) throws IOException { | |||
| PageRequest pageRequest = PageRequest.of(page, size); | |||
| return genericsSuccess(this.rayInsService.queryByPage(rayId, pageRequest)); | |||
| } | |||
| @PostMapping | |||
| @ApiOperation("新增实验实例") | |||
| public GenericsAjaxResult<RayIns> add(@RequestBody RayIns rayIns) { | |||
| return genericsSuccess(this.rayInsService.insert(rayIns)); | |||
| } | |||
| @DeleteMapping("{id}") | |||
| @ApiOperation("删除实验实例") | |||
| public GenericsAjaxResult<String> deleteById(@PathVariable("id") Long id) { | |||
| return genericsSuccess(this.rayInsService.deleteById(id)); | |||
| } | |||
| @DeleteMapping("batchDelete") | |||
| @ApiOperation("批量删除实验实例") | |||
| public GenericsAjaxResult<String> batchDelete(@RequestBody List<Long> ids) { | |||
| return genericsSuccess(this.rayInsService.batchDelete(ids)); | |||
| } | |||
| @PutMapping("{id}") | |||
| @ApiOperation("终止实验实例") | |||
| public GenericsAjaxResult<Boolean> terminateRayIns(@PathVariable("id") Long id) throws Exception { | |||
| return genericsSuccess(this.rayInsService.terminateRayIns(id)); | |||
| } | |||
| @GetMapping("{id}") | |||
| @ApiOperation("查看实验实例详情") | |||
| public GenericsAjaxResult<RayIns> getDetailById(@PathVariable("id") Long id) throws Exception { | |||
| return genericsSuccess(this.rayInsService.getDetailById(id)); | |||
| } | |||
| @PostMapping("/getExpMetrics") | |||
| @ApiOperation("获取当前实验的指标对比地址") | |||
| @ApiResponse | |||
| public GenericsAjaxResult<String> getExpMetrics(@RequestBody String trailIds) throws Exception { | |||
| return genericsSuccess(rayInsService.getExpMetrics(trailIds)); | |||
| } | |||
| } | |||
| @@ -3,7 +3,9 @@ package com.ruoyi.platform.controller.resources; | |||
| import com.ruoyi.common.core.web.controller.BaseController; | |||
| import com.ruoyi.common.core.web.domain.GenericsAjaxResult; | |||
| import com.ruoyi.platform.domain.ComputingResource; | |||
| import com.ruoyi.platform.domain.ResourceOccupy; | |||
| import com.ruoyi.platform.service.ComputingResourceService; | |||
| import com.ruoyi.platform.service.ResourceOccupyService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.springframework.data.domain.Page; | |||
| @@ -11,6 +13,7 @@ import org.springframework.data.domain.PageRequest; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.annotation.Resource; | |||
| import java.util.Map; | |||
| /** | |||
| * (ComputingResource)表控制层 | |||
| @@ -28,6 +31,9 @@ public class ComputingResourceController extends BaseController { | |||
| @Resource | |||
| private ComputingResourceService computingResourceService; | |||
| @Resource | |||
| private ResourceOccupyService resourceOccupyService; | |||
| /** | |||
| * 分页查询 | |||
| * | |||
| @@ -36,12 +42,12 @@ public class ComputingResourceController extends BaseController { | |||
| */ | |||
| @GetMapping | |||
| @ApiOperation("分页查询") | |||
| public GenericsAjaxResult<Page<ComputingResource>> queryByPage(ComputingResource computingResource, @RequestParam("page") int page, | |||
| public GenericsAjaxResult<Page<ComputingResource>> queryByPage(ComputingResource computingResource, @RequestParam("page") int page, | |||
| @RequestParam("size") int size, | |||
| @RequestParam(value = "resource_type") String resourceType ) { | |||
| @RequestParam(value = "resource_type") String resourceType) { | |||
| computingResource.setComputingResource(resourceType); | |||
| PageRequest pageRequest = PageRequest.of(page,size); | |||
| return genericsSuccess(this.computingResourceService.queryByPage(computingResource, pageRequest)); | |||
| PageRequest pageRequest = PageRequest.of(page, size); | |||
| return genericsSuccess(this.computingResourceService.queryByPage(computingResource, pageRequest)); | |||
| } | |||
| /** | |||
| @@ -53,7 +59,7 @@ public class ComputingResourceController extends BaseController { | |||
| @GetMapping("{id}") | |||
| @ApiOperation("根据id查询") | |||
| public GenericsAjaxResult<ComputingResource> queryById(@PathVariable("id") Integer id) { | |||
| return genericsSuccess(this.computingResourceService.queryById(id)); | |||
| return genericsSuccess(this.computingResourceService.queryById(id)); | |||
| } | |||
| /** | |||
| @@ -65,7 +71,7 @@ public class ComputingResourceController extends BaseController { | |||
| @PostMapping | |||
| @ApiOperation("新增计算资源") | |||
| public GenericsAjaxResult<ComputingResource> add(@RequestBody ComputingResource computingResource) { | |||
| return genericsSuccess(this.computingResourceService.insert(computingResource)); | |||
| return genericsSuccess(this.computingResourceService.insert(computingResource)); | |||
| } | |||
| /** | |||
| @@ -77,7 +83,7 @@ public class ComputingResourceController extends BaseController { | |||
| @PutMapping | |||
| @ApiOperation("编辑计算资源") | |||
| public GenericsAjaxResult<ComputingResource> edit(@RequestBody ComputingResource computingResource) { | |||
| return genericsSuccess(this.computingResourceService.update(computingResource)); | |||
| return genericsSuccess(this.computingResourceService.update(computingResource)); | |||
| } | |||
| /** | |||
| @@ -89,8 +95,21 @@ public class ComputingResourceController extends BaseController { | |||
| @DeleteMapping("{id}") | |||
| @ApiOperation("删除计算资源") | |||
| public GenericsAjaxResult<String> deleteById(@PathVariable("id") Integer id) { | |||
| return genericsSuccess(this.computingResourceService.removeById(id)); | |||
| return genericsSuccess(this.computingResourceService.removeById(id)); | |||
| } | |||
| @GetMapping("/resouceOccupy") | |||
| @ApiOperation("分页查询用户资源使用情况") | |||
| public GenericsAjaxResult<Page<ResourceOccupy>> queryResourceOccupyByPage(@RequestParam("page") int page, | |||
| @RequestParam("size") int size) { | |||
| PageRequest pageRequest = PageRequest.of(page, size); | |||
| return genericsSuccess(resourceOccupyService.queryByPage(pageRequest)); | |||
| } | |||
| @GetMapping("/credit") | |||
| @ApiOperation("查询用户积分使用情况") | |||
| public GenericsAjaxResult<Map<String, Double>> queryCredit() { | |||
| return genericsSuccess(resourceOccupyService.queryCredit()); | |||
| } | |||
| } | |||
| @@ -61,7 +61,7 @@ public class ServiceController extends BaseController { | |||
| @PostMapping("/serviceVersion") | |||
| @ApiOperation("新增服务版本") | |||
| public GenericsAjaxResult<ServiceVersion> addServiceVersion(@RequestBody ServiceVersionVo serviceVersionVo) { | |||
| public GenericsAjaxResult<ServiceVersion> addServiceVersion(@RequestBody ServiceVersionVo serviceVersionVo) throws Exception { | |||
| return genericsSuccess(serviceService.addServiceVersion(serviceVersionVo)); | |||
| } | |||
| @@ -73,7 +73,7 @@ public class ServiceController extends BaseController { | |||
| @PutMapping("/serviceVersion") | |||
| @ApiOperation("编辑服务版本") | |||
| public GenericsAjaxResult<String> editServiceVersion(@RequestBody ServiceVersionVo serviceVersionVo) { | |||
| public GenericsAjaxResult<String> editServiceVersion(@RequestBody ServiceVersionVo serviceVersionVo) throws Exception { | |||
| return genericsSuccess(serviceService.editServiceVersion(serviceVersionVo)); | |||
| } | |||
| @@ -85,13 +85,13 @@ public class ServiceController extends BaseController { | |||
| @GetMapping("/serviceVersionDetail/{id}") | |||
| @ApiOperation("查询服务版本详细信息") | |||
| public GenericsAjaxResult<ServiceVersionVo> getServiceVersion(@PathVariable("id") Long id) { | |||
| public GenericsAjaxResult<ServiceVersionVo> getServiceVersion(@PathVariable("id") Long id) throws IOException { | |||
| return genericsSuccess(serviceService.getServiceVersion(id)); | |||
| } | |||
| @GetMapping("serviceVersionCompare") | |||
| @ApiOperation("服务版本版本对比") | |||
| public GenericsAjaxResult<Map<String, Object>> serviceVersionCompare(@RequestParam("id1") Long id1, @RequestParam("id2") Long id2) throws IllegalAccessException { | |||
| public GenericsAjaxResult<Map<String, Object>> serviceVersionCompare(@RequestParam("id1") Long id1, @RequestParam("id2") Long id2) throws IllegalAccessException, IOException { | |||
| return genericsSuccess(serviceService.serviceVersionCompare(id1, id2)); | |||
| } | |||
| @@ -103,7 +103,7 @@ public class ServiceController extends BaseController { | |||
| @DeleteMapping("{id}") | |||
| @ApiOperation("删除服务") | |||
| public GenericsAjaxResult<String> deleteService(@PathVariable("id") Long id) { | |||
| public GenericsAjaxResult<String> deleteService(@PathVariable("id") Long id) throws Exception { | |||
| return genericsSuccess(serviceService.deleteService(id)); | |||
| } | |||
| @@ -29,7 +29,7 @@ public class WorkspaceController extends BaseController { | |||
| @GetMapping("/assetCount") | |||
| @ApiOperation("得到AI资产计数") | |||
| public GenericsAjaxResult<Map<String, Integer>> getAssetCount(@RequestParam(value = "isPublic", | |||
| defaultValue = "true") Boolean isPublic) { | |||
| defaultValue = "true") Boolean isPublic) throws Exception { | |||
| return genericsSuccess(this.workspaceService.getAssetCount(isPublic)); | |||
| } | |||
| @@ -0,0 +1,113 @@ | |||
| package com.ruoyi.platform.domain; | |||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | |||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | |||
| import io.swagger.annotations.ApiModel; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Data; | |||
| import java.util.Date; | |||
| @Data | |||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | |||
| @ApiModel(description = "主动学习") | |||
| public class ActiveLearn { | |||
| private Long id; | |||
| @ApiModelProperty(value = "实验名称") | |||
| private String name; | |||
| @ApiModelProperty(value = "实验描述") | |||
| private String description; | |||
| @ApiModelProperty(value = "任务类型:classification或regression") | |||
| private String taskType; | |||
| @ApiModelProperty(value = "框架类型: sklearn, keras, pytorch") | |||
| private String frameworkType; | |||
| @ApiModelProperty(value = "代码配置") | |||
| private String codeConfig; | |||
| @ApiModelProperty(value = "预训练的模型") | |||
| private String model; | |||
| @ApiModelProperty(value = "模型文件路径") | |||
| private String modelPy; | |||
| @ApiModelProperty(value = "模型类名称") | |||
| private String modelClassName; | |||
| @ApiModelProperty(value = "分类算法") | |||
| private String classifierAlg; | |||
| @ApiModelProperty(value = "回归算法") | |||
| private String regressorAlg; | |||
| @ApiModelProperty(value = "dataset处理文件路径") | |||
| private String datasetPy; | |||
| @ApiModelProperty(value = "dataset类名") | |||
| private String datasetClassName; | |||
| @ApiModelProperty(value = "数据集") | |||
| private String dataset; | |||
| @ApiModelProperty(value = "数据量") | |||
| private Integer dataSize; | |||
| @ApiModelProperty(value = "镜像") | |||
| private String image; | |||
| @ApiModelProperty(value = "计算资源id") | |||
| private Integer computingResourceId; | |||
| @ApiModelProperty(value = "是否随机打乱") | |||
| private Boolean shuffle; | |||
| @ApiModelProperty(value = "训练集数据量") | |||
| private Integer trainSize; | |||
| @ApiModelProperty(value = "初始训练数据量") | |||
| private Integer initialNum; | |||
| @ApiModelProperty(value = "查询次数") | |||
| private Integer queriesNum; | |||
| @ApiModelProperty(value = "每次查询数据量") | |||
| private Integer instancesNum; | |||
| @ApiModelProperty(value = "查询策略:uncertainty_sampling, uncertainty_batch_sampling, max_std_sampling, expected_improvement, upper_confidence_bound") | |||
| private String queryStrategy; | |||
| @ApiModelProperty(value = "loss文件路径") | |||
| private String lossPy; | |||
| @ApiModelProperty(value = "loss类名") | |||
| private String lossClassName; | |||
| @ApiModelProperty(value = "多少轮查询保存一次模型参数") | |||
| private Integer checkpointNum; | |||
| @ApiModelProperty(value = "batch_size") | |||
| private Integer batchSize; | |||
| @ApiModelProperty(value = "epochs") | |||
| private Integer epochs; | |||
| @ApiModelProperty(value = "学习率") | |||
| private Float lr; | |||
| private String createBy; | |||
| private String updateBy; | |||
| private Date createTime; | |||
| private Date updateTime; | |||
| private Integer state; | |||
| @ApiModelProperty(value = "状态列表") | |||
| private String statusList; | |||
| } | |||
| @@ -0,0 +1,48 @@ | |||
| package com.ruoyi.platform.domain; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | |||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | |||
| import io.swagger.annotations.ApiModel; | |||
| import lombok.Data; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @Data | |||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | |||
| @ApiModel(description = "主动学习实验实例") | |||
| public class ActiveLearnIns { | |||
| private Long id; | |||
| private Long activeLearnId; | |||
| private Integer state; | |||
| private String status; | |||
| private String param; | |||
| private Date createTime; | |||
| private Date updateTime; | |||
| private Date finishTime; | |||
| private String argoInsName; | |||
| private String argoInsNs; | |||
| private String resultPath; | |||
| private String nodeStatus; | |||
| private String nodeResult; | |||
| @TableField(exist = false) | |||
| private String data; | |||
| @TableField(exist = false) | |||
| private List<Map<String, Object>> trialList; | |||
| } | |||
| @@ -0,0 +1,26 @@ | |||
| package com.ruoyi.platform.domain; | |||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | |||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | |||
| import io.swagger.annotations.ApiModel; | |||
| import lombok.Data; | |||
| @Data | |||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | |||
| @ApiModel(description = "AI资产-流水线引用关系") | |||
| public class AssetWorkflow { | |||
| private Long id; | |||
| private Long workflowId; | |||
| private String workflowName; | |||
| private Long assetId; | |||
| private String assetVersion; | |||
| private String type; | |||
| private Integer state; | |||
| } | |||
| @@ -0,0 +1,184 @@ | |||
| package com.ruoyi.platform.domain; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | |||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | |||
| import com.ruoyi.platform.vo.VersionVo; | |||
| import io.swagger.annotations.ApiModel; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Data; | |||
| import java.util.Date; | |||
| import java.util.Map; | |||
| @Data | |||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | |||
| @ApiModel(description = "自动机器学习") | |||
| public class AutoMl { | |||
| private Long id; | |||
| @ApiModelProperty(value = "实验名称") | |||
| private String mlName; | |||
| @ApiModelProperty(value = "实验描述") | |||
| private String mlDescription; | |||
| @ApiModelProperty(value = "任务类型:classification或regression") | |||
| private String taskType; | |||
| @ApiModelProperty(value = "搜索合适模型的时间限制(以秒为单位)。通过增加这个值,auto-sklearn有更高的机会找到更好的模型。默认3600,非必传。") | |||
| private Integer timeLeftForThisTask; | |||
| @ApiModelProperty(value = "单次调用机器学习模型的时间限制(以秒为单位)。如果机器学习算法运行超过时间限制,将终止模型拟合。将这个值设置得足够高,这样典型的机器学习算法就可以适用于训练数据。默认600,非必传。") | |||
| private Integer perRunTimeLimit; | |||
| @ApiModelProperty(value = "集成模型数量,如果设置为0,则没有集成。默认50,非必传。") | |||
| private Integer ensembleSize; | |||
| @ApiModelProperty(value = "设置为None将禁用集成构建,设置为SingleBest仅使用单个最佳模型而不是集成,设置为default,它将对单目标问题使用EnsembleSelection,对多目标问题使用MultiObjectiveDummyEnsemble。默认default,非必传。") | |||
| private String ensembleClass; | |||
| @ApiModelProperty(value = "在构建集成时只考虑ensemble_nbest模型。这是受到了“最大限度地利用集成选择”中引入的库修剪概念的启发。这是独立于ensemble_class参数的,并且这个修剪步骤是在构造集成之前完成的。默认50,非必传。") | |||
| private Integer ensembleNbest; | |||
| @ApiModelProperty(value = "定义在磁盘中保存的模型的最大数量。额外的模型数量将被永久删除。由于这个变量的性质,它设置了一个集成可以使用多少个模型的上限。必须是大于等于1的整数。如果设置为None,则所有模型都保留在磁盘上。默认50,非必传。") | |||
| private Integer maxModelsOnDisc; | |||
| @ApiModelProperty(value = "随机种子,将决定输出文件名。默认1,非必传。") | |||
| private Integer seed; | |||
| @ApiModelProperty(value = "机器学习算法的内存限制(MB)。如果auto-sklearn试图分配超过memory_limit MB,它将停止拟合机器学习算法。默认3072,非必传。") | |||
| private Integer memoryLimit; | |||
| @ApiModelProperty(value = "如果为None,则使用所有可能的分类算法。否则,指定搜索中包含的步骤和组件。有关可用组件,请参见/pipeline/components/<step>/*。与参数exclude不兼容。多选,逗号分隔。包含:adaboost\n" + | |||
| "bernoulli_nb\n" + | |||
| "decision_tree\n" + | |||
| "extra_trees\n" + | |||
| "gaussian_nb\n" + | |||
| "gradient_boosting\n" + | |||
| "k_nearest_neighbors\n" + | |||
| "lda\n" + | |||
| "liblinear_svc\n" + | |||
| "libsvm_svc\n" + | |||
| "mlp\n" + | |||
| "multinomial_nb\n" + | |||
| "passive_aggressive\n" + | |||
| "qda\n" + | |||
| "random_forest\n" + | |||
| "sgd") | |||
| private String includeClassifier; | |||
| @ApiModelProperty(value = "如果为None,则使用所有可能的特征预处理算法。否则,指定搜索中包含的步骤和组件。有关可用组件,请参见/pipeline/components/<step>/*。与参数exclude不兼容。多选,逗号分隔。包含:densifier\n" + | |||
| "extra_trees_preproc_for_classification\n" + | |||
| "extra_trees_preproc_for_regression\n" + | |||
| "fast_ica\n" + | |||
| "feature_agglomeration\n" + | |||
| "kernel_pca\n" + | |||
| "kitchen_sinks\n" + | |||
| "liblinear_svc_preprocessor\n" + | |||
| "no_preprocessing\n" + | |||
| "nystroem_sampler\n" + | |||
| "pca\n" + | |||
| "polynomial\n" + | |||
| "random_trees_embedding\n" + | |||
| "select_percentile_classification\n" + | |||
| "select_percentile_regression\n" + | |||
| "select_rates_classification\n" + | |||
| "select_rates_regression\n" + | |||
| "truncatedSVD") | |||
| private String includeFeaturePreprocessor; | |||
| @ApiModelProperty(value = "如果为None,则使用所有可能的回归算法。否则,指定搜索中包含的步骤和组件。有关可用组件,请参见/pipeline/components/<step>/*。与参数exclude不兼容。多选,逗号分隔。包含:adaboost,\n" + | |||
| "ard_regression,\n" + | |||
| "decision_tree,\n" + | |||
| "extra_trees,\n" + | |||
| "gaussian_process,\n" + | |||
| "gradient_boosting,\n" + | |||
| "k_nearest_neighbors,\n" + | |||
| "liblinear_svr,\n" + | |||
| "libsvm_svr,\n" + | |||
| "mlp,\n" + | |||
| "random_forest,\n" + | |||
| "sgd") | |||
| private String includeRegressor; | |||
| private String excludeClassifier; | |||
| private String excludeRegressor; | |||
| private String excludeFeaturePreprocessor; | |||
| @ApiModelProperty(value = "测试集的比率,0到1之间") | |||
| private Float testSize; | |||
| @ApiModelProperty(value = "如何处理过拟合,如果使用基于“cv”的方法或Splitter对象,可能需要使用resampling_strategy_arguments。holdout或crossValid") | |||
| private String resamplingStrategy; | |||
| @ApiModelProperty(value = "重采样划分训练集和验证集,训练集的比率,0到1之间") | |||
| private Float trainSize; | |||
| @ApiModelProperty(value = "拆分数据前是否进行shuffle") | |||
| private Boolean shuffle; | |||
| @ApiModelProperty(value = "交叉验证的折数,当resamplingStrategy为crossValid时,此项必填,为整数") | |||
| private Integer folds; | |||
| @ApiModelProperty(value = "文件夹存放配置输出和日志文件,默认/tmp/automl") | |||
| private String tmpFolder; | |||
| @ApiModelProperty(value = "数据集csv文件中哪几列是预测目标列,逗号分隔") | |||
| private String targetColumns; | |||
| @ApiModelProperty(value = "自定义指标名称") | |||
| private String metricName; | |||
| @ApiModelProperty(value = "模型优化目标指标及权重,json格式。分类的指标包含:accuracy\n" + | |||
| "balanced_accuracy\n" + | |||
| "roc_auc\n" + | |||
| "average_precision\n" + | |||
| "log_loss\n" + | |||
| "precision_macro\n" + | |||
| "precision_micro\n" + | |||
| "precision_samples\n" + | |||
| "precision_weighted\n" + | |||
| "recall_macro\n" + | |||
| "recall_micro\n" + | |||
| "recall_samples\n" + | |||
| "recall_weighted\n" + | |||
| "f1_macro\n" + | |||
| "f1_micro\n" + | |||
| "f1_samples\n" + | |||
| "f1_weighted\n" + | |||
| "回归的指标包含:mean_absolute_error\n" + | |||
| "mean_squared_error\n" + | |||
| "root_mean_squared_error\n" + | |||
| "mean_squared_log_error\n" + | |||
| "median_absolute_error\n" + | |||
| "r2") | |||
| private String metrics; | |||
| @ApiModelProperty(value = "指标优化方向,是越大越好还是越小越好") | |||
| private Boolean greaterIsBetter; | |||
| @ApiModelProperty(value = "模型计算并打印指标") | |||
| private String scoringFunctions; | |||
| private Integer state; | |||
| private String runState; | |||
| private Double progress; | |||
| private String createBy; | |||
| private Date createTime; | |||
| private String updateBy; | |||
| private Date updateTime; | |||
| private String dataset; | |||
| @ApiModelProperty(value = "状态列表") | |||
| private String statusList; | |||
| } | |||
| @@ -0,0 +1,50 @@ | |||
| package com.ruoyi.platform.domain; | |||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | |||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | |||
| import io.swagger.annotations.ApiModel; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Data; | |||
| import java.util.Date; | |||
| @Data | |||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | |||
| @ApiModel(description = "自动机器学习实验实例") | |||
| public class AutoMlIns { | |||
| private Long id; | |||
| private Long autoMlId; | |||
| private String resultPath; | |||
| private String modelPath; | |||
| private String imgPath; | |||
| private String runHistoryPath; | |||
| private Integer state; | |||
| private String status; | |||
| private String nodeStatus; | |||
| private String nodeResult; | |||
| private String param; | |||
| private String source; | |||
| @ApiModelProperty(value = "Argo实例名称") | |||
| private String argoInsName; | |||
| @ApiModelProperty(value = "Argo命名空间") | |||
| private String argoInsNs; | |||
| private Date createTime; | |||
| private Date updateTime; | |||
| private Date finishTime; | |||
| } | |||
| @@ -3,9 +3,10 @@ package com.ruoyi.platform.domain; | |||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | |||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Data; | |||
| import java.util.Date; | |||
| import java.io.Serializable; | |||
| import java.util.Date; | |||
| /** | |||
| * (ComputingResource)实体类 | |||
| @@ -14,13 +15,17 @@ import java.io.Serializable; | |||
| * @since 2023-11-29 14:23:01 | |||
| */ | |||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | |||
| @Data | |||
| public class ComputingResource implements Serializable { | |||
| private static final long serialVersionUID = -42500298368776666L; | |||
| /** | |||
| /** | |||
| * 主键 | |||
| */ | |||
| @ApiModelProperty(value = "编号", notes = "唯一标识符") | |||
| private Integer id; | |||
| @ApiModelProperty(value = "编号", notes = "唯一标识符") | |||
| private Integer id; | |||
| @ApiModelProperty("资源id") | |||
| private Integer resourceId; | |||
| @ApiModelProperty("计算资源的描述") | |||
| private String computingResource; | |||
| @@ -31,6 +36,24 @@ private Integer id; | |||
| @ApiModelProperty("资源的详细描述") | |||
| private String description; | |||
| @ApiModelProperty("cpu核数") | |||
| private Integer cpuCores; | |||
| @ApiModelProperty("内存大小GB") | |||
| private Integer memoryGb; | |||
| @ApiModelProperty("显存大小GB") | |||
| private Integer gpuMemoryGb; | |||
| @ApiModelProperty("GPU个数") | |||
| private Integer gpuNums; | |||
| @ApiModelProperty("积分/小时") | |||
| private Double creditPerHour; | |||
| @ApiModelProperty("标签") | |||
| private String labels; | |||
| @ApiModelProperty(value = "创建者的用户名", example = "admin") | |||
| private String createBy; | |||
| @@ -45,101 +68,5 @@ private Integer id; | |||
| @ApiModelProperty(value = "状态标识", notes = "0表示失效,1表示生效") | |||
| private Integer state; | |||
| @ApiModelProperty(value = "占用情况(1-占用,0-未占用)") | |||
| private Integer usedState; | |||
| @ApiModelProperty(value = "节点") | |||
| private String node; | |||
| public Integer getId() { | |||
| return id; | |||
| } | |||
| public void setId(Integer id) { | |||
| this.id = id; | |||
| } | |||
| public String getComputingResource() { | |||
| return computingResource; | |||
| } | |||
| public void setComputingResource(String computingResource) { | |||
| this.computingResource = computingResource; | |||
| } | |||
| public String getStandard() { | |||
| return standard; | |||
| } | |||
| public void setStandard(String standard) { | |||
| this.standard = standard; | |||
| } | |||
| public String getDescription() { | |||
| return description; | |||
| } | |||
| public void setDescription(String description) { | |||
| this.description = description; | |||
| } | |||
| public String getCreateBy() { | |||
| return createBy; | |||
| } | |||
| public void setCreateBy(String createBy) { | |||
| this.createBy = createBy; | |||
| } | |||
| public Date getCreateTime() { | |||
| return createTime; | |||
| } | |||
| public void setCreateTime(Date createTime) { | |||
| this.createTime = createTime; | |||
| } | |||
| public String getUpdateBy() { | |||
| return updateBy; | |||
| } | |||
| public void setUpdateBy(String updateBy) { | |||
| this.updateBy = updateBy; | |||
| } | |||
| public Date getUpdateTime() { | |||
| return updateTime; | |||
| } | |||
| public void setUpdateTime(Date updateTime) { | |||
| this.updateTime = updateTime; | |||
| } | |||
| public Integer getState() { | |||
| return state; | |||
| } | |||
| public void setState(Integer state) { | |||
| this.state = state; | |||
| } | |||
| public Integer getUsedState() { | |||
| return usedState; | |||
| } | |||
| public void setUsedState(Integer usedState) { | |||
| this.usedState = usedState; | |||
| } | |||
| public String getNode() { | |||
| return node; | |||
| } | |||
| public void setNode(String node) { | |||
| this.node = node; | |||
| } | |||
| } | |||
| @@ -1,5 +1,7 @@ | |||
| package com.ruoyi.platform.domain; | |||
| import lombok.Data; | |||
| import java.util.Date; | |||
| import java.io.Serializable; | |||
| @@ -9,11 +11,14 @@ import java.io.Serializable; | |||
| * @author makejava | |||
| * @since 2024-09-12 09:42:09 | |||
| */ | |||
| @Data | |||
| public class DatasetTempStorage implements Serializable { | |||
| private static final long serialVersionUID = -44025176874790480L; | |||
| private Integer id; | |||
| private Integer repoId; | |||
| private String name; | |||
| private String version; | |||
| @@ -31,79 +36,5 @@ public class DatasetTempStorage implements Serializable { | |||
| private String updateBy; | |||
| private Date updateTime; | |||
| public Integer getId() { | |||
| return id; | |||
| } | |||
| public void setId(Integer id) { | |||
| this.id = id; | |||
| } | |||
| public String getName() { | |||
| return name; | |||
| } | |||
| public void setName(String name) { | |||
| this.name = name; | |||
| } | |||
| public String getVersion() { | |||
| return version; | |||
| } | |||
| public void setVersion(String version) { | |||
| this.version = version; | |||
| } | |||
| public String getSource() { | |||
| return source; | |||
| } | |||
| public void setSource(String source) { | |||
| this.source = source; | |||
| } | |||
| public Integer getState() { | |||
| return state; | |||
| } | |||
| public void setState(Integer state) { | |||
| this.state = state; | |||
| } | |||
| public String getCreateBy() { | |||
| return createBy; | |||
| } | |||
| public void setCreateBy(String createBy) { | |||
| this.createBy = createBy; | |||
| } | |||
| public Date getCreateTime() { | |||
| return createTime; | |||
| } | |||
| public void setCreateTime(Date createTime) { | |||
| this.createTime = createTime; | |||
| } | |||
| public String getUpdateBy() { | |||
| return updateBy; | |||
| } | |||
| public void setUpdateBy(String updateBy) { | |||
| this.updateBy = updateBy; | |||
| } | |||
| public Date getUpdateTime() { | |||
| return updateTime; | |||
| } | |||
| public void setUpdateTime(Date updateTime) { | |||
| this.updateTime = updateTime; | |||
| } | |||
| } | |||
| @@ -2,6 +2,7 @@ package com.ruoyi.platform.domain; | |||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | |||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | |||
| import lombok.Data; | |||
| import java.util.Date; | |||
| import java.io.Serializable; | |||
| @@ -13,6 +14,7 @@ import java.io.Serializable; | |||
| * @since 2024-06-03 15:17:37 | |||
| */ | |||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | |||
| @Data | |||
| public class DevEnvironment implements Serializable { | |||
| private static final long serialVersionUID = 936999018935545992L; | |||
| /** | |||
| @@ -31,6 +33,9 @@ public class DevEnvironment implements Serializable { | |||
| * 计算资源 | |||
| */ | |||
| private String computingResource; | |||
| private Integer computingResourceId; | |||
| /** | |||
| * 资源规格 | |||
| */ | |||
| @@ -80,134 +85,5 @@ public class DevEnvironment implements Serializable { | |||
| */ | |||
| private Integer state; | |||
| public Integer getId() { | |||
| return id; | |||
| } | |||
| public void setId(Integer id) { | |||
| this.id = id; | |||
| } | |||
| public String getName() { | |||
| return name; | |||
| } | |||
| public void setName(String name) { | |||
| this.name = name; | |||
| } | |||
| public String getStatus() { | |||
| return status; | |||
| } | |||
| public void setStatus(String status) { | |||
| this.status = status; | |||
| } | |||
| public String getComputingResource() { | |||
| return computingResource; | |||
| } | |||
| public void setComputingResource(String computingResource) { | |||
| this.computingResource = computingResource; | |||
| } | |||
| public String getStandard() { | |||
| return standard; | |||
| } | |||
| public void setStandard(String standard) { | |||
| this.standard = standard; | |||
| } | |||
| public String getEnvVariable() { | |||
| return envVariable; | |||
| } | |||
| public void setEnvVariable(String envVariable) { | |||
| this.envVariable = envVariable; | |||
| } | |||
| public String getImage() { | |||
| return image; | |||
| } | |||
| public void setImage(String image) { | |||
| this.image = image; | |||
| } | |||
| public String getDataset() { | |||
| return dataset; | |||
| } | |||
| public void setDataset(String dataset) { | |||
| this.dataset = dataset; | |||
| } | |||
| public String getModel() { | |||
| return model; | |||
| } | |||
| public void setModel(String model) { | |||
| this.model = model; | |||
| } | |||
| public String getUrl() { | |||
| return url; | |||
| } | |||
| public void setUrl(String url) { | |||
| this.url = url; | |||
| } | |||
| public String getAltField2() { | |||
| return altField2; | |||
| } | |||
| public void setAltField2(String altField2) { | |||
| this.altField2 = altField2; | |||
| } | |||
| public String getCreateBy() { | |||
| return createBy; | |||
| } | |||
| public void setCreateBy(String createBy) { | |||
| this.createBy = createBy; | |||
| } | |||
| public Date getCreateTime() { | |||
| return createTime; | |||
| } | |||
| public void setCreateTime(Date createTime) { | |||
| this.createTime = createTime; | |||
| } | |||
| public String getUpdateBy() { | |||
| return updateBy; | |||
| } | |||
| public void setUpdateBy(String updateBy) { | |||
| this.updateBy = updateBy; | |||
| } | |||
| public Date getUpdateTime() { | |||
| return updateTime; | |||
| } | |||
| public void setUpdateTime(Date updateTime) { | |||
| this.updateTime = updateTime; | |||
| } | |||
| public Integer getState() { | |||
| return state; | |||
| } | |||
| public void setState(Integer state) { | |||
| this.state = state; | |||
| } | |||
| } | |||
| @@ -31,6 +31,9 @@ public class ImageVersion implements Serializable { | |||
| @ApiModelProperty(value = "镜像版本") | |||
| private String version; | |||
| @ApiModelProperty(value = "镜像版本描述") | |||
| private String description; | |||
| @ApiModelProperty(value = "镜像推送地址") | |||
| private String url; | |||
| @@ -0,0 +1,42 @@ | |||
| package com.ruoyi.platform.domain; | |||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | |||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | |||
| import io.swagger.annotations.ApiModel; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Data; | |||
| import java.util.Date; | |||
| @Data | |||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | |||
| @ApiModel(description = "机器学习") | |||
| public class MachineLearn { | |||
| private Long id; | |||
| private Long experimentId; | |||
| @ApiModelProperty(value = "类型") | |||
| private String type; | |||
| @ApiModelProperty(value = "实验名称") | |||
| private String name; | |||
| @ApiModelProperty(value = "实验描述") | |||
| private String description; | |||
| private String param; | |||
| private String createBy; | |||
| private Date createTime; | |||
| private String updateBy; | |||
| private Date updateTime; | |||
| private Integer state; | |||
| @ApiModelProperty(value = "状态列表") | |||
| private String statusList; | |||
| } | |||
| @@ -0,0 +1,51 @@ | |||
| package com.ruoyi.platform.domain; | |||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | |||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | |||
| import io.swagger.annotations.ApiModel; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Data; | |||
| import java.util.Date; | |||
| @Data | |||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | |||
| @ApiModel(description = "自动机器学习实验实例") | |||
| public class MachineLearnIns { | |||
| private Long id; | |||
| private Long machineLearnId; | |||
| private String type; | |||
| private String resultPath; | |||
| private String modelPath; | |||
| private String imgPath; | |||
| private String runHistoryPath; | |||
| private Integer state; | |||
| private String status; | |||
| private String nodeStatus; | |||
| private String nodeResult; | |||
| private String param; | |||
| @ApiModelProperty(value = "Argo实例名称") | |||
| private String argoInsName; | |||
| @ApiModelProperty(value = "Argo命名空间") | |||
| private String argoInsNs; | |||
| private Date createTime; | |||
| private Date updateTime; | |||
| private Date finishTime; | |||
| } | |||
| @@ -0,0 +1,84 @@ | |||
| package com.ruoyi.platform.domain; | |||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | |||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | |||
| import io.swagger.annotations.ApiModel; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Data; | |||
| import java.util.Date; | |||
| @Data | |||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | |||
| @ApiModel(description = "自动超参数寻优") | |||
| public class Ray { | |||
| private Long id; | |||
| @ApiModelProperty(value = "实验名称") | |||
| private String name; | |||
| @ApiModelProperty(value = "实验描述") | |||
| private String description; | |||
| @ApiModelProperty(value = "数据集") | |||
| private String dataset; | |||
| @ApiModelProperty(value = "数据集挂载路径") | |||
| private String model; | |||
| @ApiModelProperty(value = "代码配置") | |||
| private String codeConfig; | |||
| @ApiModelProperty(value = "镜像") | |||
| private String image; | |||
| @ApiModelProperty(value = "主函数代码文件") | |||
| private String mainPy; | |||
| @ApiModelProperty(value = "总实验次数") | |||
| private Integer numSamples; | |||
| @ApiModelProperty(value = "参数") | |||
| private String parameters; | |||
| @ApiModelProperty(value = "手动指定需要运行的参数") | |||
| private String pointsToEvaluate; | |||
| @ApiModelProperty(value = "保存路径") | |||
| private String storagePath; | |||
| @ApiModelProperty(value = "搜索算法") | |||
| private String searchAlg; | |||
| @ApiModelProperty(value = "调度算法") | |||
| private String scheduler; | |||
| @ApiModelProperty(value = "指标") | |||
| private String metric; | |||
| @ApiModelProperty(value = "指标最大化或最小化,min or max") | |||
| private String mode; | |||
| @ApiModelProperty(value = "搜索算法为ASHA,HyperBand时传入,每次试验的最大时间单位。测试将在max_t时间单位后停止。") | |||
| private Integer maxT; | |||
| @ApiModelProperty(value = "搜索算法为MedianStopping时传入,计算中位数的最小试验数。") | |||
| private Integer minSamplesRequired; | |||
| private String resource; | |||
| private Integer computingResourceId; | |||
| private Integer state; | |||
| private String createBy; | |||
| private String updateBy; | |||
| private Date createTime; | |||
| private Date updateTime; | |||
| @ApiModelProperty(value = "状态列表") | |||
| private String statusList; | |||
| } | |||
| @@ -0,0 +1,55 @@ | |||
| package com.ruoyi.platform.domain; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | |||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | |||
| import io.swagger.annotations.ApiModel; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Data; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @Data | |||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | |||
| @ApiModel(description = "自动超参数寻优实验实例") | |||
| public class RayIns { | |||
| private Long id; | |||
| private Long rayId; | |||
| private String resultPath; | |||
| private Integer state; | |||
| private String status; | |||
| private String nodeStatus; | |||
| private String nodeResult; | |||
| private String param; | |||
| private String source; | |||
| @ApiModelProperty(value = "Argo实例名称") | |||
| private String argoInsName; | |||
| @ApiModelProperty(value = "Argo命名空间") | |||
| private String argoInsNs; | |||
| private Date createTime; | |||
| private Date updateTime; | |||
| private Date finishTime; | |||
| @TableField(exist = false) | |||
| private String resultTxt; | |||
| @TableField(exist = false) | |||
| private ArrayList<Map<String, Object>> trialList; | |||
| } | |||
| @@ -0,0 +1,25 @@ | |||
| package com.ruoyi.platform.domain; | |||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | |||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Data; | |||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | |||
| @Data | |||
| public class Resource { | |||
| @ApiModelProperty(value = "编号", notes = "唯一标识符") | |||
| private Integer id; | |||
| @ApiModelProperty("类型") | |||
| private String type; | |||
| @ApiModelProperty("gpu") | |||
| private String gpu; | |||
| @ApiModelProperty("总数") | |||
| private Integer total; | |||
| @ApiModelProperty("已被占用的数量") | |||
| private Integer used; | |||
| } | |||
| @@ -0,0 +1,60 @@ | |||
| package com.ruoyi.platform.domain; | |||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | |||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Data; | |||
| import java.util.Date; | |||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | |||
| @Data | |||
| public class ResourceOccupy { | |||
| @ApiModelProperty(value = "编号", notes = "唯一标识符") | |||
| private Integer id; | |||
| @ApiModelProperty("用户") | |||
| private Long userId; | |||
| @ApiModelProperty("计算资源") | |||
| private Integer computingResourceId; | |||
| @ApiModelProperty("描述") | |||
| private String description; | |||
| @ApiModelProperty("积分/小时") | |||
| private Double creditPerHour; | |||
| @ApiModelProperty("扣除的积分") | |||
| private Double deduceCredit; | |||
| @ApiModelProperty("上一次扣分时间") | |||
| private Date deduceLastTime; | |||
| @ApiModelProperty("状态") | |||
| private Integer state; | |||
| @ApiModelProperty("开始时间") | |||
| private Date startTime; | |||
| @ApiModelProperty("任务类型") | |||
| private String taskType; | |||
| @ApiModelProperty("任务id") | |||
| private Long taskId; | |||
| @ApiModelProperty("任务id") | |||
| private Long taskInsId; | |||
| @ApiModelProperty("流水线id") | |||
| private Long workflowId; | |||
| @ApiModelProperty("流水线节点id") | |||
| private String nodeId; | |||
| @ApiModelProperty("任务名称") | |||
| private String taskName; | |||
| @ApiModelProperty("任务状态") | |||
| private Integer taskState; | |||
| } | |||
| @@ -26,6 +26,8 @@ public class ServiceVersion implements Serializable { | |||
| private String resource; | |||
| private Integer computingResourceId; | |||
| private Integer replicas; | |||
| private String mountPath; | |||
| @@ -53,4 +55,6 @@ public class ServiceVersion implements Serializable { | |||
| private String deploymentName; | |||
| private String svcName; | |||
| private String deployType; | |||
| } | |||
| @@ -0,0 +1,29 @@ | |||
| package com.ruoyi.platform.mapper; | |||
| import com.ruoyi.platform.domain.ActiveLearn; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import org.springframework.data.domain.PageRequest; | |||
| import java.util.List; | |||
| public interface ActiveLearnDao { | |||
| long count(@Param("name") String name); | |||
| List<ActiveLearn> queryByPage(@Param("name") String name, @Param("pageable") PageRequest pageRequest); | |||
| ActiveLearn getActiveLearnByName(@Param("name") String name); | |||
| int save(@Param("activeLearn") ActiveLearn activeLearn); | |||
| int edit(@Param("activeLearn") ActiveLearn activeLearn); | |||
| ActiveLearn getActiveLearnById(@Param("id") Long id); | |||
| List<ActiveLearn> queryByDatasetId(@Param("datasetId") String datasetId); | |||
| List<ActiveLearn> queryByModelId(@Param("modelId") String modelId); | |||
| List<ActiveLearn> queryByImageId(@Param("imageId") String imageId); | |||
| List<ActiveLearn> queryByCodeConfig(@Param("codeConfig") String codeConfig); | |||
| } | |||
| @@ -0,0 +1,23 @@ | |||
| package com.ruoyi.platform.mapper; | |||
| import com.ruoyi.platform.domain.ActiveLearnIns; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import org.springframework.data.domain.Pageable; | |||
| import java.util.List; | |||
| public interface ActiveLearnInsDao { | |||
| long count(@Param("activeLearnId") Long activeLearnId); | |||
| List<ActiveLearnIns> queryAllByLimit(@Param("activeLearnId") Long activeLearnId, @Param("pageable") Pageable pageable); | |||
| int insert(@Param("activeLearnIns") ActiveLearnIns activeLearnIns); | |||
| int update(@Param("activeLearnIns") ActiveLearnIns activeLearnIns); | |||
| ActiveLearnIns queryById(@Param("id") Long id); | |||
| List<ActiveLearnIns> getByActiveLearnId(@Param("activeLearnId") Long activeLearnId); | |||
| List<ActiveLearnIns> queryActiveLearnInsIsNotTerminated(); | |||
| } | |||
| @@ -0,0 +1,15 @@ | |||
| package com.ruoyi.platform.mapper; | |||
| import com.ruoyi.platform.domain.AssetWorkflow; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import java.util.List; | |||
| public interface AssetWorkflowDao { | |||
| List<AssetWorkflow> getAssetWorkflow(@Param("assetId") Long assetId, @Param("type") String type, @Param("assetVersion") String assetVersion); | |||
| int insert(@Param("assetWorkflow") AssetWorkflow assetWorkflow); | |||
| int deleteByWorkFlowId(@Param("workflowId") Long workflowId); | |||
| } | |||
| @@ -0,0 +1,23 @@ | |||
| package com.ruoyi.platform.mapper; | |||
| import com.ruoyi.platform.domain.AutoMl; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import org.springframework.data.domain.Pageable; | |||
| import java.util.List; | |||
| public interface AutoMlDao { | |||
| long count(@Param("mlName") String mlName); | |||
| List<AutoMl> queryByPage(@Param("mlName") String mlName, @Param("pageable") Pageable pageable); | |||
| AutoMl getAutoMlById(@Param("id") Long id); | |||
| AutoMl getAutoMlByName(@Param("mlName") String mlName); | |||
| int save(@Param("autoMl") AutoMl autoMl); | |||
| int edit(@Param("autoMl") AutoMl autoMl); | |||
| List<AutoMl> queryByDatasetId(@Param("datasetId") String datasetId); | |||
| } | |||
| @@ -0,0 +1,23 @@ | |||
| package com.ruoyi.platform.mapper; | |||
| import com.ruoyi.platform.domain.AutoMlIns; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import org.springframework.data.domain.Pageable; | |||
| import java.util.List; | |||
| public interface AutoMlInsDao { | |||
| long count(@Param("autoMlIns") AutoMlIns autoMlIns); | |||
| List<AutoMlIns> queryAllByLimit(@Param("autoMlIns") AutoMlIns autoMlIns, @Param("pageable") Pageable pageable); | |||
| List<AutoMlIns> getByAutoMlId(@Param("autoMlId") Long AutoMlId); | |||
| int insert(@Param("autoMlIns") AutoMlIns autoMlIns); | |||
| int update(@Param("autoMlIns") AutoMlIns autoMlIns); | |||
| AutoMlIns queryById(@Param("id") Long id); | |||
| List<AutoMlIns> queryByAutoMlInsIsNotTerminated(); | |||
| } | |||
| @@ -73,8 +73,6 @@ public interface ComputingResourceDao { | |||
| */ | |||
| int update(@Param("computingResource") ComputingResource computingResource); | |||
| int updateUsedStateByNode(@Param("node")String node, @Param("usedState") Integer usedState); | |||
| /** | |||
| * 通过主键删除数据 | |||
| * | |||
| @@ -46,24 +46,6 @@ public interface DevEnvironmentDao { | |||
| */ | |||
| int insert(@Param("devEnvironment") DevEnvironment devEnvironment); | |||
| /** | |||
| * 批量新增数据(MyBatis原生foreach方法) | |||
| * | |||
| * @param entities List<DevEnvironment> 实例对象列表 | |||
| * @return 影响行数 | |||
| */ | |||
| int insertBatch(@Param("entities") List<DevEnvironment> entities); | |||
| /** | |||
| * 批量新增或按主键更新数据(MyBatis原生foreach方法) | |||
| * | |||
| * @param entities List<DevEnvironment> 实例对象列表 | |||
| * | |||
| * @return 影响行数 | |||
| * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参 | |||
| */ | |||
| int insertOrUpdateBatch(@Param("entities") List<DevEnvironment> entities); | |||
| /** | |||
| * 修改数据 | |||
| * | |||
| @@ -80,5 +62,14 @@ public interface DevEnvironmentDao { | |||
| */ | |||
| int deleteById(Integer id); | |||
| DevEnvironment getByName(@Param("name") String name); | |||
| List<DevEnvironment> getRunning(); | |||
| List<DevEnvironment> queryByDatasetId(@Param("datasetId") String datasetId); | |||
| List<DevEnvironment> queryByModelId(@Param("modelId") String modelId); | |||
| List<DevEnvironment> queryByImageId(@Param("imageId") String imageId); | |||
| } | |||
| @@ -81,5 +81,6 @@ public interface ImageVersionDao { | |||
| List<ImageVersion> queryByImageId(Integer imageId); | |||
| ImageVersion queryByUrl(String url); | |||
| } | |||
| @@ -0,0 +1,23 @@ | |||
| package com.ruoyi.platform.mapper; | |||
| import com.ruoyi.platform.domain.MachineLearn; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import org.springframework.data.domain.Pageable; | |||
| import java.util.List; | |||
| public interface MachineLearnDao { | |||
| long count(@Param("name") String name, @Param("type") String type); | |||
| List<MachineLearn> queryByPage(@Param("name") String name, @Param("type") String type, @Param("pageable") Pageable pageable); | |||
| int save(@Param("machineLearn") MachineLearn machineLearn); | |||
| int edit(@Param("machineLearn") MachineLearn machineLearn); | |||
| MachineLearn getMachineLearnById(@Param("id") Long id); | |||
| MachineLearn getMachineLearnByName(@Param("name") String name); | |||
| List<MachineLearn> queryByDatasetId(@Param("datasetId") String datasetId); | |||
| } | |||
| @@ -0,0 +1,23 @@ | |||
| package com.ruoyi.platform.mapper; | |||
| import com.ruoyi.platform.domain.MachineLearnIns; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import org.springframework.data.domain.Pageable; | |||
| import java.util.List; | |||
| public interface MachineLearnInsDao { | |||
| long count(@Param("machineLearnId") Long machineLearnId); | |||
| List<MachineLearnIns> queryAllByLimit(@Param("machineLearnId") Long machineLearnId, @Param("pageable") Pageable pageable); | |||
| List<MachineLearnIns> getByMachineLearnId(@Param("machineLearnId") Long machineLearnId); | |||
| int insert(@Param("machineLearnIns") MachineLearnIns machineLearnIns); | |||
| int update(@Param("machineLearnIns") MachineLearnIns machineLearnIns); | |||
| MachineLearnIns queryById(@Param("id") Long id); | |||
| List<MachineLearnIns> queryNotTerminated(); | |||
| } | |||
| @@ -25,6 +25,8 @@ public interface ModelDependency1Dao { | |||
| int deleteModel(@Param("repoId") Integer repoId, @Param("identifier") String identifier, @Param("owner") String owner, @Param("version") String version); | |||
| int deleteModelById(@Param("id") Long id); | |||
| int deleteModelDependency(@Param("parentModel") String parentModel); | |||
| String getMeta(@Param("identifier") String identifier, @Param("owner") String owner, @Param("version") String version); | |||
| @@ -0,0 +1,29 @@ | |||
| package com.ruoyi.platform.mapper; | |||
| import com.ruoyi.platform.domain.Ray; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import org.springframework.data.domain.PageRequest; | |||
| import java.util.List; | |||
| public interface RayDao { | |||
| long count(@Param("name") String name); | |||
| List<Ray> queryByPage(@Param("name") String name, @Param("pageable") PageRequest pageRequest); | |||
| Ray getRayByName(@Param("name") String name); | |||
| Ray getRayById(@Param("id") Long id); | |||
| int save(@Param("ray") Ray ray); | |||
| int edit(@Param("ray") Ray ray); | |||
| List<Ray> queryByDatasetId(@Param("datasetId") String datasetId); | |||
| List<Ray> queryByModelId(@Param("modelId") String modelId); | |||
| List<Ray> queryByImageId(@Param("imageId") String imageId); | |||
| List<Ray> queryByCodeConfig(@Param("codeConfig") String codeConfig); | |||
| } | |||
| @@ -0,0 +1,23 @@ | |||
| package com.ruoyi.platform.mapper; | |||
| import com.ruoyi.platform.domain.RayIns; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import org.springframework.data.domain.Pageable; | |||
| import java.util.List; | |||
| public interface RayInsDao { | |||
| long count(@Param("rayId") Long rayId); | |||
| List<RayIns> queryAllByLimit(@Param("rayId") Long rayId, @Param("pageable") Pageable pageable); | |||
| RayIns queryById(@Param("id") Long id); | |||
| List<RayIns> getByRayId(@Param("rayId") Long rayId); | |||
| int insert(@Param("rayIns") RayIns rayIns); | |||
| int update(@Param("rayIns") RayIns rayIns); | |||
| List<RayIns> queryByRayInsIsNotTerminated(); | |||
| } | |||
| @@ -0,0 +1,34 @@ | |||
| package com.ruoyi.platform.mapper; | |||
| import com.ruoyi.platform.domain.ResourceOccupy; | |||
| import org.apache.ibatis.annotations.Param; | |||
| import org.springframework.data.domain.Pageable; | |||
| import java.util.List; | |||
| public interface ResourceOccupyDao { | |||
| Boolean haveResource(@Param("id") Integer id, @Param("need") Integer need); | |||
| int save(@Param("resourceOccupy") ResourceOccupy resourceOccupy); | |||
| int edit(@Param("resourceOccupy") ResourceOccupy resourceOccupy); | |||
| List<ResourceOccupy> getResourceOccupyByTask(@Param("taskType") String taskType, @Param("taskId") Long taskId, @Param("taskInsId") Long taskInsId, @Param("nodeId") String nodeId); | |||
| int deduceCredit(@Param("credit") Double credit, @Param("userId") Long userId); | |||
| int updateUsed(@Param("id") Integer id, @Param("used") Integer used); | |||
| int updateUnUsed(@Param("id") Integer id, @Param("used") Integer used); | |||
| long count(@Param("userId") Long userId); | |||
| List<ResourceOccupy> queryByPage(@Param("userId") Long userId, @Param("pageable") Pageable pageable); | |||
| Double getUserCredit(@Param("userId") Long userId); | |||
| Double getDeduceCredit(@Param("userId") Long userId); | |||
| int deleteTaskState(@Param("taskType") String taskType, @Param("taskId") Long taskId, @Param("taskInsId") Long taskInsId); | |||
| } | |||
| @@ -36,4 +36,12 @@ public interface ServiceDao { | |||
| Service getServiceByName(@Param("serviceName") String serviceName); | |||
| ServiceVersion getSvByVersion(@Param("version") String version, @Param("serviceId") Long serviceId); | |||
| List<ServiceVersion> getRunning(); | |||
| List<String> queryByModelId(@Param("modelId") String modelId); | |||
| List<String> queryByImageId(@Param("imageId") String imageId); | |||
| List<String> queryByCodeConfig(@Param("codeConfig") String codeConfig); | |||
| } | |||
| @@ -85,14 +85,6 @@ public interface WorkflowDao { | |||
| */ | |||
| int update(@Param("workflow") Workflow workflow); | |||
| /** | |||
| * 通过主键删除数据 | |||
| * | |||
| * @param id 主键 | |||
| * @return 影响行数 | |||
| */ | |||
| int deleteById(Long id); | |||
| /** | |||
| * 通过名字模糊查询 | |||
| * | |||
| @@ -0,0 +1,116 @@ | |||
| package com.ruoyi.platform.scheduling; | |||
| import com.ruoyi.platform.domain.ActiveLearn; | |||
| import com.ruoyi.platform.domain.ActiveLearnIns; | |||
| import com.ruoyi.platform.mapper.ActiveLearnDao; | |||
| import com.ruoyi.platform.mapper.ActiveLearnInsDao; | |||
| import com.ruoyi.platform.mapper.ResourceOccupyDao; | |||
| import com.ruoyi.platform.service.ActiveLearnInsService; | |||
| import com.ruoyi.platform.service.ResourceOccupyService; | |||
| import com.ruoyi.system.api.constant.Constant; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.springframework.scheduling.annotation.Scheduled; | |||
| import org.springframework.stereotype.Component; | |||
| import javax.annotation.Resource; | |||
| import java.util.ArrayList; | |||
| import java.util.Iterator; | |||
| import java.util.List; | |||
| @Component() | |||
| public class ActiveLearnInsStatusTask { | |||
| @Resource | |||
| private ActiveLearnInsService activeLearnInsService; | |||
| @Resource | |||
| private ActiveLearnInsDao activeLearnInsDao; | |||
| @Resource | |||
| private ActiveLearnDao activeLearnDao; | |||
| @Resource | |||
| private ResourceOccupyDao resourceOccupyDao; | |||
| @Resource | |||
| private ResourceOccupyService resourceOccupyService; | |||
| private List<Long> activeLearnIds = new ArrayList<>(); | |||
| @Scheduled(cron = "0/30 * * * * ?") // 每30S执行一次 | |||
| public void executeActiveLearnInsStatus() { | |||
| List<ActiveLearnIns> activeLearnInsList = activeLearnInsService.queryActiveLearnInsIsNotTerminated(); | |||
| // 去argo查询状态 | |||
| List<ActiveLearnIns> updateList = new ArrayList<>(); | |||
| if (activeLearnInsList != null && activeLearnInsList.size() > 0) { | |||
| for (ActiveLearnIns activeLearnIns : activeLearnInsList) { | |||
| //当原本状态为null或非终止态时才调用argo接口 | |||
| try { | |||
| Long userId = resourceOccupyDao.getResourceOccupyByTask(Constant.TaskType_ActiveLearn, activeLearnIns.getActiveLearnId(), activeLearnIns.getId(), null).get(0).getUserId(); | |||
| if (resourceOccupyDao.getUserCredit(userId) <= 0) { | |||
| activeLearnIns.setStatus(Constant.Failed); | |||
| activeLearnInsService.terminateActiveLearnIns(activeLearnIns.getId()); | |||
| } else { | |||
| activeLearnIns = activeLearnInsService.queryStatusFromArgo(activeLearnIns); | |||
| // 扣除积分 | |||
| if (Constant.Running.equals(activeLearnIns.getStatus())) { | |||
| resourceOccupyService.deducing(Constant.TaskType_ActiveLearn, null, activeLearnIns.getId(), null, null); | |||
| } else if (Constant.Failed.equals(activeLearnIns.getStatus()) || Constant.Terminated.equals(activeLearnIns.getStatus()) | |||
| || Constant.Succeeded.equals(activeLearnIns.getStatus())) { | |||
| resourceOccupyService.endDeduce(Constant.TaskType_ActiveLearn, null, activeLearnIns.getId(), null, null); | |||
| } | |||
| } | |||
| } catch (Exception e) { | |||
| activeLearnIns.setStatus(Constant.Failed); | |||
| // 结束扣除积分 | |||
| resourceOccupyService.endDeduce(Constant.TaskType_ActiveLearn, null, activeLearnIns.getId(), null, null); | |||
| } | |||
| // 线程安全的添加操作 | |||
| synchronized (activeLearnIds) { | |||
| activeLearnIds.add(activeLearnIns.getActiveLearnId()); | |||
| } | |||
| updateList.add(activeLearnIns); | |||
| } | |||
| if (updateList.size() > 0) { | |||
| for (ActiveLearnIns activeLearnIns : updateList) { | |||
| activeLearnInsDao.update(activeLearnIns); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @Scheduled(cron = "0/30 * * * * ?") // / 每30S执行一次 | |||
| public void executeActiveLearnStatus() { | |||
| if (activeLearnIds.size() == 0) { | |||
| return; | |||
| } | |||
| // 存储需要更新的实验对象列表 | |||
| List<ActiveLearn> updateActiveLearns = new ArrayList<>(); | |||
| for (Long activeLearnId : activeLearnIds) { | |||
| // 获取当前实验的所有实例列表 | |||
| List<ActiveLearnIns> insList = activeLearnInsDao.getByActiveLearnId(activeLearnId); | |||
| List<String> statusList = new ArrayList<>(); | |||
| // 更新实验状态列表 | |||
| for (int i = 0; i < insList.size(); i++) { | |||
| statusList.add(insList.get(i).getStatus()); | |||
| } | |||
| String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); | |||
| ActiveLearn activeLearn = activeLearnDao.getActiveLearnById(activeLearnId); | |||
| if (!StringUtils.equals(activeLearn.getStatusList(), subStatus)) { | |||
| activeLearn.setStatusList(subStatus); | |||
| updateActiveLearns.add(activeLearn); | |||
| activeLearnDao.edit(activeLearn); | |||
| } | |||
| } | |||
| if (!updateActiveLearns.isEmpty()) { | |||
| // 使用Iterator进行安全的删除操作 | |||
| Iterator<Long> iterator = activeLearnIds.iterator(); | |||
| while (iterator.hasNext()) { | |||
| Long activeLearnId = iterator.next(); | |||
| for (ActiveLearn activeLearn : updateActiveLearns) { | |||
| if (activeLearn.getId().equals(activeLearnId)) { | |||
| iterator.remove(); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||