Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

11章代码问题 #9

Open
blight19 opened this issue Jan 4, 2024 · 0 comments
Open

11章代码问题 #9

blight19 opened this issue Jan 4, 2024 · 0 comments

Comments

@blight19
Copy link

blight19 commented Jan 4, 2024

	var tokenService service.TokenService
	var tokenGranter service.TokenGranter
	var tokenEnhancer service.TokenEnhancer
	var tokenStore service.TokenStore
	var userDetailsService service.UserDetailsService
	var clientDetailsService service.ClientDetailsService
	var srv service.Service


	tokenEnhancer = service.NewJwtTokenEnhancer("secret")
	tokenStore = service.NewJwtTokenStore(tokenEnhancer.(*service.JwtTokenEnhancer))
	tokenService = service.NewTokenService(tokenStore, tokenEnhancer)

这里的定义感觉不太好,
service.NewJwtTokenStore(tokenEnhancer.(*service.JwtTokenEnhancer))
这里的形参应该定义成接口,而这里声明部分使用了接口声明,
然后NewJwtTokenEnhancer以后传给接口变量,最后传给NewJwtTokenStore做实参的时候又将接口类型转换成结构体
规范写法应该在NewJwtTokenStore接收的地方就是接口
这样写让看代码的人感觉结构不清晰

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant