mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-28 17:50:56 +01:00
28 lines
915 B
Go
28 lines
915 B
Go
import { Store } from 'vuex';
|
|
|
|
export const getDefaultService = <T>(
|
|
ns: string,
|
|
store: Store<RootStoreState>
|
|
): Services<T> => {
|
|
const { dispatch } = store;
|
|
|
|
return {
|
|
getById: (id: string) => dispatch(`${ns}/getById`, id),
|
|
create: (form: T) => dispatch(`${ns}/create`, form),
|
|
updateById: (id: string, form: T) =>
|
|
dispatch(`${ns}/updateById`, { id, form }),
|
|
deleteById: (id: string) => dispatch(`${ns}/deleteById`, id),
|
|
getList: (params?: ListRequestParams) => {
|
|
if (params) {
|
|
return dispatch(`${ns}/getListWithParams`, params);
|
|
} else {
|
|
return dispatch(`${ns}/getList`);
|
|
}
|
|
},
|
|
createList: (data: T[]) => dispatch(`${ns}/createList`, data),
|
|
updateList: (ids: string[], data: T, fields: string[]) =>
|
|
dispatch(`${ns}/updateList`, { ids, data, fields }),
|
|
deleteList: (ids: string[]) => dispatch(`${ns}/deleteList`, ids),
|
|
};
|
|
};
|