mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-03 01:33:39 +00:00
28 lines
930 B
TypeScript
28 lines
930 B
TypeScript
import { BaseEntity } from '@edr/api-common';
|
|
import { Freight } from '@edr/types';
|
|
import { Column, Entity, Index } from 'typeorm';
|
|
|
|
/**
|
|
* Which trade directions (IMPORT / EXPORT / DOMESTIC=Intercity) a backoffice
|
|
* user may see. No row, or all three directions, means unrestricted.
|
|
*/
|
|
@Entity({ schema: 'freight', name: 'user_trade_access' })
|
|
export class UserTradeAccess extends BaseEntity {
|
|
/** IAM user id (iam.users) — no FK, iam schema is externally owned. */
|
|
@Index()
|
|
@Column({ name: 'user_id', type: 'uuid', unique: true })
|
|
userId!: string;
|
|
|
|
@Column({ name: 'directions', type: 'text', default: '' })
|
|
directionsRaw!: string;
|
|
|
|
@Column({ name: 'updated_by_id', type: 'uuid', nullable: true })
|
|
updatedById!: string | null;
|
|
|
|
get directions(): Freight.ScheduleTradeDirection[] {
|
|
return this.directionsRaw
|
|
? (this.directionsRaw.split(',') as Freight.ScheduleTradeDirection[])
|
|
: [];
|
|
}
|
|
}
|