コード例 #1
0
def get_master_list():
    res = {'code': 1000, 'msg': '成功'}
    data = request.json
    command = data.get("cmd") or ''

    data = data.get('data')
    if not data:
        return handle_param_error()

    user_id = data.get("userid") or 0
    page_num = data.get("page_num") or 1

    if not command or not page_num:
        return handle_param_error()

    service = ProfileService()
    try:
        result = service.get_master_list(page_num)
        res = handle_success(result, 1000, '成功')
    except:
        res = handle_failure()
        logger.error('fail|exception|master list request serve error|%s' %
                     traceback.format_exc())
    finally:
        service.close()

    return res
コード例 #2
0
def is_watch():
    res = {'code': 1000, 'msg': '成功'}
    data = request.json
    data = data.get('data')
    if not data:
        return handle_param_error()

    user_id = data.get("userid") or 0
    req_user_id = data.get("req_user_id") or 0

    if not user_id or not req_user_id:
        return handle_param_error()

    service = ProfileService()
    try:
        result = service.user_watch_relation(user_id, req_user_id)
        res = handle_success(result, 1000, '成功')
    except:
        res = handle_failure()
        logger.error('fail|exception|is watch request serve error|%s' %
                     traceback.format_exc())
    finally:
        service.close()

    return res
コード例 #3
0
def get_user_profile():
    res = {'code': 1000, 'msg': '成功'}
    data = request.json

    data = data.get('data') if data else None
    if not data:
        return handle_param_error()

    user_id = data.get("userid") or 0

    if not user_id:
        return handle_param_error()

    service = ProfileService()
    try:
        result = service.get_user_profile(user_id)
        res = handle_success(result, 1000, '成功')
    except:
        res = handle_failure()
        logger.error('fail|exception|user profile request serve error|%s' %
                     traceback.format_exc())
    finally:
        service.close()

    return res
コード例 #4
0
def update_user_profile():
    res = {'code': 1000, 'msg': '成功'}
    data = request.json

    data = data.get('data') if data else None
    if not data:
        return handle_param_error()

    user_id = data.get("userid") or 0
    signature = data.get("signature") or ''
    nickname = data.get("nickname") or ''
    user_icon = data.get("user_icon") or ''
    user_pics = data.get("user_pics") or []

    if not user_id or not nickname or not user_icon:
        return handle_param_error()

    service = ProfileService()
    try:
        result = service.update_user_profile_diy(user_id=user_id,
                                                 signature=signature,
                                                 nickname=nickname,
                                                 user_icon=user_icon,
                                                 user_pics=user_pics)
        res = handle_success(result, 1000, '成功')
    except:
        res = handle_failure()
        logger.error('fail|exception|user profile request serve error|%s' %
                     traceback.format_exc())
    finally:
        service.close()

    return res
コード例 #5
0
ファイル: fans.py プロジェクト: P79N6A/backendProject
def add_watch():
    res  = {'code' : 1000, 'msg' : '成功'}
    data = request.json

    command     = data.get("cmd") or ''
    data = data.get('data')
    if not data:
        return handle_param_error()

    user_id     = data.get("userid") or 0
    req_user_id = data.get("req_user_id") or 0
    status      = data.get("status") or 0

    if not command or not user_id:
        return handle_param_error()

    service = ProfileService()
    try:
        result = service.watch(user_id, req_user_id, status)
        res    = handle_success(result, 1000, '成功')
    except:
        res = handle_failure()
        logger.error('fail|exception|user watch request serve error|%s' % traceback.format_exc())
    finally:
        service.close()

    return res
コード例 #6
0
ファイル: login.py プロジェクト: P79N6A/backendProject
def valid_wx_access_token():
    res = {'code':1000,'msg':'success','data':{}}
    token = request.args.get("token")
    userid = request.args.get("userid")
    if not (token and userid):
        return handle_param_error()

    logger.info('get weixin token:%s, userid:%s'%(token,userid))
    ps = ProfileService()

    openid = ps.get_uid_by_userid(userid)
    try:
        token_serv = WeiXinLoginService(appid=WX_APP_ID, secret=WX_APP_SECRET)
        token,session,obj = token_serv.get_user_info_by_token(openid=openid, access_token=token)
        if not (token and session and obj):
            logger.info('fail|valid_wx_access_token fail,token:%s,session:%s, obj:%s.'%(token,session,obj))
            return handle_failure()

        result = {}
        result['token']   = token
        result['session'] = session
        #data['userinfo'] = obj

        ps.update_user_profile(obj)

        res = handle_success(result, 1000, '成功')
        logger.info('valid_wx_access_token response:%s'%result)
    except:
        res = handle_failure()
        logger.error('fail|exception|ub request serve error|%s' % traceback.format_exc())

    finally:
        ps.close()

    return res
コード例 #7
0
ファイル: old_app.py プロジェクト: P79N6A/backendProject
def get_watch():
    logger.info('rec a user watch request')
    res = {'code': 1000, 'msg': '成功'}
    data = request.json
    command = data.get("cmd") or ''
    data = data.get('data')
    if not check_param(data):
        return handle_param_error()

    logger.info('request data => {0}'.format(data))

    user_id = data.get("userid") or 0
    req_user_id = data.get("req_user_id") or 0
    page_num = data.get("page_num") or 0

    if not command or not user_id or not check_param(data):
        return handle_param_error()

    service = ProfileService()
    try:
        result = service.get_watch(req_user_id, page_num)
        res = handle_success(result, 1000, '成功')
        logger.info('success|user watch request serve success')
    except:
        res = handle_failure()
        logger.error('fail|exception|user watch request serve error|%s' %
                     traceback.format_exc())
    finally:
        service.close()

    return res
コード例 #8
0
    def get_user_see_history(self, user_id=0, req_user_id=0, page_num=0):
        self.__base = self.__base or BaseDao()
        video = Video(self.__base)
        (total, rows) = video.get_user_see_history(page_num, 30, req_user_id)

        arr = []
        for row in rows:
            v = row.toDict()
            arr.append(v)

        service = ProfileService()
        is_watch = service.is_watch(user_id, req_user_id)
        service.close()

        data = {}
        data['videos'] = arr
        data['total'] = total
        data['is_watch'] = is_watch
        return data