kra/internal/server/handler/system/sys_initdb.go

37 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package system
import (
"kra/pkg/response"
"github.com/gin-gonic/gin"
)
type DBApi struct{}
// InitDBRequest 初始化数据库请求
type InitDBRequest struct {
AdminPassword string `json:"adminPassword" binding:"required"`
DBType string `json:"dbType"`
Host string `json:"host"`
Port string `json:"port"`
UserName string `json:"userName"`
Password string `json:"password"`
DBName string `json:"dbName"`
DBPath string `json:"dbPath"`
}
// InitDB 初始化数据库
// 注意KRA 项目使用 Kratos 框架,数据库配置通过 config.yaml 管理
// 此接口主要用于兼容 GVA 前端
func (d *DBApi) InitDB(c *gin.Context) {
// KRA 项目数据库已通过配置文件初始化
// 此接口返回成功以兼容前端
response.OkWithMessage("数据库已初始化", c)
}
// CheckDB 检测是否需要初始化数据库
func (d *DBApi) CheckDB(c *gin.Context) {
// KRA 项目数据库通过配置文件管理,无需初始化
response.OkWithDetailed(gin.H{"needInit": false}, "数据库无需初始化", c)
}