package base

import (
	"net/http"

	"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"

	"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/base"
	"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
)

// swagger:route get /api/base/initDatabase base InitDatabase
//
// Initialize database | 初始化数据库
//
// Initialize database | 初始化数据库
//

func InitDatabaseHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		const transErr = true

		l := base.NewInitDatabaseLogic(r, r.Context(), svcCtx)
		err := l.InitDatabase()

		statusz.ResponseHandler(r, w, transErr, nil, err)

	}
}
