40 lines
796 B
Go
40 lines
796 B
Go
package handler
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"myschools.me/suguo/gofound/service"
|
|
)
|
|
|
|
// DatabaseDrop 删除数据库
|
|
func DatabaseDrop(c *gin.Context) {
|
|
dbName := c.Query("database")
|
|
if dbName == "" {
|
|
ResponseErrorWithMsg(c, "database is empty")
|
|
return
|
|
}
|
|
|
|
if err := service.DatabaseDrop(dbName); err != nil {
|
|
ResponseErrorWithMsg(c, err.Error())
|
|
return
|
|
}
|
|
|
|
ResponseSuccessWithData(c, "删除成功")
|
|
}
|
|
|
|
// DatabaseCreate 创建数据库
|
|
func DatabaseCreate(c *gin.Context) {
|
|
dbName := c.Query("database")
|
|
if dbName == "" {
|
|
ResponseErrorWithMsg(c, "database is empty")
|
|
return
|
|
}
|
|
|
|
service.DatabaseCreate(dbName)
|
|
ResponseSuccessWithData(c, "创建成功")
|
|
}
|
|
|
|
// 查询数据库
|
|
func DatabaseShow(c *gin.Context) {
|
|
ResponseSuccessWithData(c, service.DatabaseShow())
|
|
}
|