实现会员模块+重构用户模块+实现会员检查gin中间件#68
Merged
Merged
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #68 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 2 +1
Lines 12 42 +30
=========================================
+ Hits 12 42 +30 ☔ View full report in Codecov by Sentry. |
Contributor
|
Signed-off-by: longyue0521 <longyueli0521@gmail.com>
Signed-off-by: longyue0521 <longyueli0521@gmail.com>
flycash
reviewed
Apr 5, 2024
Signed-off-by: longyue0521 <longyueli0521@gmail.com>
Signed-off-by: longyue0521 <longyueli0521@gmail.com>
Signed-off-by: longyue0521 <longyueli0521@gmail.com>
Signed-off-by: longyue0521 <longyueli0521@gmail.com>
Collaborator
Author
|
@flycash 请帮我看一下, 这个会员权限验证的实现方式是否可行, 思路: 将 internal/pkg/membership/validator.go 中的validator在app层面构建, 然后注入到需要会员权限检查的模块, 在模块内部使用如下方式来集成: server.POST("/case/save", ginx.S(h.Permission), ginx.S(h.validator.Membership), ginx.BS[SaveReq](h.Save))因为模块内的Private路由有时部分需要会员权限检查, 所以没有采用在初始化gin的时候使用Use注册. 我还为ginx提了一个PR ecodeclub/ginx#23 请看一下 |
Signed-off-by: longyue0521 <longyueli0521@gmail.com>
Contributor
|
这个可以进一步分化的。应该是类似这样的代码: func (h *handler) PrivateRoutes()
func (h *handler) MemberRoutes()
func (h *handler) PublicRoutes()而后在 gin 初始化里面: h1.PublicRoutes()
h2.PublicRoutes()
h1.PrivateRoutes()
h2.PublicRoutes()
h3.MemberRoutes()
h4.MemberRoutes()目前来看我们的权限控制还不是特别复杂,所以可以进一步这样分离。 而后万一在将来我们需要进一步检测权限,再来重构。 |
Contributor
|
现在的 Permission 我后面是要重构的,所以你可以不用动它,我要抽取出来作为一个 admin,启用另外一个 gin.Engine,监听不同的端口。 |
Contributor
|
会员检测这里,你只修改你现在要改的那些,后面再额外提一个合并请求上来 |
flycash
reviewed
Apr 5, 2024
Signed-off-by: longyue0521 <longyueli0521@gmail.com>
Signed-off-by: longyue0521 <longyueli0521@gmail.com>
Signed-off-by: longyue0521 <longyueli0521@gmail.com>
Signed-off-by: longyue0521 <longyueli0521@gmail.com>
Signed-off-by: longyue0521 <longyueli0521@gmail.com>
Signed-off-by: longyue0521 <longyueli0521@gmail.com>
Signed-off-by: longyue0521 <longyueli0521@gmail.com>
Signed-off-by: longyue0521 <longyueli0521@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.