woj-server/internal/api/user/handler.go

38 lines
806 B
Go
Raw Normal View History

2022-09-08 22:00:25 +08:00
package user
import (
"github.com/WHUPRJ/woj-server/internal/global"
2022-09-17 11:22:55 +08:00
"github.com/WHUPRJ/woj-server/internal/repo/model"
2022-09-08 22:00:25 +08:00
"github.com/WHUPRJ/woj-server/internal/service/user"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
var _ Handler = (*handler)(nil)
type Handler interface {
Create(c *gin.Context)
2022-09-17 11:22:55 +08:00
Login(c *gin.Context)
2022-09-08 22:00:25 +08:00
// List(c *gin.Context)
2022-09-17 11:22:55 +08:00
tokenNext(c *gin.Context, user *model.User)
2022-09-08 22:00:25 +08:00
}
type handler struct {
2022-09-17 11:22:55 +08:00
log *zap.Logger
userService user.Service
jwtService global.JwtService
2022-09-08 22:00:25 +08:00
}
func RouteRegister(g *global.Global, group *gin.RouterGroup) {
app := &handler{
2022-09-17 11:22:55 +08:00
log: g.Log,
userService: user.NewUserService(g),
jwtService: g.Jwt,
2022-09-08 22:00:25 +08:00
}
2022-09-17 11:22:55 +08:00
group.POST("/login", app.Login)
group.POST("/create", app.jwtService.Handler(), app.Create)
2022-09-08 22:00:25 +08:00
// group.GET("/", app.List)
}