mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-12-15 12:16:34 +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, 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' ORDER BY index_name asc , SEQ_IN_INDEX asc`
|
||||
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,20 +73,16 @@ 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")
|
||||
|
||||
// 把查询结果以索引名分组,索引字段以逗号连接
|
||||
result := make([]map[string]interface{}, 0)
|
||||
key := ""
|
||||
i := 0
|
||||
for k, v := range res {
|
||||
// 当前的索引名
|
||||
in := fmt.Sprintf("%v", v["indexName"])
|
||||
cl := fmt.Sprintf("%v", v["columnName"])
|
||||
|
||||
in := v["indexName"].(string)
|
||||
if key == in {
|
||||
// 同索引字段以逗号连接
|
||||
cl1 := fmt.Sprintf("%v", result[i]["columnName"])
|
||||
result[i]["columnName"] = cl1 + "," + cl
|
||||
result[i]["columnName"] = result[i]["columnName"].(string) + "," + v["columnName"].(string)
|
||||
} else {
|
||||
i = k
|
||||
key = in
|
||||
|
||||
Reference in New Issue
Block a user