models.ts 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. export namespace backend {
  2. export class JobItem {
  3. code: string;
  4. site: string;
  5. channel: string;
  6. url: string;
  7. proxyServe: string;
  8. maxPages: number;
  9. threads: number;
  10. listDelay: number;
  11. trunPageDelay: number;
  12. contentDelay: number;
  13. needDownloadAttaches: boolean;
  14. static createFrom(source: any = {}) {
  15. return new JobItem(source);
  16. }
  17. constructor(source: any = {}) {
  18. if ('string' === typeof source) source = JSON.parse(source);
  19. this.code = source["code"];
  20. this.site = source["site"];
  21. this.channel = source["channel"];
  22. this.url = source["url"];
  23. this.proxyServe = source["proxyServe"];
  24. this.maxPages = source["maxPages"];
  25. this.threads = source["threads"];
  26. this.listDelay = source["listDelay"];
  27. this.trunPageDelay = source["trunPageDelay"];
  28. this.contentDelay = source["contentDelay"];
  29. this.needDownloadAttaches = source["needDownloadAttaches"];
  30. }
  31. }
  32. export class Job {
  33. code: string;
  34. name: string;
  35. items: JobItem[];
  36. proxyServe: string;
  37. maxPages: number;
  38. threads: number;
  39. listDelay: number;
  40. trunPageDelay: number;
  41. contentDelay: number;
  42. state: number;
  43. stateType: string;
  44. progress: number;
  45. needDownloadAttaches: boolean;
  46. static createFrom(source: any = {}) {
  47. return new Job(source);
  48. }
  49. constructor(source: any = {}) {
  50. if ('string' === typeof source) source = JSON.parse(source);
  51. this.code = source["code"];
  52. this.name = source["name"];
  53. this.items = this.convertValues(source["items"], JobItem);
  54. this.proxyServe = source["proxyServe"];
  55. this.maxPages = source["maxPages"];
  56. this.threads = source["threads"];
  57. this.listDelay = source["listDelay"];
  58. this.trunPageDelay = source["trunPageDelay"];
  59. this.contentDelay = source["contentDelay"];
  60. this.state = source["state"];
  61. this.stateType = source["stateType"];
  62. this.progress = source["progress"];
  63. this.needDownloadAttaches = source["needDownloadAttaches"];
  64. }
  65. convertValues(a: any, classs: any, asMap: boolean = false): any {
  66. if (!a) {
  67. return a;
  68. }
  69. if (a.slice && a.map) {
  70. return (a as any[]).map(elem => this.convertValues(elem, classs));
  71. } else if ("object" === typeof a) {
  72. if (asMap) {
  73. for (const key of Object.keys(a)) {
  74. a[key] = new classs(a[key]);
  75. }
  76. return a;
  77. }
  78. return new classs(a);
  79. }
  80. return a;
  81. }
  82. }
  83. export class AttachLink {
  84. title: string;
  85. href: string;
  86. fileName: string;
  87. fileType: string;
  88. fileSize: string;
  89. filePath: string;
  90. static createFrom(source: any = {}) {
  91. return new AttachLink(source);
  92. }
  93. constructor(source: any = {}) {
  94. if ('string' === typeof source) source = JSON.parse(source);
  95. this.title = source["title"];
  96. this.href = source["href"];
  97. this.fileName = source["fileName"];
  98. this.fileType = source["fileType"];
  99. this.fileSize = source["fileSize"];
  100. this.filePath = source["filePath"];
  101. }
  102. }
  103. export class ResultItem {
  104. no: number;
  105. site: string;
  106. channel: string;
  107. href: string;
  108. listTitle: string;
  109. listPubishTime: string;
  110. title: string;
  111. publishUnit: string;
  112. publishTime: string;
  113. content: string;
  114. contentHtml: string;
  115. attachLinks: AttachLink[];
  116. attachJson: string;
  117. static createFrom(source: any = {}) {
  118. return new ResultItem(source);
  119. }
  120. constructor(source: any = {}) {
  121. if ('string' === typeof source) source = JSON.parse(source);
  122. this.no = source["no"];
  123. this.site = source["site"];
  124. this.channel = source["channel"];
  125. this.href = source["href"];
  126. this.listTitle = source["listTitle"];
  127. this.listPubishTime = source["listPubishTime"];
  128. this.title = source["title"];
  129. this.publishUnit = source["publishUnit"];
  130. this.publishTime = source["publishTime"];
  131. this.content = source["content"];
  132. this.contentHtml = source["contentHtml"];
  133. this.attachLinks = this.convertValues(source["attachLinks"], AttachLink);
  134. this.attachJson = source["attachJson"];
  135. }
  136. convertValues(a: any, classs: any, asMap: boolean = false): any {
  137. if (!a) {
  138. return a;
  139. }
  140. if (a.slice && a.map) {
  141. return (a as any[]).map(elem => this.convertValues(elem, classs));
  142. } else if ("object" === typeof a) {
  143. if (asMap) {
  144. for (const key of Object.keys(a)) {
  145. a[key] = new classs(a[key]);
  146. }
  147. return a;
  148. }
  149. return new classs(a);
  150. }
  151. return a;
  152. }
  153. }
  154. export class SpiderConfig {
  155. site: string;
  156. channel: string;
  157. author: string;
  158. url: string;
  159. code: string;
  160. listBodyCss: string;
  161. listItemCss: string;
  162. listLinkCss: string;
  163. listPublishTimeCss: string;
  164. listNextPageCss: string;
  165. titleCss: string;
  166. publishUnitCss: string;
  167. publishTimeCss: string;
  168. contentCss: string;
  169. attachCss: string;
  170. listJs: string;
  171. contentJs: string;
  172. attachJs: string;
  173. listTrunPageJs: string;
  174. static createFrom(source: any = {}) {
  175. return new SpiderConfig(source);
  176. }
  177. constructor(source: any = {}) {
  178. if ('string' === typeof source) source = JSON.parse(source);
  179. this.site = source["site"];
  180. this.channel = source["channel"];
  181. this.author = source["author"];
  182. this.url = source["url"];
  183. this.code = source["code"];
  184. this.listBodyCss = source["listBodyCss"];
  185. this.listItemCss = source["listItemCss"];
  186. this.listLinkCss = source["listLinkCss"];
  187. this.listPublishTimeCss = source["listPublishTimeCss"];
  188. this.listNextPageCss = source["listNextPageCss"];
  189. this.titleCss = source["titleCss"];
  190. this.publishUnitCss = source["publishUnitCss"];
  191. this.publishTimeCss = source["publishTimeCss"];
  192. this.contentCss = source["contentCss"];
  193. this.attachCss = source["attachCss"];
  194. this.listJs = source["listJs"];
  195. this.contentJs = source["contentJs"];
  196. this.attachJs = source["attachJs"];
  197. this.listTrunPageJs = source["listTrunPageJs"];
  198. }
  199. }
  200. }