сделал базовые ДТО для каждой таблицы
This commit is contained in:
parent
a00fba8eca
commit
6079d975d3
@ -16,6 +16,17 @@ class UsersRepository:
|
||||
def get_by_login(self, login: str):
|
||||
return self.db.query(User).filter(User.login == login).first()
|
||||
|
||||
def change_password(self, user_id: int, old_password: str, new_password: str):
|
||||
user = self.db.query(User).filter(User.id == user_id).first()
|
||||
if user.check_password(old_password):
|
||||
user.set_password(new_password)
|
||||
self.db.merge(user)
|
||||
self.db.commit()
|
||||
self.db.refresh(user)
|
||||
return user
|
||||
|
||||
return None
|
||||
|
||||
def create(self, user: User):
|
||||
self.db.add(user)
|
||||
self.db.commit()
|
||||
|
||||
14
API/app/domain/entities/answer_files_entitity.py
Normal file
14
API/app/domain/entities/answer_files_entitity.py
Normal file
@ -0,0 +1,14 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class AnswerFileEntity(BaseModel):
|
||||
id: Optional[int] = None
|
||||
file_path: str
|
||||
file_title: str
|
||||
|
||||
answer_id: int
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
14
API/app/domain/entities/answer_options_entity.py
Normal file
14
API/app/domain/entities/answer_options_entity.py
Normal file
@ -0,0 +1,14 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class AnswerOptionEntity(BaseModel):
|
||||
id: Optional[int] = None
|
||||
text: str
|
||||
is_correct: bool
|
||||
|
||||
task_id: int
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
17
API/app/domain/entities/appeals_entity.py
Normal file
17
API/app/domain/entities/appeals_entity.py
Normal file
@ -0,0 +1,17 @@
|
||||
import datetime
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class AppealEntity(BaseModel):
|
||||
id: Optional[int] = None
|
||||
message: str
|
||||
created_date: datetime.datetime
|
||||
status: str
|
||||
|
||||
topic_id: int
|
||||
user_id: int
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
11
API/app/domain/entities/appeals_topics_entity.py
Normal file
11
API/app/domain/entities/appeals_topics_entity.py
Normal file
@ -0,0 +1,11 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class AppealTopicEntity(BaseModel):
|
||||
id: Optional[int] = None
|
||||
title: str
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
12
API/app/domain/entities/categories_entity.py
Normal file
12
API/app/domain/entities/categories_entity.py
Normal file
@ -0,0 +1,12 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class CategoryEntity(BaseModel):
|
||||
id: Optional[int] = None
|
||||
title: str
|
||||
description: str
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
16
API/app/domain/entities/course_students_entity.py
Normal file
16
API/app/domain/entities/course_students_entity.py
Normal file
@ -0,0 +1,16 @@
|
||||
import datetime
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class CourseStudentEntity(BaseModel):
|
||||
id: Optional[int] = None
|
||||
enrollment_date: datetime.date
|
||||
is_finished: bool
|
||||
|
||||
course_id: int
|
||||
user_id: int
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
15
API/app/domain/entities/courses_entity.py
Normal file
15
API/app/domain/entities/courses_entity.py
Normal file
@ -0,0 +1,15 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class CourseEntity(BaseModel):
|
||||
id: Optional[int] = None
|
||||
title: str
|
||||
description: str
|
||||
|
||||
category_id: int
|
||||
owner_user_id: int
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
15
API/app/domain/entities/lecture_entity.py
Normal file
15
API/app/domain/entities/lecture_entity.py
Normal file
@ -0,0 +1,15 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class LectureEntity(BaseModel):
|
||||
id: Optional[int] = None
|
||||
text: str
|
||||
image: Optional[str]
|
||||
number: int
|
||||
|
||||
step_id: int
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
14
API/app/domain/entities/lessons_entity.py
Normal file
14
API/app/domain/entities/lessons_entity.py
Normal file
@ -0,0 +1,14 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class LessonEntity(BaseModel):
|
||||
id: Optional[int] = None
|
||||
title: str
|
||||
description: str
|
||||
|
||||
course_id: int
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
18
API/app/domain/entities/notification_entity.py
Normal file
18
API/app/domain/entities/notification_entity.py
Normal file
@ -0,0 +1,18 @@
|
||||
import datetime
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class NotificationEntity(BaseModel):
|
||||
id: Optional[int] = None
|
||||
text: str
|
||||
datetime_notification: datetime.datetime
|
||||
is_read: bool
|
||||
|
||||
user_id: int
|
||||
type_id: int
|
||||
course_id: Optional[int]
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
12
API/app/domain/entities/notification_types_entity.py
Normal file
12
API/app/domain/entities/notification_types_entity.py
Normal file
@ -0,0 +1,12 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class NotificationTypeEntity(BaseModel):
|
||||
id: Optional[int] = None
|
||||
title: str
|
||||
description: str
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
11
API/app/domain/entities/roles_entity.py
Normal file
11
API/app/domain/entities/roles_entity.py
Normal file
@ -0,0 +1,11 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class RoleEntity(BaseModel):
|
||||
id: Optional[int] = None
|
||||
title: str
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
14
API/app/domain/entities/step_tasks_entity.py
Normal file
14
API/app/domain/entities/step_tasks_entity.py
Normal file
@ -0,0 +1,14 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class StepTaskEntity(BaseModel):
|
||||
id: Optional[int] = None
|
||||
text: str
|
||||
|
||||
step_id: int
|
||||
type_id: int
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
12
API/app/domain/entities/step_types_entity.py
Normal file
12
API/app/domain/entities/step_types_entity.py
Normal file
@ -0,0 +1,12 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class StepTypeEntity(BaseModel):
|
||||
id: Optional[int] = None
|
||||
title: str
|
||||
description: str
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
14
API/app/domain/entities/steps_entity.py
Normal file
14
API/app/domain/entities/steps_entity.py
Normal file
@ -0,0 +1,14 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class StepEntity(BaseModel):
|
||||
id: Optional[int] = None
|
||||
title: str
|
||||
|
||||
lesson_id: int
|
||||
type_id: int
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
18
API/app/domain/entities/task_answers_entity.py
Normal file
18
API/app/domain/entities/task_answers_entity.py
Normal file
@ -0,0 +1,18 @@
|
||||
import datetime
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class TaskAnswerEntity(BaseModel):
|
||||
id: Optional[int] = None
|
||||
answer_date: datetime.datetime
|
||||
text: str
|
||||
is_current: Optional[bool]
|
||||
comment: Optional[str]
|
||||
|
||||
user_id: int
|
||||
task_id: int
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
14
API/app/domain/entities/task_files_entity.py
Normal file
14
API/app/domain/entities/task_files_entity.py
Normal file
@ -0,0 +1,14 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class TaskFileEntity(BaseModel):
|
||||
id: Optional[int] = None
|
||||
file_path: str
|
||||
file_title: str
|
||||
|
||||
task_id: int
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
12
API/app/domain/entities/task_types_entity.py
Normal file
12
API/app/domain/entities/task_types_entity.py
Normal file
@ -0,0 +1,12 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class TaskTypeEntity(BaseModel):
|
||||
id: Optional[int] = None
|
||||
title: str
|
||||
description: str
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
15
API/app/domain/entities/test_answers_entity.py
Normal file
15
API/app/domain/entities/test_answers_entity.py
Normal file
@ -0,0 +1,15 @@
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class TestAnswerEntity(BaseModel):
|
||||
id: Optional[int] = None
|
||||
answer_date: datetime.datetime
|
||||
|
||||
user_id: int
|
||||
answer_id: int
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
22
API/app/domain/entities/users_entity.py
Normal file
22
API/app/domain/entities/users_entity.py
Normal file
@ -0,0 +1,22 @@
|
||||
import datetime
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class UserEntity(BaseModel):
|
||||
id: Optional[int]
|
||||
first_name: str
|
||||
last_name: str
|
||||
patronymic: Optional[str]
|
||||
gender: str
|
||||
birthday: datetime.date
|
||||
registration_date: datetime.datetime
|
||||
login: str
|
||||
password: str
|
||||
email: str
|
||||
|
||||
role_id: int
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
Loading…
x
Reference in New Issue
Block a user