Esempio n. 1
0
def createFile():
    data = utils.getRequestData()
    createLayOutFile(data)
    createI18NFile(data)
    createMocFile(data)
    createControllerFile(data)
    return utils.success(msg="保存成功")
Esempio 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)
Esempio n. 3
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)))
Esempio n. 4
0
def saveConfig():
    data = utils.getRequestData()
    try:
        utils.updateConfig("dataBase", "host", data.get("host"))
        utils.updateConfig("dataBase", "user", data.get("user"))
        utils.updateConfig("dataBase", "password", data.get("password"))
        return utils.success(msg='保存成功')
    except Exception as e:
        print(e)
        return utils.error('保存失败')
Esempio n. 5
0
def testConnection():
    data = utils.getRequestData()
    try:
        conn = pymysql.connect(data.get("host"),
                               data.get("user"),
                               data.get("password"),
                               data.get("db"),
                               charset=utils.loadConfig("dataBase", "charset"))
        conn.ping()
        return utils.success(msg='连接成功')
    except:
        return utils.error('请检查你的连接')
Esempio n. 6
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)
Esempio n. 7
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)))
Esempio n. 8
0
def translate():
    data = utils.getRequestData()
    return utils.translateWord(data.get("cn_name"))