Slide 10
Slide 10 text
10
コードはTypeScriptで書いていきます。
export class Employee {
constructor(
public id: number,
public name: string,
public callRecords: CallRecord[] = []
) {}
}
export class Customer {
constructor(
public id: number,
public name: string,
public callRecords: CallRecord[] = []
) {}
}
export class CallRecord {
constructor(
public id: number,
public durationMinutes: number,
public timestamp: Date,
public direction: Direction,
public status: CallStatus,
public topic: string, // 通話内容
public resolved: boolean,
public employee: Employee,
public customer: Customer,
public previousCallIntervalMinutes: number = 0 // 計算してセットす
る
) {
employee.callRecords.push(this);
customer.callRecords.push(this);
}
}
// enums.ts
export enum Direction {
INBOUND = "INBOUND",
OUTBOUND = "OUTBOUND",
}
export enum CallStatus {
COMPLETED = "COMPLETED",
NO_ANSWER = "NO_ANSWER",
}
//エントリーポイント index.ts
const emp = new Employee(1, "山田 太郎");
const cust = new Customer(1, "佐藤 花子");
// 1回目の通話(発信)
const call1 = new CallRecord(
1, 10, new Date("2025-04-01T10:00:00"),
Direction.OUTBOUND, CallStatus.COMPLETED,
"パスワードリセット",
true, emp, cust, 0
);