import {
        deleteByPrimaryKeyForAa01,
        selectByPrimaryKeyForAa01,
        insertForAa01,
        updateForAa01,
        deleteByMapForAa01,
        updateByMapForAa01,
        getOneForAa01,
        getAllForAa01,
        queryPageForAa01,
        countForAa01,
        insertBatchForAa01,
        deleteBatchForAa01,
        updateBatchForAa01,
        uploadSingleFile
} from '@/services/api_baseinfodata';

export default {
    namespace: 'baseinfodata',

    state: {
        data: {
            list: [],
            pagination: {},
        },
        selectRows: []
    },

    effects: {
            *delete_by_primarykey_for_aa01({ payload }, { call, put }) {
                const response = yield call(deleteByPrimaryKeyForAa01, payload);
                yield put({
                    type: 'deleteByPrimaryKeyForAa01',
                    payload: response,
                });

                const responsedata = yield call(queryPageForAa01, {});
                yield put({
					type: 'queryPageForAa01',
					payload: responsedata,
                });
				if (callback) callback(response);
            },
            *select_by_primarykey_for_aa01({ payload, callback }, { call, put }) {
                const response = yield call(selectByPrimaryKeyForAa01, payload);
                yield put({
                    type: 'selectByPrimaryKeyForAa01',
                    payload: response,
                });

                const responsedata = yield call(queryPageForAa01, {});
                yield put({
					type: 'queryPageForAa01',
					payload: responsedata,
                });

                if (callback) callback(response);
            },
            *insert_for_aa01({ payload, callback }, { call, put }) {
                const response = yield call(insertForAa01, payload);
                yield put({
                    type: 'insertForAa01',
                    payload: response,
                });

                const responsedata = yield call(queryPageForAa01, {});
                yield put({
					type: 'queryPageForAa01',
					payload: responsedata,
                });

                if (callback) callback(response);
            },
            *update_for_aa01({ payload, callback }, { call, put }) {
                const response = yield call(updateForAa01, payload);
                yield put({
                    type: 'updateForAa01',
                    payload: response,
                });


                const responsedata = yield call(queryPageForAa01, {});
                yield put({
					type: 'queryPageForAa01',
					payload: responsedata,
                });

                if (callback) callback(response);
            },
            *delete_by_map_for_aa01({ payload, callback }, { call, put }) {
                const response = yield call(deleteByMapForAa01, payload);
                yield put({
                    type: 'deleteByMapForAa01',
                    payload: response,
                });


                const responsedata = yield call(queryPageForAa01, {});
                yield put({
					type: 'queryPageForAa01',
					payload: responsedata,
                });

                if (callback) callback(response);
            },
            *update_by_map_for_aa01({ payload, callback }, { call, put }) {
                const response = yield call(updateByMapForAa01, payload);
                yield put({
                    type: 'updateByMapForAa01',
                    payload: response,
                });


                const responsedata = yield call(queryPageForAa01, {});
                yield put({
					type: 'queryPageForAa01',
					payload: responsedata,
                });

                if (callback) callback(response);
            },
            *get_one_for_aa01({ payload, callback }, { call, put }) {
                const response = yield call(getOneForAa01, payload);
                yield put({
                    type: 'getOneForAa01',
                    payload: response,
                });


                const responsedata = yield call(queryPageForAa01, {});
                yield put({
					type: 'queryPageForAa01',
					payload: responsedata,
                });

                if (callback) callback(response);
            },
            *get_all_for_aa01({ payload, callback }, { call, put }) {
                const response = yield call(getAllForAa01, payload);
                yield put({
                    type: 'getAllForAa01',
                    payload: response,
                });

                const responsedata = yield call(queryPageForAa01, {});
                yield put({
					type: 'queryPageForAa01',
					payload: responsedata,
                });

                if (callback) callback(response);
            },
            *query_page_for_aa01({ payload, callback }, { call, put }) {
                const response = yield call(queryPageForAa01, payload);
                yield put({
                    type: 'queryPageForAa01',
                    payload: response,
                });

                if (callback) callback(response);
            },
            *count_for_aa01({ payload, callback }, { call, put }) {
                const response = yield call(countForAa01, payload);
                yield put({
                    type: 'countForAa01',
                    payload: response,
                });


                const responsedata = yield call(queryPageForAa01, {});
                yield put({
					type: 'queryPageForAa01',
					payload: responsedata,
                });

                if (callback) callback(response);
            },
            *insert_batch_for_aa01({ payload, callback }, { call, put }) {
                const response = yield call(insertBatchForAa01, payload);
                yield put({
                    type: 'insertBatchForAa01',
                    payload: response,
                });


                const responsedata = yield call(queryPageForAa01, {});
                yield put({
					type: 'queryPageForAa01',
					payload: responsedata,
                });

                if (callback) callback(response);
            },
            *delete_batch_for_aa01({ payload, callback }, { call, put }) {
                const response = yield call(deleteBatchForAa01, payload);
                yield put({
                    type: 'deleteBatchForAa01',
                    payload: response,
                });

                const responsedata = yield call(queryPageForAa01, {});
                yield put({
					type: 'queryPageForAa01',
					payload: responsedata,
                });

                if (callback) callback(response);
            },
            *update_batch_for_aa01({ payload, callback }, { call, put }) {
                const response = yield call(updateBatchForAa01, payload);
                yield put({
                    type: 'updateBatchForAa01',
                    payload: response,
                });

                const responsedata = yield call(queryPageForAa01, {});
                yield put({
					type: 'queryPageForAa01',
					payload: responsedata,
                });

                if (callback) callback(response);
            },
            *upload_single_file({ payload, callback }, { call, put }) {
                const response = yield call(uploadSingleFile, payload);
                yield put({
                    type: 'uploadSingleFile',
                    payload: response,
                });

                if (callback) callback(response);
            },
            *set_selectrow_for_a01tbaseinfo({ payload }, { put }) {
                yield put({
                    type: 'setSelectRow',
                    payload: payload,
                });
            },
		},

    reducers: {
        setSelectRow(state, action) {
            return {
                ...state,
                selectRows: action.payload,
            };
        },
        deleteByPrimaryKeyForAa01(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        selectByPrimaryKeyForAa01(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        insertForAa01(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        updateForAa01(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        deleteByMapForAa01(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        updateByMapForAa01(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        getOneForAa01(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        getAllForAa01(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        queryPageForAa01(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        countForAa01(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        insertBatchForAa01(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        deleteBatchForAa01(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
        updateBatchForAa01(state, action) {
            return {
                ...state,
                data: action.payload,
            };
        },
    },
};