This commit is contained in:
2026-01-25 09:35:01 +03:30
parent dc281c4f9a
commit 2449ac447d
8 changed files with 13 additions and 242 deletions
@@ -1,39 +0,0 @@
import { Entity, Property, ManyToOne, PrimaryKey } from '@mikro-orm/core';
import { BaseEntity } from '../../../common/entities/base.entity';
import { User } from './user.entity';
@Entity({ tableName: 'user_addresses' })
export class UserAddress extends BaseEntity {
@PrimaryKey({ type: 'bigint', autoincrement: true })
id: bigint
@ManyToOne(() => User)
user!: User;
@Property()
title!: string; // e.g., "Home", "Work", "Office"
@Property()
address!: string;
@Property()
city!: string;
@Property({ nullable: true })
province?: string;
@Property({ nullable: true })
postalCode?: string | null = null;
@Property({ type: 'float' })
latitude!: number;
@Property({ type: 'float' })
longitude!: number;
@Property({ nullable: true })
phone?: string; // Contact phone for this address
@Property({ default: false })
isDefault: boolean = false; // Whether this is the default address
}
+2 -6
View File
@@ -1,6 +1,5 @@
import { Entity, Index, Property, OneToMany, Collection, Cascade, PrimaryKey } from '@mikro-orm/core';
import { BaseEntity } from '../../../common/entities/base.entity';
import { UserAddress } from './user-address.entity';
import { Order } from 'src/modules/order/entities/order.entity';
import { normalizePhone } from '../../util/phone.util';
import { ulid } from 'ulid';
@@ -41,9 +40,6 @@ export class User extends BaseEntity {
@Property({ default: 0 })
maxCredit: number;
@OneToMany(() => UserAddress, address => address.user, {
cascade: [Cascade.ALL],
orphanRemoval: true,
})
addresses = new Collection<UserAddress>(this);
@Property({ type: 'string', nullable: true })
addresse?: string
}