Skip to content

Dynamisches Modell

Die Dynamic-Model-Engine ist der Kern der Low-Code-Plattform von Doggy. Über die @Ef-Annotation in Kombination mit PHP-8-Attributen werden Geschäftsfelder markiert, wodurch automatisch Datenbank-Migrationen, APIs und Verwaltungsoberflächen generiert werden.

Übersicht

Das Dynamic-Model-System basiert auf zwei Kern-Annotationen:

  • Ef: markiert Gruppierung und Metadaten-Attribute von Geschäftsfeldern
  • EfGroup: definiert Feldgruppen

Die Annotationen sind in src/Annotation/Ef.php und src/Annotation/EfGroup.php definiert:

php
// src/Annotation/Ef.php
class Ef
{
    public $value = [];

    public function __construct(array $data)
    {
        $this->value['group'] = $data['group'] ?? null;
        $this->value['bf'] = $data['isBF'] ?? false;
    }
}

Modell definieren

php
namespace App\Entity\Organization;

use App\Annotation\Ef;
use App\Entity\Traits\CommonTrait;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
#[ORM\Table(name: 'org_department')]
class Department
{
    use CommonTrait;

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

    #[Ef(displayName: '部门名称', required: true)]
    #[ORM\Column(length: 100)]
    private string $name;

    #[Ef(displayName: '部门编码', searchable: true)]
    #[ORM\Column(length: 50, nullable: true)]
    private ?string $code = null;
}

Entitätsverwaltung

Unter Low-Code-Plattform → Entitätsverwaltung (App\Controller\Admin\Platform\EntityController) im Verwaltungs-Backend können Entitäten eingesehen und verwaltet werden:

Wichtige Entitätsverzeichnisse

VerzeichnisEntitätenBeschreibung
Entity/Organization/Department, Company, Corporation, Employee, Position, PositionLevelOrganisationsstruktur und Mitarbeiter
Entity/Platform/Entity, EntityProperty, View, ViewField, DataGrid, Menu, DataSourceLow-Code-Engine
Entity/Security/PasswordPolicy, PasswordStrengthRule, PasswordResetMethod, WebauthnCredentialSicherheitssystem
Entity/Storage/File, StorageConfig, UploadSessionDateispeicher
Entity/System/AuditLog, Task, TaskLog, EmailConfig, EmailTemplate, EmailLog, SystemCalendarEventInfrastruktur

CommonTrait

Alle Entitäten kombinieren über CommonTrait (src/Entity/CommonTrait.php) die folgenden Fähigkeiten:

php
trait CommonTrait
{
    use SoftDeleteableEntity;    // 软删除(deletedAt 字段)
    use TimestampableEntity;     // 时间戳(createdAt, updatedAt)
    use BlameableEntity;        // 操作人(createdBy, updatedBy)

    #[ORM\ManyToOne(targetEntity: Corporation::class)]
    private $corporation;

    #[ORM\ManyToOne(targetEntity: Company::class)]
    private $company;
}

Automatische Generierung

Nach der Definition des Modells übernehmen Befehle wie EfInitEntityCommand automatisch:

  • Generierung der Datenbank-Migrationsdateien
  • Rendering der CRUD-Oberflächen
  • Datenvalidierungsregeln
  • Berechtigungsprüfungen

Verwaltungs-Backend

Unter Low-Code-Plattform → Entitätsverwaltung (/admin/platform/entity) sind visuelle Operationen möglich:

  • Bearbeitung der Entitätsattribute (EntityProperty)
  • Verwaltung von Attributgruppen (EntityPropertyGroup)
  • Migrationen mit einem Klick erzeugen
  • Konfiguration von Beziehungen

Open Source unter MIT | Copyright © 2026 Doggy