def add_profile(self, user_uuid): # TODO: 需要与 add_user 写到同一个事务中 profile_uuid = helper.generate_uuid() create_time = helper.get_time() # TODO: 处理异常 self.insert('user_work_info', (profile_uuid, create_time, user_uuid), '(uuid,create_time,user_uuid)')
def add_skill(self, user_uuid): # TODO: 需要与 add_user 写到同一个事务中 skill_uuid = helper.generate_uuid() create_time = helper.get_time() # TODO: 处理异常 self.insert('user_skill', (skill_uuid, create_time, user_uuid), '(uuid,create_time,user_uuid)')
def save_chat_message(src_user, dest_user, content, recv_time): # uuid: 消息ID # src_user: 发信人 # dest_user: 收信人 # content: 消息内容 # recv_time: 服务器接收到消息的时间(也可以理解为客户端发送消息的时间) # has_send: 是否已转发给目标用户(默认0,未转发) UUID = helper.generate_uuid() DB.add_chat_message(UUID, src_user, dest_user, content, recv_time) return UUID
def generate_token(self, expire=60): # 生成随机 token token = helper.generate_uuid() # 计算过期时间 now_sec = helper.get_time_sec() expire_time_sec = now_sec + expire * 60 expire_time = helper.get_time(expire_time_sec) # 将 token 存储到数据库 DB.add_token(self.uuid, token, expire_time) if check_token(token): return token