Skip to content

동적 모델

동적 모델 엔진은 Doggy 로우코드 플랫폼의 핵심으로, @Ef 애노테이션과 PHP 8 Attribute로 비즈니스 필드를 표시하여 데이터베이스 마이그레이션, API, 관리 인터페이스를 자동 생성합니다.

개요

동적 모델 시스템은 두 개의 핵심 애노테이션을 기반으로 구축됩니다:

  • Ef: 비즈니스 필드의 그룹 및 메타데이터 속성 표시
  • EfGroup: 필드 그룹 정의

애노테이션은 src/Annotation/Ef.phpsrc/Annotation/EfGroup.php에 정의됩니다:

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;
    }
}

모델 정의

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;
}

엔티티 관리

관리 백엔드 로우코드 플랫폼 → 엔티티 관리(App\Controller\Admin\Platform\EntityController)에서 엔티티를 조회하고 관리할 수 있습니다:

주요 엔티티 디렉터리

디렉터리엔티티설명
Entity/Organization/Department, Company, Corporation, Employee, Position, PositionLevel조직 구조 및 직원
Entity/Platform/Entity, EntityProperty, View, ViewField, DataGrid, Menu, DataSource로우코드 엔진
Entity/Security/PasswordPolicy, PasswordStrengthRule, PasswordResetMethod, WebauthnCredential보안 체계
Entity/Storage/File, StorageConfig, UploadSession파일 저장
Entity/System/AuditLog, Task, TaskLog, EmailConfig, EmailTemplate, EmailLog, SystemCalendarEvent인프라

CommonTrait

모든 엔티티는 CommonTrait(src/Entity/CommonTrait.php)을 통해 다음 기능을 조합합니다:

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;
}

자동 생성

모델 정의 후 EfInitEntityCommand 등의 명령이 자동 처리:

  • 데이터베이스 마이그레이션 파일 생성
  • CRUD 인터페이스 렌더링
  • 데이터 검증 규칙
  • 권한 검사

관리 백엔드

로우코드 플랫폼 → 엔티티 관리(/admin/platform/entity)로 이동하면 시각적 작업이 가능합니다:

  • 엔티티 속성 편집(EntityProperty)
  • 속성 그룹 관리(EntityPropertyGroup)
  • 원클릭 마이그레이션 생성
  • 연관 관계 설정

MIT 라이선스 오픈소스 | Copyright © 2026 Doggy