def handle_people_list(queryparams): """ :param queryparams: :return: """ rownum, query_result = PeopleNews.query_people_list(queryparams) result = [] if rownum: for id, classid, onclick, title, titlepic, newstime, filesize_mp3, mp3_time, record_64, record, record_ts, smalltext, newstext, contentpic in query_result: obj = { 'id': id, 'classid': classid, 'onclick': onclick, 'title': title, 'titlepic': utils.urlformat(titlepic), 'newstime': utils.timeformat(newstime), 'filesize_mp3': filesize_mp3, 'mp3_time':mp3_time, 'record_64': utils.urlformat(record_64), 'record_128': utils.urlformat(record), 'record_ts': utils.urlformat(record_ts), 'smalltext': utils.strip_tags(smalltext), 'newstext': utils.filter_tags(newstext), 'contentpic': utils.urlformat(contentpic) } result.append(obj) else: result = {'message': u'查询错误', 'code': 113} return result
def handle_all_news(queryparams): rownum, query_result = OpenAPI.query_all_news(queryparams) print query_result result = [] if rownum: for id, classid, onclick, title, titlepic, newstime, filesize_mp3, mp3_time, record_64, record, record_ts, smalltext, newstext, contentpic in query_result: obj = { 'id': id, 'classid':classid, 'onclick':onclick, 'title':title, 'titlepic':utils.urlformat(titlepic), 'newstime':utils.timeformat(newstime), 'filesize_mp3':filesize_mp3, 'mp3_time':mp3_time, 'record_64':utils.urlformat(record_64), 'record_128':utils.urlformat(record), 'record_ts':utils.urlformat(record_ts), 'smalltext':utils.filter_tags(smalltext), 'newstext':utils.filter_tags(newstext), 'contentpic': utils.urlformat(contentpic) } result.append(obj) else: result = {'message': u'查询错误或者没有条目', 'code': 113} return result
def handle_user_info(queryparams): rownum, query_result = User.query_user_info(queryparams) if rownum: result = { 'id': query_result[0], 'status': query_result[1], 'name': query_result[2], 'avatar': utils.urlformat(query_result[3]), 'signture': query_result[4], 'register_time': utils.timeformat(query_result[5]) } else: result = {'message': u'查询错误', 'code': 113} return result
def handle_user_profile(queryparams): ''' 处理用户资料 ''' rownum, query_result = User.query_user_profile(queryparams) if rownum: result = { 'id': query_result[0], 'status': query_result[1], 'name': query_result[2], 'email': query_result[3], 'password': query_result[4], 'phone': query_result[5], 'avatar': utils.urllocalformat(query_result[6]), 'signture': query_result[7], 'register_time': utils.timeformat(query_result[8]), 'last_login_time': utils.timeformat(query_result[9]) } else: result = {'message': u'查询错误', 'code': 113} return result
def handle_forum_reply_list(queryparams): rownum, query_result = Reply.query_forum_reply_list(queryparams) result = [] if rownum: for id, userid, username, touserid, replyname, subjectid, content, posttime in query_result: obj = { 'id': id, 'userid': userid, 'username': username, 'touserid': touserid, 'replyname': replyname, 'subjectid': subjectid, 'content': utils.filter_tags(content), 'posttime': utils.timeformat(posttime) } result.append(obj) else: result = {'message': u'查询错误', 'code': 113} return result
def handle_user_signin(queryparams): ''' 登录验证 ''' rownum, query_result = User.query_user_signin(queryparams) if rownum: import time last_login_time = time.time() userid = query_result[0] # 更新登录时间 update_rownum = User.query_user_update_signin( userid, last_login_time) if update_rownum: result = { 'userid': query_result[0], 'name': query_result[1], 'last_login_time': utils.timeformat(last_login_time) } else: result = False return result
def handle_news_baidu_class(): news_baidu = special[:] news_baidu.extend(ordinary) news_baidu.extend(baidu) return json.dumps(news_baidu) def handle_news_categories(): try: rownum, query_result = News.query_news_category() except Exception, e: message = {'message': u'数据库查询错误', 'code': 113} return message result = [] if rownum: entities = {d[0]: {'id': d[0], 'pid': d[1], 'classname': d[2], 'image': 'http://w.duoting.fm/logo/info/%s.png' % d[0], 'status': d[3], 'nid': d[4], 'title': d[6], 'smalltext': utils.filter_tags(d[7]) if d[7] else '', 'contentpic': utils.urlformat(d[8]) if d[8] else '', 'newstime': utils.timeformat(d[9]) if d[9] else ''} for d in query_result} for e_id in entities: entitiy = entities[e_id] pid = entitiy['pid'] if pid == -1: result.append(entitiy) else: entities[pid].setdefault('sonclass', []).append(entitiy) return result else: result = {'message': u'没有栏目', 'code': 130} return result def handle_news_list(queryparams): try: