尝试引入 go-spring
This commit is contained in:
14
srv/internal/application/application.go
Normal file
14
srv/internal/application/application.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type Controller interface {
|
||||
RegisterRoute()
|
||||
}
|
||||
|
||||
func New() *gin.Engine {
|
||||
app := gin.Default()
|
||||
return app
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package middle
|
||||
|
||||
import (
|
||||
"Crimson-Gatekeeper/internal/common"
|
||||
"Crimson-Gatekeeper/internal/ero"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// GeneralResponse 通用的返回包装结构体。不管错误与否
|
||||
type GeneralResponse struct {
|
||||
success string
|
||||
data any
|
||||
}
|
||||
|
||||
// ResponsePackageMiddle 返回包装中间件
|
||||
func ResponsePackageMiddle(c *gin.Context) {
|
||||
c.Next()
|
||||
data := common.GetData(c)
|
||||
if data, ok := data.(ero.GeneralError); ok {
|
||||
c.JSON(200, &GeneralResponse{"false", data})
|
||||
} else {
|
||||
c.JSON(200, &GeneralResponse{"fail", data})
|
||||
}
|
||||
}
|
||||
24
srv/internal/module/userpak/controller.go
Normal file
24
srv/internal/module/userpak/controller.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package userpak
|
||||
|
||||
import (
|
||||
"Crimson-Gatekeeper/internal/query"
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type UserCtl struct {
|
||||
q *query.Query
|
||||
}
|
||||
|
||||
func NewUserCtl(q *query.Query) *UserCtl {
|
||||
return &UserCtl{q}
|
||||
}
|
||||
|
||||
func (u *UserCtl) login(ctx *gin.Context) {
|
||||
lp := loginParam{}
|
||||
err := ctx.ShouldBindBodyWithJSON(&lp)
|
||||
if err != nil {
|
||||
fmt.Println("出错啦")
|
||||
}
|
||||
}
|
||||
6
srv/internal/module/userpak/param.go
Normal file
6
srv/internal/module/userpak/param.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package userpak
|
||||
|
||||
type loginParam struct {
|
||||
Account string `json:"account"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
Reference in New Issue
Block a user