def GET_ALL_com_job_infos(handler=None): if not handler: handler = easy_connect() query = "select * from v_com_job" param = () result = handler.SELECT(query, param) return result
def GET_ALL_apart_infos(handler=None): if not handler: handler = easy_connect() query = "select * from apartment" param = () result = handler.SELECT(query, param) return result
def GET_VERIFY_INFOS_BY_stu_id(stu_id,handler=None): if not handler: handler=easy_connect() query = "select * from v_verify_com_job where stu_id=%s" param = (stu_id) result = handler.SELECT(query,param) return result
def GET_verify_status_BY_verify_id(verify_id,handler=None): if not handler: handler=easy_connect() query = "select status from verify where verify_id = %s" param = (verify_id) result = handler.SELECT(query, param) return result[0][0]
def UPDATE_major_student(major_id, stu_id, handler=None): if not handler: handler = easy_connect() query = "update major_student set major_id = %s where stu_id = %s" param = (int(major_id), int(stu_id)) result = handler.UPDATE(query, param) return result
def INSERT_NEW_major_student(major_id, stu_id, handler=None): if not handler: handler = easy_connect() query = "insert into major_student values (%s,%s)" param = (int(stu_id), int(major_id)) result = handler.UPDATE(query, param) return result
def DELETE_verify(verify_id,handler=None): if not handler: handler = easy_connect() query = "delete * from verify where verify_id = %s" param = (verify_id) result = handler.UPDATE(query, param) return result
def NEW_com_job(com_id, job_id, need_num, end_date, style_id, handler=None): if not handler: handler = easy_connect() query = "insert into com_job (com_id,job_id,need_num,start_time,finish_time,style_id) values (%s,%s,%s,%s,%s,%s)" param = (com_id, job_id, need_num, from_year_to_day(), end_date, style_id) return handler.UPDATE(query, param)
def DELETE_student_IN_student_job(stu_id,handler=None): if not handler: handler = easy_connect() query = "delete from student_job where stu_id=%s" param = (stu_id) result = handler.UPDATE(query, param) return result
def CHANGE_STUDENT_password(stu_id, password, handler=None): if not handler: handler = easy_connect() query = "update student set password=%s where stu_id=%s" param = (get_sha(password), stu_id) return handler.UPDATE(query, param)
def INSERT_NEW_student_job(stu_id,com_job_id,handler=None): if not handler: handler = easy_connect() query = "insert into student_job values (%s,%s,%s)" param = (stu_id,com_job_id,from_year_to_second()) result = handler.UPDATE(query, param) return result
def GET_ALL_STUDENT_INFOS(handler=None): if not handler: handler = easy_connect() query = "select * from v_major_student_infos" param = () result = handler.SELECT(query, param) return result
def CHANGE_ADMIN_password(user_name, password, handler=None): if not handler: handler = easy_connect() query = "update admin set password=%s where user_name=%s" param = (get_sha(password), user_name) return handler.UPDATE(query, param)
def INSERT_NEW_register_AND_RETURN_verify_id(com_job_id,stu_id,handler=None): if not handler: handler=easy_connect() query = "insert into verify (com_job_id,stu_id,status,create_time) values(%s,%s,%s,%s)" param = (com_job_id, stu_id,STATUS_WAITING,from_year_to_second()) handler.UPDATE(query, param) query = "select max(verify_id) from verify" result = handler.SELECT(query) return result[0][0]
def CHECK_apart_name_EXIST(apart_name, handler=None): if not handler: handler = easy_connect() query = "select * from apartment where apart_name=%s" param = (apart_name) result = handler.SELECT(query, param) if len(result) == 0: return False else: return True
def NEW_job_AND_RETURN_job_id(job_name,handler=None): if not handler: handler=easy_connect() query = "insert into job (job_name) values (%s)" param = (job_name) handler.UPDATE(query,param) query = "select max(job_id) from job" result = handler.SELECT(query) return result[0][0]
def CHECK_student_pass_or_not(stu_id,handler=None): if not handler: handler = easy_connect() query = "select * from student_job where stu_id = %s" param = (stu_id) result = handler.SELECT(query, param) if len(result)==0: return False else: return True
def GET_student_job_info_BY_stu_id(stu_id,handler=None): if not handler: handler = easy_connect() query = "select * from v_student_job_info where stu_id = %s" param = (stu_id) result = handler.SELECT(query, param) if len(result)==0: return None else: return result[0]
def CHECK_com_name_exist(com_name, handler=None): if not handler: handler = easy_connect() query = "select * from company where com_name = %s" param = (com_name) result = handler.SELECT(query, param) if len(result) == 0: return False else: return True
def CHECK_job_name_EXIST_AND_RETURN_job_id(job_name, handler=None): if not handler: handler = easy_connect() query = "select job_id from job where job_name = %s" param = (job_name) result = handler.SELECT(query, param) if len(result) == 0: return False else: return result[0][0]
def GET_student_major_INFO_BY_ID(id, handler=None): if not handler: handler = easy_connect() query = "select * from v_major_student_infos where stu_id=%s" param = (id) result = handler.SELECT(query, param) if len(result) == 0: return None else: return result[0]
def UPDATE_STUDENT(stu_id, stu_name, gender, enroll_year, gradu_year, handler=None): if not handler: handler = easy_connect() query = "update student set stu_name=%s,gender=%s,enroll_year=%s,gradu_year=%s where stu_id=%s" param = (stu_name, gender, enroll_year, gradu_year, stu_id) return handler.UPDATE(query, param)
def UPDATE_com_job(com_job_id, com_id, need_num, end_date, style_id, handler=None): if not handler: handler = easy_connect() query = "update com_job set com_id=%s,need_num=%s,finish_time=%s,style_id=%s where com_job_id=%s" param = (com_id, need_num, end_date, style_id, com_job_id) return handler.UPDATE(query, param)
def GET_ALL_major_student_INFOS(handler=None): """ :param handler: :return: """ if not handler: handler = easy_connect() query = "select * from major_student" param = () result = handler.SELECT(query, param) return result
def DELETE_USER(user_name, handler=None): """ :param user_name: :param handler: :return: """ if not handler: handler = easy_connect() query = "delete from %s where user_name=%s " param = (user_name) return handler.UPDATE(query, param)
def ADD_NEW_STUDENT(stu_id, stu_name, gender, enroll_year, gradu_year, handler=None): if not handler: handler = easy_connect() query = "insert into student values(%s,%s,%s,%s,%s,%s,%s)" param = (stu_id, stu_name, enroll_year, gradu_year, gender, '待业', get_sha(Default_password)) return handler.UPDATE(query, param)
def CHECK_EXIST(stu_id,handler=None): if not handler: handler=easy_connect() query = "select * from verify where stu_id=%s" param = (stu_id) result = handler.SELECT(query,param) if len(result)==0: return False else: for row in result: if row[3]==STATUS_WAITING or row[3]==STATUS_PASS: return True return False
def CHECK_com_job_NUM_NOT_ENOUGH(com_job_id, handler=None): if not handler: handler = easy_connect() query = "select exist_num,need_num from v_com_job where com_job_id=%s" param = (com_job_id) result = handler.SELECT(query, param) if len(result) == 0: return False else: if result[0][0] >= result[0][1]: return False else: return True
def GET_ALL_gradu_Year(handler=None): if not handler: handler=easy_connect() query = "select DISTINCT gradu_year from student " param = () result = handler.SELECT(query, param) if len(result) == 0: return [] else: new_result = [] for row in result: new_result.append(row[0]) return new_result
def GET_com_job_BY_com_id(com_id, handler=None): if not handler: handler = easy_connect() query = "select * from v_com_job where com_id=%s" param = (com_id) result = handler.SELECT(query, param) newReulst = [] for row in result: finishtime = row[6] starttime = row[5] now_time = time.time() if now_time > get_unix_time_by_date( starttime) and now_time < get_unix_time_by_date(finishtime): newReulst.append(row) return newReulst