-
Notifications
You must be signed in to change notification settings - Fork 2
/
schemas.py
134 lines (91 loc) · 2.71 KB
/
schemas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# schemas.py
# 테이블의 타입을 설정하는 파일
from sqlite3 import Timestamp
from typing import Dict, List, Optional
from pydantic import BaseModel # 객체 타입설정
class UserBase(BaseModel):
insta_id: str # user 생성 api 호출시 자동으로 부여
username: str # user 생성 api 호출시 자동으로 부여
full_name: str # user 생성 api 호출시 자동으로 부여
follower: int # user 생성 api 호출시 자동으로 부여
following: int # user 생성 api 호출시 자동으로 부여
profile_image_url: str # user 생성 api 호출시 자동으로 부여
class UserCreate(UserBase):
pass
class User(UserBase):
id: int # 자동 생성
is_deleted: bool # 기본값 false
created_at: Timestamp # db 넣을 때 생성
updated_at: Timestamp # db 넣을 때 생성
class Config:
orm_mode = True
class QuestionBase(BaseModel):
content: str
user_id: int
type: str
comment_type: str
class QuestionCreate(QuestionBase):
pass
class QuestionUpdate(BaseModel):
id: Optional[int]
type: Optional[str]
expired: bool
class Question(QuestionBase):
id: int # 자동 생성
expired: bool # 기본 값 false
created_at: Timestamp # db 넣을 때 생성
updated_at: Timestamp # db 넣을 때 생성
class Config:
orm_mode = True
class RandomQuestion(BaseModel):
id: int
content: str
type: str
created_at: Timestamp # db 넣을 때 생성
updated_at: Timestamp # db 넣을 때 생성
class Config:
orm_mode = True
class BaseVote(BaseModel):
content: str
user_id: int
class VoteCreate(BaseVote):
option: List[str]
class BaseComment(BaseModel):
content: str
question_id: int
class CommentCreate(BaseComment):
pass
class Comment(BaseComment):
id: int
type: str
created_at: Timestamp # db 넣을 때 생성
updated_at: Timestamp # db 넣을 때 생성
class Config:
orm_mode = True
class BaseVoteOption(BaseModel):
num: int
content: str
question_id: int or None
class CreateVoteOption(BaseVoteOption):
pass
class VoteOption(BaseVoteOption):
id: int
count: int
created_at: Timestamp # db 넣을 때 생성
updated_at: Timestamp # db 넣을 때 생성
class Config:
orm_mode = True
class VoteResult(BaseModel):
question_id: int
options: List[str]
count: List[int]
created_at: Timestamp # question 생성시간
updated_at: Timestamp # 마지막 투표 시간
class Config:
orm_mode = True
class QuestionWithAnswer(BaseModel):
question: str
type: str
answer: List[Dict]
class Config:
orm_mode = True