Exemple #1
0
def delete_channel():
    channel_id = request.args.get('channel_id')
    del_channel_sql = """UPDATE channel SET is_delete=1 WHERE id=%s""" % channel_id

    sql_oper = SqlOperate()
    try:
        sql_oper.delete(del_channel_sql)
    except Exception as e:
        current_app.logger.error(e)
        return jsonify(errmsg='删除失败')

    load_channel()

    highest_role = get_highest_role_id(session['role_str'])

    sql = '''
        insert into admin_opt_log 
            (channel, maintype, log_type, operator, obj, 
            val, timestamp)
        values 
            (%d, %d, %d, %d, %d, 
            %d, %d)
    ''' % (
        0, log_main_type_d["system"], log_type_d["delete_channel"], session['user_id'], int(channel_id), highest_role,
        time_util.now_sec())
    sql_oper.insert(sql)

    return jsonify(errmsg='删除成功')
Exemple #2
0
def delete_role():
    role_id = request.json.get('role_id')
    del_role_sql = """DELETE FROM role WHERE id=%s""" % role_id

    sql_oper = SqlOperate()
    try:
        sql_oper.delete(del_role_sql)
    except Exception as e:
        current_app.logger.error(e)
        return jsonify(errmsg='数据库操作失败')

    return jsonify(errmsg='删除成功')
Exemple #3
0
def delete_menu():
    menu_id = request.json.get('menu_id')
    del_menu_sql = """DELETE FROM menu WHERE id=%s""" % menu_id

    sql_oper = SqlOperate()
    try:
        sql_oper.delete(del_menu_sql)
    except Exception as e:
        current_app.logger.error(e)
        return jsonify(errno='2', errmsg='数据库操作失败')

    return jsonify(errno='0', errmsg='删除成功')
Exemple #4
0
def delete_user():
    user_id = request.json.get('user_id')
    del_user_sql = """UPDATE user SET is_delete=1 WHERE id=%s""" % user_id

    sql_oper = SqlOperate()

    sql_oper.delete(del_user_sql)
    highest_role = get_highest_role_id(session['role_str'])

    sql = '''
        insert into admin_opt_log 
            (channel, maintype, log_type, operator, obj, 
            val, timestamp)
        values 
            (%d, %d, %d, %d, %d, 
            %d, %d)
    ''' % (0, log_main_type_d["system"], log_type_d["delete_staff"],
           session['user_id'], int(user_id), highest_role, time_util.now_sec())
    sql_oper.insert(sql)

    return jsonify(errno='0', errmsg='删除成功')