创建读取模型和写入模型

时间:2019-01-17 13:13:26

标签: domain-driven-design cqrs

我有两个有界上下文:  -课程(BC)具有与模块,老师,学生有关的一切...  -论坛:学生可以为每个模块创建不同的线程。

当课程处于活动状态时,论坛BC创建的类别与课程(bc)具有模块的类别相同。因此,我在考虑这两个写模型之间最好的模型。

论坛(BC)

编写模型

class Forum extends AggregateRoot {
    private $id;
    private $courseId;
    private $teachers;
    private $students;
    private $modules;

    private function __construct(Id $id, CourseId $courseId) {
        $this->id = $id;
        $this->CourseId = $courseId;
    }
}

编写模型

class Forum extends AggregateRoot
{
    private $id;
    private $courseId;

    private function __construct(
        Id $id,
        CourseId $courseId
    ) {
        $this->id = $id;
        $this->CourseId = $courseId;
    }
}

读取模型

class Forum extends AggregateRoot
{
    private $id;
    private $courseId;

    private function __construct(
        Id $id,
        CourseId $courseId
    ) {
        $this->id = $id;
        $this->CourseId = $courseId;
    }
}

class Module extends AggregateRoot
{
    private $id;
    private $title;
    private $courseId;

    private function __construct(
        Id $id,
        Title $title,
        CourseId $courseId,
    ) {
        $this->id = $id;
        $this->title = $title;
        $this->courseId = $courseId;
    }
}

class Student extends AggregateRoot
{
    private $id;
    private $courseId;

    private function __construct(
        Id $id,
        CourseId $courseId,
    ) {
        $this->id = $id;
        $this->courseId = $courseId;
    }
}

我的问题是:我必须添加编写模型的老师,学生和模块吗?还是只能在读取模型中添加?我认为仅在读取模型中,因为我在写入模型中不需要它们,但是出于某些原因,我不得不将它们保留在两个模型中。

0 个答案:

没有答案