def web_major_managementImpl(): if not check_session(): return redirect(url_for("logout")) privilege = session['privilege'] if privilege != PRIVILEGE_ADMIN: return redirect(url_for("logout")) sidebar = GetSideBar(ADMIN_BAR, "专业管理") handler = getSQLHandler() apart_infos = GET_ALL_apart_infos(handler) major_infos = GET_ALL_major_infos(handler) major_infos_result = [] for major_info in major_infos: temp = {} temp['major_id'] = major_info[0] temp['major_name'] = major_info[1] temp['major_num'] = major_info[2] temp['apart_name'] = major_info[4] major_infos_result.append(temp) return render_template("major_management.html", sidebar=sidebar, url_dict=url_dict, apart_infos=apart_infos, data=major_infos_result)
def api_change_passwordImpl(): """ :INPUT: {'user':<user> -> str ,'old_password':<old_password> -> str, 'new_password':<new_password> -> str} :return: {'status': '旧密码错误'} or {'status': '修改成功'} or {'status': '修改失败'} or {'status': '请刷新浏览器'} """ response1 = {} if check_session(): handler = getSQLHandler() # 获取sql连接 data = json.loads(request.get_data().decode('utf-8')) user = data['user'] old_password = data['old_password'] new_password = data['new_password'] result = loginCheck(user, old_password, handler) if result: if result == PRIVILEGE_ADMIN: if CHANGE_ADMIN_password(user, new_password, handler): response1['status'] = '修改成功' else: response1['status'] = '修改失败' elif result == PRIVILEGE_STUDENT: if CHANGE_STUDENT_password(user, new_password, handler): response1['status'] = '修改成功' else: response1['status'] = '修改失败' else: response1['status'] = '旧密码错误' else: response1['status'] = "请刷新浏览器" return jsonify(response1)
def web_register_conImpl(): if not check_session(): return redirect(url_for("logout")) privilege = session['privilege'] if privilege != PRIVILEGE_STUDENT: return redirect(url_for("logout")) sidebar = GetSideBar(STUDENT_BAR, "审核状态") handler = getSQLHandler() user = session['user'] infos = GET_VERIFY_INFOS_BY_stu_id(user, handler) company_job = [] for info in infos: temp = {} temp['verify_id'] = info[0] temp['com_name'] = info[11] temp['job_name'] = info[12] temp['register_time'] = info[4] temp['verify_con'] = info[3] company_job.append(temp) return render_template("register_con.html", company_job=company_job, sidebar=sidebar, url_dict=url_dict)
def web_student_infoImpl(): if not check_session(): return redirect(url_for("logout")) sidebar = GetSideBar(STUDENT_BAR,"个人信息") handler = getSQLHandler() id = session['user'] data = {} result = GET_student_major_INFO_BY_ID(id,handler) if result == None: return redirect(url_for("logout")) else: data["name"]=result[1] data["id"] = result[0] data["gender"] = result[4] data["enroll_year"] = result[2] data["gradu_year"] = result[3] data["status"] = result[5] data['major_name']=result[8] if data['status']!="待业": student_job_info = GET_student_job_info_BY_stu_id(id,handler) if student_job_info!=None: data['company_name'] = student_job_info[6] data['job_name'] = student_job_info[3] return render_template("student_info.html",sidebar=sidebar,data=data,url_dict=url_dict)
def web_student_registerImpl(): if not check_session(): return redirect(url_for("logout")) privilege = session['privilege'] if privilege != PRIVILEGE_STUDENT: return redirect(url_for("logout")) sidebar = GetSideBar(STUDENT_BAR, "就业登记") handler = getSQLHandler() id = session['user'] company_id = int(request.args.get("com_id", 1)) data = {} result1 = GET_student_INFO_BY_ID(id, handler) if result1 == None: return redirect(url_for("logout")) else: data["name"] = result1[1] data["id"] = result1[0] data["gradu_year"] = result1[3] companies = [] company_info = GET_ALL_com_nameandid(handler) for i in company_info: temp = {} temp['id'] = i[0] temp['name'] = i[1] companies.append(temp) company_job = [] com_job_infos = GET_com_job_BY_com_id(company_id, handler) for com_job_info in com_job_infos: temp = {} temp['com_name'] = com_job_info[7] temp['job_name'] = com_job_info[8] temp['need_num'] = com_job_info[4] temp['exist_num'] = com_job_info[3] temp['start_time'] = com_job_info[5] temp['finish_time'] = com_job_info[6] temp['com_job_id'] = com_job_info[0] company_job.append(temp) return render_template("student_register.html", now_com_id=company_id, sidebar=sidebar, data=data, url_dict=url_dict, companies=companies, company_job=company_job)
def web_student_managementImpl(): if not check_session(): return redirect(url_for("logout")) privilege = session['privilege'] if privilege != PRIVILEGE_ADMIN: return redirect(url_for("logout")) sidebar = GetSideBar(ADMIN_BAR, "学生管理") handler = getSQLHandler() majors = GET_ALL_major_INFOS(handler) return render_template("student_management.html", sidebar=sidebar, url_dict=url_dict, majors=majors)
def web_admin_infoImpl(): if not check_session(): return redirect(url_for("logout")) privilege = session['privilege'] if privilege != PRIVILEGE_ADMIN: return redirect(url_for("logout")) sidebar = GetSideBar(ADMIN_BAR, "个人信息") handler = getSQLHandler() user = session['user'] return render_template("admin_info.html", sidebar=sidebar, url_dict=url_dict, user=user)
def web_company_managementImpl(): if not check_session(): return redirect(url_for("logout")) privilege = session['privilege'] if privilege != PRIVILEGE_ADMIN: return redirect(url_for("logout")) sidebar = GetSideBar(ADMIN_BAR,"公司招聘信息") handler = getSQLHandler() style_infos = GET_ALL_style_infos(handler) com_infos = GET_ALL_company_infos(handler) return render_template("company_management.html", sidebar=sidebar, url_dict=url_dict, style_infos=style_infos,com_infos=com_infos)
def api_delete_registerImpl(): privilege = session['privilege'] if privilege != PRIVILEGE_STUDENT or not check_session(): return response1 = {} handler = getSQLHandler() # 获取sql连接 data = json.loads(request.get_data().decode('utf-8')) verify_id = data['verify_id'] status = GET_verify_status_BY_verify_id(verify_id) if status != STATUS_WAITING: response1['status'] = "无法删除" else: if DELETE_student_IN_verify(verify_id, handler): response1['status'] = "删除成功" else: response1['status'] = "删除失败" return jsonify(response1)
def api_loginImpl(): """ :INPUT: {'user_name':<user_name> -> str ,'password':<password> -> str} :return: {'status': 'success'} or {'status': 'fail'} """ response1 = {} handler = getSQLHandler() # 获取sql连接 data = json.loads(request.get_data().decode('utf-8')) user = data['user_name'] password=data['password'] result=loginCheck(user,password,handler) if result: response1['status'] = 'success' response1['privilege'] = result session['privilege'] = result session['user'] = user else: response1['status'] = 'fail' session.clear() return jsonify(response1)
def web_lookImpl(): handler = getSQLHandler() # 获取handler privilege = session.get( "privilege") # 获取session中的权限,如果不存在该privilege则为None gradu_years = GET_ALL_gradu_Year(handler) # 获取所有毕业年份 now_year = int(request.args.get("year", get_year())) # 获取url中的毕业年份 if now_year not in gradu_years: now_year = gradu_years[0] infos = GET_ALL_student_INFO_BY_YEAR(now_year, handler) # 通过毕业年份获取学生信息 head = get_total_employ_con(infos) data = get_employ_con_major(handler, infos) return render_template("look.html", head=head, privilege=privilege, years=gradu_years, url_dict=url_dict, data=data, now_year=now_year)
def api_registerImpl(): privilege = session['privilege'] if privilege != PRIVILEGE_STUDENT or not check_session(): return response1 = {} handler = getSQLHandler() # 获取sql连接 data = json.loads(request.get_data().decode('utf-8')) user = session['user'] com_job_id = data['com_job_id'] if CHECK_EXIST(user, handler): response1['status'] = "不可二次登记" else: if CHECK_com_job_NUM_NOT_ENOUGH(com_job_id): if INSERT_NEW_register(com_job_id, user, handler): response1['status'] = "登记成功,待审核" else: response1['status'] = "登记失败,请重新登记" else: response1['status'] = "该职位人数已满" return jsonify(response1)
def api_major_managementImpl(): privilege = session['privilege'] if privilege != PRIVILEGE_ADMIN or not check_session(): return response1 = {'status': ""} handler = getSQLHandler() # 获取sql连接 data = json.loads(request.get_data().decode('utf-8')) control = data['control'] if control == "AddApart": apart_name = data['apart_name'] if CHECK_apart_name_EXIST(apart_name,handler): response1['status']="院系名已存在" else: if ADD_NEW_apartment(apart_name,handler): response1['status']="添加成功" else: response1['status']="添加失败" elif control == "AddMajor": major_name = data['major_name'] apart_id = data['apart_id'] if CHECK_major_name_EXIST(major_name, handler): response1['status'] = "专业名已存在" else: if ADD_NEW_major(major_name, handler): major_id = GET_major_id_BY_major_name(major_name, handler) if ADD_NEW_apart_major(major_id, apart_id, handler): response1['status'] = "添加成功" else: response1['status'] = "添加失败" else: response1['status'] = "添加失败" return jsonify(response1)
def api_student_managementImpl(): privilege = session['privilege'] if privilege != PRIVILEGE_ADMIN or not check_session(): return response1 = {'status': ""} handler = getSQLHandler() # 获取sql连接 data = json.loads(request.get_data().decode('utf-8')) control = data['control'] if control == "get_student_info": student_infos = GET_ALL_STUDENT_INFOS(handler) if student_infos: result = [] for info in student_infos: temp = {} temp['stu_id'] = info[0] temp['stu_name'] = info[1] temp['gender'] = info[4] temp['enroll_year'] = info[2] temp['gradu_year'] = info[3] temp['status'] = info[5] temp['major_name'] = info[8] result.append(temp) response1['status'] = "success" response1['data'] = result else: response1['status'] = "fail" elif control == "get_com_job_infos": com_job_infos = GET_ALL_com_job_infos(handler) if com_job_infos != None: response1['data'] = com_job_infos response1['status'] = "success" else: response1['status'] = 'fail' elif control == "add" or control == "change": stu_id = data['stu_id'] stu_name = data['stu_name'] gender = data['gender'] enroll_year = data['enroll_year'] gradu_year = data["gradu_year"] major_name = data['major_name'] stu_exist = GET_major_id_BY_stu_id(stu_id, handler) if control == "add": if stu_exist: response1['status'] = "用户已存在" else: status = ADD_NEW_STUDENT(stu_id, stu_name, gender, enroll_year, gradu_year, handler) if not status: response1['status'] = "新建失败" else: status = INSERT_NEW_major_student(major_name, stu_id, handler) if not status: response1['status'] = "新建失败" else: response1['status'] = "新建成功" elif control == "change": if not stu_exist: response1['status'] = "用户不存在" else: status = UPDATE_STUDENT(stu_id, stu_name, gender, enroll_year, gradu_year, handler) if not status: response1['status'] = "更新失败" else: status = UPDATE_major_student(major_name, stu_id, handler) if not status: response1['status'] = "更新失败" else: response1['status'] = "更新成功" elif control == "delete": stu_id = data['stu_id'] stu_exist = GET_major_id_BY_stu_id(stu_id, handler) if not stu_exist: response1['status'] = "用户不存在" else: status = DELETE_major_student(stu_id, handler) status = status and DELETE_student_IN_student_job(stu_id, handler) status = status and DELETE_student_IN_verify(stu_id, handler) status = status and DELETE_STUDENT(stu_id, handler) if not status: response1['status'] = "删除失败" else: response1['status'] = "删除成功" elif control == "reset": stu_id = data['stu_id'] stu_exist = GET_major_id_BY_stu_id(stu_id, handler) if not stu_exist: response1['status'] = "用户不存在" else: status = CHANGE_STUDENT_password(stu_id, Default_password, handler) if not status: response1['status'] = "重置失败" else: response1['status'] = "重置成功" elif control == "register": com_job_id = data['com_job_id'] stu_id = data['stu_id'] if CHECK_student_pass_or_not(stu_id, handler): response1['status'] = "学生已就业" else: if CHECK_com_job_NUM_NOT_ENOUGH(com_job_id, handler): result = INSERT_NEW_student_job(stu_id, com_job_id, handler) # 插入student_job表 verify_id = INSERT_NEW_register_AND_RETURN_verify_id( com_job_id, stu_id) result = result and UPDATE_register(verify_id, STATUS_PASS, handler) # 更改登记状态 result = result and REFRESH_student_status(stu_id, handler) # 刷新学生就业状态 if result: response1['status'] = "登记成功" else: response1['status'] = "登记失败" else: response1['status'] = "该职位需求人数已满" return jsonify(response1)
def api_register_checkImpl(): privilege = session['privilege'] if privilege != PRIVILEGE_ADMIN or not check_session(): return response1 = {} handler = getSQLHandler() # 获取sql连接 data = json.loads(request.get_data().decode('utf-8')) control = data['control'] if control == "get_register": result = GET_ALL_verify_INFOS(handler) response1['data'] = result response1['status'] = "success" elif control == STATUS_PASS: verify_id = data['verify_id'] stu_id = data['stu_id'] com_job_id = data['com_job_id'] # 若学生未被审批通过 if not CHECK_student_pass_or_not(stu_id, handler): if CHECK_com_job_NUM_NOT_ENOUGH(com_job_id, handler): result = INSERT_NEW_student_job(stu_id, com_job_id, handler) # 插入student_job表 result = result and UPDATE_register(verify_id, control, handler) #更改登记状态 result = result and REFRESH_student_status(stu_id, handler) #刷新学生就业状态 if result: response1['status'] = "操作成功" else: response1['status'] = "操作失败" else: response1['status'] = "该职位需求人数已满" else: response1['status'] = "学生已就业" elif control == STATUS_WAITING: verify_id = data['verify_id'] stu_id = data['stu_id'] com_job_id = data['com_job_id'] # 若学生未被审批通过 if not CHECK_student_pass_or_not(stu_id, handler): result = UPDATE_register(verify_id, control, handler) #更改登记状态 if result: response1['status'] = "操作成功" else: response1['status'] = "操作失败" # 若学生已审核通过 else: result = DELETE_student_job(stu_id, com_job_id, handler) # 插入student_job表 result = result and UPDATE_register(verify_id, control, handler) # 更改登记状态 result = result and REFRESH_student_status(stu_id, handler) # 刷新学生就业状态 if result: response1['status'] = "操作成功" else: response1['status'] = "操作失败" elif control == STATUS_FAIL: verify_id = data['verify_id'] result = UPDATE_register(verify_id, control, handler) # 更改登记状态 if result: response1['status'] = "操作成功" else: response1['status'] = "操作失败" return jsonify(response1)
def api_company_managementImpl(): privilege = session['privilege'] if privilege != PRIVILEGE_ADMIN or not check_session(): return response1 = {'status': ""} handler = getSQLHandler() # 获取sql连接 data = json.loads(request.get_data().decode('utf-8')) control = data['control'] if control == "get_com_job_infos": com_job_infos = GET_ALL_com_job_infos(handler) if com_job_infos != None: response1['data']=com_job_infos response1['status']="success" else: response1['status']='fail' elif control == "addCompany": com_name = data['com_name'] if not CHECK_com_name_exist(com_name,handler): if NEW_company(com_name,handler): response1['status']="新增成功" else: response1['status']="新增失败" else: response1['status']="公司名已存在" elif control == "addJobStyle": style_name = data['style_name'] if not CHECK_style_name_exist(style_name,handler): if NEW_job_style(style_name,handler): response1['status']="新增成功" else: response1['status']="新增失败" else: response1['status']="类型名已存在" elif control == "publish": job_name = data['job_name'] com_id = data['com_id'] style_id = data['style_id'] need_num = int(data['need_num']) finish_date = data['end_date'] job_id = CHECK_job_name_EXIST_AND_RETURN_job_id(job_name,handler) if not job_id: job_id = NEW_job_AND_RETURN_job_id(job_name,handler) if NEW_com_job(com_id,job_id,need_num,finish_date,style_id): response1['status']="发布成功" else: response1['status']="发布失败" elif control == "change": com_job_id = data['com_job_id'] com_id = data['com_id'] style_id = data['style_id'] need_num = int(data['need_num']) finish_date = data['end_date'] if UPDATE_com_job(com_job_id,com_id,need_num,finish_date,style_id): response1['status'] = "修改成功" else: response1['status'] = "修改失败" return jsonify(response1)