from .database import DatabaseController from models.users.user import User from models.users.customer import Customer class UserController(DatabaseController): FIELDS = ['id', 'username', 'password', 'firstName', 'lastName', 'email', 'phone', 'role'] def __init__(self): super().__init__() def create(self, user: User): params = [ user.username, user.password, user.firstName, user.lastName, user.email, user.phone, user.role ] self._conn.execute( "INSERT INTO Users (username, password, first_name, last_name, email, phone, role) VALUES (?, ?, ?, ?, ?, ?, ?)", params ) self._conn.commit() def read(self, username: str) -> User | None: params = [ username ] cursor = self._conn.execute( "SELECT * FROM Users WHERE Username = ?", params ) row = cursor.fetchone() if row != None: params = dict(zip(self.FIELDS, row)) obj = self.new_instance(Customer, params) return obj return None def update(self): print("Doing work") def delete(self): print("Doing work")