-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
45 lines (38 loc) · 1.13 KB
/
models.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
from pydantic import BaseModel, EmailStr
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, Numeric
from typing import Optional
Base = declarative_base()
class User(BaseModel):
username: str
password: str
first_name: str
last_name: str
email: EmailStr
balance: Optional[float] = 10.00
class DBUser(Base):
__tablename__ = "users"
id = Column(Integer, primary_key=True, index=True, autoincrement=True)
username = Column(String, index=True)
password = Column(String)
first_name = Column(String)
last_name = Column(String)
email = Column(String, index=True)
balance = Column(Numeric(scale=2))
account_number = Column(Integer)
class UserLogin(BaseModel):
username: str
password: str
class Transfer(BaseModel):
dest_account: int
amount: float
class ChangePassword(BaseModel):
username: str
current_password: str
new_password: str
confirm_password: str
class EditUser(BaseModel):
username: str
email: Optional[EmailStr] = None
first_name: Optional[str] = None
last_name: Optional[str] = None