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