#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ # @Version : Python 3.11.4 # @Software : Sublime Text 4 # @Author : StudentCWZ # @Email : StudentCWZ@outlook.com # @Date : 2023/10/28 23:56 # @File : user.py # @Description : """ from application.extensions.init_sqlalchemy import db from application.models.user import User class UserDao: @classmethod def get_all(cls): return User.query.all() @classmethod def get_by_id(cls, user_id: int): return User.query.get(user_id) @classmethod def create(cls, username: str, password: str, email: str): new_user = User(username=username, email=email, password=password) db.session.add(new_user) db.session.commit() return new_user