36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, CreateDateColumn } from 'typeorm';
|
|
import { Project } from '../projects/project.entity';
|
|
import { User } from '../users/user.entity';
|
|
import { ApiProperty } from '@nestjs/swagger';
|
|
|
|
@Entity()
|
|
export class Task {
|
|
@ApiProperty({ example: 1, description: 'Task ID' })
|
|
@PrimaryGeneratedColumn()
|
|
id: number;
|
|
|
|
@ApiProperty({ description: 'Project object' })
|
|
@ManyToOne(() => Project, (project) => project.id, { eager: true })
|
|
project: Project;
|
|
|
|
@ApiProperty({ example: 'My Task', description: 'Task title' })
|
|
@Column()
|
|
title: string;
|
|
|
|
@ApiProperty({ example: 'todo', description: 'Task status' })
|
|
@Column({ default: 'todo' })
|
|
status: string; // 'todo', 'in_progress', 'done'
|
|
|
|
@ApiProperty({ description: 'Assigned user object', required: false })
|
|
@ManyToOne(() => User, (user) => user.id, { nullable: true, eager: true })
|
|
assigned_user?: User;
|
|
|
|
@ApiProperty({ example: '2025-03-01T12:00:00Z', required: false })
|
|
@Column({ type: 'timestamp', nullable: true })
|
|
deadline?: Date;
|
|
|
|
@ApiProperty({ description: 'Date of creation' })
|
|
@CreateDateColumn()
|
|
created_at: Date;
|
|
}
|