Try to abstract the context entity.

This commit is contained in:
zicla
2018-11-29 17:34:53 +08:00
parent fcdcf6da60
commit 0d918fbb69
6 changed files with 80 additions and 52 deletions

29
rest/user_service.go Normal file
View File

@ -0,0 +1,29 @@
package rest
import (
"net/http"
)
//@Service
type UserService struct {
Bean
userDao *UserDao
}
//初始化方法
func (this *UserService) Init(context *Context) {
//手动装填本实例的Bean. 这里必须要用中间变量方可。
b := context.GetBean(this.userDao)
if b, ok := b.(*UserDao); ok {
this.userDao = b
}
}
//装载session信息如果session没有了根据cookie去装填用户信息。
//在所有的路由最初会调用这个方法
func (this *UserService) enter(writer http.ResponseWriter, request *http.Request) {
}