first commit
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package contracts
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/samber/do"
|
||||
)
|
||||
|
||||
type Controller interface {
|
||||
AuthDB() ResAuthDB
|
||||
Execute(GlobalParams) any
|
||||
ExecuteWs(WsClient, GlobalParams) error
|
||||
WsClientId(GlobalParams) WsClientID
|
||||
WsClientGroup(GlobalParams) WsClientGroup
|
||||
Call(code string, params map[string]any, category ...RouteCategory) (HttpResponse, error)
|
||||
}
|
||||
|
||||
type BaseController struct {
|
||||
User User
|
||||
Container *do.Injector
|
||||
Request *http.Request
|
||||
request *http.Request
|
||||
Route Route
|
||||
}
|
||||
|
||||
var defaultWsClientGroup WsClientGroup = "__DEFAULT__"
|
||||
var wsClientID WsClientID = 0
|
||||
|
||||
func (BaseController) AuthDB() ResAuthDB {
|
||||
return ResAuthOff
|
||||
}
|
||||
|
||||
func (BaseController) Execute(params GlobalParams) any {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (BaseController) ExecuteWs(wc WsClient, params GlobalParams) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (BaseController) WsClientId(GlobalParams) WsClientID {
|
||||
wsClientID++
|
||||
return wsClientID
|
||||
}
|
||||
|
||||
func (BaseController) WsClientGroup(GlobalParams) WsClientGroup {
|
||||
return defaultWsClientGroup
|
||||
}
|
||||
|
||||
func (this BaseController) Call(code string, params map[string]any, category ...RouteCategory) (HttpResponse, error) {
|
||||
return do.MustInvoke[Router](this.Container).Call(this.Request, code, params, category...)
|
||||
}
|
||||
Reference in New Issue
Block a user