def getCompanyListByIDTuple(self, info): foreignIDTuple = info['foreignIDTuple'] startIndex = info['startIndex'] pageCount = info['pageCount'] query = db.session.query(Company).filter( Company.companyID.in_(foreignIDTuple) ) info['query'] = query query = query.offset(startIndex).limit(pageCount) allResult = query.all() companyList = [Company.generateBrief(result) for result in allResult] countQuery = db.session.query(func.count(Company.companyID)).filter( Company.companyID.in_(foreignIDTuple) ) count = countQuery.first() count = count[0] result = {} result['dataList'] = companyList result['count'] = count return (True, result)
def getCompanyList(self, jsonInfo): info = json.loads(jsonInfo) startIndex = info['startIndex'] pageCount = info['pageCount'] # 获取company列表 try: query = db.session.query(Company) allResult = query.offset(startIndex).limit(pageCount).all() companyList = [Company.generateBrief(result) for result in allResult] # count countQuery = db.session.query(func.count(Company.companyID)) count = countQuery.first() count = count[0] callBackInfo = {} callBackInfo['dataList'] = companyList callBackInfo['count'] = count return (True, callBackInfo) except Exception as e: print e errorInfo = ErrorInfo['TENDER_02'] errorInfo['detail'] = str(e) db.session.rollback() return (False, errorInfo)