- Added 4 entities: DefinitionEntity, AssignmentEntity, ProgressLogEntity, MilestoneNotificationEntity - Added DTOs for definitions and assignments - Added services for definitions and assignments CRUD - Added controllers with full REST API endpoints - Added GoalsModule and registered in AppModule Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
95 lines
2.5 KiB
TypeScript
95 lines
2.5 KiB
TypeScript
import {
|
|
Entity,
|
|
PrimaryGeneratedColumn,
|
|
Column,
|
|
CreateDateColumn,
|
|
UpdateDateColumn,
|
|
ManyToOne,
|
|
OneToMany,
|
|
JoinColumn,
|
|
} from 'typeorm';
|
|
import { DefinitionEntity } from './definition.entity';
|
|
import { ProgressLogEntity } from './progress-log.entity';
|
|
import { MilestoneNotificationEntity } from './milestone-notification.entity';
|
|
|
|
export enum AssigneeType {
|
|
USER = 'user',
|
|
TEAM = 'team',
|
|
TENANT = 'tenant',
|
|
}
|
|
|
|
export enum AssignmentStatus {
|
|
ACTIVE = 'active',
|
|
ACHIEVED = 'achieved',
|
|
FAILED = 'failed',
|
|
CANCELLED = 'cancelled',
|
|
}
|
|
|
|
@Entity({ schema: 'goals', name: 'assignments' })
|
|
export class AssignmentEntity {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Column({ name: 'tenant_id', type: 'uuid' })
|
|
tenantId: string;
|
|
|
|
@Column({ name: 'definition_id', type: 'uuid' })
|
|
definitionId: string;
|
|
|
|
@Column({
|
|
name: 'assignee_type',
|
|
type: 'enum',
|
|
enum: AssigneeType,
|
|
default: AssigneeType.USER,
|
|
})
|
|
assigneeType: AssigneeType;
|
|
|
|
@Column({ name: 'user_id', type: 'uuid', nullable: true })
|
|
userId: string | null;
|
|
|
|
@Column({ name: 'team_id', type: 'uuid', nullable: true })
|
|
teamId: string | null;
|
|
|
|
@Column({ name: 'custom_target', type: 'decimal', precision: 15, scale: 2, nullable: true })
|
|
customTarget: number | null;
|
|
|
|
@Column({ name: 'current_value', type: 'decimal', precision: 15, scale: 2, default: 0 })
|
|
currentValue: number;
|
|
|
|
@Column({ name: 'progress_percentage', type: 'decimal', precision: 5, scale: 2, default: 0 })
|
|
progressPercentage: number;
|
|
|
|
@Column({ name: 'last_updated_at', type: 'timestamptz', nullable: true })
|
|
lastUpdatedAt: Date | null;
|
|
|
|
@Column({
|
|
type: 'enum',
|
|
enum: AssignmentStatus,
|
|
default: AssignmentStatus.ACTIVE,
|
|
})
|
|
status: AssignmentStatus;
|
|
|
|
@Column({ name: 'achieved_at', type: 'timestamptz', nullable: true })
|
|
achievedAt: Date | null;
|
|
|
|
@Column({ type: 'text', nullable: true })
|
|
notes: string | null;
|
|
|
|
@CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
|
|
createdAt: Date;
|
|
|
|
@UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' })
|
|
updatedAt: Date;
|
|
|
|
// Relations
|
|
@ManyToOne(() => DefinitionEntity, (definition) => definition.assignments, { onDelete: 'CASCADE' })
|
|
@JoinColumn({ name: 'definition_id' })
|
|
definition: DefinitionEntity;
|
|
|
|
@OneToMany(() => ProgressLogEntity, (log) => log.assignment)
|
|
progressLogs: ProgressLogEntity[];
|
|
|
|
@OneToMany(() => MilestoneNotificationEntity, (notification) => notification.assignment)
|
|
milestoneNotifications: MilestoneNotificationEntity[];
|
|
}
|