def post(self): data = request.get_json() project = data['project'] model = data['model'] name = data['name'] url = data['url'] headers = data['headers'] xieyi = data['xieyi'] meth = data['meth'] project_id = Project.query.filter_by(project_name=project).first().id models_id = Model.query.filter_by(model_name=model).first().id try: new_interface = Interface(model_id=models_id, projects_id=project_id, Interface_name=name, Interface_url=url, Interface_meth=meth, Interface_user_id=current_user.id, Interface_headers=headers, interfacetype=xieyi) db.session.add(new_interface) db.session.commit() return reponse(message=MessageEnum.interface_add_success.value[1], code=MessageEnum.interface_add_success.value[0]) except Exception as e: logger.error(e) db.session.rollback() return reponse(message=MessageEnum.interface_add_erroe.value[1], code=MessageEnum.interface_add_erroe.value[0], data='')
def get(self, page=1): if current_user.is_sper is True: task = [] task.append( Task.query.filter_by(status=False).order_by( Task.id.desc()).all()) else: task = [] id = [] for project in current_user.quanxians: if (project.projects.id in id) is False: task.append( Task.query.filter_by(prject=project.projects.id, status=False).all()) id.append(project.projects.id) old_yask = hebinglist(task) projects_lsit = fenye_list(Ob_list=old_yask, split=PageShow) pages = range(1, len(projects_lsit) + 1) try: pyth_post1 = projects_lsit[int(page) - 1] return render_template('home/timingtask.html', inte=pyth_post1, pages=pages) except Exception as e: logger.error(e) return redirect(url_for('home.timingtask'))
def post(self): data = request.get_json() models = Model.query.filter_by(model_name=data['name']).first() if data['project'] == '请选择': # common = True project_one = None else: project_one = Project.query.filter_by( project_name=data['project']).first().id # common = False if models: return reponse(code=MessageEnum.model_only_one.value[0], message=MessageEnum.model_only_one.value[1]) new_moel = Model(model_name=data['name'], model_user_id=current_user.id, project=project_one) db.session.add(new_moel) try: db.session.commit() return reponse(code=MessageEnum.successs.value[0], message=MessageEnum.successs.value[1]) except Exception as e: logger.error(e) db.session.rollback() return reponse(code=MessageEnum.model_edit_fial.value[0], message=MessageEnum.model_edit_fial.value[1])
def delete(self): data = request.data.decode('utf-8') event = Interfacehuan.query.filter_by(id=data).first() event.status = True try: db.session.commit() return reponse(code=MessageEnum.successs.value[0], message=MessageEnum.successs.value[1]) except Exception as e: logger.error(e) return reponse(message=MessageEnum.delete_fail.value[1], code=MessageEnum.delete_fail.value[0])
def get(self, page=1): genconfiglist = GeneralConfiguration.query.filter_by( status=False).order_by(GeneralConfiguration.id.desc()).all() projects_lsit = fenye_list(Ob_list=genconfiglist, split=PageShow) pages = range(1, len(projects_lsit) + 1) try: pyth_post1 = projects_lsit[int(page) - 1] return render_template('home/genconfig.html', inte=pyth_post1, pages=pages) except Exception as e: logger.error(e) return redirect(url_for('home.genconfig'))
def post(self, id): interface = Interface.query.filter_by(id=id, status=False).first() if interface is None: flash(MessageEnum.edit_interface.value[1]) return redirect(url_for('home.interface')) project, models = get_pro_mo() if current_user.is_sper == True: projects = Project.query.filter_by(status=False).order_by( Project.id.desc()).all() else: projects = [] id = [] for i in current_user.quanxians: if (i.projects in id) == False: if i.projects.status == False: projects.append(i.projects) id.append(i.projects) projecct = request.form.get('project') model = request.form.get('model') intername = request.form.get('inter_name') url = request.form.get('url') interfa_tey = request.form.get('interface_type') headers = request.form.get('headers') meth = request.form.get('meth') if projecct is None or model is None or intername == '' or headers == '' or url == '' or meth == '': flash(MessageEnum.edit_interface_null_parame.value[1]) return render_template('edit/edit_interface.html', interfac=interface, projects=projects, models=models) project_id = Project.query.filter_by(project_name=projecct).first().id models_id = Model.query.filter_by(model_name=model).first().id interface.projects_id = project_id interface.model_id = models_id interface.Interface_name = intername interface.Interface_headers = headers interface.Interface_url = url interface.Interface_meth = meth interface.Interface_user_id = current_user.id interface.interfacetype = interfa_tey try: flash(MessageEnum.Interface_edit.value[1]) db.session.commit() return redirect(url_for('home.interface')) except Exception as e: logger.error(e) db.session.rollback() flash(MessageEnum.Interface_edit_fail.value[1]) return redirect(url_for('home.interface'))
def get(self, id): gencofigilist = GeneralConfiguration.query.filter_by( id=id, status=False).first() if not gencofigilist: flash(MessageEnum.config_not_exict.value[1]) gencofigilist.status = True try: db.session.commit() flash(MessageEnum.successs.value[1]) return redirect(url_for('home.genconfig')) except Exception as e: logger.error('删除配置失败!原因:%s' % e) db.session.rollback() flash(MessageEnum.cobfig_delete_error.value[1]) return redirect(url_for('home.genconfig'))
def delete(self): data = request.data.decode('utf-8') model = Model.query.filter_by(id=data, status=False).first() if not model: return reponse(message=MessageEnum.model_not_exict.value[1], code=MessageEnum.model_not_exict.value[0]) model.status = True try: db.session.commit() return reponse(message=MessageEnum.successs.value[1], code=MessageEnum.successs.value[0]) except Exception as e: logger.error(e) db.session.rollback() return reponse(message=MessageEnum.delete_fail.value[1], code=MessageEnum.delete_fail.value[0])
def delete(self): data = request.data.decode('utf-8') testcase = InterfaceTest.query.filter_by(id=data).first() if not testcase: return reponse(data=MessageEnum.case_not_exict.value[1], code=MessageEnum.case_not_exict.value[0]) try: testcase.status = True db.session.commit() return reponse(data=MessageEnum.successs.value[1], code=MessageEnum.successs.value[0]) except Exception as e: logger.error(e) db.session.rollback() return reponse(data=MessageEnum.delete_case_error.value[1], code=MessageEnum.delete_case_error.value[0])
def post(self): data_post = request.get_json() name_exict = Mockserver.query.filter_by(name=data_post['name']).first() if name_exict: return reponse(code=MessageEnum.mock_name_only_one.value[0], message=MessageEnum.mock_name_only_one.value[1]) if data_post['checkout'] == u'是': is_check = True else: is_check = False if data_post['checkouheaders'] == u'是': is_headers = True else: is_headers = False if data_post['kaiqi'] == u'是': is_kaiqi = True else: is_kaiqi = False new_mock = Mockserver(name=data_post['name']) new_mock.make_uers = current_user.id new_mock.path = data_post['path'] new_mock.methods = data_post['meth'] new_mock.headers = data_post['headers'] new_mock.description = data_post['desc'] new_mock.fanhui = data_post['back'] new_mock.params = data_post['parm'] new_mock.rebacktype = data_post['type'] new_mock.status = is_kaiqi new_mock.ischeck = is_check new_mock.is_headers = is_headers new_mock.update_time = datetime.datetime.now() db.session.add(new_mock) try: db.session.commit() return reponse(code=MessageEnum.successs.value[0], message=MessageEnum.successs.value[1]) except Exception as e: logger.error(e) db.session.rollback() return reponse(code=MessageEnum.create_mock_error.value[0], message=MessageEnum.create_mock_error.value[1])
def post(self): data = request.get_json() json_data = data project = json_data['project'] url = json_data['url'] desc = json_data['desc'] name = json_data['name'] host = json_data['host'] port = json_data['port'] usernmae = json_data['username'] password = json_data['password'] url_old = Interfacehuan.query.filter_by(url=str(url)).first() if url_old: return reponse( message=MessageEnum.testeveirment_use_one_nam.value[1], code=MessageEnum.testeveirment_use_one_nam.value[0], data='') prkcyt = Project.query.filter_by(project_name=project).first() testevent = Interfacehuan(url=url, desc=desc, project=prkcyt.id, database=name, databaseuser=usernmae, databasepassword=password, dbhost=host, dbport=port, make_user=current_user.id) db.session.add(testevent) try: db.session.commit() return reponse(message=MessageEnum.successs.value[1], code=MessageEnum.successs.value[0]) except Exception as e: logger.error(e) db.session.rollback() return reponse(message=MessageEnum.add_case_erro, code=211)