def userLogin(self, username, password): user = UserDAO.getByUsername(username) if user == None: out("[userLogin] Username not found", username) return None out("[userLogin] User:", user) if getSHA256(password) == user.hashPassword: return user return None
import random from faker import Faker from user import User, UserDAO from patient import Patient, PatientDAO fake = Faker("zh_CN") users = UserDAO.listPatients() for user in users: uid = user.uid name = fake.name() balance = random.randint(0, 1000000) / 100 email = fake.email() phone = fake.phone_number() pat = Patient(uid, name, balance, email, phone) PatientDAO.add(pat) for patient in PatientDAO.listAll(): print(patient)
def goodbye(name): user = UserDAO.get(name) if user: return "Goodbye %s" % user.name else: return "you haven't said hello yet", 400
def hello_name(name): user = UserDAO.save(UserRecord(name)) return "name %s added" % user.name
def getUser(self): return UserDAO.get(self.uid)
import random from faker import Faker from doctor import Doctor, DoctorDAO from user import User, UserDAO from department import Department, DepartmentDAO fake = Faker("zh_CN") departments = DepartmentDAO.listAll() dusers = UserDAO.listDoctors() for user in dusers: print(user) uid = user.uid name = fake.name() deptID = random.choice(departments).deptID doc = Doctor(uid, name, deptID) print(doc) DoctorDAO.add(doc) print("------") docs = DoctorDAO.listAll() for doc in docs: print(doc)
import random from faker import Faker from user import User, UserDAO, getSHA256 fake = Faker("zh_CN") for i in range(800): uid = UserDAO.newID() username = fake.user_name() utype = random.choice(["patient"]*7 + ["doctor"]) if(utype == "doctor"): password = "******" else: password = fake.password(length=10, special_chars=True, digits=True, upper_case=True, lower_case=True) hashPassword = getSHA256(password) user = User(uid, username, hashPassword, utype) print(user) try: UserDAO.add(user) except: continue uid = str(random.randint(100000, 999999)) username = "******" password = "******" hashPassword = getSHA256(password) utype = "doctor" user = User(uid, username, hashPassword, utype) UserDAO.add(user)