first commit

This commit is contained in:
lihansani
2026-07-13 15:37:05 +08:00
commit 8b11aa2efc
299 changed files with 206339 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
from system.models import HistorySession
from ninja import Router, Schema, Field
router = Router()
class HistorySessionSchema(Schema):
FormId: str = Field(None, alias="formId")
Name: str = Field(None, alias="name")
MMSI: str = Field(None, alias="mmsi")
Mobile: str = Field(None, alias="mobile")
Region: str = Field(None, alias="region")
ById: str = Field(None, alias="byId")
@router.get('/getHistorySession')
def get_history_session(request):
try:
contacts = HistorySession.objects.all().values()
return {
"code": 200,
"message": "成功",
"data": list(contacts)
}
except Exception as e:
return {'code': 500, 'message': str(e)}
@router.post('/insertHistorySession')
def insert_history_session(request, data: HistorySessionSchema):
try:
existing_record = HistorySession.objects.filter(
FormId=data.FormId,
ById=data.ById
).first()
if not existing_record:
history_session = HistorySession.objects.create(
FormId=data.FormId,
Name=data.Name,
MMSI=data.MMSI,
Mobile=data.Mobile,
Region=data.Region,
ById=data.ById
)
return {
"code": 200,
"message": "成功",
}
except Exception as e:
return {'code': 500, 'message': str(e)}