50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
# 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)} |