diff --git a/base/resource.go b/base/resource.go index 7df7d10..dc38c31 100644 --- a/base/resource.go +++ b/base/resource.go @@ -434,3 +434,20 @@ func (this Resource) onUserEvent(builder *db.Builder, user contracts.User) { } }) } + +func NewVirtualResource(pRes Resource, code, name, sql string, fields []ResField) contracts.Resource { + return &Resource{ + Uuid: code, + PUuid: pRes.Uuid, + Code: code, + Name: name, + IsResVirtual: true, + Table: sql, + Namespace: pRes.Namespace, + Workspace: pRes.Workspace, + IsHistoryRecord: false, + HistoryCacheMax: 0, + Fields: fields, + Roles: nil, + } +} diff --git a/controller.go b/controller.go index 35b7dc4..9c58afb 100644 --- a/controller.go +++ b/controller.go @@ -17,18 +17,26 @@ type Controller interface { type HttpController interface { Controller + // 获取用户信息 User() User + // 获取请求信息 Request() *http.Request + // 请求处理 Execute(GlobalParams) any + // 路由信息 Route() Route + // 内部调用 Call(code string, params map[string]any, category ...RouteCategory) (HttpResponse, error) // 内部调用 // Invoke() + + // 数据库权限 + AuthDB() ResAuthDB } type WsController interface { @@ -92,6 +100,10 @@ func (HttpBaseController) Execute(params GlobalParams) any { return nil } +func (HttpBaseController) AuthDB() ResAuthDB { + return ResAuthOn +} + func (WsBaseController) ExecuteWS(params GlobalParams) error { return nil }