# `Fn_find_modleAllId` (function) > 根据sModleId获取sAllId - **Type:** FUNCTION - **Returns:** `varchar(255)` - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `p_sModelId` | `varchar(255)` | ## Body _Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE FUNCTION `Fn_find_modleAllId`'`._ ## Narrative **Business context:** Permission system, one-time initialization. This is a niche helper, not a runtime utility — it's called by exactly one routine: `sp_do_initsysjurisdiction`, which is the proc that populates the per-user permission table (`sysjurisdiction`) when an administrator runs the "initialize permissions" action on the permission-management page. The function builds the module's full ancestor-id chain so jurisdictions granted at a parent module "inherit" to descendants via a `LIKE '-{ancestor}-%'` match on the denormalized `gdsmodule.sAllId` column. **What it does:** walks `gdsmodule.sParentId` up from the input module and returns the ancestor path joined with `-`, in the shape `-{root}-{l4}-{l3}-{l2}-{l1}-{p_sModelId}`. The leading dash is intentional — it makes the column suitable for prefix matching. **Where it sits in the module tree:** not user-visible; runs only during permission initialization. Normal page loads read the already-stored `gdsmodule.sAllId` column directly. **Caveats:** - **Depth-limited to 5 ancestors.** The body unrolls the parent walk five times; modules deeper than 5 levels fall off the end and the function returns NULL (no final `RETURN` statement). - The live module tree is ≤4 levels deep today, so this hasn't bitten.