重构:移除数据库客户端模块 v0.4.0(-17,885行,专注文件管理)
- 删除全部 MySQL/Redis/MongoDB 客户端代码(dbclient/api/service/storage) - 清理 4 个驱动依赖(mysql/redis/mongo/gorm-mysql),构建体积 -10MB - 前端移除 db-cli 整个目录(40 文件)+ 7 个 API/工具文件 - 版本号升级至 v0.4.0,顶部 Tab 仅保留文件管理
This commit is contained in:
@@ -1,73 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"u-desk/internal/storage"
|
||||
"u-desk/internal/storage/models"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// 初始化数据库
|
||||
db, err := storage.Init()
|
||||
if err != nil {
|
||||
log.Fatalf("数据库初始化失败: %v", err)
|
||||
}
|
||||
|
||||
fmt.Println("=== 数据库连接配置调试工具 ===")
|
||||
fmt.Println()
|
||||
|
||||
// 列出所有连接
|
||||
var connections []models.DbConnection
|
||||
result := db.Order("id").Find(&connections)
|
||||
if result.Error != nil {
|
||||
log.Fatalf("查询失败: %v", result.Error)
|
||||
}
|
||||
|
||||
fmt.Printf("当前有 %d 个连接配置:\n", len(connections))
|
||||
fmt.Println()
|
||||
|
||||
for _, conn := range connections {
|
||||
fmt.Printf("ID: %d\n", conn.ID)
|
||||
fmt.Printf(" 名称: %s\n", conn.Name)
|
||||
fmt.Printf(" 类型: %s\n", conn.Type)
|
||||
fmt.Printf(" 主机: %s:%d\n", conn.Host, conn.Port)
|
||||
fmt.Printf(" 用户名: %s\n", conn.Username)
|
||||
fmt.Printf(" 创建时间: %s\n", conn.CreatedAt.Format("2006-01-02 15:04:05"))
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
// 询问用户操作
|
||||
var choice int
|
||||
fmt.Print("请选择操作:\n")
|
||||
fmt.Print("1. 删除指定 ID 的连接\n")
|
||||
fmt.Print("2. 列出连接详情\n")
|
||||
fmt.Print("0. 退出\n")
|
||||
fmt.Print("请输入: ")
|
||||
fmt.Scanln(&choice)
|
||||
|
||||
if choice == 1 {
|
||||
var id uint
|
||||
fmt.Print("请输入要删除的连接 ID: ")
|
||||
fmt.Scanln(&id)
|
||||
|
||||
// 确认
|
||||
var confirm string
|
||||
fmt.Printf("确认删除 ID=%d 的连接吗?(y/N): ", id)
|
||||
fmt.Scanln(&confirm)
|
||||
|
||||
if confirm == "y" || confirm == "Y" {
|
||||
result := db.Delete(&models.DbConnection{}, id)
|
||||
if result.Error != nil {
|
||||
log.Printf("删除失败: %v", result.Error)
|
||||
} else {
|
||||
fmt.Printf("删除成功!影响行数: %d\n", result.RowsAffected)
|
||||
}
|
||||
} else {
|
||||
fmt.Println("已取消删除")
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("\n工具退出")
|
||||
}
|
||||
Reference in New Issue
Block a user