Ejemplo n.º 1
0
def getEnumDict(code, dataBase):
    sql = r"select a.code , c.key " \
          r"from sys_dict a inner join sys_dict b on a.pid = b.id " \
          r"left join sys_res_i18n c on a.i18nid = c.id " \
          r"where b.code = '%s' and c.key is not null" \
          % (code)
    return list(utils.queryData(sql, dataBase))
Ejemplo n.º 2
0
def queryColumnConfig():
    data = utils.getRequestData()
    dataBase = data.get("database")
    table = data.get("table")
    columns = json.loads(data.get("columns"))
    columns = ('"' + _ + '"' for _ in columns)
    queryColumnStr = ",".join(columns)
    if dataBase == '':
        return utils.success(list())
    table = data.get("table")
    page = int(data.get("page"))
    limit = int(data.get("limit"))
    sql = r"select column_name, character_maximum_length, column_comment, column_comment cn_name" \
          r", case when data_type = 'int' then 'int' when data_type = 'datetime' then 'datetime' else 'string' end as data_type" \
          r", '1:1' layout, 100 column_width, if(column_comment='', 'off', 'on') creat_i18n" \
          r", if(column_name='id', 'on', 'off') is_hidden, if(column_name='id', 'off', 'on') is_query" \
          r", if(column_name='id', 'on', 'off') is_add_hidden, if(column_name='id', 'on', 'off') is_edit_hidden" \
          r", if(column_name='id', 'off', 'on') is_edit, if(column_name='id', 'off', 'on') is_require" \
          r" from information_schema.columns where table_schema =  '%s' and table_name ='%s' and column_name in (%s)" \
          % (dataBase, table, queryColumnStr)
    data = list(utils.queryData(sql))
    for d in data:
        if d['cn_name']:
            d['en_name'] = utils.translateWord(d['cn_name'])
    return utils.success(data, page, limit)
Ejemplo n.º 3
0
def queryDataBases():
    sql = "show databases"
    data = list(utils.queryData(sql))
    retData = []
    for i in data:
        if i['Database'] not in ('information_schema', 'mysql',
                                 'performance_schema'):
            retData.append(i)
    return utils.success(retData)
Ejemplo n.º 4
0
def queryDicts():
    data = utils.getRequestData()
    dataBase = data.get("database")
    sql = r"select a.code, b.value " \
          r"from sys_dict a " \
          r"left join sys_res_i18n_type b on a.i18nid = b.pid and b.type = 'zh_CN' " \
          r"where b.value is not null " \
          r"order by a.Pid, a.Id"
    return utils.success(list(utils.queryData(sql, dataBase)))
Ejemplo n.º 5
0
def queryColumns():
    data = utils.getRequestData()
    dataBase = data.get("database")
    if dataBase == '':
        return utils.success(list())
    table = data.get("table")
    page = int(data.get("page"))
    limit = int(data.get("limit"))
    sql = r"select column_name, case when is_nullable = 'NO' then '否' else '是' end as is_nullable" \
          r", data_type, character_maximum_length, case when ifnull(extra,'') = '' then '否' else '是' end as extra" \
          r", column_comment" \
          r" from information_schema.columns where table_schema =  '%s' and table_name ='%s' " \
          % (dataBase, table)
    return utils.success(list(utils.queryData(sql)), page, limit)
Ejemplo n.º 6
0
def queryTables():
    data = utils.getRequestData()
    dataBase = data.get("database")
    sql = r"select table_name from information_schema.tables where table_schema = '%s' and table_type = 'BASE TABLE' order by table_name" \
          % dataBase
    return utils.success(list(utils.queryData(sql)))