Skip to content

Commit

Permalink
[Feat] Generic Reaction Model / Entity (#8200)
Browse files Browse the repository at this point in the history
* feat: added reaction model

* feat: added reaction entity

* feat: added reaction commands and handlers

* feat: added reaction APIs

* feat: reaction migrations

* Update app.module.ts

---------

Co-authored-by: Ruslan Konviser <[email protected]>
  • Loading branch information
GloireMutaliko21 and evereq authored Sep 15, 2024
1 parent 4c0fcd9 commit b3cb9b5
Show file tree
Hide file tree
Showing 22 changed files with 651 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/contracts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export * from './pipeline.model';
export * from './product.model';
export * from './project.model';
export * from './proposal.model';
export * from './reaction.model';
export * from './recurring-expense.model';
export * from './report.model';
export * from './request-approval-employee.model';
Expand Down
19 changes: 19 additions & 0 deletions packages/contracts/src/reaction.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { IBasePerTenantAndOrganizationEntityModel, ID } from './base-entity.model';
import { IUser } from './user.model';

export interface IReaction extends IBasePerTenantAndOrganizationEntityModel {
entity: ReactionEntityEnum;
entityId: ID; // Indicate the ID of entity record reaction related to
emoji: string;
creator?: IUser;
creatorId?: ID; // The reaction's employee author ID
}

export enum ReactionEntityEnum {
Comment = 'Comment',
Task = 'Task'
}

export interface IReactionCreateInput extends Omit<IReaction, 'creatorId'> {}

export interface IReactionUpdateInput extends Pick<IReaction, 'emoji'> {}
6 changes: 4 additions & 2 deletions packages/core/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ import { FavoriteModule } from './favorite/favorite.module';
import { GlobalFavoriteModule } from './favorite/global-favorite-service.module';
import { CommentModule } from './comment/comment.module';
import { StatsModule } from './stats/stats.module'; // Global Stats Module
import { ReactionModule } from './reaction/reaction.module';

const { unleashConfig } = environment;

Expand Down Expand Up @@ -440,8 +441,9 @@ if (environment.THROTTLE_ENABLED) {
TaskEstimationModule,
FavoriteModule,
GlobalFavoriteModule,
CommentModule,
StatsModule // Global Stats Module
StatsModule, // Global Stats Module
ReactionModule,
CommentModule
],
controllers: [AppController],
providers: [
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/core/entities/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ import {
ProductVariant,
ProductVariantPrice,
ProductVariantSetting,
Reaction,
Report,
ReportCategory,
ReportOrganization,
Expand Down Expand Up @@ -245,6 +246,7 @@ export const coreEntities = [
ProductVariant,
ProductVariantPrice,
ProductVariantSetting,
Reaction,
Report,
ReportCategory,
ReportOrganization,
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/core/entities/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export * from '../../product-variant-price/product-variant-price.entity';
export * from '../../product-variant/product-variant.entity';
export * from '../../product/product-translation.entity';
export * from '../../product/product.entity';
export * from '../../reaction/reaction.entity';
export * from '../../reports/report-category.entity';
export * from '../../reports/report-organization.entity';
export * from '../../reports/report.entity';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { yellow } from 'chalk';
import { DatabaseTypeEnum } from '@gauzy/config';

export class CreateReactionTable1726231843184 implements MigrationInterface {
name = 'CreateReactionTable1726231843184';

/**
* Up Migration
*
* @param queryRunner
*/
public async up(queryRunner: QueryRunner): Promise<void> {
console.log(yellow(this.name + ' start running!'));

switch (queryRunner.connection.options.type) {
case DatabaseTypeEnum.sqlite:
case DatabaseTypeEnum.betterSqlite3:
await this.sqliteUpQueryRunner(queryRunner);
break;
case DatabaseTypeEnum.postgres:
await this.postgresUpQueryRunner(queryRunner);
break;
case DatabaseTypeEnum.mysql:
await this.mysqlUpQueryRunner(queryRunner);
break;
default:
throw Error(`Unsupported database: ${queryRunner.connection.options.type}`);
}
}

/**
* Down Migration
*
* @param queryRunner
*/
public async down(queryRunner: QueryRunner): Promise<void> {
switch (queryRunner.connection.options.type) {
case DatabaseTypeEnum.sqlite:
case DatabaseTypeEnum.betterSqlite3:
await this.sqliteDownQueryRunner(queryRunner);
break;
case DatabaseTypeEnum.postgres:
await this.postgresDownQueryRunner(queryRunner);
break;
case DatabaseTypeEnum.mysql:
await this.mysqlDownQueryRunner(queryRunner);
break;
default:
throw Error(`Unsupported database: ${queryRunner.connection.options.type}`);
}
}

/**
* PostgresDB Up Migration
*
* @param queryRunner
*/
public async postgresUpQueryRunner(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(
`CREATE TABLE "reaction" ("deletedAt" TIMESTAMP, "id" uuid NOT NULL DEFAULT gen_random_uuid(), "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "isActive" boolean DEFAULT true, "isArchived" boolean DEFAULT false, "archivedAt" TIMESTAMP, "tenantId" uuid, "organizationId" uuid, "entity" character varying NOT NULL, "entityId" character varying NOT NULL, "emoji" character varying NOT NULL, "creatorId" uuid, CONSTRAINT "PK_41fbb346da22da4df129f14b11e" PRIMARY KEY ("id"))`
);
await queryRunner.query(`CREATE INDEX "IDX_dc28f2b25544432f3d0fddbc3b" ON "reaction" ("isActive") `);
await queryRunner.query(`CREATE INDEX "IDX_910d87dc5f24fdc66b90c4b23e" ON "reaction" ("isArchived") `);
await queryRunner.query(`CREATE INDEX "IDX_f27bb1170c29785595c6ea142a" ON "reaction" ("tenantId") `);
await queryRunner.query(`CREATE INDEX "IDX_0f320e545c0e01268d5094c433" ON "reaction" ("organizationId") `);
await queryRunner.query(`CREATE INDEX "IDX_0617390fab6cec8855f601b293" ON "reaction" ("entity") `);
await queryRunner.query(`CREATE INDEX "IDX_6cbd023426eaa8c22a894ba7c3" ON "reaction" ("entityId") `);
await queryRunner.query(`CREATE INDEX "IDX_58350b19ecd6a1e287a09d36a2" ON "reaction" ("creatorId") `);
await queryRunner.query(
`ALTER TABLE "reaction" ADD CONSTRAINT "FK_f27bb1170c29785595c6ea142a8" FOREIGN KEY ("tenantId") REFERENCES "tenant"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
);
await queryRunner.query(
`ALTER TABLE "reaction" ADD CONSTRAINT "FK_0f320e545c0e01268d5094c4339" FOREIGN KEY ("organizationId") REFERENCES "organization"("id") ON DELETE CASCADE ON UPDATE CASCADE`
);
await queryRunner.query(
`ALTER TABLE "reaction" ADD CONSTRAINT "FK_58350b19ecd6a1e287a09d36a2e" FOREIGN KEY ("creatorId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
);
}

/**
* PostgresDB Down Migration
*
* @param queryRunner
*/
public async postgresDownQueryRunner(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(`ALTER TABLE "reaction" DROP CONSTRAINT "FK_58350b19ecd6a1e287a09d36a2e"`);
await queryRunner.query(`ALTER TABLE "reaction" DROP CONSTRAINT "FK_0f320e545c0e01268d5094c4339"`);
await queryRunner.query(`ALTER TABLE "reaction" DROP CONSTRAINT "FK_f27bb1170c29785595c6ea142a8"`);
await queryRunner.query(`DROP INDEX "public"."IDX_58350b19ecd6a1e287a09d36a2"`);
await queryRunner.query(`DROP INDEX "public"."IDX_6cbd023426eaa8c22a894ba7c3"`);
await queryRunner.query(`DROP INDEX "public"."IDX_0617390fab6cec8855f601b293"`);
await queryRunner.query(`DROP INDEX "public"."IDX_0f320e545c0e01268d5094c433"`);
await queryRunner.query(`DROP INDEX "public"."IDX_f27bb1170c29785595c6ea142a"`);
await queryRunner.query(`DROP INDEX "public"."IDX_910d87dc5f24fdc66b90c4b23e"`);
await queryRunner.query(`DROP INDEX "public"."IDX_dc28f2b25544432f3d0fddbc3b"`);
await queryRunner.query(`DROP TABLE "reaction"`);
}

/**
* SqliteDB and BetterSQlite3DB Up Migration
*
* @param queryRunner
*/
public async sqliteUpQueryRunner(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(
`CREATE TABLE "reaction" ("deletedAt" datetime, "id" varchar PRIMARY KEY NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "isActive" boolean DEFAULT (1), "isArchived" boolean DEFAULT (0), "archivedAt" datetime, "tenantId" varchar, "organizationId" varchar, "entity" varchar NOT NULL, "entityId" varchar NOT NULL, "emoji" varchar NOT NULL, "creatorId" varchar)`
);
await queryRunner.query(`CREATE INDEX "IDX_dc28f2b25544432f3d0fddbc3b" ON "reaction" ("isActive") `);
await queryRunner.query(`CREATE INDEX "IDX_910d87dc5f24fdc66b90c4b23e" ON "reaction" ("isArchived") `);
await queryRunner.query(`CREATE INDEX "IDX_f27bb1170c29785595c6ea142a" ON "reaction" ("tenantId") `);
await queryRunner.query(`CREATE INDEX "IDX_0f320e545c0e01268d5094c433" ON "reaction" ("organizationId") `);
await queryRunner.query(`CREATE INDEX "IDX_0617390fab6cec8855f601b293" ON "reaction" ("entity") `);
await queryRunner.query(`CREATE INDEX "IDX_6cbd023426eaa8c22a894ba7c3" ON "reaction" ("entityId") `);
await queryRunner.query(`CREATE INDEX "IDX_58350b19ecd6a1e287a09d36a2" ON "reaction" ("creatorId") `);
await queryRunner.query(`DROP INDEX "IDX_dc28f2b25544432f3d0fddbc3b"`);
await queryRunner.query(`DROP INDEX "IDX_910d87dc5f24fdc66b90c4b23e"`);
await queryRunner.query(`DROP INDEX "IDX_f27bb1170c29785595c6ea142a"`);
await queryRunner.query(`DROP INDEX "IDX_0f320e545c0e01268d5094c433"`);
await queryRunner.query(`DROP INDEX "IDX_0617390fab6cec8855f601b293"`);
await queryRunner.query(`DROP INDEX "IDX_6cbd023426eaa8c22a894ba7c3"`);
await queryRunner.query(`DROP INDEX "IDX_58350b19ecd6a1e287a09d36a2"`);
await queryRunner.query(
`CREATE TABLE "temporary_reaction" ("deletedAt" datetime, "id" varchar PRIMARY KEY NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "isActive" boolean DEFAULT (1), "isArchived" boolean DEFAULT (0), "archivedAt" datetime, "tenantId" varchar, "organizationId" varchar, "entity" varchar NOT NULL, "entityId" varchar NOT NULL, "emoji" varchar NOT NULL, "creatorId" varchar, CONSTRAINT "FK_f27bb1170c29785595c6ea142a8" FOREIGN KEY ("tenantId") REFERENCES "tenant" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_0f320e545c0e01268d5094c4339" FOREIGN KEY ("organizationId") REFERENCES "organization" ("id") ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT "FK_58350b19ecd6a1e287a09d36a2e" FOREIGN KEY ("creatorId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
);
await queryRunner.query(
`INSERT INTO "temporary_reaction"("deletedAt", "id", "createdAt", "updatedAt", "isActive", "isArchived", "archivedAt", "tenantId", "organizationId", "entity", "entityId", "emoji", "creatorId") SELECT "deletedAt", "id", "createdAt", "updatedAt", "isActive", "isArchived", "archivedAt", "tenantId", "organizationId", "entity", "entityId", "emoji", "creatorId" FROM "reaction"`
);
await queryRunner.query(`DROP TABLE "reaction"`);
await queryRunner.query(`ALTER TABLE "temporary_reaction" RENAME TO "reaction"`);
await queryRunner.query(`CREATE INDEX "IDX_dc28f2b25544432f3d0fddbc3b" ON "reaction" ("isActive") `);
await queryRunner.query(`CREATE INDEX "IDX_910d87dc5f24fdc66b90c4b23e" ON "reaction" ("isArchived") `);
await queryRunner.query(`CREATE INDEX "IDX_f27bb1170c29785595c6ea142a" ON "reaction" ("tenantId") `);
await queryRunner.query(`CREATE INDEX "IDX_0f320e545c0e01268d5094c433" ON "reaction" ("organizationId") `);
await queryRunner.query(`CREATE INDEX "IDX_0617390fab6cec8855f601b293" ON "reaction" ("entity") `);
await queryRunner.query(`CREATE INDEX "IDX_6cbd023426eaa8c22a894ba7c3" ON "reaction" ("entityId") `);
await queryRunner.query(`CREATE INDEX "IDX_58350b19ecd6a1e287a09d36a2" ON "reaction" ("creatorId") `);
}

/**
* SqliteDB and BetterSQlite3DB Down Migration
*
* @param queryRunner
*/
public async sqliteDownQueryRunner(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(`DROP INDEX "IDX_58350b19ecd6a1e287a09d36a2"`);
await queryRunner.query(`DROP INDEX "IDX_6cbd023426eaa8c22a894ba7c3"`);
await queryRunner.query(`DROP INDEX "IDX_0617390fab6cec8855f601b293"`);
await queryRunner.query(`DROP INDEX "IDX_0f320e545c0e01268d5094c433"`);
await queryRunner.query(`DROP INDEX "IDX_f27bb1170c29785595c6ea142a"`);
await queryRunner.query(`DROP INDEX "IDX_910d87dc5f24fdc66b90c4b23e"`);
await queryRunner.query(`DROP INDEX "IDX_dc28f2b25544432f3d0fddbc3b"`);
await queryRunner.query(`ALTER TABLE "reaction" RENAME TO "temporary_reaction"`);
await queryRunner.query(
`CREATE TABLE "reaction" ("deletedAt" datetime, "id" varchar PRIMARY KEY NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "isActive" boolean DEFAULT (1), "isArchived" boolean DEFAULT (0), "archivedAt" datetime, "tenantId" varchar, "organizationId" varchar, "entity" varchar NOT NULL, "entityId" varchar NOT NULL, "emoji" varchar NOT NULL, "creatorId" varchar)`
);
await queryRunner.query(
`INSERT INTO "reaction"("deletedAt", "id", "createdAt", "updatedAt", "isActive", "isArchived", "archivedAt", "tenantId", "organizationId", "entity", "entityId", "emoji", "creatorId") SELECT "deletedAt", "id", "createdAt", "updatedAt", "isActive", "isArchived", "archivedAt", "tenantId", "organizationId", "entity", "entityId", "emoji", "creatorId" FROM "temporary_reaction"`
);
await queryRunner.query(`DROP TABLE "temporary_reaction"`);
await queryRunner.query(`CREATE INDEX "IDX_58350b19ecd6a1e287a09d36a2" ON "reaction" ("creatorId") `);
await queryRunner.query(`CREATE INDEX "IDX_6cbd023426eaa8c22a894ba7c3" ON "reaction" ("entityId") `);
await queryRunner.query(`CREATE INDEX "IDX_0617390fab6cec8855f601b293" ON "reaction" ("entity") `);
await queryRunner.query(`CREATE INDEX "IDX_0f320e545c0e01268d5094c433" ON "reaction" ("organizationId") `);
await queryRunner.query(`CREATE INDEX "IDX_f27bb1170c29785595c6ea142a" ON "reaction" ("tenantId") `);
await queryRunner.query(`CREATE INDEX "IDX_910d87dc5f24fdc66b90c4b23e" ON "reaction" ("isArchived") `);
await queryRunner.query(`CREATE INDEX "IDX_dc28f2b25544432f3d0fddbc3b" ON "reaction" ("isActive") `);
await queryRunner.query(`DROP INDEX "IDX_58350b19ecd6a1e287a09d36a2"`);
await queryRunner.query(`DROP INDEX "IDX_6cbd023426eaa8c22a894ba7c3"`);
await queryRunner.query(`DROP INDEX "IDX_0617390fab6cec8855f601b293"`);
await queryRunner.query(`DROP INDEX "IDX_0f320e545c0e01268d5094c433"`);
await queryRunner.query(`DROP INDEX "IDX_f27bb1170c29785595c6ea142a"`);
await queryRunner.query(`DROP INDEX "IDX_910d87dc5f24fdc66b90c4b23e"`);
await queryRunner.query(`DROP INDEX "IDX_dc28f2b25544432f3d0fddbc3b"`);
await queryRunner.query(`DROP TABLE "reaction"`);
}

/**
* MySQL Up Migration
*
* @param queryRunner
*/
public async mysqlUpQueryRunner(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(
`CREATE TABLE \`reaction\` (\`deletedAt\` datetime(6) NULL, \`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), \`updatedAt\` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`isActive\` tinyint NULL DEFAULT 1, \`isArchived\` tinyint NULL DEFAULT 0, \`archivedAt\` datetime NULL, \`tenantId\` varchar(255) NULL, \`organizationId\` varchar(255) NULL, \`entity\` varchar(255) NOT NULL, \`entityId\` varchar(255) NOT NULL, \`emoji\` varchar(255) NOT NULL, \`creatorId\` varchar(255) NULL, INDEX \`IDX_dc28f2b25544432f3d0fddbc3b\` (\`isActive\`), INDEX \`IDX_910d87dc5f24fdc66b90c4b23e\` (\`isArchived\`), INDEX \`IDX_f27bb1170c29785595c6ea142a\` (\`tenantId\`), INDEX \`IDX_0f320e545c0e01268d5094c433\` (\`organizationId\`), INDEX \`IDX_0617390fab6cec8855f601b293\` (\`entity\`), INDEX \`IDX_6cbd023426eaa8c22a894ba7c3\` (\`entityId\`), INDEX \`IDX_58350b19ecd6a1e287a09d36a2\` (\`creatorId\`), PRIMARY KEY (\`id\`)) ENGINE=InnoDB`
);
await queryRunner.query(
`ALTER TABLE \`reaction\` ADD CONSTRAINT \`FK_f27bb1170c29785595c6ea142a8\` FOREIGN KEY (\`tenantId\`) REFERENCES \`tenant\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`
);
await queryRunner.query(
`ALTER TABLE \`reaction\` ADD CONSTRAINT \`FK_0f320e545c0e01268d5094c4339\` FOREIGN KEY (\`organizationId\`) REFERENCES \`organization\`(\`id\`) ON DELETE CASCADE ON UPDATE CASCADE`
);
await queryRunner.query(
`ALTER TABLE \`reaction\` ADD CONSTRAINT \`FK_58350b19ecd6a1e287a09d36a2e\` FOREIGN KEY (\`creatorId\`) REFERENCES \`user\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`
);
}

/**
* MySQL Down Migration
*
* @param queryRunner
*/
public async mysqlDownQueryRunner(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(`ALTER TABLE \`reaction\` DROP FOREIGN KEY \`FK_58350b19ecd6a1e287a09d36a2e\``);
await queryRunner.query(`ALTER TABLE \`reaction\` DROP FOREIGN KEY \`FK_0f320e545c0e01268d5094c4339\``);
await queryRunner.query(`ALTER TABLE \`reaction\` DROP FOREIGN KEY \`FK_f27bb1170c29785595c6ea142a8\``);
await queryRunner.query(`DROP INDEX \`IDX_58350b19ecd6a1e287a09d36a2\` ON \`reaction\``);
await queryRunner.query(`DROP INDEX \`IDX_6cbd023426eaa8c22a894ba7c3\` ON \`reaction\``);
await queryRunner.query(`DROP INDEX \`IDX_0617390fab6cec8855f601b293\` ON \`reaction\``);
await queryRunner.query(`DROP INDEX \`IDX_0f320e545c0e01268d5094c433\` ON \`reaction\``);
await queryRunner.query(`DROP INDEX \`IDX_f27bb1170c29785595c6ea142a\` ON \`reaction\``);
await queryRunner.query(`DROP INDEX \`IDX_910d87dc5f24fdc66b90c4b23e\` ON \`reaction\``);
await queryRunner.query(`DROP INDEX \`IDX_dc28f2b25544432f3d0fddbc3b\` ON \`reaction\``);
await queryRunner.query(`DROP TABLE \`reaction\``);
}
}
4 changes: 4 additions & 0 deletions packages/core/src/reaction/commands/handlers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { ReactionCreateHandler } from './reaction.create.handler';
import { ReactionUpdateHandler } from './reaction.update.handler';

export const CommandHandlers = [ReactionCreateHandler, ReactionUpdateHandler];
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { CommandHandler, ICommandHandler } from '@nestjs/cqrs';
import { ReactionService } from '../../reaction.service';
import { ReactionCreateCommand } from '../reaction.create.command';
import { IReaction } from '@gauzy/contracts';

@CommandHandler(ReactionCreateCommand)
export class ReactionCreateHandler implements ICommandHandler<ReactionCreateCommand> {
constructor(private readonly reactionService: ReactionService) {}

public async execute(command: ReactionCreateCommand): Promise<IReaction> {
const { input } = command;
return await this.reactionService.create(input);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { CommandHandler, ICommandHandler } from '@nestjs/cqrs';
import { UpdateResult } from 'typeorm';
import { ReactionService } from '../../reaction.service';
import { ReactionUpdateCommand } from '../reaction.update.command';
import { IReaction } from '@gauzy/contracts';

@CommandHandler(ReactionUpdateCommand)
export class ReactionUpdateHandler implements ICommandHandler<ReactionUpdateCommand> {
constructor(private readonly reactionService: ReactionService) {}

public async execute(command: ReactionUpdateCommand): Promise<IReaction | UpdateResult> {
const { id, input } = command;
return await this.reactionService.update(id, input);
}
}
2 changes: 2 additions & 0 deletions packages/core/src/reaction/commands/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './reaction.create.command';
export * from './reaction.update.command';
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ICommand } from '@nestjs/cqrs';
import { IReactionCreateInput } from '@gauzy/contracts';

export class ReactionCreateCommand implements ICommand {
static readonly type = '[Reaction] Create';

constructor(public readonly input: IReactionCreateInput) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ICommand } from '@nestjs/cqrs';
import { IReactionUpdateInput, ID } from '@gauzy/contracts';

export class ReactionUpdateCommand implements ICommand {
static readonly type = '[Reaction] Update';

constructor(public readonly id: ID, public readonly input: IReactionUpdateInput) {}
}
11 changes: 11 additions & 0 deletions packages/core/src/reaction/dto/create-reaction.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { IntersectionType, OmitType } from '@nestjs/swagger';
import { IReactionCreateInput } from '@gauzy/contracts';
import { TenantOrganizationBaseDTO } from './../../core/dto';
import { Reaction } from '../reaction.entity';

/**
* Create Reaction data validation request DTO
*/
export class CreateReactionDTO
extends IntersectionType(TenantOrganizationBaseDTO, OmitType(Reaction, ['creatorId']))
implements IReactionCreateInput {}
2 changes: 2 additions & 0 deletions packages/core/src/reaction/dto/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './create-reaction.dto';
export * from './update-reaction.dto';
Loading

0 comments on commit b3cb9b5

Please sign in to comment.