组织架构
Doggy 提供完整的企业组织架构管理能力,基于 Gedmo Nested Set 实现树形结构,支持多公司、多部门、岗位编制。
实体模型
组织架构相关实体位于 src/Entity/Organization/:
| 实体 | 表名 | 说明 |
|---|---|---|
Corporation | — | 集团/企业集团 |
Company | — | 公司 |
Department | org_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;
}部门属性
| 字段 | 类型 | 说明 |
|---|---|---|
| name | string | 部门名称 |
| code | string | 唯一编码 |
| parent | self (NestedTree) | 上级部门 |
| manager | ManyToMany(Employee) | 部门负责人 |
| company | ManyToOne(Company) | 所属公司 |
| type | string | 部门类型 |
| state | string | 启用/禁用 |
| sortOrder | integer | 排序权重 |
管理界面
管理后台入口: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.twig、companyEdit.html.twig
缓存
组织架构采用语义化缓存策略,通过 Doctrine 事件监听器自动维护缓存一致性。