Skip to content

组织架构

Doggy 提供完整的企业组织架构管理能力,基于 Gedmo Nested Set 实现树形结构,支持多公司、多部门、岗位编制。

实体模型

组织架构相关实体位于 src/Entity/Organization/

实体表名说明
Corporation集团/企业集团
Company公司
Departmentorg_department部门(Gedmo NestedTree)
Position岗位
PositionLevel职级
Employee员工(同时也是系统用户)

部门管理

部门使用 Gedmo NestedTree 实现无限层级树形结构(src/Entity/Organization/Department.php):

php
#[ORM\Entity]
#[ORM\Table(name: 'org_department')]
#[Gedmo\Tree(type: 'nested')]
class Department implements GedmoNode
{
    use CommonTrait;

    #[ORM\Id]
    #[ORM\Column(type: 'uuid', unique: true)]
    #[ORM\GeneratedValue(strategy: 'CUSTOM')]
    #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
    private $id;

    #[ORM\Column(length: 100)]
    private string $name;

    #[ORM\Column(length: 50, nullable: true)]
    private ?string $code = null;

    #[Gedmo\TreeLeft]
    #[ORM\Column(type: 'integer')]
    private int $lft;

    #[Gedmo\TreeLevel]
    #[ORM\Column(type: 'integer')]
    private int $lvl;

    #[Gedmo\TreeRight]
    #[ORM\Column(type: 'integer')]
    private int $rgt;

    #[Gedmo\TreeRoot]
    #[ORM\Column(type: 'integer', nullable: true)]
    private ?int $root = null;

    #[Gedmo\TreeParent]
    #[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'children')]
    private ?self $parent = null;

    #[ORM\OneToMany(targetEntity: self::class, mappedBy: 'parent')]
    private Collection $children;

    /** Many-to-Many with Employee for managers */
    #[ORM\ManyToMany(targetEntity: Employee::class)]
    private Collection $manager;
}

部门属性

字段类型说明
namestring部门名称
codestring唯一编码
parentself (NestedTree)上级部门
managerManyToMany(Employee)部门负责人
companyManyToOne(Company)所属公司
typestring部门类型
statestring启用/禁用
sortOrderinteger排序权重

管理界面

管理后台入口:App\Controller\Admin\OrgController

  • 树形结构可视化展示(templates/admin/org/department.html.twig
  • 部门编辑(departmentEdit.html.twig
  • 部门树节点组件(department_node.html.twig
  • 部门选择器(department/singleSelect.html.twig

岗位管理

岗位是组织中的职位定义,与部门关联,管理入口在 templates/admin/org/position/

  • 岗位列表(index.html.twig
  • 岗位创建/编辑(create_drawer.html.twig, edit_drawer.html.twig
  • 职级管理(level_index.html.twig
  • 岗位选择器(position_modal.html.twig, position_multi_modal.html.twig

公司管理

支持多公司结构:

  • Corporation:企业集团顶层
  • Company:下属公司,通过 CommonTrait 中的 corporation/company 关联
  • 管理界面:corporation.html.twigcompanyEdit.html.twig

缓存

组织架构采用语义化缓存策略,通过 Doctrine 事件监听器自动维护缓存一致性。

基于 MIT 协议开源 | Copyright © 2026 Doggy