47 lines
1.4 KiB
Go
47 lines
1.4 KiB
Go
package problem
|
|
|
|
import (
|
|
"git.0x7f.app/WOJ/woj-server/internal/misc/log"
|
|
"git.0x7f.app/WOJ/woj-server/internal/service/problem"
|
|
"git.0x7f.app/WOJ/woj-server/internal/service/storage"
|
|
"git.0x7f.app/WOJ/woj-server/internal/service/task"
|
|
"git.0x7f.app/WOJ/woj-server/internal/web/jwt"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/samber/do"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
var _ Handler = (*handler)(nil)
|
|
|
|
type Handler interface {
|
|
Details(c *gin.Context)
|
|
Search(c *gin.Context)
|
|
Update(c *gin.Context)
|
|
Upload(c *gin.Context)
|
|
CreateVersion(c *gin.Context)
|
|
}
|
|
|
|
type handler struct {
|
|
log *zap.Logger
|
|
jwtService jwt.Service
|
|
problemService problem.Service
|
|
taskService task.Service
|
|
storageService storage.Service
|
|
}
|
|
|
|
func RouteRegister(rg *gin.RouterGroup, i *do.Injector) {
|
|
app := &handler{
|
|
log: do.MustInvoke[log.Service](i).GetLogger("api.problem"),
|
|
jwtService: do.MustInvoke[jwt.Service](i),
|
|
problemService: do.MustInvoke[problem.Service](i),
|
|
taskService: do.MustInvoke[task.Service](i),
|
|
storageService: do.MustInvoke[storage.Service](i),
|
|
}
|
|
|
|
rg.POST("/search", app.Search)
|
|
rg.POST("/details", app.jwtService.Handler(false), app.Details)
|
|
rg.POST("/update", app.jwtService.Handler(true), app.Update)
|
|
rg.POST("/upload", app.jwtService.Handler(true), app.Upload)
|
|
rg.POST("/create_version", app.jwtService.Handler(true), app.CreateVersion)
|
|
}
|