File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change 18
18
import type { AxiosInstance } from 'axios' ;
19
19
20
20
import type { StreamRoutePostType } from '@/components/form-slice/FormPartStreamRoute/schema' ;
21
- import { API_STREAM_ROUTES } from '@/config/constant' ;
21
+ import {
22
+ API_STREAM_ROUTES ,
23
+ PAGE_SIZE_MAX ,
24
+ PAGE_SIZE_MIN ,
25
+ } from '@/config/constant' ;
22
26
import type { APISIXType } from '@/types/schema/apisix' ;
23
27
24
28
import type { WithServiceIdFilter } from './routes' ;
@@ -59,3 +63,21 @@ export const postStreamRouteReq = (
59
63
API_STREAM_ROUTES ,
60
64
data
61
65
) ;
66
+
67
+ export const deleteAllStreamRoutes = async ( req : AxiosInstance ) => {
68
+ const totalRes = await getStreamRouteListReq ( req , {
69
+ page : 1 ,
70
+ page_size : PAGE_SIZE_MIN ,
71
+ } ) ;
72
+ const total = totalRes . total ;
73
+ if ( total === 0 ) return ;
74
+ for ( let times = Math . ceil ( total / PAGE_SIZE_MAX ) ; times > 0 ; times -- ) {
75
+ const res = await getStreamRouteListReq ( req , {
76
+ page : 1 ,
77
+ page_size : PAGE_SIZE_MAX ,
78
+ } ) ;
79
+ await Promise . all (
80
+ res . list . map ( ( d ) => req . delete ( `${ API_STREAM_ROUTES } /${ d . value . id } ` ) )
81
+ ) ;
82
+ }
83
+ } ;
You can’t perform that action at this time.
0 commit comments