Compare commits
33 Commits
Author | SHA1 | Date |
---|---|---|
|
e57978cfb1 | 2 years ago |
|
db53d8faae | 2 years ago |
|
4328999efb | 2 years ago |
|
ea80c404bc | 2 years ago |
|
bcd37fa530 | 2 years ago |
|
343bbdb923 | 2 years ago |
|
6fe10d0805 | 2 years ago |
|
60962c31cc | 2 years ago |
|
5751ab8c4b | 2 years ago |
|
02edb60088 | 2 years ago |
|
807c9c375b | 2 years ago |
|
b7e89ea383 | 2 years ago |
|
801ebb2663 | 2 years ago |
|
84bdc96656 | 2 years ago |
|
d871de2c76 | 2 years ago |
|
5c4595a246 | 2 years ago |
|
722179e2ef | 2 years ago |
|
188378dfd3 | 2 years ago |
|
c6c750e96d | 2 years ago |
|
500cb26365 | 2 years ago |
|
fa4a738d25 | 2 years ago |
|
c521072492 | 2 years ago |
|
dca40c7442 | 2 years ago |
|
f309d32c5e | 2 years ago |
|
56b60a8bf1 | 2 years ago |
|
a72191aa8a | 2 years ago |
|
7d6d044b03 | 2 years ago |
|
ad4870e45f | 2 years ago |
|
fee42661c5 | 2 years ago |
|
444ff289ef | 2 years ago |
|
7654b85254 | 2 years ago |
|
7f56dc2dad | 2 years ago |
|
99a8a978c9 | 2 years ago |
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.
Binary file not shown.
@ -1,3 +1,5 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
from app.models import TP
|
||||
admin.site.register(TP)
|
||||
|
@ -1,6 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class AppConfig(AppConfig):
|
||||
class App01Config(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'app'
|
||||
|
@ -0,0 +1,23 @@
|
||||
import logging
|
||||
from rest_framework.views import exception_handler as drf_exception_handler # drf原生处理异常函数取别名
|
||||
from rest_framework.views import Response
|
||||
from rest_framework import status
|
||||
|
||||
|
||||
logger = logging.getLogger('mylogger')
|
||||
|
||||
|
||||
def exception_handler(exc, context):
|
||||
# drf的exception_handler做基础处理
|
||||
response = drf_exception_handler(exc, context)
|
||||
# 为空,进行自定义二次处理
|
||||
logger.error(str(exc))
|
||||
if response is None:
|
||||
# print(exc) # 错误原因
|
||||
# print(context) # 错误信息
|
||||
# print('%s - %s - %s' % (context['view'], context['request'].method, exc))
|
||||
return Response({
|
||||
'detail': '服务器错误'
|
||||
}, status=status.HTTP_500_INTERNAL_SERVER_ERROR, exception=True)
|
||||
return response
|
||||
|
Binary file not shown.
@ -1,3 +1,42 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
class TP(models.Model):
|
||||
# uid
|
||||
uid = models.AutoField(primary_key=True)
|
||||
# 视频哈希
|
||||
video_hash = models.CharField(max_length=50, verbose_name='视频哈希')
|
||||
# 记录仪时间
|
||||
record_time = models.DateTimeField(verbose_name='记录仪时间')
|
||||
# 警号
|
||||
police_id = models.CharField(max_length=50, null=True, blank=True, verbose_name='警号') # 警号可为空可不传
|
||||
# 事件类型
|
||||
event_type = models.CharField(max_length=50, verbose_name='事件类型')
|
||||
# 是否违规
|
||||
is_violation = models.BooleanField(verbose_name='是否违规')
|
||||
# 缩略图
|
||||
small_image = models.CharField(max_length=100, verbose_name='缩略图')
|
||||
# 相对时间
|
||||
relative_time = models.FloatField(verbose_name='相对时间')
|
||||
# 视频路径
|
||||
video_dir = models.CharField(max_length=100, verbose_name='视频路径')
|
||||
# 车牌号
|
||||
car_number = models.CharField(max_length=50, verbose_name='车牌号', null=True, blank=True) # 车牌可为空可不传
|
||||
# 分析结果
|
||||
ai_analysis = models.CharField(max_length=255, verbose_name='分析结果', null=True, blank=True) # 分析结果可为空可不传
|
||||
# 加入时间
|
||||
add_time = models.DateTimeField(auto_now_add=True, verbose_name='加入时间')
|
||||
# 更新时间
|
||||
update_time = models.DateTimeField(auto_now=True, verbose_name='更新时间')
|
||||
# 是否显示
|
||||
is_display = models.BooleanField(default=True, verbose_name='是否显示')
|
||||
|
||||
class Meta:
|
||||
db_table = "app_tp"
|
||||
|
||||
# 排序 uid倒序
|
||||
ordering = ['-uid']
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,9 @@
|
||||
from rest_framework.pagination import PageNumberPagination
|
||||
|
||||
|
||||
class MyPageNumberPagination(PageNumberPagination):
|
||||
page_size = 10
|
||||
page_query_param = "page"
|
||||
page_size_query_param = "page_size"
|
||||
max_page_size = 100
|
||||
|
@ -1,3 +1,20 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
from rest_framework import viewsets
|
||||
from rest_framework.response import Response
|
||||
from app.models import TP
|
||||
from app.serializers import SerialMyModel, SerialFilter
|
||||
from app.pagination import MyPageNumberPagination
|
||||
|
||||
|
||||
class ModelQuery(viewsets.ModelViewSet):
|
||||
# 查询类
|
||||
queryset = TP.objects.all().order_by("-uid") # 按照uid倒序
|
||||
# 序列化类
|
||||
serializer_class = SerialMyModel
|
||||
# 分页类
|
||||
pagination_class = MyPageNumberPagination
|
||||
|
||||
# 条件筛选
|
||||
filterset_class = SerialFilter
|
||||
|
@ -0,0 +1,6 @@
|
||||
[global]
|
||||
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
[install]
|
||||
trusted-host = https://pypi.tuna.tsinghua.edu.cn
|
||||
[list]
|
||||
format=columns
|
Binary file not shown.
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
python manage.py makemigrations&&
|
||||
python manage.py migrate&&
|
||||
uwsgi --ini /home/myproject/uwsgi.ini&&
|
||||
echo 'TP项目启动完成'
|
||||
tail -f /dev/null
|
||||
|
||||
exec "$@"
|
Loading…
Reference in New Issue