Introductionâ
The organization capability (orgcap) is a framework-level optional capability in LinaPro that provides plugins and the host with read-only projections of organization data â such as user departments and positions â along with data-scope filtering. Plugins access the consumer interface through services.Org().
The organization capability follows a Provider + Consumer Service pattern: a dedicated provider plugin (such as linapro-org-core) implements the concrete organization logic, while consumers access it through the orgcap.Service interface without directly depending on the provider implementation. When the provider is unavailable, consumers safely degrade and return empty results.
Design Approachâ
Consumer Serviceâ
orgcap.Service is the read-only consumer interface for ordinary plugins and host core services. It provides the following capabilities:
- Availability check:
Available()determines whether the organization capability provider is available - Capability status:
Status()returns detailed activation status, including provider plugin and conflict information - User department queries: Batch or single-user department assignment lookups
- User position queries: Query positions associated with a user
Providerâ
orgcap.Provider is the interface that organization capability plugins must implement. It defines the complete read-write contract for organization data, including user-department relationships, position relationships, data-scope filtering, and organization tree projections.
Providers register a factory function through orgcap.Provide(pluginID, factory). The host lazily invokes the factory on first use of the organization capability, passing in a ProviderEnv to construct the environment.
Architectural Positionâ
The organization capability serves two key roles in the system:
- Data projection: Provides display information such as department names for user lists, sessions, and audit logs
- Data scope: Provides department-level data-scope filtering for the permission module and business data (
ScopeServiceis an internal host interface, not exposed throughcapability.Services)
Key Capabilitiesâ
Primary methods of orgcap.Service (consumer side):
| Method | Description |
|---|---|
Available | Determines whether the organization capability provider is available |
Status | Returns detailed activation status and provider information |
ListUserDeptAssignments | Batch query for user department assignment projections |
GetUserDeptInfo | Queries a single user's department identifier and name |
GetUserDeptName | Queries a single user's department name (lightweight projection) |
GetUserDeptIDs | Queries a single user's list of department identifiers |
GetUserPostIDs | Queries a single user's list of associated position identifiers |
Design Constraintsâ
- The consumer side is read-only.
orgcap.Servicedoes not include write operations. User-department and position relationship maintenance is handled through the host-internalAssignmentService, which is not exposed to ordinary plugins. - Capability is optional, with safe degradation. Plugins should check
Available()before using the organization capability. When unavailable, query methods return empty results without errors. Provideris lazily constructed. The host only invokes the factory function to construct aProviderinstance on first use of the organization capability, avoiding unnecessary capability loading at startup.ScopeServiceis not exposed to plugins. Data-scope filtering involves database query builders and is used through the host's internal interface, not exposed throughcapability.Services.
Provider Guideâ
To implement a custom organization capability plugin, you need to:
- Implement the
orgcap.Providerinterface, providing methods for user departments, positions, data scope, etc. - Register a factory function through
orgcap.Provide(pluginID, factory) - The factory function receives a
ProviderEnvcontaining host services such asPluginIDandTenantFilter
Provider plugins must register the factory in init(). The host lazily constructs the instance on first use.
Related Servicesâ
- TenantService - Tenant capability complements organization capability, together forming the multi-tenant + organization data model
- PluginStateService - Uses
IsProviderEnabledto determine whether the organization provider is available - SessionService - Department names in session projections come from the organization capability