这是基于vue-vben-admin 模板适用于abp vNext的前端管理项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

2.6 KiB

组织单位创建

**本文档引用的文件** - [OrganizationUnitCreateDto.cs](file://aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application.Contracts/LINGYUN/Abp/Identity/Dto/OrganizationUnitCreateDto.cs) - [OrganizationUnitAppService.cs](file://aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application/LINGYUN/Abp/Identity/OrganizationUnitAppService.cs) - [OrganizationUnitDto.cs](file://aspnet-core/modules/identity/LINGYUN.Abp.Identity.Application.Contracts/LINGYUN/Abp/Identity/Dto/OrganizationUnitDto.cs)

目录

  1. 简介
  2. 核心组件
  3. 创建逻辑实现
  4. 属性业务规则与数据验证
  5. 树形结构完整性维护
  6. API调用示例
  7. 领域事件与后续处理
  8. 自定义扩展指导

简介

本文档详细说明了组织单位创建功能的实现机制。组织单位是系统中用于管理用户和权限的树形结构实体,支持多级嵌套。创建操作通过应用服务层协调领域逻辑,确保数据一致性与业务规则的执行。

核心组件

[深入分析核心组件及其关系]

Section sources

  • OrganizationUnitAppService.cs
  • OrganizationUnitCreateDto.cs

创建逻辑实现

CreateAsync 方法是创建组织单位的核心入口,其逻辑流程如下:

  1. 参数验证: 方法接收 OrganizationUnitCreateDto 对象作为输入,该对象的 DisplayName 属性被 [Required][DynamicStringLength] 特性修饰,确保在进入方法体前已进行非空和长度验证。
  2. 实体构建: 使用输入的 DisplayNameParentId 以及当前租户ID,通过 OrganizationUnitManager 创建一个新的 OrganizationUnit 实体实例。
  3. 关联处理: 如果指定了 ParentId,则在创建过程中会自动建立与父级组织单位的关联。
  4. 层级路径生成: 在创建实体时,OrganizationUnitManager 会根据父级信息自动生成并维护 Code 字段,该字段代表了从根节点到当前节点的完整路径,用于高效查询和权限继承。
  5. 唯一性约束检查: 在 OrganizationUnitManagerCreateAsync 方法内部,会检查在同一个父级