parent
0a9ac4c11b
commit
8940d23028
16 changed files with 434 additions and 0 deletions
@ -0,0 +1,3 @@ |
|||||||
|
from django.contrib import admin |
||||||
|
|
||||||
|
# Register your models here. |
@ -0,0 +1,6 @@ |
|||||||
|
from django.apps import AppConfig |
||||||
|
|
||||||
|
|
||||||
|
class DsptApiConfig(AppConfig): |
||||||
|
default_auto_field = 'django.db.models.BigAutoField' |
||||||
|
name = 'dspt_api' |
@ -0,0 +1,120 @@ |
|||||||
|
# Generated by Django 4.2.7 on 2024-05-23 07:57 |
||||||
|
|
||||||
|
from django.db import migrations, models |
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration): |
||||||
|
|
||||||
|
initial = True |
||||||
|
|
||||||
|
dependencies = [ |
||||||
|
] |
||||||
|
|
||||||
|
operations = [ |
||||||
|
migrations.CreateModel( |
||||||
|
name='CinemaIds', |
||||||
|
fields=[ |
||||||
|
('id', models.IntegerField(primary_key=True, serialize=False)), |
||||||
|
('env', models.CharField(max_length=10, verbose_name='环境')), |
||||||
|
('cinema_id', models.IntegerField(verbose_name='影院id')), |
||||||
|
('cinema_name', models.CharField(max_length=30, verbose_name='影院名称')), |
||||||
|
('cid', models.CharField(max_length=10, verbose_name='影院cid')), |
||||||
|
], |
||||||
|
options={ |
||||||
|
'verbose_name': '影院cid', |
||||||
|
'verbose_name_plural': '影院cid', |
||||||
|
'db_table': 'ec_cinema_cid', |
||||||
|
}, |
||||||
|
), |
||||||
|
migrations.CreateModel( |
||||||
|
name='EcApi', |
||||||
|
fields=[ |
||||||
|
('id', models.IntegerField(primary_key=True, serialize=False)), |
||||||
|
('desc', models.CharField(max_length=20, verbose_name='接口描述')), |
||||||
|
('path', models.CharField(max_length=50, verbose_name='非会员接口地址')), |
||||||
|
('m_path', models.CharField(max_length=50, verbose_name='会员接口地址')), |
||||||
|
], |
||||||
|
options={ |
||||||
|
'verbose_name': '接口', |
||||||
|
'verbose_name_plural': '接口', |
||||||
|
'db_table': 'ec_api', |
||||||
|
}, |
||||||
|
), |
||||||
|
migrations.CreateModel( |
||||||
|
name='EcApiGroup', |
||||||
|
fields=[ |
||||||
|
('id', models.IntegerField(primary_key=True, serialize=False)), |
||||||
|
('group_id', models.CharField(max_length=20, verbose_name='接口分组id')), |
||||||
|
('name', models.CharField(max_length=20, verbose_name='接口分组id')), |
||||||
|
('order', models.IntegerField(verbose_name='子接口顺序')), |
||||||
|
('api_id', models.IntegerField(verbose_name='接口id')), |
||||||
|
], |
||||||
|
options={ |
||||||
|
'verbose_name': '接口组', |
||||||
|
'verbose_name_plural': '接口组', |
||||||
|
'db_table': 'ec_api_group', |
||||||
|
}, |
||||||
|
), |
||||||
|
migrations.CreateModel( |
||||||
|
name='EcApiParams', |
||||||
|
fields=[ |
||||||
|
('id', models.IntegerField(primary_key=True, serialize=False)), |
||||||
|
('api_id', models.IntegerField(verbose_name='接口id')), |
||||||
|
('param', models.CharField(max_length=50, verbose_name='参数')), |
||||||
|
('desc', models.CharField(max_length=500, verbose_name='参数描述')), |
||||||
|
('value', models.CharField(max_length=500, verbose_name='参数值模版')), |
||||||
|
('is_checked', models.BooleanField(default=False, verbose_name='是否默认勾选')), |
||||||
|
('is_request', models.BooleanField(default=False, verbose_name='是否是必选项')), |
||||||
|
], |
||||||
|
options={ |
||||||
|
'verbose_name': '接口参数', |
||||||
|
'verbose_name_plural': '接口参数', |
||||||
|
'db_table': 'ec_api_params', |
||||||
|
}, |
||||||
|
), |
||||||
|
migrations.CreateModel( |
||||||
|
name='EcChannel', |
||||||
|
fields=[ |
||||||
|
('id', models.IntegerField(primary_key=True, serialize=False)), |
||||||
|
('env', models.CharField(max_length=10, verbose_name='环境')), |
||||||
|
('name', models.CharField(max_length=20, verbose_name='渠道名称')), |
||||||
|
('pid', models.CharField(max_length=10, verbose_name='渠道id')), |
||||||
|
('channel_key', models.CharField(max_length=20, verbose_name='渠道key')), |
||||||
|
], |
||||||
|
options={ |
||||||
|
'verbose_name': '渠道', |
||||||
|
'verbose_name_plural': '渠道', |
||||||
|
'db_table': 'ec_channel', |
||||||
|
}, |
||||||
|
), |
||||||
|
migrations.CreateModel( |
||||||
|
name='EcEnv', |
||||||
|
fields=[ |
||||||
|
('id', models.IntegerField(primary_key=True, serialize=False)), |
||||||
|
('name', models.CharField(max_length=20, verbose_name='环境名称')), |
||||||
|
('code', models.CharField(max_length=20, verbose_name='环境编码')), |
||||||
|
('host', models.CharField(max_length=50, verbose_name='环境地址')), |
||||||
|
], |
||||||
|
options={ |
||||||
|
'verbose_name': '环境', |
||||||
|
'verbose_name_plural': '环境', |
||||||
|
'db_table': 'ec_env', |
||||||
|
}, |
||||||
|
), |
||||||
|
migrations.CreateModel( |
||||||
|
name='EcRequestLog', |
||||||
|
fields=[ |
||||||
|
('id', models.IntegerField(primary_key=True, serialize=False)), |
||||||
|
('ip', models.CharField(max_length=20, verbose_name='请求ip')), |
||||||
|
('env', models.CharField(max_length=10, verbose_name='环境')), |
||||||
|
('request', models.CharField(max_length=500, verbose_name='请求链接')), |
||||||
|
('response', models.CharField(max_length=10000, verbose_name='返回值')), |
||||||
|
('request_datetime', models.DateTimeField(verbose_name='请求发送时间')), |
||||||
|
], |
||||||
|
options={ |
||||||
|
'verbose_name': '请求日志', |
||||||
|
'verbose_name_plural': '请求日志', |
||||||
|
'db_table': 'ec_request_log', |
||||||
|
}, |
||||||
|
), |
||||||
|
] |
@ -0,0 +1,18 @@ |
|||||||
|
# Generated by Django 4.2.7 on 2024-05-23 08:02 |
||||||
|
|
||||||
|
from django.db import migrations, models |
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration): |
||||||
|
|
||||||
|
dependencies = [ |
||||||
|
('dspt_api', '0001_initial'), |
||||||
|
] |
||||||
|
|
||||||
|
operations = [ |
||||||
|
migrations.AddField( |
||||||
|
model_name='ecenv', |
||||||
|
name='type', |
||||||
|
field=models.CharField(default='', max_length=20, verbose_name='会员非会员'), |
||||||
|
), |
||||||
|
] |
@ -0,0 +1,18 @@ |
|||||||
|
# Generated by Django 4.2.7 on 2024-05-23 08:34 |
||||||
|
|
||||||
|
from django.db import migrations, models |
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration): |
||||||
|
|
||||||
|
dependencies = [ |
||||||
|
('dspt_api', '0002_ecenv_type'), |
||||||
|
] |
||||||
|
|
||||||
|
operations = [ |
||||||
|
migrations.AddField( |
||||||
|
model_name='ecchannel', |
||||||
|
name='type', |
||||||
|
field=models.CharField(default='', max_length=20, verbose_name='会员非会员'), |
||||||
|
), |
||||||
|
] |
@ -0,0 +1,27 @@ |
|||||||
|
# Generated by Django 4.2.7 on 2024-05-23 09:48 |
||||||
|
|
||||||
|
from django.db import migrations, models |
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration): |
||||||
|
|
||||||
|
dependencies = [ |
||||||
|
('dspt_api', '0003_ecchannel_type'), |
||||||
|
] |
||||||
|
|
||||||
|
operations = [ |
||||||
|
migrations.RemoveField( |
||||||
|
model_name='ecapi', |
||||||
|
name='m_path', |
||||||
|
), |
||||||
|
migrations.AddField( |
||||||
|
model_name='ecapi', |
||||||
|
name='type', |
||||||
|
field=models.CharField(default='', max_length=20, verbose_name='会员非会员'), |
||||||
|
), |
||||||
|
migrations.AlterField( |
||||||
|
model_name='ecapi', |
||||||
|
name='path', |
||||||
|
field=models.CharField(max_length=50, verbose_name='接口地址'), |
||||||
|
), |
||||||
|
] |
@ -0,0 +1,18 @@ |
|||||||
|
# Generated by Django 4.2.7 on 2024-05-23 10:23 |
||||||
|
|
||||||
|
from django.db import migrations, models |
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration): |
||||||
|
|
||||||
|
dependencies = [ |
||||||
|
('dspt_api', '0004_remove_ecapi_m_path_ecapi_type_alter_ecapi_path'), |
||||||
|
] |
||||||
|
|
||||||
|
operations = [ |
||||||
|
migrations.AlterField( |
||||||
|
model_name='ecapiparams', |
||||||
|
name='value', |
||||||
|
field=models.CharField(blank=True, max_length=500, null=True, verbose_name='参数值模版'), |
||||||
|
), |
||||||
|
] |
@ -0,0 +1,116 @@ |
|||||||
|
from django.db import models |
||||||
|
|
||||||
|
|
||||||
|
class EcChannel(models.Model): |
||||||
|
id = models.IntegerField(primary_key=True) |
||||||
|
env = models.CharField(verbose_name='环境', max_length=10, null=False) # 电商平台 dspt 自营电商 zyds |
||||||
|
name = models.CharField(verbose_name='渠道名称', max_length=20, null=False) # 电商平台 dspt 自营电商 zyds |
||||||
|
pid = models.CharField(verbose_name='渠道id', max_length=10, null=False) # pid |
||||||
|
channel_key = models.CharField(verbose_name='渠道key', max_length=20, null=False) # pid key |
||||||
|
type = models.CharField(verbose_name='会员非会员', max_length=20, default='', null=False) # 会员 member 非会员 nonmember |
||||||
|
|
||||||
|
def __str__(self): |
||||||
|
return self.name |
||||||
|
|
||||||
|
class Meta: |
||||||
|
verbose_name = '渠道' |
||||||
|
verbose_name_plural = '渠道' |
||||||
|
db_table = 'ec_channel' |
||||||
|
|
||||||
|
|
||||||
|
class EcEnv(models.Model): |
||||||
|
id = models.IntegerField(primary_key=True) |
||||||
|
name = models.CharField(verbose_name='环境名称', max_length=20, null=False) # 电商平台 自营电商 |
||||||
|
code = models.CharField(verbose_name='环境编码', max_length=20, null=False) # 电商平台 dspt 自营电商 zyds |
||||||
|
type = models.CharField(verbose_name='会员非会员', max_length=20, default='', null=False) # 会员 member 非会员 nonmember |
||||||
|
host = models.CharField(verbose_name='环境地址', max_length=50, null=False) # 环境地址 |
||||||
|
|
||||||
|
def __str__(self): |
||||||
|
return self.name |
||||||
|
|
||||||
|
class Meta: |
||||||
|
verbose_name = '环境' |
||||||
|
verbose_name_plural = '环境' |
||||||
|
db_table = 'ec_env' |
||||||
|
|
||||||
|
|
||||||
|
class EcApi(models.Model): |
||||||
|
id = models.IntegerField(primary_key=True) |
||||||
|
desc = models.CharField(verbose_name='接口描述', max_length=20, null=False) |
||||||
|
path = models.CharField(verbose_name='接口地址', max_length=50, null=False) |
||||||
|
type = models.CharField(verbose_name='会员非会员', max_length=20, default='', null=False) # 会员 member 非会员 nonmember |
||||||
|
|
||||||
|
def __str__(self): |
||||||
|
return self.desc |
||||||
|
|
||||||
|
class Meta: |
||||||
|
verbose_name = '接口' |
||||||
|
verbose_name_plural = '接口' |
||||||
|
db_table = 'ec_api' |
||||||
|
|
||||||
|
|
||||||
|
class EcApiParams(models.Model): |
||||||
|
id = models.IntegerField(primary_key=True) |
||||||
|
api_id = models.IntegerField(verbose_name='接口id', null=False) |
||||||
|
param = models.CharField(verbose_name='参数', max_length=50, null=False) |
||||||
|
desc = models.CharField(verbose_name='参数描述', max_length=500, null=False) |
||||||
|
value = models.CharField(verbose_name='参数值模版', max_length=500, null=True, blank=True) |
||||||
|
is_checked = models.BooleanField(verbose_name='是否默认勾选', null=False, default=False) |
||||||
|
is_request = models.BooleanField(verbose_name='是否是必选项', null=False, default=False) |
||||||
|
|
||||||
|
def __str__(self): |
||||||
|
return self.param |
||||||
|
|
||||||
|
class Meta: |
||||||
|
verbose_name = '接口参数' |
||||||
|
verbose_name_plural = '接口参数' |
||||||
|
db_table = 'ec_api_params' |
||||||
|
|
||||||
|
|
||||||
|
class EcCinemaIds(models.Model): |
||||||
|
id = models.IntegerField(primary_key=True) |
||||||
|
env = models.CharField(verbose_name='环境', max_length=10, null=False) # 电商平台 dspt 自营电商 zyds |
||||||
|
cinema_id = models.IntegerField(verbose_name='影院id', null=False) |
||||||
|
cinema_name = models.CharField(verbose_name='影院名称', max_length=30, null=False) |
||||||
|
cid = models.CharField(verbose_name='影院cid', max_length=10, null=False) |
||||||
|
|
||||||
|
def __str__(self): |
||||||
|
return self.cid |
||||||
|
|
||||||
|
class Meta: |
||||||
|
verbose_name = '影院cid' |
||||||
|
verbose_name_plural = '影院cid' |
||||||
|
db_table = 'ec_cinema_cid' |
||||||
|
|
||||||
|
|
||||||
|
class EcRequestLog(models.Model): |
||||||
|
id = models.IntegerField(primary_key=True) |
||||||
|
ip = models.CharField(verbose_name='请求ip', max_length=20, null=False) # 接口测试人的ip |
||||||
|
env = models.CharField(verbose_name='环境', max_length=10, null=False) # 电商平台 dspt 自营电商 zyds |
||||||
|
request = models.CharField(verbose_name='请求链接', max_length=500, null=False) |
||||||
|
response = models.CharField(verbose_name='返回值', max_length=10000, null=False) |
||||||
|
request_datetime = models.DateTimeField(verbose_name='请求发送时间', null=False) |
||||||
|
|
||||||
|
def __str__(self): |
||||||
|
return self.ip |
||||||
|
|
||||||
|
class Meta: |
||||||
|
verbose_name = '请求日志' |
||||||
|
verbose_name_plural = '请求日志' |
||||||
|
db_table = 'ec_request_log' |
||||||
|
|
||||||
|
|
||||||
|
class EcApiGroup(models.Model): |
||||||
|
id = models.IntegerField(primary_key=True) |
||||||
|
group_id = models.CharField(verbose_name='接口分组id', max_length=20, null=False) |
||||||
|
name = models.CharField(verbose_name='接口分组id', max_length=20, null=False) |
||||||
|
order = models.IntegerField(verbose_name='子接口顺序', null=False) |
||||||
|
api_id = models.IntegerField(verbose_name='接口id', null=False) |
||||||
|
|
||||||
|
def __str__(self): |
||||||
|
return self.name |
||||||
|
|
||||||
|
class Meta: |
||||||
|
verbose_name = '接口组' |
||||||
|
verbose_name_plural = '接口组' |
||||||
|
db_table = 'ec_api_group' |
@ -0,0 +1,45 @@ |
|||||||
|
from rest_framework import serializers |
||||||
|
|
||||||
|
from dspt_api.models import EcChannel, EcEnv, EcApi, EcApiParams, EcCinemaIds, EcRequestLog, EcApiGroup |
||||||
|
|
||||||
|
|
||||||
|
class EcChannelSerializer(serializers.ModelSerializer): |
||||||
|
class Meta: |
||||||
|
model = EcChannel |
||||||
|
fields = '__all__' |
||||||
|
|
||||||
|
|
||||||
|
class EcEnvSerializer(serializers.ModelSerializer): |
||||||
|
class Meta: |
||||||
|
model = EcEnv |
||||||
|
fields = '__all__' |
||||||
|
|
||||||
|
|
||||||
|
class EcApiSerializer(serializers.ModelSerializer): |
||||||
|
class Meta: |
||||||
|
model = EcApi |
||||||
|
fields = '__all__' |
||||||
|
|
||||||
|
|
||||||
|
class EcApiParamsSerializer(serializers.ModelSerializer): |
||||||
|
class Meta: |
||||||
|
model = EcApiParams |
||||||
|
fields = '__all__' |
||||||
|
|
||||||
|
|
||||||
|
class EcCinemaIdsSerializer(serializers.ModelSerializer): |
||||||
|
class Meta: |
||||||
|
model = EcCinemaIds |
||||||
|
fields = '__all__' |
||||||
|
|
||||||
|
|
||||||
|
class EcRequestLogSerializer(serializers.ModelSerializer): |
||||||
|
class Meta: |
||||||
|
model = EcRequestLog |
||||||
|
fields = '__all__' |
||||||
|
|
||||||
|
|
||||||
|
class EcApiGroupSerializer(serializers.ModelSerializer): |
||||||
|
class Meta: |
||||||
|
model = EcApiGroup |
||||||
|
fields = '__all__' |
@ -0,0 +1,3 @@ |
|||||||
|
from django.test import TestCase |
||||||
|
|
||||||
|
# Create your tests here. |
@ -0,0 +1,12 @@ |
|||||||
|
from dspt_api import views |
||||||
|
from django.urls import path |
||||||
|
|
||||||
|
urlpatterns = [ |
||||||
|
path('get_channel', views.EcChannelViewSet.as_view({'get': 'list'}), name='get_ec_channel'), |
||||||
|
path('get_env', views.EcEnvViewSet.as_view({'get': 'list'}), name='get_ec_env'), |
||||||
|
path('get_api', views.EcApiViewSet.as_view({'get': 'list'}), name='get_ec_api'), |
||||||
|
path('get_api_params', views.EcApiParamsViewSet.as_view({'get': 'list'}), name='get_ec_api_params'), |
||||||
|
path('get_cinema_ids', views.EcCinemaIdsViewSet.as_view({'get': 'list'}), name='get_ec_cinema_ids'), |
||||||
|
path('get_request_log', views.EcRequestLogViewSet.as_view({'get': 'list'}), name='get_ec_request_log'), |
||||||
|
path('get_api_group', views.EcApiGroupViewSet.as_view({'get': 'list'}), name='get_ec_api_group'), |
||||||
|
] |
@ -0,0 +1,46 @@ |
|||||||
|
from django_filters.rest_framework import DjangoFilterBackend |
||||||
|
from rest_framework import filters |
||||||
|
from rest_framework import viewsets |
||||||
|
|
||||||
|
from dspt_api.models import EcChannel, EcEnv, EcApi, EcApiParams, EcCinemaIds, EcRequestLog, EcApiGroup |
||||||
|
from dspt_api.serializers import EcChannelSerializer, EcEnvSerializer, EcApiSerializer, EcApiParamsSerializer, \ |
||||||
|
EcCinemaIdsSerializer, EcRequestLogSerializer, EcApiGroupSerializer |
||||||
|
|
||||||
|
|
||||||
|
# Create your views here. |
||||||
|
class EcChannelViewSet(viewsets.ModelViewSet): |
||||||
|
queryset = EcChannel.objects.all() |
||||||
|
serializer_class = EcChannelSerializer |
||||||
|
|
||||||
|
|
||||||
|
class EcEnvViewSet(viewsets.ModelViewSet): |
||||||
|
queryset = EcEnv.objects.all() |
||||||
|
serializer_class = EcEnvSerializer |
||||||
|
|
||||||
|
|
||||||
|
class EcApiViewSet(viewsets.ModelViewSet): |
||||||
|
queryset = EcApi.objects.all() |
||||||
|
serializer_class = EcApiSerializer |
||||||
|
|
||||||
|
|
||||||
|
class EcApiParamsViewSet(viewsets.ModelViewSet): |
||||||
|
queryset = EcApiParams.objects.all() |
||||||
|
serializer_class = EcApiParamsSerializer |
||||||
|
filter_backends = (filters.SearchFilter, DjangoFilterBackend) |
||||||
|
# http://172.16.1.114:8000/ec/get_api_params?api_id=1 |
||||||
|
filterset_fields = ('api_id',) |
||||||
|
|
||||||
|
|
||||||
|
class EcCinemaIdsViewSet(viewsets.ModelViewSet): |
||||||
|
queryset = EcCinemaIds |
||||||
|
serializer_class = EcCinemaIdsSerializer |
||||||
|
|
||||||
|
|
||||||
|
class EcRequestLogViewSet(viewsets.ModelViewSet): |
||||||
|
queryset = EcRequestLog.objects.all() |
||||||
|
serializer_class = EcRequestLogSerializer |
||||||
|
|
||||||
|
|
||||||
|
class EcApiGroupViewSet(viewsets.ModelViewSet): |
||||||
|
queryset = EcApiGroup.objects.all() |
||||||
|
serializer_class = EcApiGroupSerializer |
Loading…
Reference in new issue