def getGroupByUrl(self, groupUrl): print(self.project.id) group = fakerSession.query(GroupModel).filter( (GroupModel.baseUrl == groupUrl) & (GroupModel.project_id == self.project.id)).first() print(group.id) return group if group else self.otherGroup()
def getUrlDetail(self, urlId): if (urlId == -1): return self._emptyUrlDetail() urlModel = fakerSession.query(UrlModel).filter( UrlModel.id == urlId).first() if not urlModel: return self._emptyUrlDetail() result = urlModel.toDict() if urlModel.param != None and len(urlModel.params) > 0: values = [] jsons = [] for param in urlModel.params: values.append(param.value) urlPath = self.pathWithParam(urlModel.url, param.value) jsons.append(loadUrl(urlPath)) result["param_values"] = values result["param_jsons"] = jsons result["selectParamValue"] = values[0] else: result["content"] = loadUrl(urlModel.url) urlInfo = { "methods": self.getMethods(), "sections": self.getSectionsDesc(), "urlInfo": result, "state": "修改" if urlId != -1 else "添加" } if urlModel: urlInfo["selectTitle"] = urlModel.group.baseUrl return urlInfo
def __init__(self, projectName): self.project = fakerSession.query(ProjectModel).filter( ProjectModel.name == projectName).first() if self.project: print(" \033[32mload config: {}\033[0m".format(projectName)) print(" \033[32m首页地址可访问:http://127.0.0.1:5000\033[0m") else: logDebug("加载project:{}出错".format(projectName))
def otherGroup(self): other = fakerSession.query(GroupModel).filter( (GroupModel.desc == "other") & (GroupModel.project_id == self.project.id)).first() return other if other else self.addGroup({ "name": "其他", "desc": "other", "icon": "el-icon-connection", "baseUrl": "" })
def getUrlByPath(self, path): return fakerSession.query(UrlModel).filter( UrlModel.url == path).first()
def getUrlById(self, urlId): return fakerSession.query(UrlModel).filter( UrlModel.id == urlId).first()