第一次提交代码

This commit is contained in:
陈银花 2021-09-29 09:52:00 +08:00
parent aa90eaa97f
commit 58644ffada
230 changed files with 22407 additions and 0 deletions

12
Pipfile Normal file
View File

@ -0,0 +1,12 @@
[[source]]
url = "https://pypi.douban.com/simple"
verify_ssl = true
name = "pypi"
[packages]
django = "*"
[dev-packages]
[requires]
python_version = "3.9"

52
Pipfile.lock generated Normal file
View File

@ -0,0 +1,52 @@
{
"_meta": {
"hash": {
"sha256": "c36ae28fea7b9a4cc02145632e2f41469af2e7b38b801903abb8333d3306f36b"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.9"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"asgiref": {
"hashes": [
"sha256:4ef1ab46b484e3c706329cedeff284a5d40824200638503f5768edb6de7d58e9",
"sha256:ffc141aa908e6f175673e7b1b3b7af4fdb0ecb738fc5c8b88f69f055c2415214"
],
"markers": "python_version >= '3.6'",
"version": "==3.4.1"
},
"django": {
"hashes": [
"sha256:7f92413529aa0e291f3be78ab19be31aefb1e1c9a52cd59e130f505f27a51f13",
"sha256:f27f8544c9d4c383bbe007c57e3235918e258364577373d4920e9162837be022"
],
"index": "pypi",
"version": "==3.2.6"
},
"pytz": {
"hashes": [
"sha256:83a4a90894bf38e243cf052c8b58f381bfe9a7a483f6a9cab140bc7f702ac4da",
"sha256:eb10ce3e7736052ed3623d49975ce333bcd712c7bb19a58b9e2089d4057d0798"
],
"version": "==2021.1"
},
"sqlparse": {
"hashes": [
"sha256:017cde379adbd6a1f15a61873f43e8274179378e95ef3fede90b5aa64d304ed0",
"sha256:0f91fd2e829c44362cbcfab3e9ae12e22badaa8a29ad5ff599f9ec109f0454e8"
],
"markers": "python_version >= '3.5'",
"version": "==0.4.1"
}
},
"develop": {}
}

6
apps/__init__.py Normal file
View File

@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# @Time : 2021/8/28 22:19
# @Author : Flora.Chen
# @File : __init__.py.py
# @Software: PyCharm
# @Desc:

Binary file not shown.

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

3
apps/configures/admin.py Normal file
View File

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

6
apps/configures/apps.py Normal file
View File

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

View File

@ -0,0 +1,34 @@
# Generated by Django 3.2.6 on 2021-09-13 16:08
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('interfaces', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Configures',
fields=[
('id', models.AutoField(help_text='ID', primary_key=True, serialize=False, verbose_name='ID')),
('create_time', models.DateTimeField(auto_now_add=True, help_text='创建时间', verbose_name='创建时间')),
('update_time', models.DateTimeField(auto_now=True, help_text='更新时间', verbose_name='更新时间')),
('name', models.CharField(help_text='配置名称', max_length=50, unique=True, verbose_name='配置名称')),
('author', models.CharField(help_text='编写人员', max_length=50, verbose_name='编写人员')),
('request', models.TextField(help_text='请求信息', verbose_name='请求信息')),
('interface', models.ForeignKey(help_text='所属接口', on_delete=django.db.models.deletion.CASCADE, related_name='configures', to='interfaces.interfaces', verbose_name='所属接口')),
],
options={
'verbose_name': '配置表',
'verbose_name_plural': '配置表',
'db_table': 'tb_configures',
'ordering': ['id'],
},
),
]

View File

21
apps/configures/models.py Normal file
View File

@ -0,0 +1,21 @@
from django.db import models
from utils.base_models import BaseModel
class Configures(BaseModel):
# id = models.AutoField(primary_key=True, verbose_name="ID", help_text="ID")
name = models.CharField(unique=True, max_length=50, help_text="配置名称", verbose_name="配置名称")
interface = models.ForeignKey("interfaces.Interfaces", on_delete=models.CASCADE,
help_text="所属接口", verbose_name="所属接口", related_name="configures")
author = models.CharField(max_length=50, help_text="编写人员", verbose_name="编写人员")
request = models.TextField(help_text="请求信息", verbose_name="请求信息")
class Meta:
"""内部类"""
db_table = "tb_configures"
verbose_name = "配置表"
ordering = ["id"]
verbose_name_plural = verbose_name
def __str__(self):
return f"<{self.name}>"

View File

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# @Time : 2021/9/16 23:48
# @Author : Flora.Chen
# @File : serializers.py
# @Software: PyCharm
# @Desc:
from rest_framework import serializers
from .models import Configures
class ConfiguresModelSerializers(serializers.ModelSerializer):
"""配置管理的序列化器类"""
class Meta:
model = Configures
exclude = ("create_time", "update_time")
extra_kwargs = {
}

3
apps/configures/tests.py Normal file
View File

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

16
apps/configures/urls.py Normal file
View File

@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# @Time : 2021/9/16 23:46
# @Author : Flora.Chen
# @File : urls.py
# @Software: PyCharm
# @Desc:
from rest_framework.routers import SimpleRouter
from django.urls import path, re_path
from . import views
router = SimpleRouter()
router.register(r"configures", views.ConfiguresView)
urlpatterns = []
urlpatterns += router.urls

8
apps/configures/views.py Normal file
View File

@ -0,0 +1,8 @@
from rest_framework.viewsets import ModelViewSet
from .models import Configures
from . import serializers
class ConfiguresView(ModelViewSet):
queryset = Configures.objects.all()
serializer_class = serializers.ConfiguresModelSerializers

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

3
apps/debugtalks/admin.py Normal file
View File

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

6
apps/debugtalks/apps.py Normal file
View File

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

View File

@ -0,0 +1,33 @@
# Generated by Django 3.2.6 on 2021-09-13 16:08
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('projects', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='DebugTalks',
fields=[
('id', models.AutoField(help_text='ID', primary_key=True, serialize=False, verbose_name='ID')),
('create_time', models.DateTimeField(auto_now_add=True, help_text='创建时间', verbose_name='创建时间')),
('update_time', models.DateTimeField(auto_now=True, help_text='更新时间', verbose_name='更新时间')),
('name', models.CharField(help_text='debugtalk文件名称', max_length=200, unique=True, verbose_name='debugtalk文件名称')),
('debugtalk', models.TextField(default='#debugtalk.py', help_text='debugtalk.py文件', null=True)),
('project', models.OneToOneField(help_text='所属项目', on_delete=django.db.models.deletion.CASCADE, related_name='debugtalks', to='projects.projects')),
],
options={
'verbose_name': 'debugtalk文件',
'verbose_name_plural': 'debugtalk文件',
'db_table': 'tb_debugtalks',
'ordering': ['id'],
},
),
]

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.6 on 2021-09-13 16:10
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('debugtalks', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='debugtalks',
name='name',
field=models.CharField(help_text='debugtalk文件名称', max_length=200, verbose_name='debugtalk文件名称'),
),
]

View File

@ -0,0 +1,17 @@
# Generated by Django 3.2.6 on 2021-09-13 16:11
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('debugtalks', '0002_alter_debugtalks_name'),
]
operations = [
migrations.AlterModelOptions(
name='debugtalks',
options={'verbose_name': 'debugtalk文件', 'verbose_name_plural': 'debugtalk文件'},
),
]

View File

20
apps/debugtalks/models.py Normal file
View File

@ -0,0 +1,20 @@
from django.db import models
from utils.base_models import BaseModel
class DebugTalks(BaseModel):
# id = models.AutoField(primary_key=True, verbose_name="ID", help_text="ID")
name = models.CharField(max_length=200, help_text="debugtalk文件名称", default='debugtalk.py',
verbose_name="debugtalk文件名称")
debugtalk = models.TextField(null=True, default="#debugtalk.py", help_text="debugtalk.py文件")
project = models.OneToOneField("projects.Projects", on_delete=models.CASCADE, related_name="debugtalks",
help_text="所属项目")
class Meta:
"""内部类"""
db_table = "tb_debugtalks"
verbose_name = "debugtalk文件"
verbose_name_plural = verbose_name
def __str__(self):
return f"<{self.name}>"

View File

@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
# @Time : 2021/9/16 23:50
# @Author : Flora.Chen
# @File : serializers.py
# @Software: PyCharm
# @Desc:
from rest_framework import serializers
from .models import DebugTalks
class DebugtalksModelSerailizers(serializers.ModelSerializer):
"""内置函数的序列化器类"""
project = serializers.SlugRelatedField(slug_field="name", read_only=True, label="所属项目", help_text="所属项目")
class Meta:
model = DebugTalks
exclude = ("create_time", "update_time")
extra_kwargs = {
"debugtalk": {
"write_only": "True",
"error_messages": {
"null": "debugtalk文件不能为空"
}
},
"name": {
"max_length": 50,
"error_messages": {
"max_length": "name最大长度为50"
}
}
}
class DebugtalkSerializer(serializers.ModelSerializer):
class Meta:
model = DebugTalks
fields = ('id', 'debugtalk')

3
apps/debugtalks/tests.py Normal file
View File

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

14
apps/debugtalks/urls.py Normal file
View File

@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
# @Time : 2021/9/16 23:50
# @Author : Flora.Chen
# @File : urls.py
# @Software: PyCharm
# @Desc:
from rest_framework.routers import SimpleRouter
from .views import DebugtalksView
router = SimpleRouter()
router.register(r"debugtalks", DebugtalksView)
urlpatterns = []
urlpatterns += router.urls

14
apps/debugtalks/views.py Normal file
View File

@ -0,0 +1,14 @@
from rest_framework.viewsets import GenericViewSet
from rest_framework.mixins import ListModelMixin, RetrieveModelMixin, UpdateModelMixin
from . import serializers
from .models import DebugTalks
from rest_framework import permissions
class DebugtalksView(GenericViewSet, ListModelMixin, RetrieveModelMixin, UpdateModelMixin):
queryset = DebugTalks.objects.all()
serializer_class = serializers.DebugtalksModelSerailizers
permission_classes = [permissions.IsAuthenticated]
def get_serializer_class(self):
return serializers.DebugtalkSerializer if self.action == "retrieve" else super().get_serializer_class()

0
apps/envs/__init__.py Normal file
View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

3
apps/envs/admin.py Normal file
View File

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

6
apps/envs/apps.py Normal file
View File

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

View File

@ -0,0 +1,31 @@
# Generated by Django 3.2.6 on 2021-09-13 16:08
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Envs',
fields=[
('id', models.AutoField(help_text='ID', primary_key=True, serialize=False, verbose_name='ID')),
('create_time', models.DateTimeField(auto_now_add=True, help_text='创建时间', verbose_name='创建时间')),
('update_time', models.DateTimeField(auto_now=True, help_text='更新时间', verbose_name='更新时间')),
('name', models.CharField(help_text='环境名称', max_length=200, unique=True, verbose_name='环境名称')),
('base_url', models.URLField(help_text='请求base_url', verbose_name='请求base_url')),
('desc', models.CharField(help_text='简要描述', max_length=200, verbose_name='简要描述')),
],
options={
'verbose_name': '环境信息',
'verbose_name_plural': '环境信息',
'db_table': 'tb_envs',
'ordering': ['id'],
},
),
]

View File

19
apps/envs/models.py Normal file
View File

@ -0,0 +1,19 @@
from django.db import models
from utils.base_models import BaseModel
class Envs(BaseModel):
# id = models.AutoField(primary_key=True, verbose_name="ID", help_text="ID")
name = models.CharField(unique=True, max_length=200, help_text="环境名称", verbose_name="环境名称")
base_url = models.URLField(verbose_name="请求base_url", max_length=200, help_text="请求base_url")
desc = models.CharField(verbose_name="简要描述", help_text="简要描述", max_length=200)
class Meta:
"""内部类"""
db_table = "tb_envs"
verbose_name = "环境信息"
ordering = ["id"]
verbose_name_plural = verbose_name
def __str__(self):
return f"<{self.name}>"

50
apps/envs/serializers.py Normal file
View File

@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
# @Time : 2021/9/16 23:20
# @Author : Flora.Chen
# @File : serializers.py
# @Software: PyCharm
# @Desc:
from rest_framework import serializers
from .models import Envs
class EnvsModelSerializer(serializers.ModelSerializer):
"""环境管理的序列化器类"""
class Meta:
model = Envs
exclude = ("update_time",)
extra_kwargs = {
"name": {
"min_length": 1,
"max_length": 50,
"error_messages": {
"unique": "环境名称不能重复",
"max_length": "环境名称不能超过50个字符",
"min_length": "环境名称至少输入1个字符"
}
},
"base_url": {
"max_length": 50,
"error_messages": {
"max_length": "base_url不能超过50个字符",
}
},
"desc": {
"error_messages": {
"max_length": "描述不能超过200个字符",
}
},
"create_time": {
"format": "%Y-%m-%d %H:%M:%S"
}
}
class EnvsNameSerializer(serializers.ModelSerializer):
"""返回环境的名称"""
class Meta:
model = Envs
fields = ("id", "name")

3
apps/envs/tests.py Normal file
View File

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

16
apps/envs/urls.py Normal file
View File

@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# @Time : 2021/9/16 23:14
# @Author : Flora.Chen
# @File : urls.py
# @Software: PyCharm
# @Desc:
from django.urls import path, re_path
from rest_framework.routers import SimpleRouter
from .views import EnvView
router = SimpleRouter()
router.register(r"envs", EnvView)
urlpatterns = []
urlpatterns += router.urls

30
apps/envs/views.py Normal file
View File

@ -0,0 +1,30 @@
from rest_framework.decorators import action
from .models import Envs
from . import serializers
from rest_framework.viewsets import ModelViewSet
from rest_framework import filters
from rest_framework import permissions
from utils.mixins import GetDataMinxin
class EnvView(ModelViewSet, GetDataMinxin):
queryset = Envs.objects.all()
serializer_class = serializers.EnvsModelSerializer
# filter_backends = [filters.SearchFilter, filters.OrderingFilter]
# search_fields = ['id', 'name', 'tester']
# ordering_fields = ['name', 'tester']
# permission_classes = [permissions.IsAuthenticated]
@action(detail=False)
def names(self, request, *args, **kwargs):
"""获取所有的环境名称"""
response = super().list(request, *args, **kwargs)
return response
def get_serializer_class(self):
if self.action == "names":
return serializers.EnvsNameSerializer
else:
return super(EnvView, self).get_serializer_class()

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

3
apps/interfaces/admin.py Normal file
View File

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

6
apps/interfaces/apps.py Normal file
View File

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

View File

@ -0,0 +1,34 @@
# Generated by Django 3.2.6 on 2021-09-13 16:08
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
('projects', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Interfaces',
fields=[
('id', models.AutoField(help_text='ID', primary_key=True, serialize=False, verbose_name='ID')),
('create_time', models.DateTimeField(auto_now_add=True, help_text='创建时间', verbose_name='创建时间')),
('update_time', models.DateTimeField(auto_now=True, help_text='更新时间', verbose_name='更新时间')),
('name', models.CharField(help_text='接口名称', max_length=200, unique=True, verbose_name='接口名称')),
('tester', models.CharField(help_text='测试人员', max_length=50, verbose_name='测试人员')),
('desc', models.TextField(blank=True, default='', help_text='描述', max_length=200, null=True, verbose_name='描述')),
('project', models.ForeignKey(help_text='所属项目', on_delete=django.db.models.deletion.CASCADE, related_name='interfaces', to='projects.projects', verbose_name='所属项目')),
],
options={
'verbose_name': '接口表',
'verbose_name_plural': '接口表',
'db_table': 'tb_interfaces',
'ordering': ['id'],
},
),
]

View File

21
apps/interfaces/models.py Normal file
View File

@ -0,0 +1,21 @@
from django.db import models
from utils.base_models import BaseModel
class Interfaces(BaseModel):
# id = models.AutoField(primary_key=True, verbose_name="ID", help_text="ID")
name = models.CharField(unique=True, max_length=200, help_text="接口名称", verbose_name="接口名称")
tester = models.CharField(max_length=50, help_text="测试人员", verbose_name="测试人员")
desc = models.TextField(help_text="描述", verbose_name="描述", null=True, blank=True, default="", max_length=200)
project = models.ForeignKey("projects.Projects", on_delete=models.CASCADE, related_name="interfaces",
help_text="所属项目", verbose_name="所属项目")
class Meta:
"""内部类"""
db_table = "tb_interfaces"
verbose_name = "接口表"
ordering = ["id"]
verbose_name_plural = verbose_name
def __str__(self):
return f"<{self.name}>"

View File

@ -0,0 +1,79 @@
# -*- coding: utf-8 -*-
# @Time : 2021/9/14 23:24
# @Author : Flora.Chen
# @File : serializers.py
# @Software: PyCharm
# @Desc:
from rest_framework import serializers
from .models import Interfaces
from projects.models import Projects
from configures.models import Configures
from testcases.models import TestCases
from projects.models import Projects
class InterfacesModelSerializer(serializers.ModelSerializer):
"""接口序列化器类"""
project_id = serializers.PrimaryKeyRelatedField(queryset=Projects.objects.all(), label="所属项目id", help_text="所属项目id")
project = serializers.SlugRelatedField(slug_field="name", read_only=True, label="所属项目名称", help_text="所属项目名称")
class Meta:
model = Interfaces
exclude = ("update_time",)
extra_kwargs = {
"name": {
"error_messages": {"required": "请输入接口名称", "null": "接口名称不能为null", "blank": "接口名称不能为空字符串",
"max_length": "接口名称长度不能超过200"}
},
"tester": {
"error_messages": {"required": "请输入测试人员", "null": "测试人员不能为null", "blank": "测试人员不能为空字符串",
"max_length": "测试人员长度不能超过50"}
},
"desc": {
"error_messages": {"max_length": "简要描述长度不能超过200"}
},
"project": {
"error_messages": {"required": "请选择所属项目", }
},
"create_time": {
"format": "%Y-%m-%d %H:%M:%S"
}
}
def to_internal_value(self, data):
result = super(InterfacesModelSerializer, self).to_internal_value(data)
result["project"] = result.pop("project_id")
return result
class TestcasesNameSerializer(serializers.ModelSerializer):
"""获取用例名称"""
class Meta:
model = TestCases
fields = ('id', 'name')
class TestCasesInterfaceSerializer(serializers.ModelSerializer):
testcases = TestcasesNameSerializer(many=True)
class Meta:
model = Interfaces
fields = ("testcases", )
class ConfiguresNameSerializer(serializers.ModelSerializer):
"""获取配置名称"""
class Meta:
model = Configures
fields = ('id', 'name')
class ConfiguresInterfaceSerializer(serializers.ModelSerializer):
configures = ConfiguresNameSerializer(many=True)
class Meta:
model = Interfaces
fields = ("configures", )

3
apps/interfaces/tests.py Normal file
View File

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

14
apps/interfaces/urls.py Normal file
View File

@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
# @Time : 2021/8/31 23:20
# @Author : Flora.Chen
# @File : urls.py
# @Software: PyCharm
# @Desc:
from . import views
from rest_framework import routers
router = routers.SimpleRouter()
router.register(r"interfaces", views.InterfacesViewSet)
urlpatterns = []
urlpatterns += router.urls

79
apps/interfaces/views.py Normal file
View File

@ -0,0 +1,79 @@
import logging
from rest_framework.decorators import action
from rest_framework.viewsets import ModelViewSet
from .models import Interfaces
from . import serializers
from interfaces.models import Interfaces
from testcases.models import TestCases
from configures.models import Configures
from rest_framework import filters
from rest_framework import permissions
from utils.mixins import GetDataMinxin
logger = logging.getLogger("mytest")
class InterfacesViewSet(ModelViewSet, GetDataMinxin):
"""接口"""
queryset = Interfaces.objects.all()
serializer_class = serializers.InterfacesModelSerializer
filter_backends = [filters.SearchFilter, filters.OrderingFilter]
search_fields = ['id', 'name', 'tester']
ordering_fields = ['name', 'tester']
permission_classes = [permissions.IsAuthenticated]
def list(self, request, *args, **kwargs):
response = super().list(request, *args, **kwargs)
for item in response.data["results"]:
item["testcases"] = TestCases.objects.filter(interface_id=item.get("id")).count()
item["configures"] = Configures.objects.filter(interface_id=item.get("id")).count()
return response
@action(detail=False)
def names(self, request, *args, **kwargs):
"""获取所有接口的名称"""
response = super().list(request, *args, **kwargs)
logger.error(response.data)
return response
# def get_data_by_ation(self, request, *args, **kwargs):
# response = self.retrieve(request, *args, **kwargs)
# response.data = response.data.get(self.action)
# logger.error(response.data)
# return response
#
# @action(detail=True, url_name="configs", url_path="configs")
# def configures(self, request, *args, **kwargs):
# """获取接口下的配置信息"""
# return self.get_data_by_ation(request, *args, **kwargs)
#
# @action(detail=True)
# def testcases(self, request, *args, **kwargs):
# """获取接口下的配置信息"""
# return self.get_data_by_ation(request, *args, **kwargs)
# ----------------- 使用继承的GetDataMinxin ------------------------ #
@action(detail=True, url_name="configs", url_path="configs")
def configures(self, request, *args, **kwargs):
"""获取接口下的配置信息"""
return self.get_data_by_ation(request, *args, **kwargs)
@action(detail=True)
def testcases(self, request, *args, **kwargs):
"""获取接口下的配置信息"""
return self.get_data_by_ation(request, *args, **kwargs)
# ----------------- 使用继承的GetDataMinxin ------------------------ #
def get_serializer_class(self):
if self.action == "names":
return serializers.TestcasesNameSerializer
elif self.action == "configs":
return serializers.ConfiguresInterfaceSerializer
elif self.action == "testcases":
return serializers.TestCasesInterfaceSerializer
else:
return super().get_serializer_class()

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

3
apps/projects/admin.py Normal file
View File

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

6
apps/projects/apps.py Normal file
View File

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

View File

@ -0,0 +1,34 @@
# Generated by Django 3.2.6 on 2021-09-13 16:08
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Projects',
fields=[
('id', models.AutoField(help_text='ID', primary_key=True, serialize=False, verbose_name='ID')),
('create_time', models.DateTimeField(auto_now_add=True, help_text='创建时间', verbose_name='创建时间')),
('update_time', models.DateTimeField(auto_now=True, help_text='更新时间', verbose_name='更新时间')),
('name', models.CharField(help_text='项目名称', max_length=50, unique=True, verbose_name='项目名称')),
('leader', models.CharField(help_text='负责人', max_length=50, verbose_name='负责人')),
('tester', models.CharField(help_text='测试人员', max_length=50, verbose_name='测试人员')),
('programmer', models.CharField(help_text='开发人员', max_length=50, verbose_name='开发人员')),
('publish_app', models.CharField(help_text='发布应用', max_length=100, verbose_name='发布应用')),
('desc', models.TextField(blank=True, default='', help_text='描述', max_length=200, null=True, verbose_name='描述')),
],
options={
'verbose_name': '项目表',
'verbose_name_plural': '项目表',
'db_table': 'tb_projects',
'ordering': ['id'],
},
),
]

View File

22
apps/projects/models.py Normal file
View File

@ -0,0 +1,22 @@
from django.db import models
from utils.base_models import BaseModel
class Projects(BaseModel):
# id = models.AutoField(primary_key=True, verbose_name="ID", help_text="ID")
name = models.CharField(unique=True, max_length=50, help_text="项目名称", verbose_name="项目名称")
leader = models.CharField(max_length=50, help_text="负责人", verbose_name="负责人")
tester = models.CharField(max_length=50, help_text="测试人员", verbose_name="测试人员")
programmer = models.CharField(max_length=50, help_text="开发人员", verbose_name="开发人员")
publish_app = models.CharField(max_length=100, help_text="发布应用", verbose_name="发布应用")
desc = models.TextField(help_text="描述", verbose_name="描述", null=True, blank=True, default="", max_length=200)
class Meta:
"""内部类"""
db_table = "tb_projects"
verbose_name = "项目表"
ordering = ["id"]
verbose_name_plural = verbose_name
def __str__(self):
return f"<{self.name}>"

View File

@ -0,0 +1,58 @@
# -*- coding: utf-8 -*-
# @Time : 2021/8/31 23:09
# @Author : Flora.Chen
# @File : serializers.py
# @Software: PyCharm
# @Desc:
from rest_framework import serializers, validators
from .models import Projects
from debugtalks.models import DebugTalks
from interfaces.models import Interfaces
class ProjectModelSerializer(serializers.ModelSerializer):
"""使用模型类生成序列化器类"""
class Meta:
model = Projects
# 指定不需要生成的字段
exclude = ("update_time",)
extra_kwargs = {
"name": {
"min_length": 3,
"error_messages": {"required": "name是必填字段", "null": "name不能为null", "blank": "name不能为空字符串",
"max_length": "name长度不能超过20"}
},
"create_time": {
"format": "%Y-%m-%d %H:%M:%S"
}
}
def create(self, validated_data):
"""创建项目的同时创建debugtalk.py"""
obj = super().create(validated_data)
DebugTalks.objects.create(name="debugtalk.py", project_id=obj.id)
return obj
class NamesProjectSerializer(serializers.ModelSerializer):
"""获取项目名称"""
class Meta:
model = Projects
fields = ('id', 'name')
class InterfacesNamesSerializer(serializers.ModelSerializer):
"""获取接口名称"""
class Meta:
model = Interfaces
fields = ('id', 'name')
class InterfacesProjectSerializer(serializers.ModelSerializer):
interfaces = InterfacesNamesSerializer(many=True)
class Meta:
model = Projects
fields = ('interfaces',)

Some files were not shown because too many files have changed in this diff Show More