예제 #1
0
def delete_level_test(id):
    with DbLife() as db:
        level_test = db.query(
            model.LevelTest).filter(model.LevelTest.id == id).first()
        setattr(level_test, "is_delete", 1)
        db.commit()
        db.refresh(level_test)
예제 #2
0
def examine(student_id, levetest_id, mechanism_id):
    with DbLife() as db:
        studnet = model.LevelMechanismStudent(mechanism_id=mechanism_id,
                                              level_test_id=levetest_id,
                                              student_id=student_id)
        db.add(studnet)
        db.commit()
예제 #3
0
def relation_account_role(account_id, role_id):
    with DbLife() as db:
        role = db.query(model.Role).filter(model.Role.id == role_id).first()
        account = db.query(
            model.Account).filter(model.Account.id == account_id).first()
        account.roles.append(role)
        db.commit()
예제 #4
0
def get_applications(page,pre_page,is_order_by,filter_mes):
    with DbLife() as db:
        if is_order_by != None:
            pagination = paginate(db.query(model.Application).filter(model.Application.is_delete!=1).order_by(is_order_by),page, pre_page)
        if is_order_by == None:
            pagination = paginate(db.query(model.Application).filter(model.Application.is_delete!=1), page, pre_page)
        return pagination
예제 #5
0
def delete_college(id):
    with DbLife() as db:
        college = db.query(
            model.College).filter(model.College.id == id).first()
        setattr(college, "is_delete", 1)
        db.commit()
        db.refresh(college)
예제 #6
0
def examine_fail(register_major_id):
    with DbLife() as db:
        register = db.query(model.Register_Major).filter(
            model.Register_Major.id == register_major_id).first()
        setattr(register, "status", 3)
        db.add(register)
        db.commit()
예제 #7
0
def creat_qrcode(mechanism_id,leve_test_id,path):
    with DbLife() as db:
        qrcode = model.LevelMechanism(level_test_id=leve_test_id, mechanism_id=mechanism_id, qr_code_path=path)
        db.add(qrcode)
        db.commit()
        db.refresh(qrcode)
        return qrcode
예제 #8
0
def get_orders(page, pre_page, is_order_by, filter_mes):
    with DbLife() as db:
        if is_order_by != None:
            pagination = paginate(
                db.query(model.Order).order_by(is_order_by), page, pre_page)
        if is_order_by == None:
            pagination = paginate(db.query(model.Order), page, pre_page)
        return pagination
예제 #9
0
def add_mechanism(mechanism):
    with DbLife() as db:
        mechanism = model.Mechanism(mechanism_name =mechanism.mechanism_name ,address =mechanism.address ,
                                    telephone=mechanism.telephone ,college_id = mechanism.college_id,is_delete=0)
        db.add(mechanism)
        db.commit()
        db.refresh(mechanism)
        return mechanism
예제 #10
0
def delete_major(id):
    with DbLife() as db:
        info = db.query(model.Enter_Major).filter(
            model.Enter_Major.id == id,
            model.Enter_Major.is_delete != 1).first()
        setattr(info, "is_delete", 1)
        db.commit()
        db.refresh(info)
예제 #11
0
def query_qrcode(mechanism_id,level_test_id):
    with DbLife() as db:
        query_list = [
            model.LevelMechanism.mechanism_id == mechanism_id ,
            model.LevelMechanism.level_test_id == level_test_id
        ]
        qrcode = db.query(model.LevelMechanism).filter(*query_list).all()
        return qrcode
예제 #12
0
def call_back_error(sys_order_id):
    with DbLife() as db:
        order_info = db.query(model.Order).filter(
            model.Order.sys_order_id == sys_order_id).first()
        setattr(order_info, "status", 2)
        db.commit()
        db.refresh(order_info)
    return order_info
예제 #13
0
def register(telephone,password,email):
    with DbLife() as db:
        #密码加密
        password_hash = model.Account.generate_password_hash(password)
        account = model.Account(telephone=telephone, password=password_hash,status = 0,email=email)
        db.add(account)
        db.commit()
        db.refresh(account)
        return account
예제 #14
0
def del_applications(sys_id):
    with DbLife() as db:
        application_info = db.query(model.Application).filter(model.Application.sys_id == sys_id,
                                                              model.Application.is_delete != 1).first()
        if application_info != None:
            setattr(application_info, "is_delete",1)
            setattr(application_info, "delete_time",datetime.now())
            db.commit()
            db.flush(application_info)
예제 #15
0
def call_back_success(sys_order_id, timestamp):
    with DbLife() as db:
        order_info = db.query(model.Order).filter(
            model.Order.sys_order_id == sys_order_id).first()
        setattr(order_info, "status", 1)
        setattr(order_info, "pay_time", timestamp)
        db.commit()
        db.refresh(order_info)
    return order_info
예제 #16
0
def update_mechanism(param_mechanism):
    with DbLife() as db:
        mechanism = db.query(model.Mechanism).filter(model.Mechanism.id == param_mechanism.id).first()
        setattr(mechanism,"mechanism_name",param_mechanism.mechanism_name)
        setattr(mechanism, "address", param_mechanism.address)
        setattr(mechanism, "telephone", param_mechanism.telephone)
        setattr(mechanism, "college_id", param_mechanism.college_id)
        db.commit()
        db.refresh(mechanism)
        return mechanism
예제 #17
0
def update_level_test(param_leveltest):
    with DbLife() as db:
        leveltest = db.query(model.LevelTest).filter(
            model.LevelTest.id == param_leveltest.id).first()
        setattr(leveltest, "test_name", param_leveltest.test_name)
        setattr(leveltest, "start_time", param_leveltest.start_time)
        setattr(leveltest, "end_time", param_leveltest.end_time)
        db.commit()
        db.refresh(leveltest)
    return leveltest
예제 #18
0
def updata_student(student_param: StudentBase):
    with DbLife() as db:
        data_student = db.query(model.Student).filter(
            model.Student.id == student_param.id).first()
        student_dict = student_param.dict(exclude_unset=True)  # 变成字典,修改所有
        for k, v in student_dict.items():
            setattr(data_student, k, v)
        db.commit()
        db.refresh(data_student)
    return data_student
예제 #19
0
def add_level_test(leveltest):
    with DbLife() as db:
        leveltest = model.LevelTest(test_name=leveltest.test_name,
                                    start_time=leveltest.start_time,
                                    end_time=leveltest.end_time,
                                    is_delete=0)
        db.add(leveltest)
        db.commit()
        db.refresh(leveltest)
    return leveltest
예제 #20
0
def add_major(major):
    with DbLife() as db:
        data_major = model.Enter_Major(major_name=major.major_name,
                                       level=major.level,
                                       level_test_id=major.level_test_id,
                                       is_delete=0)
        db.add(data_major)
        db.commit()
        db.refresh(data_major)
    return data_major
예제 #21
0
def add_certificate(register_major_id, belong_committee, level, filename,
                    get_time):
    with DbLife() as db:
        certificate = model.Certificate(belong_committee=belong_committee,
                                        level=level,
                                        certificate_image=filename,
                                        get_time=get_time,
                                        register_info_id=register_major_id)
        db.add(certificate)
        db.commit()
예제 #22
0
def update_major(major):
    with DbLife() as db:
        info = db.query(model.Enter_Major).filter(
            model.Enter_Major.id == major.id,
            model.Enter_Major.is_delete != 1).first()
        setattr(info, "major_name", major.major_name)
        setattr(info, "level", major.level)
        setattr(info, "level_test_id", major.level_test_id)
        db.commit()
        db.refresh(info)
    return info
예제 #23
0
def add_student(student_param: StudentBase):
    with DbLife() as db:
        data_student = model.Student()
        student_dict = student_param.dict(exclude_unset=True)  # 变成字典,修改所有
        for k, v in student_dict.items():
            if (k != "id"):
                setattr(data_student, k, v)
        db.add(data_student)
        db.commit()
        db.refresh(data_student)
    return data_student
예제 #24
0
def update_certificate(register_major_id, id, belong_committee, level,
                       filename, get_time):
    with DbLife() as db:
        certificate = db.query(
            model.Certificate).filter(model.Certificate.id == id).first()
        setattr(certificate, "belong_committee", belong_committee)
        setattr(certificate, "level", level)
        setattr(certificate, "certificate_image", filename)
        setattr(certificate, "get_time", get_time)
        db.commit()
        db.refresh(certificate)
        return certificate
예제 #25
0
def add_college(college_name, college_eng_name, address, telephone, filename):
    with DbLife() as db:
        college = model.College(college_name=college_name,
                                college_eng_name=college_eng_name,
                                address=address,
                                telephone=telephone,
                                icon=filename,
                                is_delete=0)
        db.add(college)
        db.commit()
        db.refresh(college)
        return college
예제 #26
0
def get_leveltest_by_mid(mechanism_id):
    with DbLife() as db:
        leveltests = []
        levelmechanisms = db.query(model.LevelMechanism).filter(
            model.LevelMechanism.mechanism_id == mechanism_id,
            model.LevelMechanism.is_delete != 1).all()
        for levelmechanism in levelmechanisms:
            leveltest = db.query(model.LevelTest).filter(
                model.LevelTest.id == levelmechanism.level_test_id,
                model.LevelTest.is_delete != 1).first()
            leveltests.append(leveltest)
        return leveltests
예제 #27
0
def upload_video(file_name_list, track_ids, register_ids, register_id):
    with DbLife() as db:
        register = db.query(model.Register_Major).filter(
            model.Register_Major.id == register_id).first()
        setattr(register, "video_status", 1)
        db.add(register)
        for i, file_name in enumerate(file_name_list):
            video = model.Video(video_name=file_name,
                                path=file_name,
                                register_info_id=register_ids[i],
                                track_id=track_ids[i])
            db.add(video)
        db.commit()
예제 #28
0
def update_college(id, college_name, college_eng_name, address, telephone,
                   filename):
    with DbLife() as db:
        college = db.query(
            model.College).filter(model.College.id == id).first()
        setattr(college, "college_name", college_name)
        setattr(college, "college_eng_name", college_eng_name)
        setattr(college, "address", address)
        setattr(college, "telephone", telephone)
        setattr(college, "icon", filename)
        db.commit()
        db.refresh(college)
        return college
예제 #29
0
def add_track(track_name:list):
    with DbLife() as db:
        temp = []
        for v in track_name:
            same_track = db.query(model.Track).filter(model.Track.track_name == v).first()
            if same_track is None:
                track = model.Track(track_name=v)
                db.add(track)
                db.flush()
                temp.append(track.id)
                db.commit()
            else:
                temp.append(same_track.id)
    return temp
예제 #30
0
def updata_applications(sys_id,app):
    with DbLife() as db:
       application_info = db.query(model.Application).filter(model.Application.sys_id==sys_id,model.Application.is_delete!=1).first()
       if application_info != None:
           setattr(application_info, "name",app.name)
           setattr(application_info, "public_key", app.public_key)
           setattr(application_info, "key", app.key)
           setattr(application_info, "account", app.account)
           setattr(application_info, "email", app.email)
           setattr(application_info, "admin_name", app.admin_name)
           setattr(application_info, "admin_phone", app.admin_phone)
           setattr(application_info, "update_time", datetime.now())
           db.commit()
           db.flush(application_info)