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

44 lines
1.2 KiB
Go
Raw Normal View History

2022-09-26 16:13:31 +08:00
package problem
import (
2022-10-20 16:50:19 +08:00
"github.com/WHUPRJ/woj-server/internal/global"
2022-09-26 16:13:31 +08:00
"github.com/WHUPRJ/woj-server/internal/service/problem"
"github.com/WHUPRJ/woj-server/internal/service/storage"
"github.com/WHUPRJ/woj-server/internal/service/task"
2022-09-26 16:13:31 +08:00
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
var _ Handler = (*handler)(nil)
type Handler interface {
Details(c *gin.Context)
2022-09-26 16:13:31 +08:00
Search(c *gin.Context)
Update(c *gin.Context)
Upload(c *gin.Context)
2022-09-26 16:13:31 +08:00
}
type handler struct {
log *zap.Logger
jwtService global.JwtService
problemService problem.Service
taskService task.Service
storageService storage.Service
2022-09-26 16:13:31 +08:00
}
func RouteRegister(g *global.Global, group *gin.RouterGroup) {
app := &handler{
log: g.Log,
jwtService: g.Jwt,
problemService: problem.NewService(g),
taskService: task.NewService(g),
storageService: storage.NewService(g),
2022-09-26 16:13:31 +08:00
}
group.POST("/search", app.Search)
group.POST("/details", app.jwtService.Handler(false), app.Details)
group.POST("/update", app.jwtService.Handler(true), app.Update)
group.POST("/upload", app.jwtService.Handler(true), app.Upload)
group.POST("/create_version", app.jwtService.Handler(true), app.CreateVersion)
2022-09-26 16:13:31 +08:00
}