From 7403e2fb5c7e1d9c98e7fa82b0a2a02e839263b4 Mon Sep 17 00:00:00 2001 From: qz_cx Date: Fri, 17 Oct 2025 14:08:54 +0800 Subject: [PATCH 1/2] Add machine usage completion function --- appStore/api/router.py | 8 +- appStore/testMachine/models.py | 9 +- appStore/testMachine/views.py | 27 ++++-- templates/front-project/src/api/api.js | 66 +++++++++++---- .../src/views/machineViews/ServerList.vue | 83 +++++++++++-------- 5 files changed, 120 insertions(+), 73 deletions(-) diff --git a/appStore/api/router.py b/appStore/api/router.py index 7eaf21b..f4c8343 100644 --- a/appStore/api/router.py +++ b/appStore/api/router.py @@ -1,10 +1,3 @@ -""" - * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. - * PilotGo-plugin licensed under the Mulan Permissive Software License, Version 2. - * See LICENSE file for more details. - * Author: wangqingzheng - * Date: Fri Feb 23 11:19:26 2024 +0800 -""" from django.conf.urls import url, include from rest_framework import routers @@ -48,6 +41,7 @@ urlpatterns = [ url(r'', include(router.urls)), url('^apply_use_machine/', TestMachineViewSet.as_view({'post': 'apply_use_machine'}), name='apply_use_machine'), url('^cancel_apply_use_machine/', TestMachineViewSet.as_view({'post': 'cancel_apply_use_machine'}), name='cancel_apply_use_machine'), + url('^finished_using/', TestMachineViewSet.as_view({'post': 'finished_using'}), name='finished_using'), url('^modify_server/', TestMachineViewSet.as_view({'post': 'modify_server'}), name='modify_server'), url('^get_filter_name/', ProjectViewSet.as_view({'get': 'get_filter_name'}), name='get_filter_name'), url('^merge_data/', ProjectViewSet.as_view({'post': 'merge_data'}), name='merge_data'), diff --git a/appStore/testMachine/models.py b/appStore/testMachine/models.py index 0e71842..7757029 100644 --- a/appStore/testMachine/models.py +++ b/appStore/testMachine/models.py @@ -1,10 +1,3 @@ -""" - * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. - * PilotGo-plugin licensed under the Mulan Permissive Software License, Version 2. - * See LICENSE file for more details. - * Author: wangqingzheng - * Date: Fri Mar 1 10:09:12 2024 +0800 -""" from django.db import models @@ -29,7 +22,7 @@ class TestMachine(models.Model): BMC_password = models.CharField(max_length=50, verbose_name='BMC密码') create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间') - owner = models.CharField(max_length=50, verbose_name='当前操作系统负责人', default=None) + owner = models.CharField(max_length=50, verbose_name='当前操作系统负责人', null=True, blank=True) server_IP = models.CharField(max_length=50, verbose_name='server_IP', null=True, blank=True) server_user_name = models.CharField(max_length=50, verbose_name='服务器用户名', null=True, blank=True) server_password = models.CharField(max_length=50, verbose_name='服务器密码', null=True, blank=True) diff --git a/appStore/testMachine/views.py b/appStore/testMachine/views.py index 7334c10..09c1f0b 100644 --- a/appStore/testMachine/views.py +++ b/appStore/testMachine/views.py @@ -1,10 +1,4 @@ -""" - * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. - * PilotGo-plugin licensed under the Mulan Permissive Software License, Version 2. - * See LICENSE file for more details. - * Author: wangqingzheng - * Date: Fri Mar 1 10:09:12 2024 +0800 -""" +# Create your views here. from appStore.testMachine.models import TestMachine from appStore.testMachine.serializers import TestMachineSerializer from rest_framework import status, viewsets @@ -96,6 +90,25 @@ class TestMachineViewSet(viewsets.ModelViewSet): machine_data.save() return json_response({}, status.HTTP_200_OK, '修改成功') + def finished_using(self, request, *args, **kwargs): + machine_id = request.data.get('id') + machine_data = TestMachine.objects.get(id=machine_id) + if not machine_id or not machine_data: + return json_response({}, status.HTTP_205_RESET_CONTENT, '没有该数据') + if machine_data.owner == request.user.chinese_name: + machine_data.owner = None + machine_data.server_IP = None + machine_data.server_user_name = None + machine_data.server_password = None + machine_data.os_version = None + machine_data.link_status = None + machine_data.task_status = None + machine_data.save() + return json_response({}, status.HTTP_200_OK, '使用完成状态修改成功') + else: + return json_response({}, status.HTTP_200_OK, '不可取消别人的使用状态') + + def delete(self, request, *args, **kwargs): id = request.data.get('id', None) if not id or not TestMachine.objects.filter(id=id): diff --git a/templates/front-project/src/api/api.js b/templates/front-project/src/api/api.js index 8cb593f..108bb82 100644 --- a/templates/front-project/src/api/api.js +++ b/templates/front-project/src/api/api.js @@ -1,13 +1,9 @@ -/* - * Copyright (c) KylinSoft Co., Ltd. 2024.All rights reserved. - * PilotGo-plugin licensed under the Mulan Permissive Software License, Version 2. - * See LICENSE file for more details. - * Author: wqz - * Date: Mon May 20 11:10:24 2024 +0800 - */ // 项目中我们大多数时候都会把对应的接口请求封装成api来调用 import service from '../service.js' +//data 一般适用于POST、PUT请求 +//params 一般适用于GET请求 + // 登录接口 export function login(data) { return service({ @@ -74,6 +70,25 @@ export function project(type, paramsOrData) { return service(commonConfig); } + +// // 获取指定的project组 +// export function get_project(params) { +// return service({ +// method: 'get', +// url: '/project/', +// params +// }) +// } + +// // project +// export function project(type, data) { +// return service({ +// method: type, +// url: '/project/', +// data +// }) +// } + // project 合并数据接口 export function mergeData(data) { return service({ @@ -100,6 +115,14 @@ export function env(params) { }) } +// // stream +// export function stream(params) { +// return service({ +// method: 'get', +// url: '/stream/', +// params, +// }) +// } //修改stream数据 export function get_modify_stream(params) { return service({ @@ -226,6 +249,24 @@ export function machine_list(type, paramsOrData) { return service(commonConfig); } +//修改服务器系统信息 +export function modify_server(data) { + return service({ + method: 'post', + url: '/modify_server/', + data + }) +} + +//机器使用完成 +export function finished_using(data) { + return service({ + method: 'post', + url: '/finished_using/', + data + }) +} + //申请使用设备 export function apply_use_machine(data) { return service({ @@ -243,12 +284,7 @@ export function cancel_apply_use_machine(data) { }) } -//修改服务器系统信息 -export function modify_server(data) { - return service({ - method: 'post', - url: '/modify_server/', - data - }) -} + + + diff --git a/templates/front-project/src/views/machineViews/ServerList.vue b/templates/front-project/src/views/machineViews/ServerList.vue index 63f0620..5d54b79 100644 --- a/templates/front-project/src/views/machineViews/ServerList.vue +++ b/templates/front-project/src/views/machineViews/ServerList.vue @@ -1,10 +1,3 @@ -