mirror of
				https://gitee.com/dromara/mayfly-go
				synced 2025-11-04 08:20:25 +08:00 
			
		
		
		
	feat: 小功能优化&前端基于setup语法糖重构
This commit is contained in:
		@@ -17,10 +17,10 @@ const (
 | 
			
		||||
    WHERE table_schema = (SELECT database())`
 | 
			
		||||
 | 
			
		||||
	// mysql 索引信息
 | 
			
		||||
	MYSQL_INDEX_INFO = `SELECT index_name indexName, group_concat(column_name) columnName, index_type indexType, non_unique nonUnique, 
 | 
			
		||||
	MYSQL_INDEX_INFO = `SELECT index_name indexName, column_name columnName, index_type indexType, non_unique nonUnique, 
 | 
			
		||||
	SEQ_IN_INDEX seqInIndex, INDEX_COMMENT indexComment
 | 
			
		||||
	FROM information_schema.STATISTICS 
 | 
			
		||||
    WHERE table_schema = (SELECT database()) AND table_name = '%s' GROUP by index_name`
 | 
			
		||||
	WHERE table_schema = (SELECT database()) AND table_name = '%s' ORDER BY index_name asc , SEQ_IN_INDEX asc`
 | 
			
		||||
 | 
			
		||||
	// mysql 列信息元数据
 | 
			
		||||
	MYSQL_COLUMN_MA = `SELECT table_name tableName, column_name columnName, column_type columnType, column_default columnDefault,
 | 
			
		||||
@@ -73,7 +73,23 @@ func (mm *MysqlMetadata) GetTableInfos() []map[string]interface{} {
 | 
			
		||||
func (mm *MysqlMetadata) GetTableIndex(tableName string) []map[string]interface{} {
 | 
			
		||||
	res, err := mm.di.innerSelect(fmt.Sprintf(MYSQL_INDEX_INFO, tableName))
 | 
			
		||||
	biz.ErrIsNilAppendErr(err, "获取表索引信息失败: %s")
 | 
			
		||||
	return res
 | 
			
		||||
	// 把查询结果以索引名分组,索引字段以逗号连接
 | 
			
		||||
	result := make([]map[string]interface{}, 0)
 | 
			
		||||
	key := ""
 | 
			
		||||
	i := 0
 | 
			
		||||
	for k, v := range res {
 | 
			
		||||
		// 当前的索引名
 | 
			
		||||
		in := v["indexName"].(string)
 | 
			
		||||
		if key == in {
 | 
			
		||||
			// 同索引字段以逗号连接
 | 
			
		||||
			result[i]["columnName"] = result[i]["columnName"].(string) + "," + v["columnName"].(string)
 | 
			
		||||
		} else {
 | 
			
		||||
			i = k
 | 
			
		||||
			key = in
 | 
			
		||||
			result = append(result, v)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return result
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 获取建表ddl
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user