oak-domain/lib/types/Trigger.js

67 lines
1.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CHECKER_PRIORITY_MAP = exports.CHECKER_MAX_PRIORITY = exports.TRIGGER_MAX_PRIORITY = exports.TRIGGER_DEFAULT_PRIORITY = exports.TRIGGER_MIN_PRIORITY = void 0;
/* ============================================================================
* 优先级常量定义
*
* 触发器按优先级从小到大依次执行,数值越小越先执行。
* 合理设置优先级可以控制触发器的执行顺序,确保数据处理的正确性。
* ============================================================================ */
/**
* 触发器最小优先级(最先执行)
* 用于需要最早执行的触发器,如数据预处理
*/
exports.TRIGGER_MIN_PRIORITY = 1;
/**
* 触发器默认优先级
* 未指定优先级时使用此值
*/
exports.TRIGGER_DEFAULT_PRIORITY = 25;
/**
* 触发器最大优先级(在普通触发器中最后执行)
* 用于依赖其他触发器处理结果的场景
*/
exports.TRIGGER_MAX_PRIORITY = 50;
/**
* Checker检查器的最大优先级
* Checker 优先级范围是 51-99在所有普通触发器之后执行
* 这确保了数据校验在数据处理完成后进行
*/
exports.CHECKER_MAX_PRIORITY = 99;
/**
* 不同类型 Checker 的默认优先级映射
*
* 执行顺序(从先到后):
* 1. logicalData (31) - 逻辑数据检查,可修改 data 中的值
* 2. logical (33) - 纯逻辑检查
* 3. row (51) - 行级检查,检查数据库中已存在的行
* 4. relation (56) - 关系检查,检查关联数据
* 5. data (61) - 数据完整性检查
*
* @example
* // logicalData 类型可以自动填充默认值
* // logical 类型进行业务逻辑校验
* // row 类型检查当前行状态是否允许操作
*/
exports.CHECKER_PRIORITY_MAP = {
logicalData: 31,
logical: 33,
row: 51,
data: 61,
relation: 56
};
;
;
;
;
;
;
;
;
;
;
;
;
;
;