def post(self): res = ResMsg() if session.get('role') != 3: res.update(code=-4, data='', msg=permission_denied) return jsonify(res.data) data = request.get_json() flag, mes = format_checker(del_pro_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) project_id = data.get('project_id') exist_project = Project.query.filter_by(id=project_id, status=True).first() if not exist_project: res.update(code=-1, data='', msg=project_not_exist_error) return jsonify(res.data) exist_project.status = False try: db.session.commit() res.update(code=1, data='', msg=request_success) return jsonify(res.data) except Exception as e: db.session.rollback() res.update(code=-1, data=str(e), msg=request_fail) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(statistics_task_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) password = data.get('password') if password != 'za-test': res.update(code=-1, data='', msg=password_error) return jsonify(res.data) run_time = '0 2 * * *' job_name = 'case_statistics_%s' % password try: if sched.get_job(job_name): mes = {'error': '缓存中已存在任务 %s 信息' % job_name} res.update(code=-1, data=mes, msg=task_start_error) return jsonify(res.data) # 标准crontab格式'5 2 * * *' 每天凌晨2点5分执行 sched.add_job(case_data_statistics, CronTrigger.from_crontab(run_time), id=job_name, args=[], jobstore='redis', replace_existing=True) res.update(code=1, data='', msg=request_success) return jsonify(res.data) except Exception as e: res.update(code=-1, data=str(e), msg=task_start_error) return jsonify(res.data)
def post(self): res = ResMsg() if session.get('role') != 3: res.update(code=-4, data='', msg=permission_denied) return jsonify(res.data) data = request.get_json() flag, mes = format_checker(add_pro_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) project_name = data.get('project_name') project_desc = data.get('project_desc') exist_project = Project.query.filter_by(project_name=project_name, status=True).first() if exist_project: res.update(code=-1, data='', msg=name_exist_error) return jsonify(res.data) project_desc = project_desc if project_desc else '' new_project = Project(project_name=project_name, project_desc=project_desc, c_uid=current_user.id) db.session.add(new_project) try: db.session.commit() project_info = { 'project_id': new_project.id, 'project_name': project_name, 'create_user': current_user.id, } res.update(code=1, data=project_info, msg=request_success) return jsonify(res.data) except Exception as e: db.session.rollback() res.update(code=-1, data=str(e), msg=request_fail) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(del_mf_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) mf_id = data.get('mf_id') exist_mf = Manufacturer.query.filter_by(id=mf_id, status=1).first() if not exist_mf: res.update(code=-1, data='', msg=mf_not_exist_error) return jsonify(res.data) exist_eq = Equipment.query.filter_by(mf_id=mf_id, status=1).first() if exist_eq: print(exist_eq) res.update(code=-1, data='', msg=mf_is_related_error) return jsonify(res.data) exist_mf.status = 0 try: db.session.commit() res.update(code=1, data='', msg=request_success) return jsonify(res.data) except Exception as e: db.session.rollback() res.update(code=-1, data=str(e), msg=request_fail) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(edit_header_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) interface_id = data.get('interface_id') header = data.get('header') if not is_json(header): res.update(code=-1, data=header, msg=param_not_json_error) return jsonify(res.data) exist_interface = Interface.query.filter_by(id=interface_id, status=True).first() if not exist_interface: res.update(code=-1, data='', msg=interface_not_exist_error) return jsonify(res.data) exist_interface.header = header try: db.session.commit() res.update(code=1, data='', msg=request_success) return jsonify(res.data) except Exception as e: db.session.rollback() res.update(code=-1, data=str(e), msg=request_fail) return jsonify(res.data)
def get(self): res = ResMsg() day = 7 case_stat = CaseStatistics.query.order_by( CaseStatistics.id.desc()).limit(day) if case_stat.count() == 0: res.update(code=1, data='', msg=request_success) return jsonify(res.data) new_cs = case_stat.first() cs_date_list = [] for cs in reversed(case_stat.all()): date_cs = { 'open_date': cs.open_date, 'today_run_case_num': cs.today_run_case_num, 'today_suc_case_num': cs.today_suc_case_num, 'today_fail_case_num': cs.today_fail_case_num, } cs_date_list.append(date_cs) data = { 'interface_num': new_cs.interface_num, 'case_num': new_cs.case_num, 'run_case_num': new_cs.run_case_num, 'success_case_num': new_cs.success_case_num, 'failure_case_num': new_cs.failure_case_num, 'exception_case_num': new_cs.exception_case_num, 'cs_date_list': cs_date_list } res.update(code=1, data=data, msg=request_success) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(set_role_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) uid = data.get('uid') role_id = data.get('role_id') exist_user = User.query.filter_by(id=uid).first() if not exist_user: res.update(code=-1, data='', msg=user_not_exist) return jsonify(res.data) if session.get('role') == 3: pass elif session.get('role') == 2 and exist_user.role_id != 3 and role_id != 3: pass else: res.update(code=-4, data='', msg=permission_denied) return jsonify(res.data) exist_user.role_id = role_id try: db.session.commit() res.update(code=1, data='', msg=set_role_success) return jsonify(res.data) except Exception as e: db.session.rollback() res.update(code=-1, data=str(e), msg=set_role_failure) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(login_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) username = data.get('username') password = data.get('password') user = User.query.filter_by(username=username).first() if user: if user.status is False: res.update(code=-1, data='', msg=user_login_forbidden) return jsonify(res.data) if user.check_password(password): login_user(user) session['username'] = username session['role'] = user.role_id token = session['_id'] data = { 'user': username, 'uid': user.id, 'user_role': user.role_id, 'token': token, } res.update(code=1, data=data, msg=login_success) return jsonify(res.data) else: res.update(code=-1, data='', msg=password_error) return jsonify(res.data) res.update(code=-1, data='', msg=user_not_exist) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(edit_eq_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) eq_id = data.get('eq_id') eq_code = data.get('eq_code') eq_name = data.get('eq_name') eq_desc = data.get('eq_desc') eq_type = data.get('eq_type') eq_sys = data.get('eq_sys') eq_sys_ver = data.get('eq_sys_ver') eq_owner = data.get('eq_owner') borrower = data.get('borrower') have_sim = data.get('have_sim') mf_id = data.get('mf_id') exist_eq = Equipment.query.filter_by(id=eq_id, status=1).first() if not exist_eq: res.update(code=-1, data='', msg=eq_not_exist_error) return jsonify(res.data) other_eq = Equipment.query.filter_by(eq_code=eq_code, status=1).first() if other_eq and other_eq != exist_eq: res.update(code=-1, data='', msg=eq_code_exist_error) return jsonify(res.data) exist_eq.eq_code = eq_code exist_eq.eq_name = eq_name exist_eq.eq_desc = eq_desc exist_eq.eq_type = eq_type exist_eq.eq_sys = eq_sys exist_eq.eq_sys_ver = eq_sys_ver exist_eq.eq_owner = eq_owner exist_eq.borrower = borrower exist_eq.have_sim = have_sim exist_eq.mf_id = mf_id try: db.session.commit() eq_info = { 'eq_code': eq_code, 'eq_name': eq_name, 'eq_desc': eq_desc, 'eq_type': eq_type, 'eq_sys': eq_sys, 'eq_sys_ver': eq_sys_ver, 'eq_owner': eq_owner, 'borrower': borrower, 'have_sim': have_sim, 'mf_id': mf_id, 'eq_id': eq_id } add_eq_log(eq_info, 2) res.update(code=1, data=eq_info, msg=request_success) return jsonify(res.data) except Exception as e: db.session.rollback() res.update(code=-1, data=str(e), msg=request_fail) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(CourseInfoByLiveId_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) live_id = data.get('live_id') data = get_teacher_info_by_live_id(live_id) res.update(code=1, data=data, msg=request_success) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(edit_env_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) env_id = data.get('env_id') env_name = data.get('env_name') desc = data.get('desc') url = data.get('url') use_db = data.get('use_db') db_host = data.get('db_host') db_port = data.get('db_port') db_user = data.get('db_user') db_pass = data.get('db_pass') database = data.get('database') desc = desc if desc else '' use_db = True if use_db == 1 else False db_host = db_host if db_host else '' db_port = db_port if db_port else '' db_user = db_user if db_user else '' db_pass = db_pass if db_pass else '' database = database if database else '' if use_db: if db_host and db_port and db_user and db_pass and database: pass else: res.update(code=-1, data='', msg=db_info_empty_error) return jsonify(res.data) else: db_host = db_port = db_user = db_pass = database = '' exist_env = Environment.query.filter_by(id=env_id, status=True).first() if not exist_env: res.update(code=-1, data='', msg=env_not_exist_error) return jsonify(res.data) exist_env.env_name = env_name exist_env.desc = desc exist_env.url = url exist_env.use_db = use_db exist_env.db_host = db_host exist_env.db_port = db_port exist_env.db_user = db_user exist_env.db_pass = db_pass exist_env.database = database try: db.session.commit() res.update(code=1, data='', msg=request_success) return jsonify(res.data) except Exception as e: db.session.rollback() res.update(code=-1, data=str(e), msg=request_fail) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(UserInfoByXid_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) xid = data.get('xid') data = get_user_info_by_xid(xid) pager = Pager(data) data = pager.page_data() res.update(code=1, data=data, msg=request_success) res.add_field(name='data_total', value=pager.data_count) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(case_res_list_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) case_id = data.get('case_id') page_num = data.get('page_num') page_size = data.get('page_size', 10) case_res_list = list() exist_case = TestCase.query.filter_by(id=case_id, status=True).first() if not exist_case: res.update(code=-1, data='', msg=case_not_exist_error) return jsonify(res.data) try: case_results = CaseResult.query.filter_by(case_id=case_id).order_by(CaseResult.id.desc()).all() except Exception as e: res.update(code=-1, data=str(e), msg=request_fail) return jsonify(res.data) if case_results: for cr in case_results: case_info = { 'case_result_id': cr.id, 'case_type': cr.case_type, 'method': cr.method, 'path': cr.path, 'case_result': cr.case_result, 'start_time': datetime.datetime.strftime(cr.start_time, "%Y-%m-%d %H:%M:%S"), } case_res_list.append(case_info) data, total = list_page(case_res_list, page_size, page_num) res.update(code=1, data=data, msg=request_success) res.add_field(name='page_total_num', value=total) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(edit_interface_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) interface_id = data.get('interface_id') interface_name = data.get('interface_name') interface_desc = data.get('interface_desc') interface_type = data.get('interface_type') method = data.get('method') path = data.get('path') exist_interface = Interface.query.filter_by(id=interface_id, status=True).first() if not exist_interface: res.update(code=-1, data='', msg=interface_not_exist_error) return jsonify(res.data) exist_interface.Interface_name = interface_name exist_interface.Interface_desc = interface_desc exist_interface.interface_type = interface_type exist_interface.method = method exist_interface.path = path try: db.session.commit() res.update(code=1, data='', msg=request_success) return jsonify(res.data) except Exception as e: db.session.rollback() res.update(code=-1, data=str(e), msg=request_fail) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(add_model_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) project_id = data.get('project_id') model_name = data.get('model_name') model_desc = data.get('model_desc') exist_project = Project.query.filter_by(id=project_id, status=True).first() if not exist_project: res.update(code=-1, data='', msg=project_not_exist_error) return jsonify(res.data) model_desc = model_desc if model_desc else '' new_model = Model(model_name=model_name, model_desc=model_desc, project_id=project_id, c_uid=current_user.id) db.session.add(new_model) try: db.session.commit() model_info = { 'model_id': new_model.id, 'model_name': model_name, 'create_user': current_user.id, } res.update(code=1, data=model_info, msg=request_success) return jsonify(res.data) except Exception as e: db.session.rollback() res.update(code=-1, data=str(e), msg=request_fail) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(add_model_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) model_id = data.get('model_id') model_name = data.get('model_name') model_desc = data.get('model_desc') exist_model = Model.query.filter_by(id=model_id, status=True).first() if not exist_model: res.update(code=-1, data='', msg=model_not_exist_error) return jsonify(res.data) model_desc = model_desc if model_desc else '' exist_model.model_name = model_name exist_model.model_desc = model_desc try: db.session.commit() res.update(code=1, data='', msg=request_success) return jsonify(res.data) except Exception as e: db.session.rollback() res.update(code=-1, data=str(e), msg=request_fail) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(del_eq_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) eq_id = data.get('eq_id') exist_eq = Equipment.query.filter_by(id=eq_id, status=1).first() if not exist_eq: res.update(code=-1, data='', msg=eq_not_exist_error) return jsonify(res.data) exist_eq.status = 0 try: db.session.commit() eq_info = { 'eq_code': exist_eq.eq_code, 'eq_name': exist_eq.eq_name, 'eq_desc': exist_eq.eq_desc, 'eq_type': exist_eq.eq_type, 'eq_sys': exist_eq.eq_sys, 'eq_sys_ver': exist_eq.eq_sys_ver, 'eq_owner': exist_eq.eq_owner, 'borrower': exist_eq.borrower, 'have_sim': exist_eq.have_sim, 'mf_id': exist_eq.mf_id, 'eq_id': exist_eq.id } add_eq_log(eq_info, 5) res.update(code=1, data='', msg=request_success) return jsonify(res.data) except Exception as e: db.session.rollback() res.update(code=-1, data=str(e), msg=request_fail) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(user_list_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) page_num = data.get('page_num') page_size = data.get('page_size', 10) user_list = list() if not page_num: res.update(code=-1, data='', msg=param_error) return jsonify(res.data) try: users = User.query.all() except Exception as e: res.update(code=-1, data=str(e), msg=request_fail) return jsonify(res.data) if users: for u in users: status = 1 if u.status else 0 user_info = { 'uid': u.id, 'username': u.username, 'role': u.roles.name, 'status': status, } user_list.append(user_info) data, total = list_page(user_list, page_size, page_num) res.update(code=1, data=data, msg=request_success) res.add_field(name='page_total_num', value=total) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(duplicate_case_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) case_id = data.get('case_id') exist_case = TestCase.query.filter_by(id=case_id, status=True).first() if not exist_case: res.update(code=-1, data='', msg=case_not_exist_error) return jsonify(res.data) new_case = TestCase( case_name=exist_case.case_name, case_desc=exist_case.case_desc, case_type=exist_case.case_type, method=exist_case.method, path=exist_case.path, params=exist_case.params, header=exist_case.header, has_sign=exist_case.has_sign, ak=exist_case.ak, sk=exist_case.sk, res_assert=exist_case.res_assert, rely_params=exist_case.rely_params, has_output=exist_case.has_output, output_para=exist_case.output_para, has_input=exist_case.has_input, input_para=exist_case.input_para, input_header=exist_case.input_header, save_result=exist_case.save_result, use_db=exist_case.use_db, sql=exist_case.sql, field_value=exist_case.field_value, project_id=exist_case.project_id, model_id=exist_case.model_id, interface_id=exist_case.interface_id, env_id=exist_case.env_id, c_uid=current_user.id ) db.session.add(new_case) db.session.flush() for exist_rc in exist_case.rely_case.all(): new_case.rely_case.append(exist_rc) try: db.session.commit() case_info = { 'case_id': new_case.id, 'case_name': new_case.case_name, } res.update(code=1, data=case_info, msg=request_success) return jsonify(res.data) except Exception as e: db.session.rollback() res.update(code=-1, data=str(e), msg=request_fail) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(run_multiple_case_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) project_id = data.get('project_id') case_list = data.get('case_list') day = time.strftime("%Y%m%d%H%M%S", time.localtime(time.time())) task_name = "执行用例任务_%s" % day # project = Project.query.filter_by(id=project_id, status=True).first() # if not project: # res.update(code=-1, data='', msg=project_not_exist_error) # return jsonify(res.data) new_task = Task( task_name=task_name, task_type=0, run_time='', run_status=1, c_uid=current_user.id, s_uid=current_user.id, project_id=project_id, ) db.session.add(new_task) db.session.flush() add_case_list, err_case_list, debug_case_list = [[], [], []] for case_id in case_list: exist_case = TestCase.query.filter_by(id=case_id, status=True).first() if exist_case: if not exist_case.is_debug: debug_case_list.append(case_id) continue new_task.interface.append(exist_case) add_case_list.append(case_id) else: err_case_list.append(case_id) case_info = { 'add_case': add_case_list, 'err_case': err_case_list, 'debug_case': debug_case_list, } if len(add_case_list) == 0: db.session.rollback() res.update(code=-1, data=case_info, msg=task_add_case_error) return jsonify(res.data) try: db.session.commit() run_task(new_task.id, current_user.id, day) res.update(code=1, data=case_info, msg=request_success) return jsonify(res.data) except Exception as e: db.session.rollback() res.update(code=-1, data=str(e), msg=request_fail) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(add_env_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) env_name = data.get('env_name') desc = data.get('desc') url = data.get('url') use_db = data.get('use_db') db_host = data.get('db_host') db_port = data.get('db_port') db_user = data.get('db_user') db_pass = data.get('db_pass') database = data.get('database') desc = desc if desc else '' use_db = True if use_db == 1 else False db_host = db_host if db_host else '' db_port = db_port if db_port else '' db_user = db_user if db_user else '' db_pass = db_pass if db_pass else '' database = database if database else '' if use_db: if db_host and db_port and db_user and db_pass and database: pass else: res.update(code=-1, data='', msg=db_info_empty_error) return jsonify(res.data) else: db_host = db_port = db_user = db_pass = database = '' new_env = Environment(env_name=env_name, desc=desc, url=url, use_db=use_db, db_host=db_host, db_port=db_port, db_user=db_user, db_pass=db_pass, database=database, c_uid=current_user.id) db.session.add(new_env) try: db.session.commit() env_info = { 'env_id': new_env.id, 'env_name': env_name, } res.update(code=1, data=env_info, msg=request_success) return jsonify(res.data) except Exception as e: db.session.rollback() res.update(code=-1, data=str(e), msg=request_fail) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(CourseInfoByMobile_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) mobile = data.get('mobile') page_size = data.get('pageSize') page_num = data.get('pageNum') data = get_course_info_by_mobile(mobile) pager = Pager(data, page_size) data = pager.page_data(page_num) res.update(code=1, data=data, msg=request_success) res.add_field(name='page_size', value=pager.page_size) res.add_field(name='page_num', value=page_num) res.add_field(name='page_total', value=pager.page_total_num) res.add_field(name='data_total', value=pager.data_count) return jsonify(res.data)
def post(self): # 返回 res = ResMsg() # 获取请求数据 data = request.get_json() product_id = data.get("product_id") module_id = data.get("module_id") product_name = data.get("product_name") module_name = data.get("module_name") start_day = data.get("start_day") end_day = data.get("end_day") if end_day == '': end_day = datetime.datetime.now().strftime("%Y-%m-%d") update_return = update_data(product_id, module_id, product_name, module_name, start_day, end_day) if update_return is None: res.update(code=1, data='', msg='创建/更新成功!') return jsonify(res.data) else: res.update(code=-1, data='', msg=str(update_return)) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(env_list_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) page_num = data.get('page_num') page_size = data.get('page_size', 10) env_list = list() try: environments = Environment.query.filter_by(status=True).order_by( Environment.id.desc()).all() except Exception as e: res.update(code=-1, data=str(e), msg=request_fail) return jsonify(res.data) if environments: for env in environments: env_info = { 'env_id': env.id, 'env_name': env.env_name, 'url': env.url, 'create_user': env.users.username, } env_list.append(env_info) data, total = list_page(env_list, page_size, page_num) res.update(code=1, data=data, msg=request_success) res.add_field(name='page_total_num', value=total) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(eq_info_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) eq_id = data.get('eq_id') exist_eq = Equipment.query.filter_by(id=eq_id, status=1).first() if not exist_eq: res.update(code=-1, data='', msg=eq_not_exist_error) return jsonify(res.data) eq_info = { 'eq_id': exist_eq.id, 'eq_code': exist_eq.eq_code, 'eq_name': exist_eq.eq_name, 'eq_desc': exist_eq.eq_desc, 'eq_type': exist_eq.eq_type, 'eq_sys': exist_eq.eq_sys, 'eq_sys_ver': exist_eq.eq_sys_ver, 'eq_owner': exist_eq.eq_owner, 'borrower': exist_eq.borrower, 'have_sim': exist_eq.have_sim, 'eq_status': exist_eq.eq_status, 'mf_id': exist_eq.mf_id, } res.update(code=1, data=eq_info, msg=request_success) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(env_info_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) env_id = data.get('env_id') exist_env = Environment.query.filter_by(id=env_id, status=True).first() if not exist_env: res.update(code=-1, data='', msg=env_not_exist_error) return jsonify(res.data) use_db = 1 if exist_env.use_db else 0 env_info = { 'env_id': exist_env.id, 'env_name': exist_env.env_name, 'desc': exist_env.desc, 'url': exist_env.url, 'use_db': use_db, 'db_host': exist_env.db_host, 'db_port': exist_env.db_port, 'db_user': exist_env.db_user, 'db_pass': exist_env.db_pass, 'database': exist_env.database, 'create_user': exist_env.users.username, } res.update(code=1, data=env_info, msg=request_success) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(model_list_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) project_id = data.get('project_id') page_num = data.get('page_num') page_size = data.get('page_size', 10) model_list = list() try: models = Model.query.filter_by(project_id=project_id, status=True).order_by( Model.id.desc()).all() except Exception as e: res.update(code=-1, data=str(e), msg=request_fail) return jsonify(res.data) if models: for m in models: model_info = { 'model_id': m.id, 'model_name': m.model_name, 'create_user': m.users.username, } model_list.append(model_info) data, total = list_page(model_list, page_size, page_num) res.update(code=1, data=data, msg=request_success) res.add_field(name='page_total_num', value=total) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(edd_param_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) interface_id = data.get('interface_id') Parameter.query.filter_by(interface_id=interface_id).delete( synchronize_session=False) params = data.get('params') if len(params) > 0: for para in params: new_param = Parameter( param_name=para.get('param_name'), param_desc=para.get('param_desc'), necessary=True if para.get('is_necessary') == 1 else False, default=para.get('default'), interface_id=interface_id, c_uid=current_user.id) db.session.add(new_param) try: db.session.commit() res.update(code=1, data='', msg=request_success) return jsonify(res.data) except Exception as e: db.session.rollback() res.update(code=-1, data=str(e), msg=request_fail) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(eq_list_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) page_num = data.get('page_num') page_size = data.get('page_size', 10) eq_list = list() try: equip = Equipment.query.filter_by(status=1).order_by(Equipment.id.desc()).all() except Exception as e: res.update(code=-1, data=str(e), msg=request_fail) return jsonify(res.data) if equip: for eq in equip: eq_info = { 'eq_id': eq.id, 'eq_code': eq.eq_code, 'eq_name': eq.eq_name, 'eq_type': eq.eq_type, 'eq_sys': eq.eq_sys, 'eq_sys_ver': eq.eq_sys_ver, 'eq_owner': eq.eq_owner, 'borrower': eq.borrower, 'have_sim': eq.have_sim, 'eq_status': eq.eq_status, 'mf_name': eq.manufacturers.name, } eq_list.append(eq_info) data, total = list_page(eq_list, page_size, page_num) res.update(code=1, data=data, msg=request_success) res.add_field(name='page_total_num', value=total) return jsonify(res.data)
def post(self): res = ResMsg() data = request.get_json() flag, mes = format_checker(mf_list_schema, data) if not flag: res.update(code=-1, data=mes, msg=param_format_error) return jsonify(res.data) page_num = data.get('page_num') page_size = data.get('page_size', 10) mf_list = list() try: mfs = Manufacturer.query.filter_by(status=1).all() except Exception as e: res.update(code=-1, data=str(e), msg=request_fail) return jsonify(res.data) if mfs: for mf in mfs: mf_info = { 'mf_id': mf.id, 'mf_name': mf.name, } mf_list.append(mf_info) data, total = list_page(mf_list, page_size, page_num) res.update(code=1, data=data, msg=request_success) res.add_field(name='page_total_num', value=total) return jsonify(res.data)