コード例 #1
0
def desc_show(request, db_name):
    # db_name = []
    db_id = ''
    us_table = []
    field_info = []
    # us_china = getPinyin(china_db)
    # 连接点击的数据库
    china_db = request.session.get('user_login_name')
    db = con(china_db)
    cursor = db.cursor()
    sql = """select id,us_tableName from savetable where  tableName='{0}';""".format(
        db_name)
    sql_ending = sql.encode(encoding="utf8")
    cursor.execute(sql_ending)
    dbs = cursor.fetchall()
    for db in dbs:
        db_id = db[0]
        us_table.append(db[1])
    # print(db_id,'#'*100)
    # print(dbs[0],"*"*100)
    sql = """select * from add_field where tableKey_id={0};""".format(db_id)
    sql_ending = sql.encode(encoding="utf8")
    cursor.execute(sql_ending)
    field_list = cursor.fetchall()
    for field in field_list:
        field_info.append({
            'fieldName': field[1],
            'fieldDesc': field[2],
            "us_table": us_table
        })
    # print(field_info, '*'*100)
    return JsonResponse({'data': field_info})
コード例 #2
0
def index(request):
    # 海云列表
    resourceId_list = []
    # 中软列表
    resourceID_list = []
    db = con("test")
    cursor = db.cursor()
    # 海云查询
    sql = """select resourceId from hyParticipation where isTransact = 1;"""
    print(sql)
    sql_ending = sql.encode(encoding="utf8")
    cursor.execute(sql_ending)
    resourceIdSet = cursor.fetchall()
    for one in resourceIdSet:
        for two in one:
            resourceId_list.append(two)

    # 中软查询
    sql = """select resourceId from noticedata where isTransact = 1;"""
    print(sql)
    sql_ending = sql.encode(encoding="utf8")
    cursor.execute(sql_ending)
    resourceIdSet = cursor.fetchall()
    for one in resourceIdSet:
        for two in one:
            resourceID_list.append(two)
    db.commit()
    db.close()
    print(resourceId_list)
    return render(request,'controlCenter/controlCenter.html', {"resourceId_list": resourceId_list, "resourceID_list":resourceID_list})
コード例 #3
0
def insert_log(depart,obj_name,username,starttinme,endtime,status):

    us_china= getPinyin(depart)
    db = con(us_china)
    cursor = db.cursor()
    sql = """insert into mylog values (null,"{0}",'{1}','{2}','{3}','{4}','{5}')""".format(task,obj_name,username,starttinme,endtime,status)
    print(sql,'*'*100)
    sql_ending = sql.encode(encoding="utf8")
    cursor.execute(sql_ending)
    db.commit()
    cursor.close()
    db.close()

    return True
コード例 #4
0
def isTransact(request):
    print(1)
    if request.method == "POST":
        tableName = request.POST.get("tableName")
        resourceID = request.POST.get("resourceID")
        print(resourceID)
        db =con("test")
        cursor = db.cursor()
        sql = """update {0} set isTransact = 0 where resourceId = '{1}';""".format(tableName,resourceID)
        print(sql)
        sql_ending = sql.encode(encoding="utf8")
        cursor.execute(sql_ending)
        db.commit()
        db.close()
        return JsonResponse({'result': 1})
コード例 #5
0
def get_thirddir(request):
    if request.method == "POST":
        secondList = []
        secondName_list = []
        # 获取选中的二级目录
        second_name = request.POST.get('second_dir')
        # 获取点击的库名并转换成英文
        depart = request.POST.get('depart')
        if depart and second_name:
            us_china = getPinyin(depart)
            db = con(us_china)
            # print(db)
            cursor = db.cursor()
            # 获取二级目录id
            sql = """select id from AdminSecond where chinese_abb='{0}';""".format(
                second_name)
            sql_ending = sql.encode(encoding="utf8")
            cursor.execute(sql_ending)
            second_tuple = cursor.fetchall()
            for S_tuple in second_tuple:
                for second_id in S_tuple:
                    # print(second_id)
                    secondList.append(second_id)
            sql = """select chinese_abb from AdminThird where second_id={0};""".format(
                secondList[0])
            sql_ending = sql.encode(encoding="utf8")
            cursor.execute(sql_ending)
            secondName_tuple = cursor.fetchall()
            for t_tuple in secondName_tuple:
                for thirdName in t_tuple:
                    us_thirdName = getPinyin(thirdName)
                    secondName_list.append({
                        'third_dir': thirdName,
                        'thdir_map': us_thirdName
                    })

            Result = result(secondName_list)
        else:
            status = 500
            data = "传参有误"
            Result = result3(data, status)

    else:
        status = 404
        data = "该请求方式为POST请求"
        Result = result3(data, status)

    return JsonResponse(Result)
コード例 #6
0
def get_seconddir(request):
    if request.method == "POST":
        first_list = []
        secondName_list = []
        # 获取选中的一级目录名称
        first_name = request.POST.get('first_dir')
        # 获取点击的库名并转换成英文
        depart = request.POST.get('depart')
        if depart and first_name:
            us_china = getPinyin(depart)
            db = con(us_china)
            # print(db)
            cursor = db.cursor()
            # 查询一级目录id
            sql = """select id from AdminFirst where chinese_abb='{0}';""".format(
                first_name)
            sql_ending = sql.encode(encoding="utf8")
            cursor.execute(sql_ending)
            first_tuple = cursor.fetchall()
            for F_tuple in first_tuple:
                for first_id in F_tuple:
                    first_list.append(first_id)
            # 获取二级目录列表
            sql = """select chinese_abb from AdminSecond where first_id={0};""".format(
                first_list[0])
            sql_ending = sql.encode(encoding="utf8")
            cursor.execute(sql_ending)
            secondName_tuple = cursor.fetchall()
            for s_tuple in secondName_tuple:
                for secondName in s_tuple:
                    us_secondName = getPinyin(secondName)
                    secondName_list.append({
                        'second_dir': secondName,
                        'sedir_map': us_secondName
                    })

            Result = result(secondName_list)
        else:
            status = 500
            data = "传参有误"
            Result = result3(data, status)

    else:
        status = 404
        data = "该请求方式为POST请求"
        Result = result3(data, status)

    return JsonResponse(Result)
コード例 #7
0
def serviceFind(request, args=None):
    db = con('Service_dic')
    cursor = db.cursor()
    if args is None:
        sql = """select * from servicedata """
        sql_ending = sql.encode(encoding="utf8")
        # print(sql)
        cursor.execute(sql_ending)
        services = cursor.fetchall()
        return JsonResponse({'result':services})
    else:
        sql = """select * from servicedata where  link_name ='{0}'; """.format(args)
        sql_ending = sql.encode(encoding="utf8")
        # print(sql)
        cursor.execute(sql_ending)
        services = cursor.fetchall()
        return JsonResponse({'result': services})
コード例 #8
0
def findData(request, args=None):
    db = con('Data_dic')
    cursor = db.cursor()
    if args is None:
        sql = """select * from dataname """
        sql_ending = sql.encode(encoding="utf8")
        # print(sql)
        cursor.execute(sql_ending)
        datas = cursor.fetchall()
        return JsonResponse({'result': datas})
    else:
        sql = """select * from dataname where  data_name ='{0}'; """.format(
            args)
        sql_ending = sql.encode(encoding="utf8")
        # print(sql)
        cursor.execute(sql_ending)
        datas = cursor.fetchall()
        return JsonResponse({'result': datas})
コード例 #9
0
def get_citydp(request):

    if request.method == "GET":
        data = []
        db = con('test')
        cursor = db.cursor()
        sql = """select dataname from department where dataname like '%市%';"""
        print(sql)
        sql_ending = sql.encode(encoding="utf8")
        cursor.execute(sql_ending)
        total_dep = cursor.fetchall()
        for to_de in total_dep:
            print(to_de[0])
            data.append(to_de[0])
        Result = result(data)
    else:
        status = 404
        data = "该请求方式为GET请求"
        Result = result3(data, status)

    return JsonResponse(Result)
コード例 #10
0
def get_firstdir(request):
    data = []
    if request.method == "POST":
        depart = request.POST.get('depart')
        if depart:
            print(depart, '部门')
            # 转义
            us_china = getPinyin(depart)
            # 连接数据库
            db = con(us_china)
            cursor = db.cursor()
            # 获取一级目录id
            sql = """select * from AdminFirst """
            print(sql)
            sql_ending = sql.encode(encoding="utf8")
            cursor.execute(sql_ending)
            firstdir = cursor.fetchall()
            print(firstdir, 'firstdir')
            for firstDir in firstdir:
                print(firstDir, 'firstDir')
                data.append({
                    "first_dir": firstDir[2],
                    "firstdir_mapping": firstDir[1]
                })

            Result = result(data)
        else:
            status = 500
            data = "depart传参有误"
            Result = result3(data, status)
    else:
        status = 404
        data = "该请求方式为POST请求"
        Result = result3(data, status)

    return JsonResponse(Result)
コード例 #11
0
def get_num(data):
    # 用户接口数计算
    db = con('test')
    cursor = db.cursor()
    sql = """select count(*) from Uuser where depart = '{0}';""".format(data)
    print(sql)
    sql_ending = sql.encode(encoding="utf8")
    cursor.execute(sql_ending)
    user_num = cursor.fetchall()[0][0]
    print(user_num, "+" * 100)

    sql = """select dataname from department where us_dataname = '{0}';""".format(
        data)
    sql_ending = sql.encode(encoding="utf8")
    cursor.execute(sql_ending)
    departName = cursor.fetchall()[0][0]
    print(departName)
    db.close()
    # 数据目录接口数计算
    db = con(data)
    cursor = db.cursor()
    sql = """select count(*) from Uservice;"""
    sql_ending = sql.encode(encoding="utf8")
    cursor.execute(sql_ending)
    service_num = cursor.fetchall()[0][0]
    print(service_num)
    # 访问控制接口数计算
    sql = """select count(*) from Uacl;"""
    sql_ending = sql.encode(encoding="utf8")
    cursor.execute(sql_ending)
    acl_num = cursor.fetchall()[0][0]
    print(acl_num)
    # 流量控制接口数计算
    sql = """select count(*) from Ucontrols;"""
    sql_ending = sql.encode(encoding="utf8")
    cursor.execute(sql_ending)
    controls_num = cursor.fetchall()[0][0]
    print(controls_num)
    # 安全目录接口总数
    safe_num = acl_num + controls_num
    # 数据库桥接接口数计算
    sql = """select count(*) from dbList"""
    sql_ending = sql.encode(encoding="utf8")
    cursor.execute(sql_ending)
    dbList_num = cursor.fetchall()[0][0]
    print(dbList_num)
    # 文件接口数计算
    sql = """select count(*) from fileList"""
    sql_ending = sql.encode(encoding="utf8")
    cursor.execute(sql_ending)
    fileList_num = cursor.fetchall()[0][0]
    print(fileList_num)
    # 接口数数量计算
    sql = """select count(*) from interfaceList"""
    sql_ending = sql.encode(encoding="utf8")
    cursor.execute(sql_ending)
    interfaceList_num = cursor.fetchall()[0][0]
    print(interfaceList_num)
    # 信息接口数计算
    sql = """select count(*) from messageList"""
    sql_ending = sql.encode(encoding="utf8")
    cursor.execute(sql_ending)
    messageList_num = cursor.fetchall()[0][0]
    print(messageList_num)
    # 数据桥接接口总数
    data_num = dbList_num + fileList_num + interfaceList_num + messageList_num
    db.close()
    # 超管总接口数
    total_num = user_num + service_num + safe_num + data_num
    get_number = {
        'departname': departName,
        'user_num': user_num,
        'service_num': service_num,
        'acl_num': acl_num,
        'controls_num': controls_num,
        'dbList_num': dbList_num,
        'fileList_num': fileList_num,
        'interfaceList_num': interfaceList_num,
        'messageList_num': messageList_num,
        'safe_num': safe_num,
        'data_num': data_num,
        'total_num': total_num
    }

    return get_number