CheckDatabase check database if exist when installation @Summary check database if exist when installation @Description check database if exist when installation @Tags installation @Accept json @Produce json @Param data body install.CheckDatabaseReq true "CheckDatabaseReq" @Success 200 {object} han
(ctx *gin.Context)
| 129 | // @Success 200 {object} handler.RespBody{data=install.CheckConfigFileResp{}} |
| 130 | // @Router /installation/db/check [post] |
| 131 | func CheckDatabase(ctx *gin.Context) { |
| 132 | req := &CheckDatabaseReq{} |
| 133 | if handler.BindAndCheck(ctx, req) { |
| 134 | return |
| 135 | } |
| 136 | |
| 137 | resp := &CheckDatabaseResp{} |
| 138 | dataConf := &data.Database{ |
| 139 | Driver: req.DbType, |
| 140 | Connection: req.GetConnection(), |
| 141 | } |
| 142 | resp.ConnectionSuccess = cli.CheckDBConnection(dataConf) |
| 143 | if !resp.ConnectionSuccess { |
| 144 | handler.HandleResponse(ctx, errors.BadRequest(reason.DatabaseConnectionFailed), schema.ErrTypeAlert) |
| 145 | return |
| 146 | } |
| 147 | handler.HandleResponse(ctx, nil, resp) |
| 148 | } |
| 149 | |
| 150 | // InitEnvironment init environment |
| 151 | // @Summary init environment |
nothing calls this directly
no test coverage detected