You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1023 B

  1. import "reflect-metadata"
  2. import { Expose, Type } from 'class-transformer'
  3. export class ExampleItem {
  4. id: number;
  5. text: string;
  6. meta: object;
  7. @Expose({ name: 'annotation_approver' })
  8. annotationApprover: boolean | null;
  9. @Expose({ name: 'comment_count' })
  10. commentCount: number;
  11. @Expose({ name: 'filename' })
  12. fileUrl: string;
  13. @Expose({ name: 'is_confirmed' })
  14. isConfirmed: boolean;
  15. @Expose({ name: 'upload_name' })
  16. filename: string;
  17. get url() {
  18. const l = this.fileUrl.indexOf('media/')
  19. const r = this.fileUrl.indexOf('media/', l + 1)
  20. return this.fileUrl.slice(0, l) + this.fileUrl.slice(r)
  21. }
  22. toObject(): Object {
  23. return {
  24. id: this.id,
  25. text: this.text,
  26. meta: this.meta,
  27. annotation_approver: this.annotationApprover,
  28. comment_count: this.commentCount
  29. }
  30. }
  31. }
  32. export class ExampleItemList {
  33. count: number;
  34. next: string | null;
  35. prev: string | null;
  36. @Type(() => ExampleItem)
  37. @Expose({ name: 'results' })
  38. items: ExampleItem[];
  39. }