2022-10-22 17:38:39 +08:00
|
|
|
package status
|
|
|
|
|
|
|
|
import (
|
2023-07-15 16:19:49 +08:00
|
|
|
"git.0x7f.app/WOJ/woj-server/internal/misc/log"
|
2023-07-14 21:47:11 +08:00
|
|
|
"git.0x7f.app/WOJ/woj-server/internal/service/status"
|
2023-12-22 15:19:13 +08:00
|
|
|
"git.0x7f.app/WOJ/woj-server/internal/service/submission"
|
2023-07-15 16:19:49 +08:00
|
|
|
"git.0x7f.app/WOJ/woj-server/internal/web/jwt"
|
2022-10-22 17:38:39 +08:00
|
|
|
"github.com/gin-gonic/gin"
|
2023-07-15 16:19:49 +08:00
|
|
|
"github.com/samber/do"
|
2022-10-22 17:38:39 +08:00
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ Handler = (*handler)(nil)
|
|
|
|
|
|
|
|
type Handler interface {
|
|
|
|
Query(c *gin.Context)
|
2023-12-22 15:19:13 +08:00
|
|
|
QueryBySubmissionID(c *gin.Context)
|
2022-10-22 17:38:39 +08:00
|
|
|
QueryByProblemVersion(c *gin.Context)
|
|
|
|
}
|
|
|
|
|
|
|
|
type handler struct {
|
2023-12-22 15:19:13 +08:00
|
|
|
log *zap.Logger
|
|
|
|
statusService status.Service
|
|
|
|
submissionService submission.Service
|
|
|
|
jwtService jwt.Service
|
2022-10-22 17:38:39 +08:00
|
|
|
}
|
|
|
|
|
2023-07-15 16:19:49 +08:00
|
|
|
func RouteRegister(rg *gin.RouterGroup, i *do.Injector) {
|
2022-10-22 17:38:39 +08:00
|
|
|
app := &handler{
|
2023-12-22 15:19:13 +08:00
|
|
|
log: do.MustInvoke[log.Service](i).GetLogger("api.status"),
|
|
|
|
submissionService: do.MustInvoke[submission.Service](i),
|
|
|
|
statusService: do.MustInvoke[status.Service](i),
|
|
|
|
jwtService: do.MustInvoke[jwt.Service](i),
|
2022-10-22 17:38:39 +08:00
|
|
|
}
|
|
|
|
|
2023-12-22 15:19:13 +08:00
|
|
|
rg.POST("/query", app.jwtService.Handler(true), app.Query)
|
|
|
|
rg.POST("/query/submission", app.jwtService.Handler(true), app.QueryBySubmissionID)
|
|
|
|
rg.POST("/query/version", app.jwtService.Handler(true), app.QueryByProblemVersion)
|
2022-10-22 17:38:39 +08:00
|
|
|
}
|