Exemplo n.º 1
0
def get_hot_record():
    """
    获取热门记录
    :return:
    """
    items = record_dao.select_hot_record()
    return http.BaseRes(data=items).to_json()
Exemplo n.º 2
0
def record_detail():
    """
    记录详细信息
    :return:
    """
    record_id = request.values.get('record_id')
    record = record_dao.select_by_record_id(record_id)
    return http.BaseRes(data=record).to_json()
Exemplo n.º 3
0
def get_my_follow():
    """
    我的关注人发布的记录
    :return:
    """
    user_id = request.headers.get('user_id')
    items = record_dao.select_follow_by_user_id(user_id)
    return http.BaseRes(data=items).to_json()
Exemplo n.º 4
0
def fans():
    """
    粉丝
    :return:
    """
    user_id = request.headers.get('user_id')
    items = user_dao.get_fans(user_id)
    return http.BaseRes(data=items).to_json()
Exemplo n.º 5
0
def get_my_record():
    """
    获取个人发布信息
    :return:
    """
    user_id = request.headers.get('user_id')
    items = record_dao.select_by_user_id(user_id)
    return http.BaseRes(data=items).to_json()
Exemplo n.º 6
0
def do_unfollow():
    """
    取消关注
    :return:
    """
    user_id = request.headers.get('user_id')
    followed_id = request.args.get('followed_id')
    user_dao.remove_follow(user_id, followed_id)
    return http.BaseRes()
Exemplo n.º 7
0
def do_follow():
    """
    进行关注
    :return:
    """
    user_id = request.headers.get('user_id')
    followed_id = request.args.get('followed_id')
    user_dao.add_follow(user_id, followed_id)
    return http.BaseRes()
Exemplo n.º 8
0
def publish_record():
    """
    发布关注信息
    :return:
    """
    user_id = request.headers.get('user_id')
    content = request.values.get('content')
    user_record = UserRecord(user_id=user_id, content=content)
    record_dao.add_record(user_record)
    return http.BaseRes(message='发布成功!').to_json()
Exemplo n.º 9
0
def send_verify_code():
    """
    发送验证码
    :param phone:
    :param verify_code:
    :return:
    """
    phone = request.args.get('phone')
    verify_code = str(uuid.uuid1())[0:4]
    res = sms_service.send_verify_code(phone, verify_code)
    if res == 'ok':
        redis_service.put_with_expire(USER_VERIFY_CODE_PREFIX + phone,
                                      verify_code, 5 * 60)
        return http.BaseRes().to_json()
    else:
        raise BussinessException()
Exemplo n.º 10
0
def login():
    """
    用户登录
    :return:
    """
    phone = request.args.get('phone')
    verify_code = request.args.get('verify_code')
    if config.isDebug:
        if phone[0:4] != verify_code:
            raise BussinessException(error_type.VERIFY_CODE_ERROR)
    else:
        check_verify_code(phone, verify_code)
    if not user_dao.select_by_phone(phone):
        raise BussinessException(error_type.USER_NOT_EXIST)

    user_info = user_dao.select_by_phone(phone)
    token = user_dao.create_token(user_info)
    return http.BaseRes(data=UserInfoVo(user_info.phone, user_info.nickname,
                                        user_info.id, token)).to_json()
Exemplo n.º 11
0
def register():
    """
    用户注册接口
    :return:
    """
    phone = request.args.get('phone')
    verify_code = request.args.get('verify_code')
    nickname = request.args.get('nickname')
    if config.isDebug:
        if phone[0:4] != verify_code:
            raise BussinessException(error_type.VERIFY_CODE_ERROR)
    else:
        check_verify_code(phone, verify_code)
    try:
        user_dao.insert_user(UserInfo(phone=phone, nickname=nickname))
    except IntegrityError as e:
        message = e.orig.args[1]
        if 'phone' in message:
            raise BussinessException(error_type.PHONE_EXIST)
        if 'nickname' in message:
            raise BussinessException(error_type.NICKNAME_EXIST)
    return http.BaseRes().to_json()