예제 #1
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
예제 #2
0
def is_watch():
    logger.info('rec a is 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

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

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

    return res