尝试引入 go-spring

This commit is contained in:
des
2026-01-21 17:44:51 +08:00
parent 35a31a6614
commit feb235e11d
9 changed files with 107 additions and 48 deletions

View 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
}

View File

@@ -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})
}
}

View 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("出错啦")
}
}

View File

@@ -0,0 +1,6 @@
package userpak
type loginParam struct {
Account string `json:"account"`
Password string `json:"password"`
}