Esempio n. 1
0
 def get_detail(cls, id):
     sql = 'select * from view_user where user_id = %s;'
     res = query(sql, [id])
     if res:
         item = res[0]
         return utils.format_model_item(item)
     return None
Esempio n. 2
0
def query_user_timeline(user_id, types, start, per_page):
    """查询用户时间线"""
    sql = "select * from action where type in %s and user_id = %s " \
          "and create_ts < %s order by create_ts desc limit 0,%s"

    t = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(start))

    return query(sql, [types, user_id, t, per_page])
Esempio n. 3
0
 def get_user_last_location_time(cls, user_id):
     '''查询用户最后的位置'''
     sql = 'select * from view_last_location_time where user_id = %s'
     res = query(sql, [user_id])
     if res:
         return res[0]['create_ts']
     else:
         return 0
Esempio n. 4
0
    def query_related_videos(cls, id):
        sql = "SELECT * FROM view_video where user_id <='' LIMIT 0,4;"

        res = query(sql, [])

        map(utils.map_model_item, res)

        return res
Esempio n. 5
0
    def get_video_detail(cls, id):
        sql = "SELECT * FROM view_video WHERE res_id = %s;"

        res = query(sql, [id])
        if res:
            item = res[0]
            return utils.format_model_item(item)
        return None
Esempio n. 6
0
 def get_collection_detail(cls, id):
     sql = "select * from view_collection where res_id = %s;"
     res = query(sql, [id])
     if res:
         item = res[0]
         item = utils.format_model_item(item)
         return item
     else:
         return None
Esempio n. 7
0
    def get_comments(cls, **params):
        '''获取评论列表'''
        start = int(params['start'])
        res_id = params['res_id']
        per_page = int(params['per_page'])

        sql = "select * from view_comment WHERE res_id = %s " \
              "and create_ts < %s limit 0,%s;"
        res = query(sql, [res_id, start, per_page])
        return res
Esempio n. 8
0
    def get_similar_users(cls, user_id):
        sql = """
            SELECT id AS user_id,name,portrait,gender FROM user WHERE id IN (
              SELECT distinct user_id from action WHERE res_id IN (
              SELECT res_id FROM action WHERE type = 27 AND user_id = %s
            ) AND user_id>''
            );
        """

        return query(sql, [user_id])
Esempio n. 9
0
    def get_pushs(cls):
        sql = "select * from view_push"

        return query(sql, [])
Esempio n. 10
0
 def get_replys(cls, **params):
     '''根据评论id过去回复列表'''
     comment_id = params['comment_id']
     sql = ' select * from view_reply where comment_id = %s'
     res = query(sql, [comment_id])
     return res
Esempio n. 11
0
 def get_items(cls, ):
     sql = "select * from view_collection"
     res = query(sql, [])
     map(utils.map_model_item, res)
     return res
Esempio n. 12
0
 def get_items(cls):
     sql = 'select * from view_audio'
     res = query(sql, [])
     map(utils.map_model_item, res)
     return res
Esempio n. 13
0
 def get_videos(cls):
     sql = "SELECT * FROM view_video"
     res = query(sql, [])
     map(utils.map_model_item, res)
     return res
Esempio n. 14
0
 def get_normal_users(cls):
     sql = "SELECT * FROM view_user WHERE status = 52;"
     res = query(sql, [])
     map(utils.map_model_item, res)
     return res