order.ts 751 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import {
  2. Column,
  3. CreateDateColumn,
  4. Entity,
  5. ManyToOne,
  6. PrimaryGeneratedColumn,
  7. UpdateDateColumn,
  8. } from 'typeorm';
  9. import { Installation } from './installation';
  10. @Entity()
  11. export class Order {
  12. @PrimaryGeneratedColumn()
  13. readonly id: number;
  14. @CreateDateColumn()
  15. readonly createdAt: Date;
  16. @UpdateDateColumn()
  17. readonly updatedAt: Date;
  18. @ManyToOne(() => Installation)
  19. readonly installation: Installation;
  20. @Column({ nullable: true, default: false })
  21. isCompleted?: boolean;
  22. @Column()
  23. growiUrl: string;
  24. @Column()
  25. tokenGtoP: string;
  26. @Column()
  27. tokenPtoG: string;
  28. isExpired(): boolean {
  29. const now = Date.now();
  30. const expiredAt = this.createdAt.getTime() + 600000;
  31. return expiredAt < now;
  32. }
  33. }