-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschemas.py
146 lines (116 loc) · 2.8 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
135
136
137
138
139
140
141
142
143
144
145
146
from ctypes import WinError
from pydantic import BaseModel
from typing import List, Optional
from fastapi import Form
class JeanBase(BaseModel):
title: str
body: str
class Jean(JeanBase):
class Config():
orm_mode = True
class User(BaseModel):
username: str
email: str
password: str
phonenumber: str
birthday: str
height: int
weight: int
jeansize: str
@classmethod
def as_form(
cls,
username: str = Form(...),
email: str = Form(...),
password: str = Form(...),
phonenumber: str = Form(...),
birthday: str = Form(...),
height: str = Form(...),
weight: str = Form(...),
jeansize: str = Form(...)
):
return cls(username=username, email=email, password=password, phonenumber=phonenumber, birthday=birthday, height=int(height), weight=int(weight), jeansize=jeansize)
class ShowUser(BaseModel):
username: str
email: str
jeans: List[Jean] = []
class Config():
orm_mode = True
# class ShowJean(Jean):
# buyer: ShowUser
# class Config():
# orm_mode = True
class ShowProduct(BaseModel):
product_id: int
name: str
brand: str
hashtag: Optional[str] = None
rating: Optional[float] = None
image: str
xs_size: str
purchase_total: str
view_total: str
purchase_age: str
view_age: str
price: int
heart: int
class Config():
orm_mode = True
class ShowReview(BaseModel):
review_id = int
product_id = int
name = str
gender = str
height = int
weight = int
rating = float
fit_size = str
evls = int
evlb = int
evlc = int
evlt = int
link = str
class Config():
orm_mode = True
class Login(BaseModel):
email: str
password: str
@classmethod
def as_form(
cls,
email: str = Form(...),
password: str = Form(...)
):
return cls(email=email, password=password)
class Token(BaseModel):
access_token: str
token_type: str
class TokenData(BaseModel):
id: Optional[int] = None
email: Optional[str] = None
class Preference(BaseModel):
trend: int
agegroup: int
rating: int
@classmethod
def as_form(
cls,
trend: str = Form(...),
agegroup: str = Form(...),
rating: str = Form(...)
):
return cls(trend=(4-int(trend)), agegroup=(4-int(agegroup)), rating=(4-int(rating)))
class Style(BaseModel):
wide: float
slim: float
tapered: float
crop: float
@classmethod
def as_form(
cls,
wide: str = Form(...),
slim: str = Form(...),
tapered: str = Form(...),
crop: str = Form(...)
):
return cls(wide=float(wide), slim=float(slim), tapered=float(tapered), crop=float(crop))