Skip to content

Commit

Permalink
将列表接口都作为公共接口
Browse files Browse the repository at this point in the history
  • Loading branch information
flycash committed Oct 6, 2024
1 parent 4959c60 commit cc80a36
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
6 changes: 4 additions & 2 deletions internal/cases/internal/web/case_set_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
1 change: 1 addition & 0 deletions internal/project/internal/integration/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion internal/project/internal/web/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down
6 changes: 4 additions & 2 deletions internal/question/internal/web/question_set_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
7 changes: 5 additions & 2 deletions ioc/gin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit cc80a36

Please sign in to comment.