1- import Http from './Http'
21import { isPlainObj } from '@tap/shared'
32import Cookie from '@tap/shared/src/cookie'
3+ import Http from './Http'
44
55export default class Task extends Http {
66 constructor ( ) {
@@ -16,10 +16,13 @@ export default class Task extends Http {
1616 } else if ( typeof filter === 'string' ) {
1717 queryStr = filter
1818 }
19- const qs = queryStr ? ' ?filter=' + encodeURIComponent ( queryStr ) : ''
20- return this . axios . get ( this . url + '/' + params . join ( '/' ) + qs )
19+ const qs = queryStr ? ` ?filter=${ encodeURIComponent ( queryStr ) } ` : ''
20+ return this . axios . get ( ` ${ this . url } / ${ params . join ( '/' ) } ${ qs } ` )
2121 } else if ( typeof params === 'string' ) {
22- return this . axios . get ( this . url + '/' + params , { params : filter , headers } )
22+ return this . axios . get ( `${ this . url } /${ params } ` , {
23+ params : filter ,
24+ headers,
25+ } )
2326 }
2427 params = params || { }
2528 return this . axios . get ( this . url , { params } )
@@ -31,111 +34,135 @@ export default class Task extends Http {
3134 * @returns {* }
3235 */
3336 copy ( id ) {
34- return this . axios . put ( this . url + ` /copy/${ id } `)
37+ return this . axios . put ( ` ${ this . url } /copy/${ id } `)
3538 }
3639
3740 pause ( id ) {
38- return this . axios . put ( this . url + ` /pause/${ id } `)
41+ return this . axios . put ( ` ${ this . url } /pause/${ id } `)
3942 }
4043 batchDelete ( ids ) {
41- return this . axios . delete ( this . url + `/batchDelete?taskIds=` + ids . join ( '&taskIds=' ) )
44+ return this . axios . delete (
45+ `${ this . url } /batchDelete?taskIds=${ ids . join ( '&taskIds=' ) } ` ,
46+ )
4247 }
4348 batchRenew ( ids ) {
44- return this . axios . patch ( this . url + `/batchRenew?taskIds=` + ids . join ( '&taskIds=' ) )
49+ return this . axios . patch (
50+ `${ this . url } /batchRenew?taskIds=${ ids . join ( '&taskIds=' ) } ` ,
51+ )
4552 }
4653 batchStop ( ids ) {
47- return this . axios . put ( this . url + `/batchStop?taskIds=` + ids . join ( '&taskIds=' ) )
54+ return this . axios . put (
55+ `${ this . url } /batchStop?taskIds=${ ids . join ( '&taskIds=' ) } ` ,
56+ )
4857 }
4958
5059 patchId ( id , params ) {
5160 return this . axios . patch ( `${ this . url } /${ id } ` , params )
5261 }
5362
5463 findTaskDetailById ( id ) {
55- return this . axios . get ( this . url + ' /findTaskDetailById/' + id )
64+ return this . axios . get ( ` ${ this . url } /findTaskDetailById/${ id } ` )
5665 }
5766 tranModelVersionControl ( params ) {
58- return this . axios . post ( this . url + ' /tranModelVersionControl' , params )
67+ return this . axios . post ( ` ${ this . url } /tranModelVersionControl` , params )
5968 }
6069 getId ( id , params , filter ) {
6170 if ( Array . isArray ( params ) ) {
6271 filter = typeof filter === 'object' ? JSON . stringify ( filter ) : filter
63- const qs = filter ? ' ?filter=' + encodeURIComponent ( filter ) : ''
64- return this . axios . get ( this . url + '/' + id + params . join ( '/' ) + qs )
72+ const qs = filter ? ` ?filter=${ encodeURIComponent ( filter ) } ` : ''
73+ return this . axios . get ( ` ${ this . url } / ${ id } ${ params . join ( '/' ) } ${ qs } ` )
6574 }
6675 params = params || { }
67- return this . axios . get ( this . url + '/' + id , { params } )
76+ return this . axios . get ( ` ${ this . url } / ${ id } ` , { params } )
6877 }
6978 edit ( params ) {
70- return this . axios . patch ( this . url + ' /confirm/' + params . id , params )
79+ return this . axios . patch ( ` ${ this . url } /confirm/${ params . id } ` , params )
7180 }
7281
7382 export ( ids ) {
74- const href = this . url + `/batch/load?taskId=${ ids . join ( '&taskId=' ) } &access_token=${ Cookie . get ( 'access_token' ) } `
83+ const href = `${
84+ this . url
85+ } /batch/load?taskId=${ ids . join ( '&taskId=' ) } &access_token=${ Cookie . get ( 'access_token' ) } `
7586 window . open ( href )
7687 }
7788 checkRun ( id ) {
78- return this . axios . get ( this . url + ' /checkRun/' + id )
89+ return this . axios . get ( ` ${ this . url } /checkRun/${ id } ` )
7990 }
8091
8192 batchUpdateListtags ( params ) {
8293 return this . axios . patch ( `${ this . url } /batchUpdateListtags` , params )
8394 }
8495 save ( params , config ) {
85- return this . axios . patch ( this . url + '/confirm/' + ( params . id || '' ) , params , config )
96+ return this . axios . patch (
97+ `${ this . url } /confirm${ params . id ? `/${ params . id } ` : '' } ` ,
98+ params ,
99+ config ,
100+ )
86101 }
87102
88103 saveAndStart ( params , config ) {
89- return this . axios . patch ( this . url + '/confirmStart/' + ( params . id || '' ) , params , config )
104+ return this . axios . patch (
105+ `${ this . url } /confirmStart/${ params . id || '' } ` ,
106+ params ,
107+ config ,
108+ )
90109 }
91110
92111 getMetadata ( params ) {
93- return this . axios . post ( this . url + ' /metadata' , params )
112+ return this . axios . post ( ` ${ this . url } /metadata` , params )
94113 }
95114
96115 start ( id , config ) {
97- return this . axios . put ( this . url + ` /start/${ id } `, null , config )
116+ return this . axios . put ( ` ${ this . url } /start/${ id } `, null , config )
98117 }
99118
100119 batchStart ( taskIds , config ) {
101- return this . axios . put ( this . url + `/batchStart?taskIds=` + taskIds . join ( '&taskIds=' ) , null , config )
120+ return this . axios . put (
121+ `${ this . url } /batchStart?taskIds=${ taskIds . join ( '&taskIds=' ) } ` ,
122+ null ,
123+ config ,
124+ )
102125 //return this.axios.put(this.url + `/batchStart`, qs.stringify({ taskIds }))
103126 }
104127
105128 stop ( id ) {
106- return this . axios . put ( this . url + ` /stop/${ id } `)
129+ return this . axios . put ( ` ${ this . url } /stop/${ id } `)
107130 }
108131
109132 forceStop ( id ) {
110- return this . axios . put ( this . url + ` /stop/${ id } ?force=true`)
133+ return this . axios . put ( ` ${ this . url } /stop/${ id } ?force=true`)
111134 }
112135
113136 reset ( id ) {
114- return this . axios . put ( this . url + ` /renew/${ id } `)
137+ return this . axios . put ( ` ${ this . url } /renew/${ id } `)
115138 }
116139
117140 chart ( id ) {
118141 if ( id ) {
119142 return this . axios . get ( `${ this . url } /chart?user_id=${ id } ` )
120143 } else {
121- return this . axios . get ( this . url + ' /chart' )
144+ return this . axios . get ( ` ${ this . url } /chart` )
122145 }
123146 }
124147
125148 checkName ( params = { } ) {
126- return this . axios . post ( this . url + ' /checkName' , params )
149+ return this . axios . post ( ` ${ this . url } /checkName` , params )
127150 }
128151 getNodeTableInfo ( params = { } ) {
129152 const config = { params }
130153 if ( isPlainObj ( params ) ) {
131154 Object . assign ( config , params )
132155 }
133- return this . axios . get ( this . url + ' /getNodeTableInfo' , config )
156+ return this . axios . get ( ` ${ this . url } /getNodeTableInfo` , config )
134157 }
135158
136159 //表的状态
137160 tableStatus ( connectionId , tableName ) {
138- return this . axios . get ( this . url + '/table/status?connectionId=' + connectionId + '&tableName=' + tableName )
161+ return this . axios . get (
162+ `${ this . url } /table/status?connectionId=${ connectionId } &tableName=${
163+ tableName
164+ } `,
165+ )
139166 }
140167
141168 getConsole ( params ) {
@@ -160,40 +187,47 @@ export default class Task extends Http {
160187 }
161188
162189 records ( id , params ) {
163- return this . axios . get ( this . url + ` /records/${ id } `, { params } )
190+ return this . axios . get ( ` ${ this . url } /records/${ id } `, { params } )
164191 }
165192
166193 autoInspectResultsGroupByTable ( params ) {
167- return this . axios . post ( this . url + `/auto-inspect-results-group-by-table` , params )
194+ return this . axios . post (
195+ `${ this . url } /auto-inspect-results-group-by-table` ,
196+ params ,
197+ )
168198 }
169199
170200 autoInspectResults ( taskId , params ) {
171- return this . axios . get ( this . url + `/${ taskId } /auto-inspect-results` , { params } )
201+ return this . axios . get ( `${ this . url } /${ taskId } /auto-inspect-results` , {
202+ params,
203+ } )
172204 }
173205
174206 autoInspectTotals ( params ) {
175- return this . axios . post ( this . url + ` /auto-inspect-totals`, params )
207+ return this . axios . post ( ` ${ this . url } /auto-inspect-totals`, params )
176208 }
177209
178210 getStats ( ) {
179- return this . axios . get ( this . url + ` /stats`)
211+ return this . axios . get ( ` ${ this . url } /stats`)
180212 }
181213
182214 //再次校验
183215 autoInspectAgain ( taskId , params ) {
184- return this . axios . post ( this . url + ` /${ taskId } /auto-inspect-again`, params )
216+ return this . axios . post ( ` ${ this . url } /${ taskId } /auto-inspect-again`, params )
185217 }
186218
187219 putLogSetting ( taskId , params ) {
188- return this . axios . put ( this . url + ` /logSetting/${ taskId } `, params )
220+ return this . axios . put ( ` ${ this . url } /logSetting/${ taskId } `, params )
189221 }
190222
191223 taskConsoleRelations ( params ) {
192224 return this . axios . post ( `/api/task-console/relations` , params )
193225 }
194226
195227 rename ( taskId , newName ) {
196- return this . axios . patch ( `${ this . url } /rename/${ taskId } ?newName=${ encodeURIComponent ( newName ) } ` )
228+ return this . axios . patch (
229+ `${ this . url } /rename/${ taskId } ?newName=${ encodeURIComponent ( newName ) } ` ,
230+ )
197231 }
198232
199233 getTaskByConnection ( params ) {
@@ -222,7 +256,7 @@ export default class Task extends Http {
222256 getTimeRange ( data , params ) {
223257 return this . axios . get ( `${ this . url } /calculatedTimeRange` , {
224258 data : JSON . stringify ( data ) ,
225- params
259+ params,
226260 } )
227261 }
228262
@@ -237,13 +271,13 @@ export default class Task extends Http {
237271 downloadAnalyze ( taskId , params ) {
238272 return this . axios . post ( `${ this . url } /analyze/${ taskId } ` , null , {
239273 ...params ,
240- responseType : 'blob'
274+ responseType : 'blob' ,
241275 } )
242276 }
243277
244278 refreshSchema ( taskId , params ) {
245279 return this . axios . put ( `${ this . url } /${ taskId } /re-schemas` , null , {
246- params
280+ params,
247281 } )
248282 }
249283}
0 commit comments