Przeglądaj źródła

添加用户组

刘凡 3 lat temu
rodzic
commit
1831addc1e
100 zmienionych plików z 961 dodań i 0 usunięć
  1. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/.DS_Store
  2. 8 0
      TestLaboratory_ali_v1.3/TestLaboratory/.idea/.gitignore
  3. 34 0
      TestLaboratory_ali_v1.3/TestLaboratory/.idea/TestLaboratory.iml
  4. 34 0
      TestLaboratory_ali_v1.3/TestLaboratory/.idea/inspectionProfiles/Project_Default.xml
  5. 6 0
      TestLaboratory_ali_v1.3/TestLaboratory/.idea/inspectionProfiles/profiles_settings.xml
  6. 7 0
      TestLaboratory_ali_v1.3/TestLaboratory/.idea/misc.xml
  7. 8 0
      TestLaboratory_ali_v1.3/TestLaboratory/.idea/modules.xml
  8. 6 0
      TestLaboratory_ali_v1.3/TestLaboratory/.idea/sqldialects.xml
  9. 8 0
      TestLaboratory_ali_v1.3/TestLaboratory/.idea/vcs.xml
  10. 0 0
      TestLaboratory_ali_v1.3/TestLaboratory/Config/__init__.py
  11. 7 0
      TestLaboratory_ali_v1.3/TestLaboratory/Config/database_mysql.cnf
  12. 13 0
      TestLaboratory_ali_v1.3/TestLaboratory/Dockerfile
  13. 37 0
      TestLaboratory_ali_v1.3/TestLaboratory/README.md
  14. 3 0
      TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/__init__.py
  15. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/__pycache__/__init__.cpython-38.pyc
  16. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/__pycache__/__init__.cpython-39.pyc
  17. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/__pycache__/settings.cpython-38.pyc
  18. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/__pycache__/settings.cpython-39.pyc
  19. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/__pycache__/urls.cpython-38.pyc
  20. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/__pycache__/urls.cpython-39.pyc
  21. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/__pycache__/wsgi.cpython-38.pyc
  22. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/__pycache__/wsgi.cpython-39.pyc
  23. 16 0
      TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/asgi.py
  24. 283 0
      TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/settings.py
  25. 28 0
      TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/urls.py
  26. 16 0
      TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/wsgi.py
  27. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/__pycache__/util_doc.cpython-38.pyc
  28. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/__pycache__/util_doc.cpython-39.pyc
  29. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/__pycache__/util_xlsx.cpython-38.pyc
  30. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/__pycache__/util_xlsx.cpython-39.pyc
  31. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/api2.0.xlsx
  32. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/.DS_Store
  33. 0 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/__init__.py
  34. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/__pycache__/__init__.cpython-38.pyc
  35. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/__pycache__/__init__.cpython-39.pyc
  36. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/.DS_Store
  37. 0 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/__init__.py
  38. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/__pycache__/__init__.cpython-38.pyc
  39. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/__pycache__/__init__.cpython-39.pyc
  40. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/__pycache__/admin.cpython-38.pyc
  41. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/__pycache__/admin.cpython-39.pyc
  42. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/__pycache__/apps.cpython-38.pyc
  43. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/__pycache__/apps.cpython-39.pyc
  44. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/__pycache__/models.cpython-38.pyc
  45. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/__pycache__/models.cpython-39.pyc
  46. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/__pycache__/urls.cpython-38.pyc
  47. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/__pycache__/urls.cpython-39.pyc
  48. 3 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/admin.py
  49. 6 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/apps.py
  50. 30 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/migrations/0001_initial.py
  51. 18 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/migrations/0002_alter_filemanager_id.py
  52. 0 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/migrations/__init__.py
  53. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/migrations/__pycache__/0001_initial.cpython-38.pyc
  54. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/migrations/__pycache__/0001_initial.cpython-39.pyc
  55. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/migrations/__pycache__/0002_alter_filemanager_id.cpython-39.pyc
  56. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/migrations/__pycache__/__init__.cpython-38.pyc
  57. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/migrations/__pycache__/__init__.cpython-39.pyc
  58. 24 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/models.py
  59. 3 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/tests.py
  60. 7 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/urls.py
  61. 0 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/views/__init__.py
  62. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/views/__pycache__/__init__.cpython-38.pyc
  63. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/views/__pycache__/__init__.cpython-39.pyc
  64. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/views/__pycache__/fileview.cpython-38.pyc
  65. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/views/__pycache__/fileview.cpython-39.pyc
  66. 128 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/file/views/fileview.py
  67. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/.DS_Store
  68. 0 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/__init__.py
  69. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/__pycache__/__init__.cpython-38.pyc
  70. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/__pycache__/__init__.cpython-39.pyc
  71. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/__pycache__/admin.cpython-38.pyc
  72. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/__pycache__/admin.cpython-39.pyc
  73. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/__pycache__/apps.cpython-38.pyc
  74. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/__pycache__/apps.cpython-39.pyc
  75. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/__pycache__/models.cpython-38.pyc
  76. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/__pycache__/models.cpython-39.pyc
  77. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/__pycache__/urls.cpython-38.pyc
  78. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/__pycache__/urls.cpython-39.pyc
  79. 3 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/admin.py
  80. 6 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/apps.py
  81. 0 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/middleware/__init__.py
  82. 33 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/middleware/loginfo.py
  83. 35 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/migrations/0001_initial.py
  84. 18 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/migrations/0002_alter_log_id.py
  85. 0 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/migrations/__init__.py
  86. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/migrations/__pycache__/0001_initial.cpython-38.pyc
  87. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/migrations/__pycache__/0001_initial.cpython-39.pyc
  88. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/migrations/__pycache__/0002_alter_log_id.cpython-39.pyc
  89. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/migrations/__pycache__/__init__.cpython-38.pyc
  90. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/migrations/__pycache__/__init__.cpython-39.pyc
  91. 77 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/models.py
  92. 3 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/tests.py
  93. 6 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/urls.py
  94. 0 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/views/__init__.py
  95. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/views/__pycache__/__init__.cpython-38.pyc
  96. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/views/__pycache__/__init__.cpython-39.pyc
  97. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/views/__pycache__/loglistview.cpython-38.pyc
  98. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/views/__pycache__/loglistview.cpython-39.pyc
  99. 47 0
      TestLaboratory_ali_v1.3/TestLaboratory/apps/log/views/loglistview.py
  100. BIN
      TestLaboratory_ali_v1.3/TestLaboratory/apps/plan/.DS_Store

BIN
TestLaboratory_ali_v1.3/TestLaboratory/.DS_Store


+ 8 - 0
TestLaboratory_ali_v1.3/TestLaboratory/.idea/.gitignore

@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/

+ 34 - 0
TestLaboratory_ali_v1.3/TestLaboratory/.idea/TestLaboratory.iml

@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="PYTHON_MODULE" version="4">
+  <component name="FacetManager">
+    <facet type="django" name="Django">
+      <configuration>
+        <option name="rootFolder" value="$MODULE_DIR$" />
+        <option name="settingsModule" value="TestLaboratory/settings.py" />
+        <option name="manageScript" value="$MODULE_DIR$/manage.py" />
+        <option name="environment" value="&lt;map/&gt;" />
+        <option name="doNotUseTestRunner" value="false" />
+        <option name="trackFilePattern" value="migrations" />
+      </configuration>
+    </facet>
+  </component>
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
+    </content>
+    <orderEntry type="jdk" jdkName="Python 3.9 (base)" jdkType="Python SDK" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+  <component name="PackageRequirementsSettings">
+    <option name="versionSpecifier" value="Strong equality (==x.y.z)" />
+    <option name="removeUnused" value="true" />
+    <option name="modifyBaseFiles" value="true" />
+  </component>
+  <component name="PyDocumentationSettings">
+    <option name="format" value="PLAIN" />
+    <option name="myDocStringFormat" value="Plain" />
+  </component>
+  <component name="TemplatesService">
+    <option name="TEMPLATE_CONFIGURATION" value="Django" />
+  </component>
+</module>

+ 34 - 0
TestLaboratory_ali_v1.3/TestLaboratory/.idea/inspectionProfiles/Project_Default.xml

@@ -0,0 +1,34 @@
+<component name="InspectionProjectProfileManager">
+  <profile version="1.0">
+    <option name="myName" value="Project Default" />
+    <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
+    <inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
+      <option name="ignoredPackages">
+        <value>
+          <list size="3">
+            <item index="0" class="java.lang.String" itemvalue="pymysql" />
+            <item index="1" class="java.lang.String" itemvalue="pyjwt" />
+            <item index="2" class="java.lang.String" itemvalue="django-cors-headers" />
+          </list>
+        </value>
+      </option>
+    </inspection_tool>
+    <inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
+      <option name="ignoredErrors">
+        <list>
+          <option value="E722" />
+        </list>
+      </option>
+    </inspection_tool>
+    <inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
+      <option name="ignoredErrors">
+        <list>
+          <option value="N802" />
+          <option value="N806" />
+          <option value="N801" />
+        </list>
+      </option>
+    </inspection_tool>
+    <inspection_tool class="Stylelint" enabled="true" level="ERROR" enabled_by_default="true" />
+  </profile>
+</component>

+ 6 - 0
TestLaboratory_ali_v1.3/TestLaboratory/.idea/inspectionProfiles/profiles_settings.xml

@@ -0,0 +1,6 @@
+<component name="InspectionProjectProfileManager">
+  <settings>
+    <option name="USE_PROJECT_PROFILE" value="false" />
+    <version value="1.0" />
+  </settings>
+</component>

+ 7 - 0
TestLaboratory_ali_v1.3/TestLaboratory/.idea/misc.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (base)" project-jdk-type="Python SDK" />
+  <component name="PyCharmProfessionalAdvertiser">
+    <option name="shown" value="true" />
+  </component>
+</project>

+ 8 - 0
TestLaboratory_ali_v1.3/TestLaboratory/.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/TestLaboratory.iml" filepath="$PROJECT_DIR$/.idea/TestLaboratory.iml" />
+    </modules>
+  </component>
+</project>

+ 6 - 0
TestLaboratory_ali_v1.3/TestLaboratory/.idea/sqldialects.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="SqlDialectMappings">
+    <file url="file://$PROJECT_DIR$/mysql-init/TestLaboratory.sql" dialect="MariaDB" />
+  </component>
+</project>

+ 8 - 0
TestLaboratory_ali_v1.3/TestLaboratory/.idea/vcs.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$/../../../.." vcs="Git" />
+    <mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
+    <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
+  </component>
+</project>

+ 0 - 0
TestLaboratory_ali_v1.3/TestLaboratory/Config/__init__.py


+ 7 - 0
TestLaboratory_ali_v1.3/TestLaboratory/Config/database_mysql.cnf

@@ -0,0 +1,7 @@
+[client]
+host = 127.0.0.1
+port = 3306
+database = TestLaboratory
+user = root
+password = liufan3344
+default-character-set = utf8

+ 13 - 0
TestLaboratory_ali_v1.3/TestLaboratory/Dockerfile

@@ -0,0 +1,13 @@
+From python:3.9
+
+MAINTAINER Liufan<1649750212@qq.com>
+ENV PYTHONUNBUFFERED 1
+
+COPY . /code
+WORKDIR /code
+
+RUN pip install -r requirements.txt -i https://pypi.douban.com/simple
+
+EXPOSE 8003
+
+ENTRYPOINT ["/bin/sh","startup.sh"]

+ 37 - 0
TestLaboratory_ali_v1.3/TestLaboratory/README.md

@@ -0,0 +1,37 @@
+# lims测试实验室管理平台
+
+## 作者:刘凡
+
+## 系统地址
+
+http://127.0.0.1:8002 **(本地)**
+
+http://172.26.0.13:8002 **(局域网)**
+
+## 用户操作手册
+
+- 详见 **附件1**
+
+## 源代码地址
+
+- /home/dell/lims/TestLaboratory
+
+## 系统部署安装
+
+### step1:安装mysql镜像
+
+```shell
+docker pull mysql:8.0.26
+```
+
+### step2: 部署前后端镜像
+
+```shell
+docker-compose up -d
+```
+
+## 系统运行环境
+
+- linux系统
+- 浏览器建议使用最新的chrome(老版本浏览器可能出现文件无法下载的问题)
+- docker 2.0

+ 3 - 0
TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/__init__.py

@@ -0,0 +1,3 @@
+import pymysql
+pymysql.version_info = (1, 4, 13, "final", 0)
+pymysql.install_as_MySQLdb()

BIN
TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/__pycache__/__init__.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/__pycache__/__init__.cpython-39.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/__pycache__/settings.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/__pycache__/settings.cpython-39.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/__pycache__/urls.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/__pycache__/urls.cpython-39.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/__pycache__/wsgi.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/__pycache__/wsgi.cpython-39.pyc


+ 16 - 0
TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/asgi.py

@@ -0,0 +1,16 @@
+"""
+ASGI config for TestLaboratory project.
+
+It exposes the ASGI callable as a module-level variable named ``application``.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
+"""
+
+import os
+
+from django.core.asgi import get_asgi_application
+
+os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'TestLaboratory.settings')
+
+application = get_asgi_application()

+ 283 - 0
TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/settings.py

@@ -0,0 +1,283 @@
+"""
+Django settings for TestLaboratory project.
+
+Generated by 'django-admin startproject' using Django 3.2.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/3.2/topics/settings/
+
+For the full list of settings and their values, see
+https://docs.djangoproject.com/en/3.2/ref/settings/
+"""
+import datetime
+from pathlib import Path
+import sys
+import os
+
+# Build paths inside the project like this: BASE_DIR / 'subdir'.
+# import apps.user.middleware.authentication
+
+BASE_DIR = Path(__file__).resolve().parent.parent
+sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))
+
+MEDIA_ROOT = os.path.join(BASE_DIR, 'static')
+MEDIA_URL = '/media/'
+
+SOFTWARE_ROOT = "static/software/"
+PLAN_ROOT = "static/plan-statement/"
+TASK_ROOT = 'static/task-statement/'
+CASE_TEMPLATE_ROOT = 'static/case-template/测试用例模版.xlsx'
+CASE_FILE_ROOT = 'static/case-file/'
+CASE_FILE_EXPORT = 'static/case-file-export/'
+HTTP_HEAD = 'http://112.124.117.37:8003/'
+
+
+# Quick-start development settings - unsuitable for production
+# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
+
+# SECURITY WARNING: keep the secret key used in production secret!
+SECRET_KEY = 'django-insecure-zo64fvv02msf-se7!dek5*w$17#3nh6zta#!i=79bt9d#f88@i'
+
+# SECURITY WARNING: don't run with debug turned on in production!
+DEBUG = True
+
+ALLOWED_HOSTS = ['*']
+# AUTH_USER_MODEL = "user.User"
+# AUTHENTICATION_BACKENDS = (
+#     'user.middleware.authentication.CustomBackend',
+# )
+# Application definition
+
+INSTALLED_APPS = [
+    'simpleui',
+    'django.contrib.admin',
+    'django.contrib.auth',
+    'django.contrib.contenttypes',
+    'django.contrib.sessions',
+    'django.contrib.messages',
+    'django.contrib.staticfiles',
+    'rest_framework',
+    'corsheaders',
+    'user',
+    'software',
+    'plan',
+    'apps.task',
+    'file',
+    'log'
+]
+
+MIDDLEWARE = [
+    'django.middleware.security.SecurityMiddleware',
+    'django.contrib.sessions.middleware.SessionMiddleware',
+    'django.middleware.common.CommonMiddleware',
+    # 'django.middleware.csrf.CsrfViewMiddleware',
+    'django.contrib.auth.middleware.AuthenticationMiddleware',
+    'django.contrib.messages.middleware.MessageMiddleware',
+    'django.middleware.clickjacking.XFrameOptionsMiddleware',
+    'corsheaders.middleware.CorsMiddleware',
+    'django.middleware.common.CommonMiddleware',
+]
+
+ROOT_URLCONF = 'TestLaboratory.urls'
+
+TEMPLATES = [
+    {
+        'BACKEND': 'django.template.backends.django.DjangoTemplates',
+        'DIRS': [os.path.join(BASE_DIR, 'templates')],
+        'APP_DIRS': True,
+        'OPTIONS': {
+            'context_processors': [
+                'django.template.context_processors.debug',
+                'django.template.context_processors.request',
+                'django.contrib.auth.context_processors.auth',
+                'django.contrib.messages.context_processors.messages',
+            ],
+        },
+    },
+]
+
+WSGI_APPLICATION = 'TestLaboratory.wsgi.application'
+
+# Database
+# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
+
+DATABASES = {
+    'default': {
+        'ENGINE': 'django.db.backends.mysql',
+        'OPTIONS': {
+            'read_default_file': 'Config/database_mysql.cnf',
+        },
+    }
+}
+
+# Password validation
+# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
+
+AUTH_PASSWORD_VALIDATORS = [
+    {
+        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
+    },
+    {
+        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
+    },
+    {
+        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
+    },
+    {
+        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
+    },
+]
+
+REST_FRAMEWORK = {
+    'DEFAULT_PERMISSION_CLASSES': (
+        'rest_framework.permissions.IsAuthenticated'
+    ),
+    'DEFAULT_AUTHENTICATION_CLASSES': (
+        'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
+        'rest_framework.authentication.BasicAuthentication',
+        'rest_framework.authentication.SessionAuthentication'
+    )
+}
+
+JWT_AUTH = {
+    # 设置token有效时间
+    'JWT_EXPIRATION_DELTA': datetime.timedelta(seconds=60 * 60 * 2)
+}
+
+# Internationalization
+# https://docs.djangoproject.com/en/3.2/topics/i18n/
+
+LANGUAGE_CODE = 'en-us'
+
+TIME_ZONE = 'Asia/Shanghai'
+
+USE_I18N = True
+
+USE_L10N = True
+
+USE_TZ = False
+
+# Static files (CSS, JavaScript, Images)
+# https://docs.djangoproject.com/en/3.2/howto/static-files/
+
+STATIC_URL = '/static/'
+STATICFILES_DIRS = [
+    os.path.join(BASE_DIR, "static"),
+]
+
+# Default primary key field type
+# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
+
+DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
+
+REST_FRAMEWORK = {
+    "DEFAULT_AUTHENTICATION_CLASSES": ["apps.user.middleware.authentication.JwtAutentication"]
+}
+
+CORS_ALLOW_CREDENTIALS = True
+CORS_ORIGIN_ALLOW_ALL = True
+
+CORS_ALLOW_METHODS = (
+    'GET',
+    'POST',
+    'PUT',
+    'PATCH',
+    'DELETE',
+    'OPTIONS'
+)
+
+CORS_ALLOW_HEADERS = (
+    'x-requested-with',
+    'content-type',
+    'accept',
+    'origin',
+    'authorization',
+    'x-csrftoken'
+)
+
+import time
+
+cur_path = os.path.dirname(os.path.realpath(__file__))  # log_path是存放日志的路径
+log_path = os.path.join(os.path.dirname(cur_path), 'logs')
+if not os.path.exists(log_path): os.mkdir(log_path)  # 如果不存在这个logs文件夹,就自动创建一个
+
+LOGGING = {
+    'version': 1,
+    'disable_existing_loggers': False,
+    'formatters': {
+        # 日志格式
+        'standard': {
+            'format': '[%(levelname)s] [%(asctime)s] [%(filename)s:%('
+                      'lineno)d] [%(module)s:%(funcName)s] '
+                      '- %(message)s'},
+        'simple': {  # 简单格式
+            'format': '%(levelname)s %(message)s'
+        },
+    },
+    # 过滤
+    'filters': {
+        'require_debug_true': {
+            '()': 'django.utils.log.RequireDebugTrue',  # 过滤掉调试信息
+        },
+    },
+    # 定义具体处理日志的方式
+    'handlers': {
+        # 默认记录所有日志
+        'default': {
+            'level': 'INFO',
+            'class': 'logging.handlers.RotatingFileHandler',
+            'filename': os.path.join(log_path, 'all-{}.log'.format(
+                time.strftime('%Y-%m-%d'))),
+            'maxBytes': 1024 * 1024 * 300,  # 文件大小
+            'backupCount': 10,  # 备份数
+            'formatter': 'standard',  # 输出格式
+            'encoding': 'utf-8',  # 设置默认编码,否则打印出来汉字乱码
+        },
+        # 输出错误日志
+        'error': {
+            'level': 'ERROR',
+            'class': 'logging.handlers.RotatingFileHandler',
+            'filename': os.path.join(log_path, 'error-{}.log'.format(
+                time.strftime('%Y-%m-%d'))),
+            'maxBytes': 1024 * 1024 * 5,  # 文件大小
+            'backupCount': 5,  # 备份数
+            'formatter': 'standard',  # 输出格式
+            'encoding': 'utf-8',  # 设置默认编码
+        },
+        # 控制台输出
+        'console': {
+            'level': 'DEBUG',
+            'class': 'logging.StreamHandler',
+            'formatter': 'standard'
+        },
+        #输出info日志
+        'info': {
+            'level': 'INFO',
+            'class': 'logging.handlers.RotatingFileHandler',
+            'filename': os.path.join(log_path, 'info-{}.log'.format(
+                time.strftime('%Y-%m-%d'))),
+            'maxBytes': 1024 * 1024 * 5,
+            'backupCount': 5,
+            'formatter': 'standard',
+            'encoding': 'utf-8',  # 设置默认编码
+        },
+    },
+    # 配置用哪几种 handlers 来处理日志
+    'loggers': {
+        # 类型 为 django 处理所有类型的日志, 默认调用
+        'django': {
+            'handlers': ['default', 'console'],
+            'level': 'INFO',
+            'propagate': False
+        },
+        # log 调用时需要当作参数传入
+        'log': {
+            'handlers': ['error', 'info', 'console', 'default'],
+            'level': 'INFO',
+            'propagate': True
+        },
+    }
+}
+"""
+python manage.py runserver 172.16.100.180:8000   
+"""

+ 28 - 0
TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/urls.py

@@ -0,0 +1,28 @@
+"""TestLaboratory URL Configuration
+
+The `urlpatterns` list routes URLs to views. For more information please see:
+    https://docs.djangoproject.com/en/3.2/topics/http/urls/
+Examples:
+Function views
+    1. Add an import:  from my_app import views
+    2. Add a URL to urlpatterns:  path('', views.home, name='home')
+Class-based views
+    1. Add an import:  from other_app.views import Home
+    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
+Including another URLconf
+    1. Import the include() function: from django.urls import include, path
+    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
+"""
+from django.conf.urls.static import static
+from django.urls import path, include
+
+from TestLaboratory import settings
+
+urlpatterns = [
+    path('api/v1/users/', include('user.urls')),
+    path('api/v1/software/', include('software.urls')),
+    path('api/v1/test-plans/', include('plan.urls')),
+    path('api/v1/test-tasks/', include('task.urls')),
+    path('api/v1/log-info/', include('log.urls')),
+    path('api/v1/files/', include('file.urls'))
+] + static(settings.STATIC_URL, document_root=settings.STATICFILES_DIRS)

+ 16 - 0
TestLaboratory_ali_v1.3/TestLaboratory/TestLaboratory/wsgi.py

@@ -0,0 +1,16 @@
+"""
+WSGI config for TestLaboratory project.
+
+It exposes the WSGI callable as a module-level variable named ``application``.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/
+"""
+
+import os
+
+from django.core.wsgi import get_wsgi_application
+
+os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'TestLaboratory.settings')
+
+application = get_wsgi_application()

BIN
TestLaboratory_ali_v1.3/TestLaboratory/__pycache__/util_doc.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/__pycache__/util_doc.cpython-39.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/__pycache__/util_xlsx.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/__pycache__/util_xlsx.cpython-39.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/api2.0.xlsx


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/.DS_Store


+ 0 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/__init__.py


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/__pycache__/__init__.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/__pycache__/__init__.cpython-39.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/.DS_Store


+ 0 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/__init__.py


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/__pycache__/__init__.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/__pycache__/__init__.cpython-39.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/__pycache__/admin.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/__pycache__/admin.cpython-39.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/__pycache__/apps.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/__pycache__/apps.cpython-39.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/__pycache__/models.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/__pycache__/models.cpython-39.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/__pycache__/urls.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/__pycache__/urls.cpython-39.pyc


+ 3 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/admin.py

@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.

+ 6 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/apps.py

@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class FileConfig(AppConfig):
+    default_auto_field = 'django.db.models.BigAutoField'
+    name = 'apps.file'

+ 30 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/migrations/0001_initial.py

@@ -0,0 +1,30 @@
+# Generated by Django 3.2 on 2021-07-17 20:05
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    initial = True
+
+    dependencies = [
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='FileManager',
+            fields=[
+                ('id', models.CharField(default='TestLaboratory_V1_File_1', max_length=30, primary_key=True, serialize=False, unique=True, verbose_name='文件id')),
+                ('path', models.FilePathField(max_length=200, verbose_name='文件路径')),
+                ('create_time', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
+                ('update_time', models.DateTimeField(auto_now=True, verbose_name='修改时间')),
+                ('delete', models.BooleanField(default=False)),
+                ('category', models.CharField(max_length=20, verbose_name='文件类型')),
+            ],
+            options={
+                'verbose_name': '文件管理',
+                'verbose_name_plural': '文件管理',
+                'db_table': 'file_manager',
+            },
+        ),
+    ]

+ 18 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/migrations/0002_alter_filemanager_id.py

@@ -0,0 +1,18 @@
+# Generated by Django 3.2.4 on 2022-06-19 10:43
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('file', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='filemanager',
+            name='id',
+            field=models.CharField(default='TestLaboratory_V1_File_1', max_length=128, primary_key=True, serialize=False, unique=True, verbose_name='文件id'),
+        ),
+    ]

+ 0 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/migrations/__init__.py


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/migrations/__pycache__/0001_initial.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/migrations/__pycache__/0001_initial.cpython-39.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/migrations/__pycache__/0002_alter_filemanager_id.cpython-39.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/migrations/__pycache__/__init__.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/migrations/__pycache__/__init__.cpython-39.pyc


+ 24 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/models.py

@@ -0,0 +1,24 @@
+from django.db import models
+
+
+# Create your models here.
+class FileManager(models.Model):
+    id = models.CharField(max_length=128, unique=True, verbose_name='文件id', primary_key=True,
+                          default='TestLaboratory_V1_File_1')
+    path = models.FilePathField(max_length=200, verbose_name='文件路径')
+    create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
+    update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')
+    delete = models.BooleanField(default=False)
+    # category: software, report, plan_statement, task_statement, case_file
+    category = models.CharField(max_length=20, verbose_name='文件类型')
+
+    def __str__(self):
+        return self.path
+
+    class Meta:
+        verbose_name = '文件管理'
+        verbose_name_plural = verbose_name
+        db_table = 'file_manager'
+
+
+

+ 3 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/tests.py

@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.

+ 7 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/urls.py

@@ -0,0 +1,7 @@
+from django.urls import path
+
+from .views.fileview import FileView
+
+urlpatterns = [
+    path('', FileView.as_view()),
+]

+ 0 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/views/__init__.py


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/views/__pycache__/__init__.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/views/__pycache__/__init__.cpython-39.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/views/__pycache__/fileview.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/views/__pycache__/fileview.cpython-39.pyc


+ 128 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/file/views/fileview.py

@@ -0,0 +1,128 @@
+import datetime
+import os
+
+from django.http import HttpResponse
+from rest_framework.views import APIView
+
+from TestLaboratory.settings import PLAN_ROOT, TASK_ROOT
+from apps.file.models import FileManager
+from apps.log.models import get_log, gen_log
+from apps.plan.models import TestPlan
+from apps.task.models import TestTask
+from apps.user.middleware.rolecontrol import RoleControl
+from utils.util_add_id import gen_next_id
+
+import logging
+logger = logging.getLogger('django')
+
+
+class FileView(APIView):
+    # create file
+    @staticmethod
+    @RoleControl
+    def post(request, *args, **kwargs):
+        file_type = request.POST.get('type')
+        plan_id = request.POST.get('plan_id')
+        task_id = request.POST.get('task_id')
+        files = request.FILES.getlist('files')
+
+        model_object = None
+        path_head = None
+        if file_type == 'plan_statement':
+            model_object = TestPlan.objects.filter(id=plan_id, delete=False)
+            if not model_object:
+                logger.error("测试计划已删除或不存在")
+                return HttpResponse(status=404, content='测试计划已删除或不存在')
+            model_object = model_object[0]
+            path_head = PLAN_ROOT
+
+        elif file_type == 'task_statement':
+            model_object = TestTask.objects.filter(id=task_id, delete=False)
+            if not model_object:
+                logger.error("测试任务已删除或不存在")
+                return HttpResponse(status=404, content='测试任务已删除或不存在')
+            model_object = model_object[0]
+            path_head = TASK_ROOT
+
+        # step7:创建文件的数据库字段
+        fids = ''
+        file_paths = []
+        for file in files:
+            try:
+                create_time = update_time = datetime.datetime.now()
+                file_dir = path_head + "/" + model_object.id + "/" + str(create_time)
+                if not os.path.exists(file_dir):
+                    os.makedirs(file_dir)
+                file_path = file_dir + "/" + file.name
+                with open(file_path, 'wb') as f:
+                    f.write(file.read())
+                f.close()
+            except:
+                logger.error("文件上传失败")
+                return HttpResponse(status=500, content="文件上传失败")
+
+            if not FileManager.objects.last():
+                id_file = "TestLaboratory_V1_File_1"
+            else:
+                id_file = gen_next_id(FileManager.objects.order_by('create_time').last().id)
+
+            try:
+                file_new = FileManager.objects.create(id=id_file, category=file_type,
+                                                      path=model_object.id+ "/" + str(create_time) + "/" + file.name,
+                                                      create_time=create_time,
+                                                      update_time=update_time)
+            except:
+                logger.error("文件路径写入数据库失败")
+                return HttpResponse(status=500, content="文件路径写入数据库失败")
+            file_paths.append(PLAN_ROOT + file_new.path)
+            fids += id_file + "&&"
+        fids = fids[:-2]
+        model_object.statement_file += ("&&" + fids)
+        model_object.save()
+        executor, action, method = get_log(request)
+        gen_log(action, "说明文档", model_object.title, method, executor)
+        return HttpResponse(status=200, content='新建文件成功')
+
+    # create file
+    @staticmethod
+    @RoleControl
+    def delete(request, *args, **kwargs):
+        file_id = request.GET.get('file_id')
+        file_type = request.GET.get('type')
+        plan_id = request.GET.get('plan_id')
+        task_id = request.GET.get('task_id')
+
+        model_object = None
+        if file_type == 'plan_statement':
+            model_object = TestPlan.objects.filter(id=plan_id, delete=False)
+            if not model_object:
+                logger.error("测试计划已删除或不存在")
+                return HttpResponse(status=404, content='测试计划已删除或不存在')
+            model_object = model_object[0]
+
+        elif file_type == 'task_statement':
+            model_object = TestTask.objects.filter(id=task_id, delete=False)
+            if not model_object:
+                logger.error("测试任务已删除或不存在")
+                return HttpResponse(status=404, content='测试任务已删除或不存在')
+            model_object = model_object[0]
+
+        file = FileManager.objects.filter(id=file_id, delete=False)
+        if not file:
+            logger.error("文件已删除不存在")
+            return HttpResponse(status=404, content='文件已删除不存在')
+        file = file[0]
+        file_list = model_object.statement_file.split('&&')
+        if file.id not in file_list:
+            logger.error("该文件不存在于测试计划或测试任务中,数据库错误")
+            return HttpResponse(status=404, content='该文件不存在于测试计划或测试任务中,数据库错误')
+        file_list.remove(file.id)
+        file_str = ''
+        for file_name in file_list:
+            file_str += file_name + "&&"
+        file_str = file_str[:-2]
+        model_object.statement_file = file_str
+        model_object.save()
+        executor, action, method = get_log(request)
+        gen_log(action, "说明文档", file.path.split('/')[-1], method, executor)
+        return HttpResponse(status=200, content='删除成功')

BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/.DS_Store


+ 0 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/__init__.py


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/__pycache__/__init__.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/__pycache__/__init__.cpython-39.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/__pycache__/admin.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/__pycache__/admin.cpython-39.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/__pycache__/apps.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/__pycache__/apps.cpython-39.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/__pycache__/models.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/__pycache__/models.cpython-39.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/__pycache__/urls.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/__pycache__/urls.cpython-39.pyc


+ 3 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/admin.py

@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.

+ 6 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/apps.py

@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class LogInfoConfig(AppConfig):
+    default_auto_field = 'django.db.models.BigAutoField'
+    name = 'apps.log'

+ 0 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/middleware/__init__.py


+ 33 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/middleware/loginfo.py

@@ -0,0 +1,33 @@
+import re
+
+import jwt
+from django.http import HttpResponse
+
+from TestLaboratory.settings import SECRET_KEY
+from apps.user.models import User, Role
+
+
+class LogInfo(object):
+    """使用类装饰器来权限校验"""
+    def __init__(self, func):
+        self.func = func
+
+    def __call__(self, request, *args, **kwargs):
+        token = request.META.get('HTTP_ACCESSTOKEN')
+        SALT = SECRET_KEY
+
+        payload = jwt.decode(token, SALT, True)
+
+        user = User.objects.get(username=payload['username'])
+
+        role = Role.objects.get(id="TestLaboratory_V1_Role_"+str(user.identify+1))
+        permission = role.permissions.filter(method=request.method)
+
+        log = None
+        for per in permission:
+            if re.search(per.url, request.path[:-1]):
+                log = per
+                break
+
+        return self.func(request, *args, **kwargs)
+

+ 35 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/migrations/0001_initial.py

@@ -0,0 +1,35 @@
+# Generated by Django 3.2 on 2021-07-17 20:05
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    initial = True
+
+    dependencies = [
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='Log',
+            fields=[
+                ('id', models.CharField(default='TestLaboratory_V1_Log_1', max_length=50, primary_key=True, serialize=False, verbose_name='日志id')),
+                ('action', models.CharField(max_length=100, verbose_name='操作名称')),
+                ('entity_class', models.CharField(max_length=50, verbose_name='实体类型')),
+                ('entity_name', models.CharField(max_length=50, null=True, verbose_name='实体名称')),
+                ('method', models.CharField(max_length=30, verbose_name='操作方法')),
+                ('executor_id', models.CharField(max_length=50, verbose_name='操作者id')),
+                ('executor_username', models.CharField(max_length=50, verbose_name='操作者名称')),
+                ('executor_identify', models.IntegerField(verbose_name='操作者身份')),
+                ('create_time', models.DateTimeField(auto_now_add=True, verbose_name='创建时间')),
+                ('update_time', models.DateTimeField(auto_now=True, verbose_name='修改时间')),
+                ('delete', models.BooleanField(default=False)),
+            ],
+            options={
+                'verbose_name': '日志',
+                'verbose_name_plural': '日志',
+                'db_table': 'log',
+            },
+        ),
+    ]

+ 18 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/migrations/0002_alter_log_id.py

@@ -0,0 +1,18 @@
+# Generated by Django 3.2.4 on 2022-06-19 10:43
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('log', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='log',
+            name='id',
+            field=models.CharField(default='TestLaboratory_V1_Log_1', max_length=128, primary_key=True, serialize=False, verbose_name='日志id'),
+        ),
+    ]

+ 0 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/migrations/__init__.py


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/migrations/__pycache__/0001_initial.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/migrations/__pycache__/0001_initial.cpython-39.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/migrations/__pycache__/0002_alter_log_id.cpython-39.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/migrations/__pycache__/__init__.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/migrations/__pycache__/__init__.cpython-39.pyc


+ 77 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/models.py

@@ -0,0 +1,77 @@
+import datetime
+import re
+
+import jwt
+from django.db import models
+
+# Create your models here.
+from TestLaboratory.settings import SECRET_KEY
+from apps.user.models import User, Role
+from utils.util_add_id import get_id, gen_next_id
+
+
+class Log(models.Model):
+    id = models.CharField(max_length=128, primary_key=True, verbose_name='日志id', default='TestLaboratory_V1_Log_1')
+    action = models.CharField(max_length=100, verbose_name='操作名称')
+    entity_class = models.CharField(max_length=50, verbose_name='实体类型')
+    entity_name = models.CharField(max_length=50, null=True, verbose_name='实体名称')
+    method = models.CharField(max_length=30, verbose_name='操作方法')
+    executor_id = models.CharField(max_length=50, verbose_name='操作者id')
+    executor_username = models.CharField(max_length=50, verbose_name='操作者名称')
+    executor_identify = models.IntegerField(verbose_name='操作者身份')
+    create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
+    update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')
+    delete = models.BooleanField(default=False)
+
+    def __str__(self):
+        return self.executor_username + self.action
+
+    class Meta:
+        verbose_name = '日志'
+        verbose_name_plural = verbose_name
+        db_table = 'log'
+
+
+def gen_log(action, entity_class, entity_name, method, executor):
+    log_id = get_id(Log, "TestLaboratory_V1_Log_1")
+    create_time = update_time = datetime.datetime.now()
+    try:
+        log_new = Log.objects.create(id=log_id, action=action, entity_class=entity_class, entity_name=entity_name,
+                                     method=method, executor_id=executor.id, executor_username=executor.username,
+                                     executor_identify=executor.identify, create_time=create_time,
+                                     update_time=update_time)
+    except:
+        log_id = gen_next_id(log_id)
+        log_new = Log.objects.create(id=log_id, action=action, entity_class=entity_class, entity_name=entity_name,
+                                     method=method, executor_id=executor.id, executor_username=executor.username,
+                                     executor_identify=executor.identify, create_time=create_time,
+                                     update_time=update_time)
+
+
+def get_log(request):
+    token = request.META.get('HTTP_ACCESSTOKEN')
+    SALT = SECRET_KEY
+
+    payload = jwt.decode(token, SALT, True)
+
+    user = User.objects.get(id=payload['userid'])
+
+    role = Role.objects.get(id="TestLaboratory_V1_Role_" + str(user.identify + 1))
+    permission = role.permissions.filter(method=request.method)
+    # print(user.username)
+
+    perm = None
+    for per in permission:
+        path = request.path
+        if request.path[-1] == '/':
+            path = request.path[:-1]
+        # print(per.url, per.name, path, re.search(per.url, path))
+
+        if re.search(per.url, path):
+            # print("匹配", per.url, request.path)
+            if not perm:
+                perm = per
+            elif len(per.url) > len(perm.url):
+                perm = per
+    # print(perm.url, perm.name, perm.method)
+    return user, perm.name, perm.method

+ 3 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/tests.py

@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.

+ 6 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/urls.py

@@ -0,0 +1,6 @@
+from django.urls import path
+from .views.loglistview import LogListView
+
+urlpatterns = [
+    path('', LogListView.as_view())
+]

+ 0 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/views/__init__.py


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/views/__pycache__/__init__.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/views/__pycache__/__init__.cpython-39.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/views/__pycache__/loglistview.cpython-38.pyc


BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/views/__pycache__/loglistview.cpython-39.pyc


+ 47 - 0
TestLaboratory_ali_v1.3/TestLaboratory/apps/log/views/loglistview.py

@@ -0,0 +1,47 @@
+from django.db.models import Q
+from rest_framework.response import Response
+from rest_framework.views import APIView
+from django.http import HttpResponse
+
+from apps.log.models import Log
+
+
+class LogListView(APIView):
+    # view log_list
+    @staticmethod
+    def get(request, *args, **kwargs):
+        entity_class = request.GET.get('entity_class')
+        action = request.GET.get('action')
+        executor_username = request.GET.get('executor_username')
+        executor_identify = request.GET.get('executor_identify')
+        sort = request.GET.get('sort')
+        dont_get = request.GET.get('dontGet')
+
+        log_all = Log.objects.order_by('-create_time')
+        if entity_class:
+            log_all = log_all.filter(entity_class=entity_class)
+        if action:
+            log_all = log_all.filter(method=action)
+        if executor_username:
+            log_all = log_all.filter(executor_username=executor_username)
+        if executor_identify:
+            log_all = log_all.filter(executor_identify=executor_identify)
+        if dont_get == '1':
+            log_all = log_all.filter(~Q(method='GET'))
+        if sort:
+            log_all = log_all.order_by(sort)
+
+        log_infos = []
+        for log in log_all:
+            log_infos.append({
+                'entity_class': log.entity_class,
+                'entity_name': log.entity_name,
+                'action': log.action,
+                'method': log.method,
+                'executor_id': log.executor_id,
+                'executor_username': log.executor_username,
+                'executor_identify': log.executor_identify,
+                'execute_time': log.create_time
+            })
+
+        return Response(log_infos)

BIN
TestLaboratory_ali_v1.3/TestLaboratory/apps/plan/.DS_Store


Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików