2024-03-11 09:28:05 +00:00
|
|
|
|
# coding=utf-8
|
|
|
|
|
|
"""
|
|
|
|
|
|
@project: maxkb
|
|
|
|
|
|
@Author:虎
|
|
|
|
|
|
@file: problem_api.py
|
|
|
|
|
|
@date:2024/3/11 10:49
|
|
|
|
|
|
@desc:
|
|
|
|
|
|
"""
|
|
|
|
|
|
from drf_yasg import openapi
|
|
|
|
|
|
|
|
|
|
|
|
from common.mixins.api_mixin import ApiMixin
|
2025-01-13 08:38:28 +00:00
|
|
|
|
from django.utils.translation import gettext_lazy as _
|
2024-03-11 09:28:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ProblemApi(ApiMixin):
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_response_body_api():
|
|
|
|
|
|
return openapi.Schema(
|
|
|
|
|
|
type=openapi.TYPE_OBJECT,
|
|
|
|
|
|
required=['id', 'content', 'hit_num', 'dataset_id', 'create_time', 'update_time'],
|
|
|
|
|
|
properties={
|
|
|
|
|
|
'id': openapi.Schema(type=openapi.TYPE_STRING, title="id",
|
|
|
|
|
|
description="id", default="xx"),
|
2025-01-13 08:38:28 +00:00
|
|
|
|
'content': openapi.Schema(type=openapi.TYPE_STRING, title=_('content'),
|
|
|
|
|
|
description=_('content'), default=_('content')),
|
|
|
|
|
|
'hit_num': openapi.Schema(type=openapi.TYPE_INTEGER, title=_('hit num'), description=_('hit num'),
|
2024-03-11 09:28:05 +00:00
|
|
|
|
default=1),
|
2025-01-13 08:38:28 +00:00
|
|
|
|
'dataset_id': openapi.Schema(type=openapi.TYPE_STRING, title=_('dataset id'),
|
|
|
|
|
|
description=_('dataset id'), default='xxx'),
|
|
|
|
|
|
'update_time': openapi.Schema(type=openapi.TYPE_STRING, title=_('update time'),
|
|
|
|
|
|
description=_('update time'),
|
2024-03-11 09:28:05 +00:00
|
|
|
|
default="1970-01-01 00:00:00"),
|
2025-01-13 08:38:28 +00:00
|
|
|
|
'create_time': openapi.Schema(type=openapi.TYPE_STRING, title=_('create time'),
|
|
|
|
|
|
description=_('create time'),
|
2024-03-11 09:28:05 +00:00
|
|
|
|
default="1970-01-01 00:00:00"
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2024-09-20 09:07:52 +00:00
|
|
|
|
class BatchAssociation(ApiMixin):
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_params_api():
|
|
|
|
|
|
return ProblemApi.BatchOperate.get_request_params_api()
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_body_api():
|
|
|
|
|
|
return openapi.Schema(
|
|
|
|
|
|
type=openapi.TYPE_OBJECT,
|
|
|
|
|
|
required=['problem_id_list'],
|
|
|
|
|
|
properties={
|
2025-01-13 08:38:28 +00:00
|
|
|
|
'problem_id_list': openapi.Schema(type=openapi.TYPE_ARRAY, title=_('problem id list'),
|
|
|
|
|
|
description=_('problem id list'),
|
2024-09-20 09:07:52 +00:00
|
|
|
|
items=openapi.Schema(type=openapi.TYPE_STRING)),
|
2025-01-13 08:38:28 +00:00
|
|
|
|
'paragraph_list': openapi.Schema(type=openapi.TYPE_ARRAY, title=_('Associated paragraph information list'),
|
|
|
|
|
|
description=_('Associated paragraph information list'),
|
2024-09-20 09:07:52 +00:00
|
|
|
|
items=openapi.Schema(type=openapi.TYPE_OBJECT,
|
|
|
|
|
|
required=['paragraph_id', 'document_id'],
|
|
|
|
|
|
properties={
|
|
|
|
|
|
'paragraph_id': openapi.Schema(
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
2025-01-13 08:38:28 +00:00
|
|
|
|
title=_('paragraph id')),
|
2024-09-20 09:07:52 +00:00
|
|
|
|
'document_id': openapi.Schema(
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
2025-01-13 08:38:28 +00:00
|
|
|
|
title=_('document id'))
|
2024-09-20 09:07:52 +00:00
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2024-04-09 03:33:28 +00:00
|
|
|
|
class BatchOperate(ApiMixin):
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_params_api():
|
|
|
|
|
|
return [openapi.Parameter(name='dataset_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
2025-01-13 08:38:28 +00:00
|
|
|
|
description=_('dataset id')),
|
2024-04-09 03:33:28 +00:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_body_api():
|
|
|
|
|
|
return openapi.Schema(
|
2025-01-13 08:38:28 +00:00
|
|
|
|
title=_('problem id list'),
|
|
|
|
|
|
description=_('problem id list'),
|
2024-04-09 03:33:28 +00:00
|
|
|
|
type=openapi.TYPE_ARRAY,
|
|
|
|
|
|
items=openapi.Schema(type=openapi.TYPE_STRING)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2024-03-11 09:28:05 +00:00
|
|
|
|
class Operate(ApiMixin):
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_params_api():
|
|
|
|
|
|
return [openapi.Parameter(name='dataset_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
2025-01-13 08:38:28 +00:00
|
|
|
|
description=_('dataset id')),
|
2024-03-11 09:28:05 +00:00
|
|
|
|
openapi.Parameter(name='problem_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
2025-01-13 08:38:28 +00:00
|
|
|
|
description=_('problem id'))]
|
2024-03-11 09:28:05 +00:00
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_body_api():
|
|
|
|
|
|
return openapi.Schema(
|
|
|
|
|
|
type=openapi.TYPE_OBJECT,
|
|
|
|
|
|
required=['content'],
|
|
|
|
|
|
properties={
|
2025-01-13 08:38:28 +00:00
|
|
|
|
'content': openapi.Schema(type=openapi.TYPE_STRING, title=_('content'),
|
|
|
|
|
|
description=_('content')),
|
2024-03-11 09:28:05 +00:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class Paragraph(ApiMixin):
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_params_api():
|
|
|
|
|
|
return ProblemApi.Operate.get_request_params_api()
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_response_body_api():
|
|
|
|
|
|
return openapi.Schema(
|
|
|
|
|
|
type=openapi.TYPE_OBJECT,
|
|
|
|
|
|
required=['content'],
|
|
|
|
|
|
properties={
|
2025-01-13 08:38:28 +00:00
|
|
|
|
'content': openapi.Schema(type=openapi.TYPE_STRING, max_length=4096, title=_('content'),
|
|
|
|
|
|
description=_('content')),
|
|
|
|
|
|
'title': openapi.Schema(type=openapi.TYPE_STRING, max_length=256, title=_('Section title'),
|
|
|
|
|
|
description=_('Section title')),
|
|
|
|
|
|
'is_active': openapi.Schema(type=openapi.TYPE_BOOLEAN, title=_('Is active'), description=_('Is active')),
|
|
|
|
|
|
'hit_num': openapi.Schema(type=openapi.TYPE_NUMBER, title=_('Hit num'), description=_('Hit num')),
|
|
|
|
|
|
'update_time': openapi.Schema(type=openapi.TYPE_STRING, title=_('update time'),
|
|
|
|
|
|
description=_('update time'),
|
2024-03-11 09:28:05 +00:00
|
|
|
|
default="1970-01-01 00:00:00"),
|
2025-01-13 08:38:28 +00:00
|
|
|
|
'create_time': openapi.Schema(type=openapi.TYPE_STRING, title=_('create time'),
|
|
|
|
|
|
description=_('create time'),
|
2024-03-11 09:28:05 +00:00
|
|
|
|
default="1970-01-01 00:00:00"
|
|
|
|
|
|
),
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class Query(ApiMixin):
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_params_api():
|
|
|
|
|
|
return [openapi.Parameter(name='dataset_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
2025-01-13 08:38:28 +00:00
|
|
|
|
description=_('dataset id')),
|
2024-03-11 09:28:05 +00:00
|
|
|
|
openapi.Parameter(name='content',
|
|
|
|
|
|
in_=openapi.IN_QUERY,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=False,
|
2025-01-13 08:38:28 +00:00
|
|
|
|
description=_('content')),]
|
2024-03-11 09:28:05 +00:00
|
|
|
|
|
|
|
|
|
|
class BatchCreate(ApiMixin):
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_body_api():
|
|
|
|
|
|
return openapi.Schema(type=openapi.TYPE_ARRAY,
|
|
|
|
|
|
items=ProblemApi.Create.get_request_body_api())
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_params_api():
|
|
|
|
|
|
return ProblemApi.Create.get_request_params_api()
|
|
|
|
|
|
|
|
|
|
|
|
class Create(ApiMixin):
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_body_api():
|
2025-01-13 08:38:28 +00:00
|
|
|
|
return openapi.Schema(type=openapi.TYPE_STRING, description=_('content'), title=_('content'))
|
2024-03-11 09:28:05 +00:00
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_params_api():
|
|
|
|
|
|
return [openapi.Parameter(name='dataset_id',
|
|
|
|
|
|
in_=openapi.IN_PATH,
|
|
|
|
|
|
type=openapi.TYPE_STRING,
|
|
|
|
|
|
required=True,
|
2025-01-13 08:38:28 +00:00
|
|
|
|
description=_('dataset id'))]
|