Example #1
0
def get_user():
    global DBSESSION
    check_dbsession(DBSESSION)
    sql = 'SELECT uid, nickname, update_time FROM profile ORDER BY update_time DESC'
    users = DBSESSION.execute(sql)
    res = []
    for u in users:
        res.append({
            'uid': u.uid,
            'nickname': u.nickname,
            'update_time': millisecond_to_datestr(u.update_time),
        })

    return res
Example #2
0
def get_comment(root_id):
    global DBSESSION
    check_dbsession(DBSESSION)
    sql = 'SELECT * FROM comment WHERE status=0 AND root_id="' + root_id + '" ORDER BY update_time DESC'
    print sql
    comments = DBSESSION.execute(sql)
    res = []

    for c in comments:
        res.append({
            'id': c.id,
            'parent_id': c.parent_id,
            'reply_user': c.reply_user,
            'root_id': c.root_id,
            'content': c.content,
            'author_id': c.author_id,
            'nickname': c.nickname,
            'avatar': 'http://image.ciwei.io/' + c.avatar,
            'type': c.type,
            'comment_count': c.comment_count,
            'like_count': c.like_count,
            'update_time': millisecond_to_datestr(c.update_time)
        })
    return res
Example #3
0
def get_post():
    global DBSESSION
    check_dbsession(DBSESSION)
    sql = ('SELECT * '
           'FROM post WHERE status=0 ORDER BY update_time DESC'
           )
    posts = DBSESSION.execute(sql)
    res = []
    for p in posts:
        res.append({
            'id': p.id,
            'parent_id': p.parent_id,
            'author_id': p.author_id,
            'nickname': p.nickname,
            'avatar': 'http://image.ciwei.io/' + p.avatar,
            'group_name': p.group_name,
            'content': p.content,
            'pictures': p.pictures,
            'comment_count': p.comment_count,
            'like_count': p.like_count,
            'update_time': millisecond_to_datestr(p.update_time),
        })

    return res