Ejemplo n.º 1
0
    async def put(self):
        user_info = await self.user_info
        user_id = str(user_info['_id'])
        jsonObj = self.json_body
        #可更新内容列表
        Update_module = {
            #'phoneNumber':'',
            #'password':'',
            #'weixinopenid':'',
            'realName': '',
            'avatar': '',
            'gender': '',
            'university': '',
            'campus': '',
            'realIdentity': '',
            'certificationInfo': '',
            'identity': '',
            'campus': '',
            'location': '',
            'coverPhoto': '',
            #'masterId':'',
            #'userOrders':[],
            #'userBalance':[],
            #'userNotification':[]
            'isNew': 'NO',
            'labelList': [],
        }

        user_default = self.db.base.dict_match(user_info, Update_module)
        user_info = self.db.base.dict_match(jsonObj['user'], user_default)
        if 'realName' in jsonObj['user'].keys(
        ) and 'avatar' in jsonObj['user'].keys() and len(
                jsonObj['user'].keys()) == 2:
            pass
        else:
            user_info['isNew'] = 'NO'
        await self.db.user.update(user_id, user_info)
        user = await self.db.user.get_by_id(user_id)
        await self.db.user.update(user_id, user_info)

        if 'labelList' in jsonObj['user'].keys(
        ) and jsonObj['user']['labelList'] != []:

            condition = {'$or': []}
            for _id in jsonObj['user']['labelList']:
                condition['$or'].append({'_id': ObjectId(_id)})
            await self.db.label.updateS(
                condition, {'$addToSet': {
                    'userList': str(user_id)
                }})
        if self.is_master(user['masterId']) == True:
            await self.db.master.update(
                user['masterId'], {
                    'realName': user['realName'],
                    'avatar': user['avatar'],
                    'certificationInfo': user['certificationInfo'],
                    'coverPhoto': user['coverPhoto'],
                })
        self.finish_success(result="OK")
Ejemplo n.º 2
0
    async def get(self):
        days = 0
        user_info = await self.user_info
        user_id = user_info['_id']
        time_stamp_list = await self.db.user.get_signup_days(ObjectId(user_id))
        days = len(time_stamp_list)
        isTodaySignUp = ''
        if days == 0:
            user_info['isAward'] = 'No'
            await self.db.user.reset_award(user_info['_id'])
            isTodaySignUp = 'No'
        elif (days < 7 and days > 0):
            user_info['isAward'] = 'No'
            await self.db.user.reset_award(user_info['_id'])
            present_time = time.time()
            last_time = max(time_stamp_list)
            if (isOneDay(last_time, present_time)):
                isTodaySignUp = 'Yes'
            elif (isNextDay(last_time, present_time)):
                isTodaySignUp = 'No'
            #存在一天没签到
            else:
                await self.db.user.delete_signup(user_id)
                isTodaySignUp = 'No'
                days = 0
        elif days == 7:
            present_time = time.time()
            last_time = max(time_stamp_list)
            if (isOneDay(last_time, present_time)):
                isTodaySignUp = 'Yes'
            elif (isNextDay(last_time, present_time)):
                user_info['isAward'] = 'No'
                await self.db.user.reset_award(user_info['_id'])
                await self.db.user.delete_signup(user_id)
                isTodaySignUp = 'No'
                days = 0
            else:
                user_info['isAward'] = 'No'
                await self.db.user.reset_award(user_info['_id'])
                await self.db.user.delete_signup(user_id)
                isTodaySignUp = 'No'
                days = 0
        else:
            user_info['isAward'] = 'No'
            await self.db.user.reset_award(user_info['_id'])
            await self.db.user.delete_signup(user_id)
            isTodaySignUp = 'No'
            days = 0

        signUpObj = {
            'isTodaySignUp': isTodaySignUp,
            'days': days,
            'isAward': user_info['isAward'],
        }
        self.finish_success(result=signUpObj)
Ejemplo n.º 3
0
 async def get(self):
     user_info=await self.user_info
     userTeam={}
     uTeam=[]
     if 'userTeam' not in user_info.keys() or user_info['userTeam'] == '':
         isleader='null'
         token = await self.db.token.get_by_user(user_info['_id'])
         noticeholder=await self.db.noticeholder.get_by_user(user_info['_id'])
         uTeam.append(
             {
                 'accessToken':token['accessToken'],
                 'userId':user_info['_id'],
                 'realName':user_info['realName'],
                 'avatar':user_info['avatar'],
                 'isleader':'null',
                 'noticeNum':len(noticeholder['unhandle']),
                 'issupervise':await self.is_supervise(user_info['_id'])
             }
         )
     else:
         userTeam=await self.db.userteam.get_by_id(user_info['userTeam'])
         if str(user_info['_id'])== userTeam['teamLeader']    :
             isleader='yes'
         else:
             isleader='no'
         teamLeader_token = await self.db.token.get_by_user(ObjectId(userTeam['teamLeader']))
         teamLeader_info = await self.db.user.get_by_id(userTeam['teamLeader'])
         noticeholder=await self.db.noticeholder.get_by_user(userTeam['teamLeader'])
         userTeam['teamLeader']={
             'accessToken':teamLeader_token['accessToken'],
             'userId':userTeam['teamLeader'],
             'realName':teamLeader_info['realName'],
             'avatar':teamLeader_info['avatar'],
             'isleader':'yes',
             'noticeNum':len(noticeholder['unhandle']),
             'issupervise':await self.is_supervise(userTeam['teamLeader'])
         }
         
         uTeam.append(userTeam['teamLeader'])
         for i in range(0,len(userTeam['teamMember'])):
             member_id=userTeam['teamMember'][i]
             member_token =await self.produce_accessToken(member_id)
             member_info = await self.db.master.get_by_user(member_id)
             noticeholder=await self.db.noticeholder.get_by_user(member_id)
             member={
                 'accessToken':member_token['accessToken'],
                 'userId':member_id,
                 'realName':member_info['realName'],
                 'avatar':member_info['avatar'],
                 'isleader':'no',
                 'noticeNum':len(noticeholder['unhandle']),
                 'issupervise':await self.is_supervise(member_id)
             }
             uTeam.append(member)
     self.finish_success(result={'isleader':isleader,'uTeam':uTeam})
Ejemplo n.º 4
0
 async def produce_accessToken(self, user_id):
     utoken = await self.db.token.get_by_user(user_id)
     if utoken is None:
         utoken = self.db.base.dict_match(
             {
                 'userId': ObjectId(user_id),
                 'accessToken': self.db.token.produce_token(),
                 'accessTime': self.get_timestamp()
             }, self.db.base.get_token_default())
         token_id = await self.db.token.insert(utoken)
         utoken = await self.db.token.get_by_user(user_id)
         return utoken
     else:
         return utoken
Ejemplo n.º 5
0
    async def put(self):
        user_info = await self.user_info
        user_id = str(user_info['_id'])
        jsonObj = self.json_body
        #可更新内容列表
        Update_module = {
            'labelList': [],
        }

        user_default = self.db.base.dict_match(user_info, Update_module)
        user_info = self.db.base.dict_match(jsonObj['user'], user_default)
        await self.db.user.update(user_id, user_info)
        condition = {'$or': []}
        for _id in jsonObj['user']['labelList']:
            condition['$or'].append({'_id': ObjectId(_id)})
        await self.db.label.updateS(
            condition, {'$addtoSet': {
                'userList': str(user_info['_id'])
            }})
        self.finish_success(result="OK")
Ejemplo n.º 6
0
 async def post(self):
     user_info = await self.user_info
     vcoin_number = self.json_body['vcoin_number']
     time_stamp_list = await self.db.user.get_signup_days(
         ObjectId(user_info['_id']))
     days = len(time_stamp_list)
     print(days)
     present_time = time.time()
     if days == 0:
         await self.db.user.record_signup(user_info['_id'], present_time)
         await self.db.user.add_vcoin_number(user_info['_id'],
                                             int(vcoin_number))
         self.finish_success(result='OK')
     elif (days < 7 and days > 0):
         last_time = max(time_stamp_list)
         if (isOneDay(last_time, present_time)):
             self.finish_err(result='今日已签到')
         elif (isNextDay(last_time, present_time)):
             await self.db.user.record_signup(user_info['_id'],
                                              present_time)
             await self.db.user.add_vcoin_number(user_info['_id'],
                                                 int(vcoin_number))
             self.finish_success(result='OK')
         else:
             await self.db.user.delete_signup(user_info['_id'])
             await self.db.user.record_signup(user_info['_id'],
                                              present_time)
             await self.db.user.add_vcoin_number(user_info['_id'],
                                                 int(vcoin_number))
             self.finish_success(result='OK')
     elif days == 7:
         last_time = max(time_stamp_list)
         if (isOneDay(last_time, present_time)):
             self.finish_err(result='今日已签到')
         else:
             await self.db.user.delete_signup(user_info['_id'])
             self.finish_err(result='其他')
     else:
         await self.db.user.delete_signup(user_info['_id'])
         self.finish_err(result='其他')
Ejemplo n.º 7
0
 async def get_by_user(self, id):
     condition = {'userId': ObjectId(id)}
     utoken = await self.db.get_document_one(condition, self.colName)
     return utoken