From cc80a366692b0bf3d8a1c3555338292cca99a830 Mon Sep 17 00:00:00 2001 From: Deng Ming Date: Sun, 6 Oct 2024 16:38:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E9=83=BD=E4=BD=9C=E4=B8=BA=E5=85=AC=E5=85=B1=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/cases/internal/web/case_set_handler.go | 6 ++++-- internal/project/internal/integration/project_test.go | 1 + internal/project/internal/web/handler.go | 6 +++++- internal/question/internal/web/question_set_handler.go | 6 ++++-- ioc/gin.go | 7 +++++-- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/internal/cases/internal/web/case_set_handler.go b/internal/cases/internal/web/case_set_handler.go index c0202a04..b54a831a 100644 --- a/internal/cases/internal/web/case_set_handler.go +++ b/internal/cases/internal/web/case_set_handler.go @@ -33,11 +33,13 @@ func NewCaseSetHandler( } } -func (h *CaseSetHandler) PublicRoutes(server *gin.Engine) {} +func (h *CaseSetHandler) PublicRoutes(server *gin.Engine) { + g := server.Group("/case-sets") + g.POST("/list", ginx.B[Page](h.ListCaseSets)) +} func (h *CaseSetHandler) PrivateRoutes(server *gin.Engine) { g := server.Group("/case-sets") - g.POST("/list", ginx.B[Page](h.ListCaseSets)) g.POST("/detail", ginx.BS(h.RetrieveCaseSetDetail)) g.POST("/detail/biz", ginx.BS(h.GetDetailByBiz)) } diff --git a/internal/project/internal/integration/project_test.go b/internal/project/internal/integration/project_test.go index 112a8f76..23452e2a 100644 --- a/internal/project/internal/integration/project_test.go +++ b/internal/project/internal/integration/project_test.go @@ -98,6 +98,7 @@ func (s *ProjectTestSuite) SetupSuite() { econf.Set("server", map[string]any{"contextTimeout": "10s"}) server := egin.Load("server").Build() + s.hdl.PublicRoutes(server.Engine) server.Use(func(ctx *gin.Context) { ctx.Set(session.CtxSessionKey, session.NewMemorySession(session.Claims{ Uid: 123, diff --git a/internal/project/internal/web/handler.go b/internal/project/internal/web/handler.go index 2e6935f8..c763ed1b 100644 --- a/internal/project/internal/web/handler.go +++ b/internal/project/internal/web/handler.go @@ -46,9 +46,13 @@ func NewHandler(svc service.Service, } } -func (h *Handler) PrivateRoutes(server *gin.Engine) { +func (h *Handler) PublicRoutes(server *gin.Engine) { g := server.Group("/project") g.POST("/list", ginx.B[Page](h.List)) +} + +func (h *Handler) PrivateRoutes(server *gin.Engine) { + g := server.Group("/project") g.POST("/detail", ginx.BS(h.Detail)) } diff --git a/internal/question/internal/web/question_set_handler.go b/internal/question/internal/web/question_set_handler.go index 680756ef..a07d226a 100644 --- a/internal/question/internal/web/question_set_handler.go +++ b/internal/question/internal/web/question_set_handler.go @@ -50,11 +50,13 @@ func NewQuestionSetHandler( } } -func (h *QuestionSetHandler) PublicRoutes(server *gin.Engine) {} +func (h *QuestionSetHandler) PublicRoutes(server *gin.Engine) { + g := server.Group("/question-sets") + g.POST("/list", ginx.B[Page](h.ListQuestionSets)) +} func (h *QuestionSetHandler) PrivateRoutes(server *gin.Engine) { g := server.Group("/question-sets") - g.POST("/list", ginx.B[Page](h.ListQuestionSets)) g.POST("/detail", ginx.BS(h.RetrieveQuestionSetDetail)) g.POST("/detail/biz", ginx.BS(h.GetDetailByBiz)) } diff --git a/ioc/gin.go b/ioc/gin.go index ffe8a3ce..64e024bf 100644 --- a/ioc/gin.go +++ b/ioc/gin.go @@ -123,10 +123,13 @@ func initGinxServer(sp session.Provider, res.Use(localActiveLimiterMiddleware.Build()) user.PublicRoutes(res.Engine) qh.PublicRoutes(res.Engine) + qsh.PublicRoutes(res.Engine) cosHdl.PublicRoutes(res.Engine) caseHdl.PublicRoutes(res.Engine) skillHdl.PublicRoutes(res.Engine) csHdl.PublicRoutes(res.Engine) + prjHdl.PublicRoutes(res.Engine) + // 登录校验 res.Use(session.CheckLoginMiddleware()) user.PrivateRoutes(res.Engine) @@ -141,12 +144,12 @@ func initGinxServer(sp session.Provider, creditHdl.PrivateRoutes(res.Engine) marketingHdl.PrivateRoutes(res.Engine) intrHdl.PrivateRoutes(res.Engine) - - // 权限校验 prjHdl.PrivateRoutes(res.Engine) bffHdl.PrivateRoutes(res.Engine) csHdl.PrivateRoutes(res.Engine) + // 权限校验 + // 会员校验 res.Use(checkMembershipMiddleware.Build()) qh.MemberRoutes(res.Engine)