editable property added to deck short dto

This commit is contained in:
magdo
2025-10-26 21:27:00 +01:00
parent b75d27c7c8
commit fe8d5a53a5
4 changed files with 17 additions and 5 deletions
@@ -1,6 +1,7 @@
import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn, CreateDateColumn, UpdateDateColumn } from 'typeorm';
import { OrganizationAggregate } from '../Organization/OrganizationAggregate';
import { UserAggregate } from '../User/UserAggregate';
import { logError } from '../../Application/Services/Logger';
export enum Type {
LUCK = 0,
@@ -86,4 +87,11 @@ export class DeckAggregate {
@ManyToOne(() => UserAggregate, { eager: false })
@JoinColumn({ name: 'user_id' })
user!: UserAggregate | null;
isEditable() {
// A deck is editable if the user is the creator
return (userId: string) => {
return this.user?.id.toString() === userId;
};
}
}