初步搭建
This commit is contained in:
21
srv/internal/common/database-client.go
Normal file
21
srv/internal/common/database-client.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func GetDataBaseClient() *gorm.DB {
|
||||
dsn := "host=localhost " +
|
||||
"user=gatekeeper " +
|
||||
"dbname=crimson " +
|
||||
"sslmode=disable " +
|
||||
"port=5432 " +
|
||||
"password=crimson " +
|
||||
"connect_timeout=20 "
|
||||
client, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})
|
||||
if err != nil {
|
||||
panic("无法连接数据库")
|
||||
}
|
||||
return client
|
||||
}
|
||||
17
srv/internal/user/controller.go
Normal file
17
srv/internal/user/controller.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/labstack/echo"
|
||||
)
|
||||
|
||||
type Controller struct{}
|
||||
|
||||
func (Controller) GetLogin(ctx echo.Context) error {
|
||||
return ctx.String(http.StatusOK, "success")
|
||||
}
|
||||
|
||||
func New() *Controller {
|
||||
return &Controller{}
|
||||
}
|
||||
Reference in New Issue
Block a user