48 lines
1.5 KiB
Go
48 lines
1.5 KiB
Go
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
|
||
// @Tags InitDB
|
||
// @Summary 初始化用户数据库
|
||
// @Produce application/json
|
||
// @Param data body InitDBRequest true "初始化数据库参数"
|
||
// @Success 200 {object} response.Response{msg=string} "初始化用户数据库"
|
||
// @Router /init/initdb [post]
|
||
// 注意:KRA 项目使用 Kratos 框架,数据库配置通过 config.yaml 管理
|
||
// 此接口主要用于兼容前端初始化流程
|
||
func (d *DBApi) InitDB(c *gin.Context) {
|
||
// KRA 项目数据库已通过配置文件初始化
|
||
// 此接口返回成功以兼容前端
|
||
response.OkWithMessage("数据库已初始化", c)
|
||
}
|
||
|
||
// CheckDB
|
||
// @Tags CheckDB
|
||
// @Summary 初始化用户数据库
|
||
// @Produce application/json
|
||
// @Success 200 {object} response.Response{data=map[string]interface{},msg=string} "初始化用户数据库"
|
||
// @Router /init/checkdb [post]
|
||
func (d *DBApi) CheckDB(c *gin.Context) {
|
||
// KRA 项目数据库通过配置文件管理,无需初始化
|
||
response.OkWithDetailed(gin.H{"needInit": false}, "数据库无需初始化", c)
|
||
}
|