models.ts 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. export namespace handlers {
  2. export class ImageResult {
  3. goods_art_no: string;
  4. image_path: string;
  5. category: string;
  6. description: string;
  7. price: string;
  8. image_base64: string;
  9. static createFrom(source: any = {}) {
  10. return new ImageResult(source);
  11. }
  12. constructor(source: any = {}) {
  13. if ('string' === typeof source) source = JSON.parse(source);
  14. this.goods_art_no = source["goods_art_no"];
  15. this.image_path = source["image_path"];
  16. this.category = source["category"];
  17. this.description = source["description"];
  18. this.price = source["price"];
  19. this.image_base64 = source["image_base64"];
  20. }
  21. }
  22. export class PhotoRecordList {
  23. goods_art_no: string;
  24. action_time: string;
  25. items: string[];
  26. static createFrom(source: any = {}) {
  27. return new PhotoRecordList(source);
  28. }
  29. constructor(source: any = {}) {
  30. if ('string' === typeof source) source = JSON.parse(source);
  31. this.goods_art_no = source["goods_art_no"];
  32. this.action_time = source["action_time"];
  33. this.items = source["items"];
  34. }
  35. }
  36. export class PhotoRecordResponse {
  37. list: PhotoRecordList[];
  38. current_page: number;
  39. size: number;
  40. total_count: number;
  41. total_pages: number;
  42. has_prev: boolean;
  43. has_next: boolean;
  44. static createFrom(source: any = {}) {
  45. return new PhotoRecordResponse(source);
  46. }
  47. constructor(source: any = {}) {
  48. if ('string' === typeof source) source = JSON.parse(source);
  49. this.list = this.convertValues(source["list"], PhotoRecordList);
  50. this.current_page = source["current_page"];
  51. this.size = source["size"];
  52. this.total_count = source["total_count"];
  53. this.total_pages = source["total_pages"];
  54. this.has_prev = source["has_prev"];
  55. this.has_next = source["has_next"];
  56. }
  57. convertValues(a: any, classs: any, asMap: boolean = false): any {
  58. if (!a) {
  59. return a;
  60. }
  61. if (a.slice && a.map) {
  62. return (a as any[]).map(elem => this.convertValues(elem, classs));
  63. } else if ("object" === typeof a) {
  64. if (asMap) {
  65. for (const key of Object.keys(a)) {
  66. a[key] = new classs(a[key]);
  67. }
  68. return a;
  69. }
  70. return new classs(a);
  71. }
  72. return a;
  73. }
  74. }
  75. }