def removeStudent(request): uid = request.GET.get("id") callback = request.GET.get("callback") mysql.change("delete from ll_student where id=%s", [ uid, ]) result = {"status": "成功"} return HttpResponse(callback + "(" + str(result) + ")")
def changeTeacher(request): callback = request.GET.get("callback") name = request.GET.get("name") id = request.GET.get("id") result = mysql.change("update ll_teacher set name=%s WHERE id=%s", [name, id]) return HttpResponse(callback + "(" + json.dumps(result) + ")")
def addTeacher(request): callback = request.GET.get("callback") name = request.GET.get("name") status = mysql.change("insert into ll_teacher(name) values(%s)", [name]) result = mysql.view("select * from ll_teacher order by id DESC limit 1", [])[0] allresult = {"status": status, "result": result} return HttpResponse(callback + '( ' + json.dumps(allresult) + ' )')
def assignTeacher(request): callback = request.GET.get("assignTeacher") teIds = request.GET.getlist("teId") csid = request.GET.get("csid") manyVal = [] for i in teIds: manyVal.append((csid, i)) print(manyVal) mysql.change("delete from ll_classes_classestoteacher where classes_id=%s", [ csid, ]) result = mysql.manyChange( "insert into ll_classes_classestoteacher(classes_id,teacher_id) values(%s,%s)", manyVal) return HttpResponse(callback + "(" + json.dumps(result) + ")")
def removeTeacher(request): uid = request.GET.get("id") callback = request.GET.get("callback") res = mysql.change("delete from ll_teacher where id=%s", [ uid, ]) result = {"status": res} return HttpResponse(callback + "(" + json.dumps(result) + ")")
def changeClasses(request): callback = request.GET.get("changeClasses") name = request.GET.get("name") id = request.GET.get("id") result = mysql.change("update ll_classes set name=%s WHERE id=%s", [name, id]) print(name) print(id) print(request.GET) return HttpResponse(callback + "(" + json.dumps(result) + ")")
def changeStudent(request): callback = request.GET.get("callback") age = request.GET.get("age") name = request.GET.get("name") id = request.GET.get("id") csid = request.GET.get("csid") result = mysql.change( "update ll_student set name=%s,age=%s,csid_id=%s WHERE id=%s", [ name, age, csid, id, ]) print(result) return HttpResponse(callback + "(" + json.dumps(result) + ")")
def student(request): callback = request.GET.get("callback") name = request.GET.get("name") age = request.GET.get("age") cs = request.GET.get("cs") status = mysql.change( "insert into ll_student(name,age,csid_id) values(%s,%s,%s)", [name, age, cs]) result = mysql.view( "select id,name,age from ll_student order by id DESC limit 1", [])[0] classesId = mysql.view("select * from ll_classes where id=%s", [ cs, ])[0] result["classes"] = classesId allresult = {"status": status, "result": result} return HttpResponse(callback + '( ' + json.dumps(allresult) + ' )')