def AddActivity(ID, Information): ''' 描述:添加一个活动到数据库 参数:创建者ID,数据信息 返回:{result:success,activityId:xxx}/失败{result:fail,reason:xxx, code:xxx} ''' Return = {} Success = True Code = Constants.UNDEFINED_NUMBER Reason = "" CurTime = 0 StartTime = 0 EndTime = 0 StartSignTime = 0 StopSignTime = 0 TheMinUser = 0 TheMaxUser = 0 TheStatus = 0 TheSearched = False TheGlobalRule = -1 TheAcceptRule = [] TheAuditRule = [] TheRejectRule = [] TheType = "" #把时间转化为时间戳,并且判断时间和人数是否合法 if Success: try: CurTime = GlobalFunctions.GetCurrentTime() StartTime = GlobalFunctions.TimeStringToTimeStamp( Information["start"]) EndTime = GlobalFunctions.TimeStringToTimeStamp(Information["end"]) if 'signupBeginAt' in Information: StartSignTime = GlobalFunctions.TimeStringToTimeStamp( Information["signupBeginAt"]) else: StartSignTime = CurTime if 'signupStopAt' in Information: StopSignTime = GlobalFunctions.TimeStringToTimeStamp( Information["signupStopAt"]) else: StopSignTime = StartTime if 'minUser' in Information: TheMinUser = int(Information["minUser"]) else: TheMinUser = 0 if 'maxUser' in Information: TheMaxUser = int(Information["maxUser"]) else: TheMaxUser = Constants.UNDEFINED_NUMBER JudgeResult = JudgeValid.JudgeParameterValid( CurTime, StartTime, EndTime, StartSignTime, StopSignTime, 1, TheMinUser, TheMaxUser) if "imageUrl" in Information: TheImageURL = Information["imageUrl"] else: TheImageURL = "UNDEFINED" if "position" in Information: ThePosition = Information["position"] else: ThePosition = "" if JudgeResult["result"] != "success": Success = False Reason = JudgeResult["reason"] Code = Constants.ERROR_CODE_INVALID_CHANGE except: Success = False Reason = "输入的开始/结束/开始报名/报名截止时间不合理!" Code = Constants.ERROR_CODE_INVALID_PARAMETER #判断活动状态,类型等是否合法 if Success: try: TheType = Information["type"] TheSearched = bool(Information["canBeSearched"]) if JudgeValid.JudgeActivityTypeValid(TheType) == False: Success = False Reason = "活动类型不合法,添加活动失败!" Code = Constants.ERROR_CODE_INVALID_PARAMETER TheStatusGlobal = GlobalFunctions.GetStartActivityGlobalStatus( TheType) TheStatusJoin = GlobalFunctions.GetStartActivityJoinStatus( StartSignTime, StopSignTime) TheStatusCheck = GlobalFunctions.GetStartActivityCheckStatus( StartTime, EndTime) except: Success = False Reason = "参数不合法,添加活动失败!" Code = Constants.ERROR_CODE_INVALID_PARAMETER #获得标签,正文,头像 if Success: try: TheTagsList = Information["tags"] TheDescription = Information["description"] if JudgeValid.JudgeTagListValid(TheTagsList) != True: Success = False Reason = "参数不合法,标签不能带有英文逗号!" Code = Constants.ERROR_CODE_INVALID_PARAMETER TheTags = GlobalFunctions.MergeTags(TheTagsList) except: Success = False Reason = "参数不合法,添加活动失败!" Code = Constants.ERROR_CODE_INVALID_PARAMETER #获得高级报名信息 if Success: try: #判断是否合法 TheGlobalRule = Information["rules"]["ruleType"] if JudgeValid.JudgeRuleTypeValid(TheGlobalRule) != True: Success = False Reason = "参数不合法,规则类型不合法!" Code = Constants.ERROR_CODE_INVALID_PARAMETER TheJudgeAdvanceRuleResult = JudgeValid.JudgeAdvancedRuleValid( Information["rules"]) #print(TheJudgeAdvanceRuleResult) if TheJudgeAdvanceRuleResult["result"] != "success": Success = False Reason = TheJudgeAdvanceRuleResult["reason"] Code = TheJudgeAdvanceRuleResult["code"] try: TheAcceptRule = Information["rules"]["accept"] except: TheAcceptRule = [] try: TheAuditRule = Information["rules"]["needAudit"] except: TheAuditRule = [] try: TheRejectRule = Information["rules"]["reject"] except: TheRejectRule = [] except: Success = False Reason = "参数不合法,添加活动失败!" Code = Constants.ERROR_CODE_INVALID_PARAMETER #print(CurTime, StartTime, EndTime, StartSignTime, StopSignTime) #print(Success) #插入数据库 if Success: try: TheName = Information["name"] ThePlace = Information["place"] #TheCreator = User.objects.get(OpenID = ID) #print(TheCreator.ID) TheCreateTime = GlobalFunctions.GetCurrentTime() NewActivity = Activity.objects.create(Name = TheName, Place = ThePlace, CreateTime = TheCreateTime, StartTime = StartTime, EndTime = EndTime, SignUpStartTime = StartSignTime,\ SignUpEndTime = StopSignTime, MinUser = TheMinUser, MaxUser = TheMaxUser, CurrentUser = 0, Type = TheType, \ StatusGlobal = TheStatusGlobal, StatusJoin = TheStatusJoin, StatusCheck = TheStatusCheck, CanBeSearched = TheSearched, \ GlobalRule = TheGlobalRule, Tags = TheTags, Description = TheDescription, ImageURL = TheImageURL, GPSPlace = ThePosition) NewActivity.save() ActivityID = NewActivity.ID TheSearcher = SearchAndRecommend.WhooshSearcher.Create() TheSearcher.AddOneInfo(ActivityID, TheName + ',' + TheTags) except: Success = False Reason = "参数不合法,添加活动失败!" Code = Constants.ERROR_CODE_INVALID_PARAMETER if Success: if "rules" in Information: try: #添加rules for item in TheAcceptRule: AddAdvancedRules(ActivityID, item, Constants.ADVANCED_RULE_ACCEPT) for item in TheAuditRule: AddAdvancedRules(ActivityID, item, Constants.ADVANCED_RULE_AUDIT) for item in TheRejectRule: AddAdvancedRules(ActivityID, item, Constants.ADVANCED_RULE_REJECT) except: Success = False Reason = "参数不合法,添加活动失败!" Code = Constants.ERROR_CODE_INVALID_PARAMETER #print(Success) #让creator加入活动 if Success: try: #print(int(Return["id"])) JoinActivityResult = AddCreatorIntoActivity(ID, ActivityID) if JoinActivityResult["result"] != "success": Success = False Reason = JoinActivityResult["reason"] Code = JoinActivityResult["code"] else: Return["activityId"] = ActivityID except: Success = False Reason = "添加活动失败" Code = Constants.ERROR_CODE_UNKNOWN if Success: if TheStatusGlobal == Constants.ACTIVITY_STATUS_GLOBAL_NORMAL: Return["result"] = "success" else: Return["result"] = "needAudit" else: Return["result"] = "fail" Return["reason"] = Reason Return["code"] = Code return Return
def ChangeActivity(TheUserID, Information): ''' 描述:修改活动信息 参数:用户openid,待修改信息 返回:{result:success}/{result:fail,reason:xxx, code:xxx} ''' Success = True Return = {} Reason = "" Code = Constants.UNDEFINED_NUMBER ChangeDictionary = {} #判断是否能找到这个活动 if Success: try: TheUser = User.objects.get(OpenID=TheUserID) TheActivity = Activity.objects.get(ID=Information["id"]) if JudgeValid.JudgeWhetherManager(TheUserID, Information["id"]) != True: Success = False Reason = "没有修改权限,需要是管理员或者创建者!" Code = Constants.ERROR_CODE_LACK_ACCESS except: Success = False Reason = "没有修改权限" Code = Constants.ERROR_CODE_LACK_ACCESS if Success: if JudgeValid.JudgeActivityNormal(Information["id"]) != True: Success = False Reason = "活动状态为异常或结束,不能操作!" Code = Constants.ERROR_CODE_INVALID_CHANGE #读取修改数据 WhetherJudgeTime = False if Success: try: if "name" in Information: ChangeDictionary["name"] = Information["name"] else: ChangeDictionary["name"] = TheActivity.Name if "place" in Information: ChangeDictionary["place"] = Information["place"] else: ChangeDictionary["place"] = TheActivity.Place if "start" in Information: WhetherJudgeTime = True ChangeDictionary["start"] = int( GlobalFunctions.TimeStringToTimeStamp( Information["start"])) else: ChangeDictionary["start"] = TheActivity.StartTime if "end" in Information: WhetherJudgeTime = True ChangeDictionary["end"] = int( GlobalFunctions.TimeStringToTimeStamp(Information["end"])) else: ChangeDictionary["end"] = TheActivity.EndTime if "signupBeginAt" in Information: WhetherJudgeTime = True ChangeDictionary["signupBeginAt"] = int( GlobalFunctions.TimeStringToTimeStamp( Information["signupBeginAt"])) else: ChangeDictionary["signupBeginAt"] = TheActivity.SignUpStartTime if "signupStopAt" in Information: WhetherJudgeTime = True ChangeDictionary["signupStopAt"] = int( GlobalFunctions.TimeStringToTimeStamp( Information["signupStopAt"])) else: ChangeDictionary["signupStopAt"] = TheActivity.SignUpEndTime if "minUser" in Information: ChangeDictionary["minUser"] = int(Information["minUser"]) else: ChangeDictionary["minUser"] = TheActivity.MinUser if "maxUser" in Information: ChangeDictionary["maxUser"] = int(Information["maxUser"]) else: ChangeDictionary["maxUser"] = TheActivity.MaxUser if "type" in Information: ChangeDictionary["type"] = Information["type"] else: ChangeDictionary["type"] = TheActivity.Type if "statusGlobal" in Information: ChangeDictionary["statusGlobal"] = Information["statusGlobal"] else: ChangeDictionary["statusGlobal"] = TheActivity.StatusGlobal if "statusJoin" in Information: ChangeDictionary["statusJoin"] = Information["statusJoin"] else: ChangeDictionary["statusJoin"] = TheActivity.StatusJoin if "statusCheck" in Information: ChangeDictionary["statusCheck"] = Information["statusCheck"] else: ChangeDictionary["statusCheck"] = TheActivity.StatusCheck if "canBeSearched" in Information: ChangeDictionary["canBeSearched"] = bool( Information["canBeSearched"]) else: ChangeDictionary["canBeSearched"] = TheActivity.CanBeSearched if "imageUrl" in Information: ChangeDictionary["imageUrl"] = Information["imageUrl"] else: ChangeDictionary["imageUrl"] = TheActivity.ImageURL if "position" in Information: ChangeDictionary["position"] = Information["position"] else: ChangeDictionary["position"] = TheActivity.GPSPlace if "tags" in Information: if JudgeValid.JudgeTagListValid(Information["tags"]) != True: Success = False Reason = "参数不合法,标签不能带有英文逗号!" Code = Constants.ERROR_CODE_INVALID_PARAMETER ChangeDictionary["tags"] = GlobalFunctions.MergeTags( Information["tags"]) else: ChangeDictionary["tags"] = TheActivity.Tags #如果rules不存在就changedictionary为空,要判断 if "rules" in Information: if "ruleType" in Information["rules"]: ChangeDictionary["ruleType"] = Information["rules"][ "ruleType"] else: ChangeDictionary["ruleType"] = TheActivity.GlobalRule ChangeDictionary["rules"] = Information["rules"] else: ChangeDictionary["rules"] = [] ChangeDictionary["ruleType"] = TheActivity.GlobalRule ChangeDictionary["curTime"] = GlobalFunctions.GetCurrentTime() ChangeDictionary["curUser"] = TheActivity.CurrentUser except: Success = False Reason = "待修改数据格式不合法" Code = Constants.ERROR_CODE_INVALID_PARAMETER #print(Success) #判断活动type修改后是否有效 if Success: try: JudgeResult = JudgeValid.JudgeTypeChangeValid( TheActivity.Type, ChangeDictionary["type"], TheActivity.StatusGlobal) if JudgeResult["result"] != "success": Success = False Reason = JudgeResult["reason"] Code = JudgeResult["code"] except: Success = False Reason = "待修改数据格式不合法" Code = Constants.ERROR_CODE_INVALID_PARAMETER #判断时间,人数等修改后是否有效 if Success and WhetherJudgeTime: try: JudgeResult = JudgeValid.JudgeParameterValid(ChangeDictionary["curTime"], ChangeDictionary["start"], ChangeDictionary["end"], \ ChangeDictionary["signupBeginAt"], ChangeDictionary["signupStopAt"], ChangeDictionary["curUser"], ChangeDictionary["minUser"], \ ChangeDictionary["maxUser"]) if JudgeResult["result"] != "success": Success = False Reason = JudgeResult["reason"] Code = Constants.ERROR_CODE_INVALID_CHANGE except: Success = False Reason = "待修改数据格式不合法" Code = Constants.ERROR_CODE_INVALID_PARAMETER if Success and ChangeDictionary["maxUser"] != Constants.UNDEFINED_NUMBER: try: if ChangeDictionary["minUser"] > ChangeDictionary["maxUser"]: Success = False Reason = "最小人数不能大于最大人数!" Code = Constants.ERROR_CODE_INVALID_CHANGE if ChangeDictionary["curUser"] > ChangeDictionary["maxUser"]: Success = False Reason = "当前人数不能大于最大人数!" Code = Constants.ERROR_CODE_INVALID_CHANGE except: Success = False Reason = "待修改数据格式不合法" Code = Constants.ERROR_CODE_INVALID_PARAMETER #判断状态等改后是否有效 if Success: try: JudgeResult = JudgeValid.JudgeActivityStatusChangeValid( TheActivity.StatusGlobal, ChangeDictionary["statusGlobal"]) if JudgeResult["result"] != "success": Success = False Reason = JudgeResult["reason"] Code = Constants.ERROR_CODE_INVALID_CHANGE if JudgeValid.JudgeActivityStatusJoinValid( ChangeDictionary["statusJoin"]) != True: Success = False Reason = "待修改的活动加入状态不合法" Code = Constants.ERROR_CODE_INVALID_PARAMETER if JudgeValid.JudgeActivityStatusCheckValid( ChangeDictionary["statusCheck"]) != True: Success = False Reason = "待修改的活动签到状态不合法" Code = Constants.ERROR_CODE_INVALID_PARAMETER if JudgeValid.JudgeRuleTypeValid( ChangeDictionary["ruleType"]) != True: Success = False Reason = "待修改的活动规则类型不合法!" Code = Constants.ERROR_CODE_INVALID_PARAMETER except: Success = False Reason = "待修改数据格式不合法" Code = Constants.ERROR_CODE_INVALID_PARAMETER #判断高级规则等改后是否有效 if Success: try: if ChangeDictionary["rules"] != []: JudgeResult = JudgeValid.JudgeAdvancedRuleValid( ChangeDictionary["rules"]) if JudgeResult["result"] != "success": Success = False Reason = JudgeResult["reason"] Code = Constants.ERROR_CODE_INVALID_CHANGE except: Success = False Reason = "待修改数据格式不合法" Code = Constants.ERROR_CODE_INVALID_PARAMETER #修改 #print(Success) if Success: try: TheActivity.Name = ChangeDictionary["name"] TheActivity.Place = ChangeDictionary["place"] TheActivity.StartTime = ChangeDictionary["start"] TheActivity.EndTime = ChangeDictionary["end"] TheActivity.SignUpStartTime = ChangeDictionary["signupBeginAt"] TheActivity.SignUpEndTime = ChangeDictionary["signupStopAt"] TheActivity.MinUser = ChangeDictionary["minUser"] TheActivity.MaxUser = ChangeDictionary["maxUser"] TheActivity.Type = ChangeDictionary["type"] TheActivity.StatusGlobal = ChangeDictionary["statusGlobal"] TheActivity.StatusJoin = ChangeDictionary["statusJoin"] TheActivity.StatusCheck = ChangeDictionary["statusCheck"] TheActivity.CanBeSearched = ChangeDictionary["canBeSearched"] TheActivity.GlobalRule = ChangeDictionary["ruleType"] TheActivity.Tags = ChangeDictionary["tags"] TheActivity.ImageURL = ChangeDictionary["imageUrl"] TheActivity.GPSPlace = ChangeDictionary["position"] TheActivity.save() TheSearcher = SearchAndRecommend.WhooshSearcher.Create() TheSearcher.UpdateOneInfo( Information["id"], TheActivity.Name + ',' + TheActivity.Tags) except: Success = False Reason = "修改数据失败" Code = Constants.ERROR_CODE_UNKNOWN if Success: try: #print(ChangeDictionary["rules"], Information["id"]) if ChangeDictionary["rules"] != []: #修改高级报名规则 if ChangeAdvancedRules(Information["id"], ChangeDictionary["rules"]) != True: Success = False Reason = "修改数据失败" Code = Constants.ERROR_CODE_UNKNOWN except: Success = False Reason = "修改数据失败" Code = Constants.ERROR_CODE_UNKNOWN if Success == False: Return["result"] = "fail" Return["reason"] = Reason Return["code"] = Code else: Return["result"] = "success" return Return
def AdvancedSearch(TheUserID, Information, TheLastSeenID, TheMost): ''' 描述:高级检索 参数:用户openid,检索信息,上一个id,最多 返回:Result, errorinfo ''' Success = True Return = {} ErrorInfo = {} Reason = "" Code = Constants.UNDEFINED_NUMBER SearchDictionary = {} if Success: try: TheUser = User.objects.get(OpenID=TheUserID) except: Success = False Reason = "用户不存在!" Code = Constants.ERROR_CODE_INVALID_PARAMETER #读取修改数据 if Success: try: if "place" in Information: SearchDictionary["place"] = Information["place"] else: SearchDictionary["place"] = "" if "startMin" in Information: SearchDictionary["startMin"] = int( GlobalFunctions.TimeStringToTimeStamp( Information["startMin"])) else: SearchDictionary["startMin"] = 0 if "startMax" in Information: SearchDictionary["startMax"] = int( GlobalFunctions.TimeStringToTimeStamp( Information["startMax"])) else: SearchDictionary["startMax"] = Constants.MAX_NUMBER if "endMin" in Information: SearchDictionary["endMin"] = int( GlobalFunctions.TimeStringToTimeStamp( Information["endMin"])) else: SearchDictionary["endMin"] = 0 if "endMax" in Information: SearchDictionary["endMax"] = int( GlobalFunctions.TimeStringToTimeStamp( Information["endMax"])) else: SearchDictionary["endMax"] = Constants.MAX_NUMBER if "signupBeginAtMin" in Information: SearchDictionary["signupBeginAtMin"] = int( GlobalFunctions.TimeStringToTimeStamp( Information["signupBeginAtMin"])) else: SearchDictionary["signupBeginAtMin"] = 0 if "signupBeginAtMax" in Information: SearchDictionary["signupBeginAtMax"] = int( GlobalFunctions.TimeStringToTimeStamp( Information["signupBeginAtMax"])) else: SearchDictionary["signupBeginAtMax"] = Constants.MAX_NUMBER if "signupStopAtMin" in Information: SearchDictionary["signupStopAtMin"] = int( GlobalFunctions.TimeStringToTimeStamp( Information["signupStopAtMin"])) else: SearchDictionary["signupStopAtMin"] = 0 if "signupStopAtMax" in Information: SearchDictionary["signupStopAtMax"] = int( GlobalFunctions.TimeStringToTimeStamp( Information["signupStopAtMax"])) else: SearchDictionary["signupStopAtMax"] = Constants.MAX_NUMBER if "type" in Information: SearchDictionary["type"] = Information["type"] else: SearchDictionary["type"] = "" if "statusGlobal" in Information: SearchDictionary["statusGlobal"] = Information["statusGlobal"] else: SearchDictionary["statusGlobal"] = Constants.UNDEFINED_NUMBER if "statusJoin" in Information: SearchDictionary["statusJoin"] = Information["statusJoin"] else: SearchDictionary["statusJoin"] = Constants.UNDEFINED_NUMBER if "statusCheck" in Information: SearchDictionary["statusCheck"] = Information["statusCheck"] else: SearchDictionary["statusCheck"] = Constants.UNDEFINED_NUMBER if "selfStatus" in Information: SearchDictionary["selfStatus"] = Information["selfStatus"] else: SearchDictionary["selfStatus"] = Constants.UNDEFINED_NUMBER - 1 if "ruleForMe" in Information: SearchDictionary["ruleForMe"] = Information["ruleForMe"] else: SearchDictionary["ruleForMe"] = Constants.UNDEFINED_NUMBER - 1 except: Success = False Reason = "高级检索格式不合法" Code = Constants.ERROR_CODE_INVALID_PARAMETER if Success: try: JudgeResult = {} JudgeResult = JudgeValid.JudgeSearchStatusValid(SearchDictionary["statusGlobal"], SearchDictionary["statusJoin"], \ SearchDictionary["statusCheck"], SearchDictionary["selfStatus"], SearchDictionary["ruleForMe"]) if JudgeResult["result"] != "success": Success = False Reason = JudgeResult["reason"] Code = JudgeResult["code"] JudgeResult = JudgeValid.JudgeSearchTimeValid( SearchDictionary["startMin"], SearchDictionary["startMax"]) if JudgeResult["result"] != "success": Success = False Reason = "最小开始时间必须小于等于最大开始时间!" Code = Constants.ERROR_CODE_INVALID_PARAMETER JudgeResult = JudgeValid.JudgeSearchTimeValid( SearchDictionary["endMin"], SearchDictionary["endMax"]) if JudgeResult["result"] != "success": Success = False Reason = "最小结束时间必须小于等于最大结束时间!" Code = Constants.ERROR_CODE_INVALID_PARAMETER JudgeResult = JudgeValid.JudgeSearchTimeValid( SearchDictionary["signupBeginAtMin"], SearchDictionary["signupBeginAtMax"]) if JudgeResult["result"] != "success": Success = False Reason = "最小开始报名时间必须小于等于最大开始报名时间!" Code = Constants.ERROR_CODE_INVALID_PARAMETER JudgeResult = JudgeValid.JudgeSearchTimeValid( SearchDictionary["signupStopAtMin"], SearchDictionary["signupStopAtMax"]) if JudgeResult["result"] != "success": Success = False Reason = "最小结束报名时间必须小于等于最大结束报名时间!" Code = Constants.ERROR_CODE_INVALID_PARAMETER except: Success = False Reason = "高级检索格式不合法" Code = Constants.ERROR_CODE_INVALID_PARAMETER SearchResult = [] #查询时间,地点,状态,直接数据库函数 if Success: try: QuerySet = Activity.objects.all() Conditions = {'StartTime__gte': SearchDictionary["startMin"], 'StartTime__lte': SearchDictionary["startMax"],\ 'EndTime__gte': SearchDictionary["endMin"], 'EndTime__lte': SearchDictionary["endMax"],\ 'SignUpStartTime__gte': SearchDictionary["signupBeginAtMin"], 'SignUpStartTime__lte': SearchDictionary["signupBeginAtMax"],\ 'SignUpEndTime__gte': SearchDictionary["signupStopAtMin"], 'SignUpEndTime__lte': SearchDictionary["signupStopAtMax"]} if SearchDictionary["statusGlobal"] != Constants.UNDEFINED_NUMBER: Conditions['StatusGlobal'] = SearchDictionary["statusGlobal"] if SearchDictionary["statusJoin"] != Constants.UNDEFINED_NUMBER: Conditions['StatusJoin'] = SearchDictionary["statusJoin"] if SearchDictionary["statusCheck"] != Constants.UNDEFINED_NUMBER: Conditions['StatusCheck'] = SearchDictionary["statusCheck"] if SearchDictionary["place"] != '': Conditions["Place__icontains"] = SearchDictionary["place"] SearchResult = QuerySet.filter(**Conditions) except: Success = False Reason = "高级检索失败" Code = Constants.ERROR_CODE_UNKNOWN #查询活动类型,加入后结果等 NewSearchResult = [] if Success: try: i = len(SearchResult) - 1 while i >= 0: item = SearchResult[i] WhetherMatch = True if SearchDictionary["type"] != "": if JudgeValid.JudgeActivityTypeMatch( SearchDictionary["type"], item.Type) != True: WhetherMatch = False if SearchDictionary[ "selfStatus"] != Constants.UNDEFINED_NUMBER - 1: TheStatus = JudgeValid.GetSelfStatus(TheUserID, item.ID) if TheStatus != SearchDictionary["selfStatus"]: WhetherMatch = False if SearchDictionary[ "ruleForMe"] != Constants.UNDEFINED_NUMBER - 1: TheRule = JudgeValid.GetSelfJoinStatus(TheUserID, item.ID) if TheRule != SearchDictionary["ruleForMe"]: WhetherMatch = False if JudgeValid.JudgeActivityCanBeSearched(item.ID) != True: WhetherMatch = False if WhetherMatch == True: print(item.ID) TheInfo = QueryActivity(item.ID) TheInfo["id"] = item.ID NewSearchResult.append(TheInfo) i -= 1 except: Success = False Reason = "高级检索失败" Code = Constants.ERROR_CODE_UNKNOWN ReturnList = [] #分页显示 if Success: CurrentNum = 0 WhetherFindStart = False if TheLastSeenID == Constants.UNDEFINED_NUMBER: WhetherFindStart = True for item in NewSearchResult: if WhetherFindStart == True: if TheMost != Constants.UNDEFINED_NUMBER and CurrentNum >= TheMost: break ReturnList.append(item) CurrentNum += 1 if TheLastSeenID != Constants.UNDEFINED_NUMBER and item[ "id"] == TheLastSeenID: WhetherFindStart = True #print(NewSearchResult) if Success == False: ErrorInfo["reason"] = Reason ErrorInfo["code"] = Code else: Return["activityList"] = ReturnList ErrorInfo = {} return Return, ErrorInfo