def to_json(self, type=0): # type 0默认 1简短 2... 3... if type == -1: #专家详情 json_user = { '_id': self.id, 'name': self.name.encode('utf-8'), 'sex': self.sex, 'job': self.job.encode('utf-8'), 'auth': {'vip': 1}, # self.auth.vip 'grade': common.getgrade(self.stats.comment_count, self.stats.comment_total), 'meet_c': self.stats.meet, 'follow':{'baidu':self.stats.baidu,'weixin':self.stats.weixin,'zhihu':self.stats.zhihu,'sina':self.stats.sina}, # [39.9442, 116.324] 'geo': [self.geo['coordinates'][1], self.geo['coordinates'][0]], 'intro': self.intro.encode('utf-8'), 'content': self.content.encode('utf-8'), 'bgurl': self.bgurl.encode('utf-8'), 'fileurl': self.fileurl.encode('utf-8'), 'avaurl': common.getavaurl(self.avaurl),#common.getavatar(userid=self.id) 'work': [item.to_json() for item in self.workexp], 'edu': [item.to_json() for item in self.edu], 'label':self.label, 'role_id':self.role_id, 'domainid':self.domainid, 'industryid':self.industryid } return json_user
def to_json(self, type=0): # 0默认 1发现首页专家团 2发现首页专家话题 json = { '_id': self.id, 'user_id': self.user_id, 'title': self.title.encode('utf-8'), 'intro': self.intro.encode('utf-8'), 'pay': self.pay.to_json(), # self.auth.vip 'grade': common.getgrade(self.stats.topic_count, self.stats.topic_total) #'config': self.config.to_json() } return json
def to_json(self, type=0): # type 0默认 1简短 2... 3... if type == -1: #专家详情 json_user = { '_id': self.id, 'name': self.name.encode('utf-8'), 'sex': self.sex, 'job': self.job.encode('utf-8'), 'auth': { 'expert': self.auth.expert, 'expertprocess': self.auth.expertprocess }, # self.auth.vip 'grade': common.getgrade(self.stats.comment_count, self.stats.comment_total), 'meet_c': self.stats.meet, 'follow': [item.to_json() for item in self.openplatform], #'follow':[{'baidu':self.stats.baidu,'baiduurl':self.stats.baiduurl},{'weixin':self.stats.weixin,'weixinurl':self.stats.weixinurl},{'zhihu':self.stats.zhihu,'zhihuurl':self.stats.zhihuurl},{'sina':self.stats.sina,'sinaurl':self.stats.sinaurl},{'twitter':self.stats.twitter,'twitterurl':self.stats.twitterurl},{'facebook':self.stats.facebook,'facebookurl':self.stats.facebookurl},{'github':self.stats.github,'githuburl':self.stats.githuburl}], # [39.9442, 116.324] 'geo': [self.geo['coordinates'][1], self.geo['coordinates'][0]], 'intro': self.intro.encode('utf-8'), 'content': self.content.encode('utf-8'), 'bgurl': self.bgurl.encode('utf-8'), 'fileurl': self.fileurl.encode('utf-8'), 'avaurl': common.getavaurl( self.avaurl), #common.getavatar(userid=self.id) 'work': [item.to_json() for item in self.workexp], 'edu': [item.to_json() for item in self.edu], 'label': self.label, 'role_id': self.role_id, 'domainid': self.domainid, 'industryid': self.industryid, 'phone': self.username } elif type == 0: #普通用户 json_user = { '_id': self.id, 'name': self.name.encode('utf-8'), 'sex': self.sex, 'job': self.job.encode('utf-8'), 'auth': { 'becomeexpert': self.auth.becomeexpert, 'expertprocess': self.auth.expertprocess }, # self.auth.vip 'grade': common.getgrade(self.stats.comment_count, self.stats.comment_total), 'meet_c': self.stats.meet, # [39.9442, 116.324] 'geo': [self.geo['coordinates'][1], self.geo['coordinates'][0]], 'intro': self.intro.encode('utf-8'), 'fileurl': self.fileurl.encode('utf-8'), 'avaurl': common.getavaurl( self.avaurl), #common.getavatar(userid=self.id) 'work': [item.to_json() for item in self.workexp], 'edu': [item.to_json() for item in self.edu], 'label': self.label, 'role_id': self.role_id, 'domainid': self.domainid, 'industryid': self.industryid, 'money': self.money, 'apptime': self.apptime, 'calltime': self.calltime, 'wish': self.wish, 'calltype': (self.apptype & 0x01) == 0x01 and 1 or 0, #通话模式开启 'meettype': (self.apptype & 0x02) == 0x02 and 1 or 0, #见面模式开启 'phone': self.username, 'weixin': self.weixin, 'qq': self.qq, 'email': self.email, 'rong_token': self.rong_token } elif type == 1: json_user = { '_id': self.id, 'name': self.name.encode('utf-8'), 'avaurl': common.getavaurl(self.avaurl) } elif type == 2: json_user = { '_id': self.id, 'name': self.name.encode('utf-8'), 'intro': self.intro.encode('utf-8'), 'job': self.job.encode('utf-8'), 'avaurl': common.getavaurl(self.avaurl) } elif type == 3: json_user = { '_id': self.id, 'name': self.name.encode('utf-8'), 'job': self.job.encode('utf-8'), 'avaurl': common.getavaurl(self.avaurl) } elif type == 4: json_user = { '_id': self.id, 'name': self.name.encode('utf-8'), 'job': self.job.encode('utf-8'), 'avaurl': common.getavaurl(self.avaurl), 'grade': common.getgrade(self.stats.comment_count, self.stats.comment_total), 'auth': { 'vip': 1 }, 'stats': self.stats.to_json(), 'sex': self.sex } elif type == 5: json_user = { '_id': self.id, 'name': self.name.encode('utf-8'), 'job': self.job.encode('utf-8'), 'avaurl': common.getavaurl(self.avaurl), 'grade': common.getgrade(self.stats.comment_count, self.stats.comment_total), 'auth': { 'vip': 1 } } elif type == 6: #地图专家列表 json_user = { '_id': self.id, 'name': self.name.encode('utf-8'), 'job': self.job.encode('utf-8'), 'geo': [self.geo['coordinates'][1], self.geo['coordinates'][0]], 'avaurl': common.getavaurl(self.avaurl), 'grade': common.getgrade(self.stats.comment_count, self.stats.comment_total), 'auth': { 'vip': 1 } } return json_user
def to_json(self, type=0): # type 0默认 1简短 2... 3... if type == -1: #专家详情 json_user = { '_id': self.id, 'name': self.name.encode('utf-8'), 'sex': self.sex, 'job': self.job.encode('utf-8'), 'auth': {'expert': self.auth.expert,'expertprocess': self.auth.expertprocess}, # self.auth.vip 'grade': common.getgrade(self.stats.comment_count, self.stats.comment_total), 'meet_c': self.stats.meet, 'follow':[item.to_json() for item in self.openplatform], #'follow':[{'baidu':self.stats.baidu,'baiduurl':self.stats.baiduurl},{'weixin':self.stats.weixin,'weixinurl':self.stats.weixinurl},{'zhihu':self.stats.zhihu,'zhihuurl':self.stats.zhihuurl},{'sina':self.stats.sina,'sinaurl':self.stats.sinaurl},{'twitter':self.stats.twitter,'twitterurl':self.stats.twitterurl},{'facebook':self.stats.facebook,'facebookurl':self.stats.facebookurl},{'github':self.stats.github,'githuburl':self.stats.githuburl}], # [39.9442, 116.324] 'geo': [self.geo['coordinates'][1], self.geo['coordinates'][0]], 'intro': self.intro.encode('utf-8'), 'content': self.content.encode('utf-8'), 'bgurl': self.bgurl.encode('utf-8'), 'fileurl': self.fileurl.encode('utf-8'), 'avaurl': common.getavaurl(self.avaurl),#common.getavatar(userid=self.id) 'work': [item.to_json() for item in self.workexp], 'edu': [item.to_json() for item in self.edu], 'label':self.label, 'role_id':self.role_id, 'domainid':self.domainid, 'industryid':self.industryid, 'phone':self.username } elif type == 0: #普通用户 json_user = { '_id': self.id, 'name': self.name.encode('utf-8'), 'sex': self.sex, 'job': self.job.encode('utf-8'), 'auth': {'becomeexpert': self.auth.becomeexpert,'expertprocess': self.auth.expertprocess}, # self.auth.vip 'grade': common.getgrade(self.stats.comment_count, self.stats.comment_total), 'meet_c': self.stats.meet, # [39.9442, 116.324] 'geo': [self.geo['coordinates'][1], self.geo['coordinates'][0]], 'intro': self.intro.encode('utf-8'), 'fileurl': self.fileurl.encode('utf-8'), 'avaurl': common.getavaurl(self.avaurl),#common.getavatar(userid=self.id) 'work': [item.to_json() for item in self.workexp], 'edu': [item.to_json() for item in self.edu], 'label':self.label, 'role_id':self.role_id, 'domainid':self.domainid, 'industryid':self.industryid, 'money':self.money, 'apptime':self.apptime, 'calltime':self.calltime, 'wish':self.wish, 'calltype':(self.apptype&0x01)==0x01 and 1 or 0, #通话模式开启 'meettype':(self.apptype&0x02)==0x02 and 1 or 0, #见面模式开启 'phone':self.username, 'weixin':self.weixin, 'qq':self.qq, 'email':self.email, 'rong_token':self.rong_token } elif type == 1: json_user = { '_id': self.id, 'name': self.name.encode('utf-8'), 'avaurl': common.getavaurl(self.avaurl) } elif type == 2: json_user = { '_id': self.id, 'name': self.name.encode('utf-8'), 'intro': self.intro.encode('utf-8'), 'job': self.job.encode('utf-8'), 'avaurl': common.getavaurl(self.avaurl) } elif type == 3: json_user = { '_id': self.id, 'name': self.name.encode('utf-8'), 'job': self.job.encode('utf-8'), 'avaurl': common.getavaurl(self.avaurl) } elif type == 4: json_user = { '_id': self.id, 'name': self.name.encode('utf-8'), 'job': self.job.encode('utf-8'), 'avaurl': common.getavaurl(self.avaurl), 'grade': common.getgrade(self.stats.comment_count, self.stats.comment_total), 'auth': {'vip': 1}, 'stats': self.stats.to_json(), 'sex': self.sex } elif type == 5: json_user = { '_id': self.id, 'name': self.name.encode('utf-8'), 'job': self.job.encode('utf-8'), 'avaurl': common.getavaurl(self.avaurl), 'grade': common.getgrade(self.stats.comment_count, self.stats.comment_total), 'auth': {'vip': 1} } elif type == 6: #地图专家列表 json_user = { '_id': self.id, 'name': self.name.encode('utf-8'), 'job': self.job.encode('utf-8'), 'geo': [self.geo['coordinates'][1], self.geo['coordinates'][0]], 'avaurl': common.getavaurl(self.avaurl), 'grade': common.getgrade(self.stats.comment_count, self.stats.comment_total), 'auth': {'vip': 1} } return json_user