def classname(): phone = session.get("tel") cursor.execute( "SELECT name FROM `classes` WHERE id in (SELECT classid FROM students WHERE phone=%s)", phone) res = cursor.fetchone() # print(res['name']) return json.dumps(res['name'])
def findsame(): phone=request.args.get('phone') cursor.execute('select * from user where tel=%s',phone) result=cursor.fetchone() if(result): return 'error' else: return 'ok'
def seleClasses(): cid = request.args.get('cid') cursor.execute("select * from teacher where cid=%s", cid) result1 = cursor.fetchall() db.commit() for i in range(len(result1)): id = result1[i]['classid'] cursor.execute("select name,id from classes where id=%s", id) result2 = cursor.fetchone() result1[i]['banjiID'] = result2['id'] result1[i]['classid'] = result2['name'] # print(result1) return json.dumps(result1)
def insertOne(): name=request.args.get("name") tel=request.args.get("tel") pswd=request.args.get("pass") md5 = hashlib.md5() md5.update(pswd.encode('utf8')) pswd = md5.hexdigest() roots=request.args.get("YH") cursor.execute('select rid from role where rinfo=%s', roots) result = cursor.fetchone() roots = result['rid'] cursor.execute("insert into user (name,tel,pass,rid) values(%s,%s,%s,%s)", (name, tel, pswd, roots)) db.commit() return 'ok'
def updausers(): uid = request.form["uid"] username = request.form['uname'] usertel = request.form['utel'] userpass = request.form['upass'] md5 = hashlib.md5() md5.update(userpass.encode('utf8')) userpass = md5.hexdigest() roots = request.form['roots'] cursor.execute('select rid from role where rinfo=%s', roots) result = cursor.fetchone() roots = result['rid'] cursor.execute("update user set name=%s,tel=%s,pass=%s,rid=%s where id=%s",(username,usertel,userpass,roots,uid)) db.commit() return 'ok'
def deleTea(): phone = request.args.get("phone") cursor.execute("delete from teacher where phone=%s", phone) cursor.execute("delete from user where tel=%s", phone) db.commit() cid = request.args.get('cid') cursor.execute("select * from teacher where cid=%s", cid) result1 = cursor.fetchall() for i in range(len(result1)): id = result1[i]['classid'] cursor.execute("select name,id from classes where id=%s", id) result2 = cursor.fetchone() result1[i]['banjiID'] = result2['id'] result1[i]['classid'] = result2['name'] db.commit() return json.dumps(result1)
def updateOne(): id = request.args.get('id') name = request.args.get('name') phone = request.args.get('tel') banji = request.args.get('banji') FX = request.args.get('FX') # print(id,name,phone,banji,FX) # name = name.upper() print(name, phone, id) cursor.execute("select * from user where tel=%s", phone) result = cursor.fetchone() tid = result['id'] print(tid) cursor.execute( "update teacher set name=%s,phone=%s,cid=%s,classid=%s where id=%s", (name, phone, FX, banji, id)) cursor.execute("update user set name=%s,tel=%s where id=%s", (name, phone, tid)) db.commit() return 'ok'
def updateOne(): uid = request.args.get("uid") name = request.args.get('name') tel = request.args.get('tel') pswd = request.args.get('pass') roots = request.args.get("YH") # uid = request.form['id'] # name=request.form['name'] # tel=request.form['tel'] # pswd=request.form['pass'] # roots=request.form['roots'] md5 = hashlib.md5() md5.update(pswd.encode('utf8')) pswd = md5.hexdigest() cursor.execute('select rid from role where rinfo=%s', roots) result = cursor.fetchone() roots = result['rid'] # print(uid,name,tel,pswd,roots) cursor.execute("update user set name=%s,tel=%s,pass=%s,rid=%s where id=%s", (name, tel, pswd, roots, uid)) db.commit() return 'ok'
def delu(): tel = request.form['tel'] pswd = request.form['userpass'] code = request.form['code'] # print(code,session.get("code")) if code != session.get("code"): return redirect("/login") md5 = hashlib.md5() md5.update(pswd.encode('utf8')) pswd = md5.hexdigest() cursor.execute("select * from user where tel=%s and pass=%s", (tel, pswd)) result = cursor.fetchone() print(tel, pswd) if (result): res = make_response(redirect('/')) res.set_cookie('gg', str(result['rid'])) session['login'] = '******' session['name'] = result['name'] session['rid'] = result['rid'] session['tel'] = result['tel'] return res else: return redirect("/login")
def selecategory(): cid=request.args.get('cid') cursor.execute("select * from category where cid=%s",cid) result=cursor.fetchone() print(result) return json.dumps(result)
def seleitems(): items = request.cookies.get("gg") cursor.execute('select rinfo from role where rid=%s', items) result = cursor.fetchone() return json.dumps(result['rinfo'])
def ShowLog(): id = request.args.get("id") cursor.execute("select * from logs where id=%s", id) result = cursor.fetchone() return json.dumps(result, default=str)