Skip to content

Commit 3ca94e7

Browse files
Added commands and orm annotations
1 parent 1700b75 commit 3ca94e7

File tree

86 files changed

+1771
-399
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1771
-399
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: 'Test'
22

33
on:
44
push:
5-
# pull_request:
5+
pull_request:
66

77
jobs:
88
analyse:

config/packages/doctrine.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ doctrine:
2727
dir: '%kernel.project_dir%/src/Skills/Infrastructure/Database/ORM/Aggregate'
2828
prefix: 'App\Skills\Domain\Aggregate'
2929
alias: Skills
30+
Testing:
31+
is_bundle: false
32+
type: xml
33+
dir: '%kernel.project_dir%/src/Testing/Infrastructure/Database/ORM/Aggregate'
34+
prefix: 'App\Testing\Domain\Aggregate'
35+
alias: Testing
3036

3137
#when@test:
3238
# doctrine:

deptrac-modules.yaml

-6
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ parameters:
99
collectors:
1010
- type: directory
1111
regex: /src/Shared/.*
12-
- name: Company
13-
collectors:
14-
- type: directory
15-
regex: /src/Company/.*
1612
- name: Skills
1713
collectors:
1814
- type: directory
@@ -26,8 +22,6 @@ parameters:
2622
- type: directory
2723
regex: /src/Users/.*
2824
ruleset:
29-
Company:
30-
- Shared
3125
Skills:
3226
- Shared
3327
Testing:

src/Company/Domain/Entity/Company/Company.php

-25
This file was deleted.

src/Company/Domain/Entity/Company/ContactPerson.php

-22
This file was deleted.

src/Shared/Domain/Entity/Aggregate.php

-33
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Shared\Infrastructure\Database\Migrations;
6+
7+
use Doctrine\DBAL\Schema\Schema;
8+
use Doctrine\Migrations\AbstractMigration;
9+
10+
/**
11+
* Auto-generated Migration: Please modify to your needs!
12+
*/
13+
final class Version20231114004337 extends AbstractMigration
14+
{
15+
public function getDescription(): string
16+
{
17+
return '';
18+
}
19+
20+
public function up(Schema $schema): void
21+
{
22+
// this up() migration is auto-generated, please modify it to your needs
23+
$this->addSql('CREATE TABLE testing_answer_option (id VARCHAR(26) NOT NULL, question_id VARCHAR(26) DEFAULT NULL, description VARCHAR(255) NOT NULL, correct BOOLEAN NOT NULL, PRIMARY KEY(id))');
24+
$this->addSql('CREATE INDEX IDX_62DD1EDE1E27F6BF ON testing_answer_option (question_id)');
25+
$this->addSql('CREATE TABLE testing_question (id VARCHAR(26) NOT NULL, test_id VARCHAR(26) DEFAULT NULL, name VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, position_number INT DEFAULT NULL, published BOOLEAN NOT NULL, type VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
26+
$this->addSql('CREATE INDEX IDX_804A23011E5D0459 ON testing_question (test_id)');
27+
$this->addSql('CREATE TABLE testing_test (id VARCHAR(26) NOT NULL, owner_id VARCHAR(26) NOT NULL, name VARCHAR(255) NOT NULL, description VARCHAR(255) NOT NULL, correct_answers_percentage INT DEFAULT 0 NOT NULL, published BOOLEAN NOT NULL, skill_id VARCHAR(26) DEFAULT NULL, difficulty_level VARCHAR(255) NOT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, deleted_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
28+
$this->addSql('CREATE UNIQUE INDEX UNIQ_8F8FA01C5E237E06 ON testing_test (name)');
29+
$this->addSql('COMMENT ON COLUMN testing_test.created_at IS \'(DC2Type:datetime_immutable)\'');
30+
$this->addSql('COMMENT ON COLUMN testing_test.updated_at IS \'(DC2Type:datetime_immutable)\'');
31+
$this->addSql('COMMENT ON COLUMN testing_test.deleted_at IS \'(DC2Type:datetime_immutable)\'');
32+
$this->addSql('CREATE TABLE testing_testing_session (id VARCHAR(26) NOT NULL, test_id VARCHAR(26) DEFAULT NULL, user_id VARCHAR(26) NOT NULL, correct_answers_percentage INT DEFAULT 0 NOT NULL, is_passed_successfully BOOLEAN NOT NULL, started_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, completed_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id))');
33+
$this->addSql('CREATE INDEX IDX_485F2E0A1E5D0459 ON testing_testing_session (test_id)');
34+
$this->addSql('COMMENT ON COLUMN testing_testing_session.started_at IS \'(DC2Type:datetime_immutable)\'');
35+
$this->addSql('COMMENT ON COLUMN testing_testing_session.completed_at IS \'(DC2Type:datetime_immutable)\'');
36+
$this->addSql('CREATE TABLE testing_user_answer (id VARCHAR(26) NOT NULL, testing_session_id VARCHAR(26) DEFAULT NULL, question_id VARCHAR(26) DEFAULT NULL, answered_options TEXT DEFAULT \'[]\' NOT NULL, PRIMARY KEY(id))');
37+
$this->addSql('CREATE INDEX IDX_EE8BD7CFBBB901EE ON testing_user_answer (testing_session_id)');
38+
$this->addSql('CREATE INDEX IDX_EE8BD7CF1E27F6BF ON testing_user_answer (question_id)');
39+
$this->addSql('COMMENT ON COLUMN testing_user_answer.answered_options IS \'(DC2Type:array)\'');
40+
$this->addSql('ALTER TABLE testing_answer_option ADD CONSTRAINT FK_62DD1EDE1E27F6BF FOREIGN KEY (question_id) REFERENCES testing_question (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
41+
$this->addSql('ALTER TABLE testing_question ADD CONSTRAINT FK_804A23011E5D0459 FOREIGN KEY (test_id) REFERENCES testing_test (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
42+
$this->addSql('ALTER TABLE testing_testing_session ADD CONSTRAINT FK_485F2E0A1E5D0459 FOREIGN KEY (test_id) REFERENCES testing_test (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
43+
$this->addSql('ALTER TABLE testing_user_answer ADD CONSTRAINT FK_EE8BD7CFBBB901EE FOREIGN KEY (testing_session_id) REFERENCES testing_testing_session (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
44+
$this->addSql('ALTER TABLE testing_user_answer ADD CONSTRAINT FK_EE8BD7CF1E27F6BF FOREIGN KEY (question_id) REFERENCES testing_question (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
45+
}
46+
47+
public function down(Schema $schema): void
48+
{
49+
// this down() migration is auto-generated, please modify it to your needs
50+
$this->addSql('CREATE SCHEMA public');
51+
$this->addSql('ALTER TABLE testing_answer_option DROP CONSTRAINT FK_62DD1EDE1E27F6BF');
52+
$this->addSql('ALTER TABLE testing_question DROP CONSTRAINT FK_804A23011E5D0459');
53+
$this->addSql('ALTER TABLE testing_testing_session DROP CONSTRAINT FK_485F2E0A1E5D0459');
54+
$this->addSql('ALTER TABLE testing_user_answer DROP CONSTRAINT FK_EE8BD7CFBBB901EE');
55+
$this->addSql('ALTER TABLE testing_user_answer DROP CONSTRAINT FK_EE8BD7CF1E27F6BF');
56+
$this->addSql('DROP TABLE testing_answer_option');
57+
$this->addSql('DROP TABLE testing_question');
58+
$this->addSql('DROP TABLE testing_test');
59+
$this->addSql('DROP TABLE testing_testing_session');
60+
$this->addSql('DROP TABLE testing_user_answer');
61+
}
62+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Shared\Infrastructure\Database\Migrations;
6+
7+
use Doctrine\DBAL\Schema\Schema;
8+
use Doctrine\Migrations\AbstractMigration;
9+
10+
/**
11+
* Auto-generated Migration: Please modify to your needs!
12+
*/
13+
final class Version20231114221513 extends AbstractMigration
14+
{
15+
public function getDescription(): string
16+
{
17+
return '';
18+
}
19+
20+
public function up(Schema $schema): void
21+
{
22+
// this up() migration is auto-generated, please modify it to your needs
23+
$this->addSql('ALTER TABLE testing_testing_session ALTER is_passed_successfully DROP NOT NULL');
24+
}
25+
26+
public function down(Schema $schema): void
27+
{
28+
// this down() migration is auto-generated, please modify it to your needs
29+
$this->addSql('CREATE SCHEMA public');
30+
$this->addSql('ALTER TABLE testing_testing_session ALTER is_passed_successfully SET NOT NULL');
31+
}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Shared\Infrastructure\Database\Migrations;
6+
7+
use Doctrine\DBAL\Schema\Schema;
8+
use Doctrine\Migrations\AbstractMigration;
9+
10+
/**
11+
* Auto-generated Migration: Please modify to your needs!
12+
*/
13+
final class Version20231114224929 extends AbstractMigration
14+
{
15+
public function getDescription(): string
16+
{
17+
return '';
18+
}
19+
20+
public function up(Schema $schema): void
21+
{
22+
// this up() migration is auto-generated, please modify it to your needs
23+
$this->addSql('CREATE TABLE skills_skill_confirmation (id VARCHAR(26) NOT NULL, specialist_id VARCHAR(26) DEFAULT NULL, skill_id VARCHAR(26) DEFAULT NULL, level VARCHAR(50) NOT NULL, PRIMARY KEY(id))');
24+
$this->addSql('CREATE INDEX IDX_722F1C197B100C1A ON skills_skill_confirmation (specialist_id)');
25+
$this->addSql('CREATE INDEX IDX_722F1C195585C142 ON skills_skill_confirmation (skill_id)');
26+
$this->addSql('CREATE TABLE skills_skill_confirmation_proof (id VARCHAR(26) NOT NULL, skill_confirmation_id VARCHAR(26) DEFAULT NULL, test_id VARCHAR(26) NOT NULL, PRIMARY KEY(id))');
27+
$this->addSql('CREATE INDEX IDX_5F2C86C75D6D96DB ON skills_skill_confirmation_proof (skill_confirmation_id)');
28+
$this->addSql('ALTER TABLE skills_skill_confirmation ADD CONSTRAINT FK_722F1C197B100C1A FOREIGN KEY (specialist_id) REFERENCES skills_specialist (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
29+
$this->addSql('ALTER TABLE skills_skill_confirmation ADD CONSTRAINT FK_722F1C195585C142 FOREIGN KEY (skill_id) REFERENCES skills_skill (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
30+
$this->addSql('ALTER TABLE skills_skill_confirmation_proof ADD CONSTRAINT FK_5F2C86C75D6D96DB FOREIGN KEY (skill_confirmation_id) REFERENCES skills_skill_confirmation (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
31+
}
32+
33+
public function down(Schema $schema): void
34+
{
35+
// this down() migration is auto-generated, please modify it to your needs
36+
$this->addSql('CREATE SCHEMA public');
37+
$this->addSql('ALTER TABLE skills_skill_confirmation DROP CONSTRAINT FK_722F1C197B100C1A');
38+
$this->addSql('ALTER TABLE skills_skill_confirmation DROP CONSTRAINT FK_722F1C195585C142');
39+
$this->addSql('ALTER TABLE skills_skill_confirmation_proof DROP CONSTRAINT FK_5F2C86C75D6D96DB');
40+
$this->addSql('DROP TABLE skills_skill_confirmation');
41+
$this->addSql('DROP TABLE skills_skill_confirmation_proof');
42+
}
43+
}

src/Shared/Infrastructure/Security/UserFetcher.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
use App\Shared\Domain\Security\AuthUserInterface;
88
use App\Shared\Domain\Security\UserFetcherInterface;
9+
use Symfony\Bundle\SecurityBundle\Security;
910
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
10-
use Symfony\Component\Security\Core\Security;
1111
use Webmozart\Assert\Assert;
1212

1313
readonly class UserFetcher implements UserFetcherInterface

src/Skills/Application/Private/Command/AddSkillToSpeciality/AddSkillToSpecialityCommandHandler.php

+7-18
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,12 @@
88
use App\Shared\Domain\Security\UserFetcherInterface;
99
use App\Shared\Domain\Service\AssertService;
1010
use App\Skills\Application\Shared\Service\AccessControl\SkillAccessControl;
11-
use App\Skills\Domain\Aggregate\Speciality\Level;
12-
use App\Skills\Domain\Aggregate\Speciality\SpecialitySkill;
13-
use App\Skills\Domain\Repository\SpecialitySkillRepositoryInterface;
14-
use App\Skills\Domain\Service\SkillFetcher;
15-
use App\Skills\Domain\Service\SpecialityFetcher;
16-
use Webmozart\Assert\Assert;
11+
use App\Skills\Domain\Service\SpecialitySkillOrganizer;
1712

1813
readonly class AddSkillToSpecialityCommandHandler implements CommandHandlerInterface
1914
{
2015
public function __construct(
21-
private SkillFetcher $skillFetcher,
22-
private SpecialityFetcher $specialityFetcher,
23-
private SpecialitySkillRepositoryInterface $specialitySkillRepository,
16+
private SpecialitySkillOrganizer $specialitySkillOrganizer,
2417
private SkillAccessControl $skillAccessControl,
2518
private UserFetcherInterface $userFetcher,
2619
) {
@@ -38,15 +31,11 @@ public function __invoke(AddSkillToSpecialityCommand $command): AddSkillToSpecia
3831
'Запрещено'
3932
);
4033

41-
$skill = $this->skillFetcher->getRequiredSkill($command->skillId);
42-
$speciality = $this->specialityFetcher->getRequiredSpeciality($command->specialityId);
43-
44-
$existingSpecialitySkill = $this->specialitySkillRepository
45-
->findOneBySpecialityAndSkill($speciality->getId(), $skill->getId());
46-
Assert::null($existingSpecialitySkill, 'Навык уже добавлен');
47-
48-
$specialitySkill = new SpecialitySkill($speciality, $skill, Level::from($command->level));
49-
$this->specialitySkillRepository->add($specialitySkill);
34+
$specialitySkill = $this->specialitySkillOrganizer->addSkillToSpeciality(
35+
$command->skillId,
36+
$command->specialityId,
37+
$command->level
38+
);
5039

5140
return new AddSkillToSpecialityCommandResult($specialitySkill->getId());
5241
}

src/Skills/Application/Private/Command/CreateSkill/CreateSkillCommandHandler.php

+4-13
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,23 @@
66

77
use App\Shared\Application\Command\CommandHandlerInterface;
88
use App\Shared\Domain\Security\UserFetcherInterface;
9-
use App\Skills\Domain\Factory\SkillFactory;
10-
use App\Skills\Domain\Repository\SkillGroupRepositoryInterface;
11-
use App\Skills\Domain\Repository\SkillRepositoryInterface;
12-
use Webmozart\Assert\Assert;
9+
use App\Skills\Domain\Service\SkillMaker;
1310

1411
readonly class CreateSkillCommandHandler implements CommandHandlerInterface
1512
{
1613
public function __construct(
17-
private SkillGroupRepositoryInterface $skillGroupRepository,
18-
private SkillRepositoryInterface $skillRepository,
19-
private SkillFactory $skillFactory,
14+
private SkillMaker $skillMaker,
2015
private UserFetcherInterface $userFetcher
2116
) {
2217
}
2318

2419
public function __invoke(CreateSkillCommand $command): CreateSkillCommandResult
2520
{
26-
$skillGroup = $this->skillGroupRepository->findOneById($command->skillGroupId);
27-
Assert::notNull($skillGroup, 'Группа навыков не найдена');
28-
29-
$skill = $this->skillFactory->create(
21+
$skill = $this->skillMaker->make(
3022
$command->name,
31-
$skillGroup,
23+
$command->skillGroupId,
3224
$this->userFetcher->requiredUser()->getId()
3325
);
34-
$this->skillRepository->add($skill);
3526

3627
return new CreateSkillCommandResult($skill->getId());
3728
}

src/Skills/Application/Private/Command/CreateSkillGroup/CreateSkillGroupCommandHandler.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,22 @@
66

77
use App\Shared\Application\Command\CommandHandlerInterface;
88
use App\Shared\Domain\Security\UserFetcherInterface;
9-
use App\Skills\Domain\Factory\SkillGroupFactory;
10-
use App\Skills\Domain\Repository\SkillGroupRepositoryInterface;
9+
use App\Skills\Domain\Service\SkillGroupMaker;
1110

1211
readonly class CreateSkillGroupCommandHandler implements CommandHandlerInterface
1312
{
1413
public function __construct(
15-
private SkillGroupRepositoryInterface $skillGroupRepository,
16-
private SkillGroupFactory $skillGroupFactory,
14+
private SkillGroupMaker $skillGroupMaker,
1715
private UserFetcherInterface $userFetcher
1816
) {
1917
}
2018

2119
public function __invoke(CreateSkillGroupCommand $command): CreateSkillGroupCommandResult
2220
{
23-
$skillGroup = $this->skillGroupFactory->create(
21+
$skillGroup = $this->skillGroupMaker->make(
2422
$command->name,
2523
$this->userFetcher->requiredUser()->getId()
2624
);
27-
$this->skillGroupRepository->add($skillGroup);
2825

2926
return new CreateSkillGroupCommandResult($skillGroup->getId());
3027
}

0 commit comments

Comments
 (0)