Meta Directive API
The meta directive system issues corresponding instructions to the function processing flow by performing bitwise AND marking on the directive fields of the request context. The system mainly includes two types of instructions: request context directives and data directives.
I. Data Directives
Most data directives are system kernel directives, which are usually not required in business development, so they are not described in detail here. The system kernel has reserved the first 20 bits.
II. Request Context Directives
Request context directives are set through the non-persistent META_BIT
attribute in the session context. The specific directives are as follows:
Bit | Directive | Directive Name | Frontend Default | Backend Default | Description | Corresponding Operations |
---|---|---|---|---|---|---|
20 | builtAction | Built-in Action | No | No | Determine if it is a platform-built server action | PamirsSession.directive().disableBuiltAction(); PamirsSession.directive().enableBuiltAction(); |
21 | unlock | Disable Optimistic Lock | No | No | The system default enables the optimistic lock for models with optimistic locks, and this directive controls its switch | PamirsSession.directive().enableOptimisticLocker(); PamirsSession.directive().disableOptimisticLocker(); |
22 | check | Data Validation | Yes | No | The system backend operations do not perform data validation by default, and it takes effect after marking | PamirsSession.directive().enableCheck(); PamirsSession.directive().disableCheck(); |
23 | defaultValue | Default Value Calculation | Yes | No | Control whether to automatically fill in default values | PamirsSession.directive().enableDefaultValue(); PamirsSession.directive().disableDefaultValue(); |
24 | extPoint | Execute Extension Points | Yes | No | Frontend requests execute extension points by default and can be marked to ignore; programmatic calls to the data manager in the backend do not execute extension points by default | PamirsSession.directive().enableExtPoint(); PamirsSession.directive().disableExtPoint(); |
25 | hook | Interception | Yes | No | Control whether to perform function call interception | PamirsSession.directive().enableHook(); PamirsSession.directive().disableHook(); |
26 | authenticate | Authentication | Yes | No | The system performs permission verification and filtering by default, and enables permission verification after marking | PamirsSession.directive().sudo(); PamirsSession.directive().disableSudo(); |
27 | ormColumn | ORM Field Alias | No | No | System directive, setting is prohibited | None |
28 | usePkStrategy | Use PK Strategy | Yes | No | Determine the persistence strategy of addition or update according to whether the PK is empty | PamirsSession.directive().enableUsePkStrategy(); PamirsSession.directive().disableUsePkStrategy(); |
29 | fromClient | Client Call | Yes | No | Determine if it is a client (frontend) call | PamirsSession.directive().enableFromClient(); PamirsSession.directive().disableFromClient(); |
30 | sync | Execute Function Synchronously | No | No | Force asynchronous execution of functions to execute synchronously (only valid for Spring Beans) | None |
31 | ignoreFunManagement | Ignore Function Management | No | No | Ignore function manager processing to avoid repeated interception of Spring calls | PamirsSession.directive().enableIgnoreFunManagement(); PamirsSession.directive().disableIgnoreFunManagement(); |
III. Meta Directive Usage Modes
(Ⅰ) Normal Mode
PamirsSession.directive().disableOptimisticLocker();
try {
// Update logic
} finally {
PamirsSession.directive().enableOptimisticLocker();
}
(Ⅱ) Batch Setting Mode
Models.directive().run(() -> { /* Add logic here */}, SystemDirectiveEnum.AUTHENTICATE);