예제 #1
0
def update_name():
    """
    根据手机号码更换用户名
    :return:
    """
    phone = request.form["phone"]
    name = request.form["name"]
    res = UserTable.query(phone)
    if res is None:
        return json.dumps({"data": '帐号不存在', "ret_code": constant.DB_FAILURE})
    UserTable.update_name(phone, name)
    return json.dumps({"data": '修改成功', "ret_code": constant.DB_SUCCESS})
예제 #2
0
def update_region():
    """
    根据手机号码更换地区
    :return:
    """
    phone = request.form["phone"]
    region = request.form["region"]
    res = UserTable.query(phone)
    if res is None:
        return json.dumps({"data": '帐号不存在', "ret_code": constant.DB_FAILURE})
    UserTable.update_region(phone, region)
    return json.dumps({"data": '修改成功', "ret_code": constant.DB_SUCCESS})
예제 #3
0
def update_birthday():
    """
    根据手机号码更换生日
    :return:
    """
    phone = request.form["phone"]
    birthday = request.form["birthday"]
    res = UserTable.query(phone)
    if res is None:
        return json.dumps({"data": '帐号不存在', "ret_code": constant.DB_FAILURE})
    UserTable.update_birthday(phone, birthday)
    return json.dumps({"data": '修改成功', "ret_code": constant.DB_SUCCESS})
예제 #4
0
def update_sex():
    """
    根据手机号码更换性别
    :return:
    """
    phone = request.form["phone"]
    sex = request.form["sex"]
    res = UserTable.query(phone)
    if res is None:
        return json.dumps({"data": '帐号不存在', "ret_code": constant.DB_FAILURE})
    UserTable.update_sex(phone, sex)
    return json.dumps({"data": '修改成功', "ret_code": constant.DB_SUCCESS})
예제 #5
0
def follow():
    """
    用户点击关注后,添加关系数据库
    :return:
    """
    user_phone = request.form["user"]
    target_phone = request.form["target"]
    res_user = UserTable.query(user_phone)
    res_target = UserTable.query(target_phone)
    if res_user is None or res_target is None:
        return json.dumps({"data": "关注失败", "ret_code": constant.DB_SUCCESS})
    RelationTable.follow(target_phone, user_phone)
    return json.dumps({"data": "关注成功", "ret_code": constant.DB_SUCCESS})
예제 #6
0
def register():
    """
    用户注册
    :return:
    """
    phone = request.form["phone"]
    password = request.form["password"]
    res = UserTable.query(phone)
    if res is None:
        UserTable.insert(phone, password)
        return json.dumps({"data": '注册成功', "ret_code": constant.DB_SUCCESS})
    else:
        return json.dumps({"data": '帐号已存在', "ret_code": constant.DB_FAILURE})
예제 #7
0
def update_account():
    """
    根据手机号码更换抖音账户名
    :return:
    """
    phone = request.form["phone"]
    account = request.form["account"]
    res = UserTable.query(phone)
    flag = UserTable.check_account(account)
    if res is None:
        return json.dumps({"data": '帐号不存在', "ret_code": constant.DB_FAILURE})
    if flag:
        return json.dumps({
            "data": '该抖音号已经存在',
            "ret_code": constant.DB_FAILURE
        })
    UserTable.update_account(phone, account)
    return json.dumps({"data": '修改成功', "ret_code": constant.DB_SUCCESS})
예제 #8
0
def update_password():
    """
    根据手机号更换密码
    :return:
    """
    phone = request.form["phone"]
    old_password = request.form["old_password"]
    new_password = request.form["new_password"]
    print(phone)
    print(old_password)
    print(new_password)
    res = UserTable.query(phone)
    if res is None:
        return json.dumps({"data": '帐号不存在', "ret_code": constant.DB_FAILURE})
    if res[2] == old_password:
        UserTable.update_password(phone, new_password)
        return json.dumps({"data": '密码修改成功', "ret_code": constant.DB_SUCCESS})
    else:
        return json.dumps({"data": '旧密码输入错误', "ret_code": constant.DB_FAILURE})
예제 #9
0
def get_info(phone):
    """
    得到个人信息
    :return:
    """
    if not UserTable.query(phone):
        return json.dumps({"data": None, "ret_code": constant.DB_FAILURE})
    res = UserTable.query(phone)
    data = {
        'phone': res[1],
        'account': res[3],
        'nickname': res[4],
        'introduction': res[5],
        'sex': res[6],
        'birthday': res[7],
        'region': res[8]
    }
    print(data)
    return json.dumps({"data": data, "ret_code": constant.DB_SUCCESS})
예제 #10
0
def user_table_test():
    # UserTable.create_table()
    # UserTable.insert('1234','123456')
    res = (UserTable.query('1234'))
    if res[2] == '123456':
        print(constant.SUCCESS)
    # UserTable.update_birthday(phone,'1999-10-23')
    # UserTable.update_introduction(phone,'日子和我都很难过:(')
    # UserTable.update_name(phone,'QiQi')
    # UserTable.update_region(phone,'二次元')
    # UserTable.update_sex(phone,'女')
    pass
예제 #11
0
def login():
    """
    用户登录
    :return:
    """
    phone = request.form["phone"]
    password = request.form["password"]
    print(phone)
    print(password)
    res = UserTable.query(phone)
    print(res)
    if res is None:
        return json.dumps({"data": '帐号不存在', "ret_code": constant.DB_FAILURE})
    if res[2] == password:
        return json.dumps({"data": '登录成功', "ret_code": constant.DB_SUCCESS})
    else:
        return json.dumps({"data": '密码错误', "ret_code": constant.DB_FAILURE})