- 6 entities: structure, rank, node, commission, bonus, rank_history - 4 DTOs with validation - 4 services with tree operations (LTREE path queries) - 4 controllers with full CRUD - Commission calculation and rank evaluation logic - My network endpoints for user dashboard Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
import {
|
|
Entity,
|
|
PrimaryGeneratedColumn,
|
|
Column,
|
|
CreateDateColumn,
|
|
ManyToOne,
|
|
JoinColumn,
|
|
} from 'typeorm';
|
|
import { NodeEntity } from './node.entity';
|
|
import { RankEntity } from './rank.entity';
|
|
|
|
@Entity({ schema: 'mlm', name: 'rank_history' })
|
|
export class RankHistoryEntity {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Column({ name: 'tenant_id', type: 'uuid' })
|
|
tenantId: string;
|
|
|
|
@Column({ name: 'node_id', type: 'uuid' })
|
|
nodeId: string;
|
|
|
|
@Column({ name: 'rank_id', type: 'uuid' })
|
|
rankId: string;
|
|
|
|
@Column({ name: 'previous_rank_id', type: 'uuid', nullable: true })
|
|
previousRankId: string | null;
|
|
|
|
@Column({ name: 'personal_volume_at', type: 'decimal', precision: 15, scale: 2, nullable: true })
|
|
personalVolumeAt: number | null;
|
|
|
|
@Column({ name: 'group_volume_at', type: 'decimal', precision: 15, scale: 2, nullable: true })
|
|
groupVolumeAt: number | null;
|
|
|
|
@Column({ name: 'direct_referrals_at', type: 'integer', nullable: true })
|
|
directReferralsAt: number | null;
|
|
|
|
@CreateDateColumn({ name: 'achieved_at', type: 'timestamptz' })
|
|
achievedAt: Date;
|
|
|
|
// Relations
|
|
@ManyToOne(() => NodeEntity, (node) => node.rankHistory, { onDelete: 'CASCADE' })
|
|
@JoinColumn({ name: 'node_id' })
|
|
node: NodeEntity;
|
|
|
|
@ManyToOne(() => RankEntity, { onDelete: 'CASCADE' })
|
|
@JoinColumn({ name: 'rank_id' })
|
|
rank: RankEntity;
|
|
|
|
@ManyToOne(() => RankEntity, { onDelete: 'SET NULL' })
|
|
@JoinColumn({ name: 'previous_rank_id' })
|
|
previousRank: RankEntity | null;
|
|
}
|