def SearchDocs(): data = request.get_json() phone = data['phone'] name = data['name'] hospital = data['hospital'] department = data['department'] user = Users() user.setInfo(Phone=phone, U_Name=name, Hospital=hospital, Department=department) row = user.searchDocs() return json.dumps(row, indent=2, ensure_ascii=False).encode('latin1').decode('gbk')
def ModInfo(): data = request.get_json() uid = data['uid'] user = Users(msg=uid, msgid=True) identity = data['identity'] new_name = data['new_name'] new_gender = data['new_gender'] new_age = data['new_age'] if identity == 'D': new_title = data['new_title'] new_department = data['new_department'] new_hospital = data['new_hospital'] else: new_title = new_department = new_hospital = '' user.setInfo(Phone='', Pass='', U_Name=new_name, U_Identity=identity, Gender=new_gender, Age=new_age, Title=new_title, Department=new_department, Hospital=new_hospital) user.modInfo() return json.dumps({ 'code': 200, }, indent=2, ensure_ascii=False)
def SignUp(): phone = request.values['phone'] password = request.values['password'] name = request.values['name'] identity = request.values['identity'] gender = request.values['gender'] if request.values['age'] == '': age = -1 else: age = int(request.values['age']) if identity == 'D': certificate = request.values['certificate'] title = request.values['title'] department = request.values['department'] hospital = request.values['hospital'] else: certificate = title = department = hospital = '' user = Users() user.setInfo(Phone=phone, Pass=password, U_Name=name, U_Identity=identity, Gender=gender, Age=age, Certificate_ID=certificate, Title=title, Department=department, Hospital=hospital) code, uid = user.signUp() return json.dumps({ 'state': code, 'U_ID': uid }, indent=2, ensure_ascii=False)
def Login(): phone = request.values['phone'] password = request.values['password'] user = Users(msg=phone, Password=password, msgid=False) code, data = user.logIn() #code,data = DB.Login(phone,password) if code == 0: return json.dumps( { 'valid': code, 'U_ID': data['U_ID'], 'identity': data['U_Identity'] }, indent=2, ensure_ascii=False) else: return json.dumps({ 'valid': code, 'U_ID': 'None' }, indent=2, ensure_ascii=False)
def GetContacts(): uid = request.values['uid'] user = Users(msg=uid, msgid=True) return json.dumps(user.getContacts(), indent=2, ensure_ascii=False)