Selaa lähdekoodia

♻️ refactor(contracts): remove circular dependencies between entities

- remove direct import of Hetong in hetong-renew.entity.ts
- remove direct import of HetongRenew in hetong.entity.ts
- use string references for entity relationships to break circular dependencies
- temporarily set relationship properties to 'any' type to resolve type issues
yourname 4 kuukautta sitten
vanhempi
sitoutus
7bb906f561

+ 2 - 3
src/server/modules/contracts/hetong-renew.entity.ts

@@ -2,7 +2,6 @@ import { Entity, PrimaryGeneratedColumn, Column, Index, ForeignKey, ManyToOne, J
 import { Client } from '../clients/client.entity';
 
 import { z } from '@hono/zod-openapi';
-import { Hetong } from './hetong.entity';
 
 @Entity('hetong_renew')
 export class HetongRenew {
@@ -12,9 +11,9 @@ export class HetongRenew {
   @Column({ name: 'contract_id', type: 'int', unsigned: true })
   contractId!: number;
 
-  @ManyToOne(() => Hetong, hetong => hetong.renews)
+  @ManyToOne('Hetong', 'renews')
   @JoinColumn({ name: 'contract_id' })
-  contract!: Hetong;
+  contract!: any;
 
   @Column({ name: 'amount', type: 'varchar', length: 50, nullable: true })
   amount?: string;

+ 2 - 3
src/server/modules/contracts/hetong.entity.ts

@@ -1,5 +1,4 @@
 import { Entity, PrimaryGeneratedColumn, Column, Index, ForeignKey, OneToMany, ManyToOne, JoinColumn } from 'typeorm';
-import { HetongRenew } from './hetong-renew.entity';
 import { Client } from '../clients/client.entity';
 import { z } from '@hono/zod-openapi';
 
@@ -86,8 +85,8 @@ export class Hetong {
   })
   updatedAt!: Date;
   
-  @OneToMany(() => HetongRenew, renew => renew.contract)
-  renews!: HetongRenew[];
+  @OneToMany('HetongRenew', 'contract')
+  renews!: any[];
 }
 
 export const HetongSchema = z.object({