コード例 #1
0
 def get_score_list(self, info):
     '''
     积分列表
     第一步: 验证用户身份
     第二步: 获取积分列表
     :param info: {'token_id': '', 'user_id': '', 'activity_id': ''}
     :return: {'data': '', 'status': 'SUCCESS'}
     '''
     user_id = info['user_id']
     start_index = info['start_index']
     page_count = info['page_count']
     query = db.session.query(UserInfo)
     all_result = query.order_by(desc(
         UserInfo.user_score)).offset(start_index).limit(page_count).all()
     callback_data = []
     imagemanager = ImageManager()
     img_request = {}
     for result in all_result:
         (status, user_info) = UserInfo.generate(result=result)
         count = db.session.query(func.count(UserInfo.user_id)).filter(
             UserInfo.user_score > user_info['user_score']).first()
         user_info['index_number'] = count[0] + 1
         img_request['foreign_id'] = result.user_id
         if result.open_id is None:
             (status, image_info) = imagemanager.get_image(info=img_request)
         else:
             imgpath = db.session.query(ImgPath).filter(
                 ImgPath.foreign_id == result.user_id).first()
             (status, image_info) = ImgPath.generate(result=imgpath)
         user_info.update(image_info)
         callback_data.append(user_info)
     return (True, callback_data)
コード例 #2
0
 def get_score_list(self, info):
     '''
     积分列表
     第一步: 验证用户身份
     第二步: 获取积分列表
     :param info: {'token_id': '', 'user_id': '', 'activity_id': ''}
     :return: {'data': '', 'status': 'SUCCESS'}
     '''
     user_id = info['user_id']
     start_index = info['start_index']
     page_count = info['page_count']
     query = db.session.query(UserInfo)
     all_result = query.order_by(desc(UserInfo.user_score)).offset(start_index).limit(page_count).all()
     callback_data = []
     imagemanager = ImageManager()
     img_request = {}
     for result in all_result:
         (status, user_info) = UserInfo.generate(result=result)
         count = db.session.query(
             func.count(UserInfo.user_id)
         ).filter(
             UserInfo.user_score > user_info['user_score']
         ).first()
         user_info['index_number'] = count[0] + 1
         img_request['foreign_id'] = result.user_id
         if result.open_id is None:
             (status, image_info) = imagemanager.get_image(info=img_request)
         else:
             imgpath = db.session.query(ImgPath).filter(ImgPath.foreign_id == result.user_id).first()
             (status, image_info) = ImgPath.generate(result=imgpath)
         user_info.update(image_info)
         callback_data.append(user_info)
     return (True, callback_data)
コード例 #3
0
 def get_score_info(self, info):
     '''
     获取活动成绩
     :param info: {'token_id': '', 'user_id': '', 'activity_id': ''}
     :return: {'data': '', 'status': 'SUCCESS'}
     '''
     activity_id = info['activity_id']
     part_query = db.session.query(Participate, UserInfo).outerjoin(
         UserInfo, Participate.user_id == UserInfo.user_id
     ).filter(and_(Participate.activity_id == activity_id, Participate.score != SCORE_EMPTY))
     all_result = part_query.order_by(desc(Participate.score)).all()
     callback_data = []
     img_request = {}
     imagemanager = ImageManager()
     for score_result in all_result:
         user = score_result.UserInfo
         participate = score_result.Participate
         img_request['foreign_id'] = participate.user_id
         if user.open_id is None:
             (status, image_info) = imagemanager.get_image(info=img_request)
         else:
             imgpath = db.session.query(ImgPath).filter(ImgPath.foreign_id == user.user_id).first()
             (status, image_info) = ImgPath.generate(result=imgpath)
         (status, part_info) = Participate.generate(result=participate)
         (status, user_info) = UserInfo.generate(result=user)
         part_info.update(user_info)
         part_info.update(image_info)
         callback_data.append(part_info)
     return (True, callback_data)
コード例 #4
0
 def get_club_score_list(self, info):
     '''
     俱乐部积分列表
     第一步: 验证用户身份
     第二步: 获取积分最多的俱乐部积分列表
     :param info: {'token_id': '', 'user_id': '', 'activity_id': ''}
     :return: {'data': '', 'status': 'SUCCESS'}
     '''
     user_id = info['user_id']
     start_index = info['start_index']
     page_count = info['page_count']
     if info['club_id'] == '-1':
         club_query = db.session.query(ClubScore).filter(
             ClubScore.user_id == user_id)
         club_result = club_query.order_by(desc(
             ClubScore.club_number)).first()
     else:
         club_result = db.session.query(ClubScore).filter(
             ClubScore.club_id == info['club_id']).first()
         print(club_result)
     if club_result:
         club_id = club_result.club_id
         query = db.session.query(UserInfo, ClubScore).outerjoin(
             ClubScore, UserInfo.user_id == ClubScore.user_id).filter(
                 ClubScore.club_id == club_id)
         all_result = query.order_by(desc(ClubScore.club_number)).offset(
             start_index).limit(page_count).all()
         callback_data = []
         imagemanager = ImageManager()
         img_request = {}
         for result in all_result:
             user = result.UserInfo
             clubscore = result.ClubScore
             (status, _club) = ClubScore.generate(result=clubscore)
             (status, _user_info) = UserInfo.generate(result=user)
             count = db.session.query(func.count(
                 ClubScore.score_id)).filter(
                     and_(ClubScore.club_id == club_id,
                          ClubScore.club_number >
                          _club['club_number'])).first()
             _club['index_number'] = count[0] + 1
             img_request['foreign_id'] = user.user_id
             if user.open_id is None:
                 (status,
                  image_info) = imagemanager.get_image(info=img_request)
             else:
                 imgpath = db.session.query(ImgPath).filter(
                     ImgPath.foreign_id == user.user_id).first()
                 (status, image_info) = ImgPath.generate(result=imgpath)
             _club.update(image_info)
             _club.update(_user_info)
             callback_data.append(_club)
         return (True, callback_data)
     else:
         return (False, None)
コード例 #5
0
 def get_club_score_list(self, info):
     '''
     俱乐部积分列表
     第一步: 验证用户身份
     第二步: 获取积分最多的俱乐部积分列表
     :param info: {'token_id': '', 'user_id': '', 'activity_id': ''}
     :return: {'data': '', 'status': 'SUCCESS'}
     '''
     user_id = info['user_id']
     start_index = info['start_index']
     page_count = info['page_count']
     if info['club_id'] == '-1':
         club_query = db.session.query(ClubScore).filter(ClubScore.user_id == user_id)
         club_result = club_query.order_by(desc(ClubScore.club_number)).first()
     else:
         club_result = db.session.query(ClubScore).filter(ClubScore.club_id == info['club_id']).first()
         print(club_result)
     if club_result:
         club_id = club_result.club_id
         query = db.session.query(UserInfo, ClubScore).outerjoin(
             ClubScore, UserInfo.user_id == ClubScore.user_id
         ).filter(ClubScore.club_id == club_id)
         all_result = query.order_by(desc(ClubScore.club_number)).offset(start_index).limit(page_count).all()
         callback_data = []
         imagemanager = ImageManager()
         img_request = {}
         for result in all_result:
             user = result.UserInfo
             clubscore = result.ClubScore
             (status, _club) = ClubScore.generate(result=clubscore)
             (status, _user_info) = UserInfo.generate(result=user)
             count = db.session.query(
                 func.count(ClubScore.score_id)
             ).filter(
                 and_(
                     ClubScore.club_id == club_id,
                     ClubScore.club_number > _club['club_number']
                 )
             ).first()
             _club['index_number'] = count[0] + 1
             img_request['foreign_id'] = user.user_id
             if user.open_id is None:
                 (status, image_info) = imagemanager.get_image(info=img_request)
             else:
                 imgpath = db.session.query(ImgPath).filter(ImgPath.foreign_id == user.user_id).first()
                 (status, image_info) = ImgPath.generate(result=imgpath)
             _club.update(image_info)
             _club.update(_user_info)
             callback_data.append(_club)
         return (True, callback_data)
     else:
         return (False, None)
コード例 #6
0
 def get_room_detail(self, info):
     '''
     活动详情
     第一步: 验证用户身份
     第二步: 判断活动是否存在,是否已经加入,是否已经满员
     第三步: 自动分配活动位置, 创建参加记录
     :param info: {'token_id': '', 'user_id': '', 'activity_id': ''}
     :return: {'data': '', 'status': 'SUCCESS'}
     '''
     activity_id = info['activity_id']
     user_id = info['user_id']
     (status, activity_detail) = self._get_activity_detail(info)
     (status, judge_info) = self._get_activity_judge(info)
     part_query = db.session.query(Participate, UserInfo).outerjoin(
         UserInfo, Participate.user_id == UserInfo.user_id).filter(
             Participate.activity_id == activity_id)
     all_result = part_query.order_by(Participate.location).all()
     role_list = []
     callback_data = {}
     my_info = {}
     img_request = {}
     imagemanager = ImageManager()
     for result in all_result:
         participate = result.Participate
         user = result.UserInfo
         img_request['foreign_id'] = participate.user_id
         (status, part_info) = Participate.generate(result=participate)
         if user.open_id is None:
             (status, image_info) = imagemanager.get_image(info=img_request)
         else:
             imgpath = db.session.query(ImgPath).filter(
                 ImgPath.foreign_id == user.user_id).first()
             (status, image_info) = ImgPath.generate(result=imgpath)
         (status, user_info) = UserInfo.generate(result=user)
         part_info.update(image_info)
         part_info.update(user_info)
         if part_info['user_id'] == user_id:
             my_info.update(part_info)
         role_list.append(part_info)
     callback_data['role_list'] = role_list
     callback_data['activity_detail'] = activity_detail
     callback_data['judge_info'] = judge_info
     callback_data['my_info'] = my_info
     return (True, callback_data)
コード例 #7
0
 def get_room_detail(self, info):
     '''
     活动详情
     第一步: 验证用户身份
     第二步: 判断活动是否存在,是否已经加入,是否已经满员
     第三步: 自动分配活动位置, 创建参加记录
     :param info: {'token_id': '', 'user_id': '', 'activity_id': ''}
     :return: {'data': '', 'status': 'SUCCESS'}
     '''
     activity_id = info['activity_id']
     user_id = info['user_id']
     (status, activity_detail) = self._get_activity_detail(info)
     (status, judge_info) = self._get_activity_judge(info)
     part_query = db.session.query(Participate, UserInfo).outerjoin(
         UserInfo, Participate.user_id == UserInfo.user_id
     ).filter(Participate.activity_id == activity_id)
     all_result = part_query.order_by(Participate.location).all()
     role_list = []
     callback_data = {}
     my_info = {}
     img_request = {}
     imagemanager = ImageManager()
     for result in all_result:
         participate = result.Participate
         user = result.UserInfo
         img_request['foreign_id'] = participate.user_id
         (status, part_info) = Participate.generate(result=participate)
         if user.open_id is None:
             (status, image_info) = imagemanager.get_image(info=img_request)
         else:
             imgpath = db.session.query(ImgPath).filter(ImgPath.foreign_id == user.user_id).first()
             (status, image_info) = ImgPath.generate(result=imgpath)
         (status, user_info) = UserInfo.generate(result=user)
         part_info.update(image_info)
         part_info.update(user_info)
         if part_info['user_id'] == user_id:
             my_info.update(part_info)
         role_list.append(part_info)
     callback_data['role_list'] = role_list
     callback_data['activity_detail'] = activity_detail
     callback_data['judge_info'] = judge_info
     callback_data['my_info'] = my_info
     return (True, callback_data)