[feat] 重新梳理依赖
This commit is contained in:
@@ -3,6 +3,7 @@ package contracts
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.fsdpf.net/go/req"
|
||||
"github.com/samber/do"
|
||||
)
|
||||
|
||||
@@ -19,36 +20,36 @@ type HttpController interface {
|
||||
Controller
|
||||
|
||||
// 获取用户信息
|
||||
User() User
|
||||
User() req.User
|
||||
|
||||
// 获取请求信息
|
||||
Request() *http.Request
|
||||
|
||||
// 请求处理
|
||||
Execute(GlobalParams) any
|
||||
Execute(req.GlobalParams) any
|
||||
|
||||
// 路由信息
|
||||
Route() Route
|
||||
Route() req.Route
|
||||
|
||||
// 内部调用
|
||||
Call(code string, params map[string]any, category ...RouteCategory) (HttpResponse, error)
|
||||
Call(code string, params map[string]any, category ...req.RouteCategory) (req.HttpResponse, error)
|
||||
// 内部调用
|
||||
// Invoke()
|
||||
|
||||
// 数据库权限
|
||||
AuthDB() ResAuthDB
|
||||
AuthDB() req.ResAuthDB
|
||||
}
|
||||
|
||||
type WsController interface {
|
||||
HttpController
|
||||
// 请求处理
|
||||
ExecuteWS(GlobalParams) error
|
||||
ExecuteWS(req.GlobalParams) error
|
||||
// 获取 Ws 客户端
|
||||
WsClient() WsClient
|
||||
// 获取 Ws 标识
|
||||
WsClientId(GlobalParams) WsClientID
|
||||
WsClientId(req.GlobalParams) WsClientID
|
||||
// 获取 Ws 分组
|
||||
WsClientGroup(GlobalParams) WsClientGroup
|
||||
WsClientGroup(req.GlobalParams) WsClientGroup
|
||||
}
|
||||
|
||||
type HttpHandleController struct {
|
||||
@@ -65,27 +66,27 @@ func (this HttpHandleController) Request() *http.Request {
|
||||
return this.request
|
||||
}
|
||||
|
||||
func (this HttpHandleController) Route() Route {
|
||||
return this.Request().Context().Value(RouteCtx{Name: "Route"}).(Route)
|
||||
func (this HttpHandleController) Route() req.Route {
|
||||
return this.Request().Context().Value(req.RouteCtx{Name: "Route"}).(req.Route)
|
||||
}
|
||||
|
||||
func (this HttpHandleController) User() User {
|
||||
return this.Request().Context().Value(RouteCtx{Name: "User"}).(User)
|
||||
func (this HttpHandleController) User() req.User {
|
||||
return this.Request().Context().Value(req.RouteCtx{Name: "User"}).(req.User)
|
||||
}
|
||||
|
||||
func (this HttpHandleController) Call(code string, params map[string]any, category ...RouteCategory) (HttpResponse, error) {
|
||||
return do.MustInvoke[Router](this.Container()).Call(this.Request(), code, params, category...)
|
||||
func (this HttpHandleController) Call(code string, params map[string]any, category ...req.RouteCategory) (req.HttpResponse, error) {
|
||||
return do.MustInvoke[req.Router](this.Container()).Call(this.Request(), code, params, category...)
|
||||
}
|
||||
|
||||
func (HttpHandleController) Execute(params GlobalParams) any {
|
||||
func (HttpHandleController) Execute(params req.GlobalParams) any {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (HttpHandleController) AuthDB() ResAuthDB {
|
||||
return ResAuthOn
|
||||
func (HttpHandleController) AuthDB() req.ResAuthDB {
|
||||
return req.ResAuthOn
|
||||
}
|
||||
|
||||
func (WsHandleController) ExecuteWS(params GlobalParams) error {
|
||||
func (WsHandleController) ExecuteWS(params req.GlobalParams) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -93,12 +94,12 @@ func (this WsHandleController) WsClient() WsClient {
|
||||
return this.ws
|
||||
}
|
||||
|
||||
func (WsHandleController) WsClientId(GlobalParams) WsClientID {
|
||||
func (WsHandleController) WsClientId(req.GlobalParams) WsClientID {
|
||||
wsClientID++
|
||||
return wsClientID
|
||||
}
|
||||
|
||||
func (WsHandleController) WsClientGroup(GlobalParams) WsClientGroup {
|
||||
func (WsHandleController) WsClientGroup(req.GlobalParams) WsClientGroup {
|
||||
return defaultWsClientGroup
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user