mirror of https://gitee.com/answerdev/answer.git
Merge branch 'ai_0.3_install_api' into 'test'
add mock api See merge request opensource/answer!175
This commit is contained in:
commit
a9a59f801d
|
@ -4,6 +4,7 @@ import (
|
|||
"embed"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
|
@ -11,6 +12,7 @@ import (
|
|||
"github.com/answerdev/answer/internal/base/handler"
|
||||
"github.com/answerdev/answer/ui"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/segmentfault/pacman/errors"
|
||||
"github.com/segmentfault/pacman/log"
|
||||
)
|
||||
|
||||
|
@ -93,11 +95,29 @@ func (a *UIRouter) Register(r *gin.Engine) {
|
|||
})
|
||||
|
||||
r.POST("/installation/db/check", func(c *gin.Context) {
|
||||
handler.HandleResponse(c, nil, gin.H{})
|
||||
num := rand.Intn(10)
|
||||
if num > 5 {
|
||||
err := errors.BadRequest("connection error")
|
||||
handler.HandleResponse(c, err, gin.H{})
|
||||
} else {
|
||||
handler.HandleResponse(c, nil, gin.H{
|
||||
"connection_success": true,
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
r.POST("/installation/config-file/check", func(c *gin.Context) {
|
||||
handler.HandleResponse(c, nil, gin.H{})
|
||||
num := rand.Intn(10)
|
||||
if num > 5 {
|
||||
handler.HandleResponse(c, nil, gin.H{
|
||||
"exist": true,
|
||||
})
|
||||
} else {
|
||||
handler.HandleResponse(c, nil, gin.H{
|
||||
"exist": false,
|
||||
})
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
r.POST("/installation/init", func(c *gin.Context) {
|
||||
|
|
Loading…
Reference in New Issue