MSP-3107 add accessListService
This commit is contained in:
1 parent
8a65a03a13
commit
e924ae9ad2
4 files changed
+94
-1
No files matched your search
@@ -10,6 +10,9 @@ type PathKeys =
|
||||
| 'logout'
|
||||
| 'getProfile'
|
||||
| 'getSystemTree'
|
||||
| 'getById'
|
||||
| 'setList'
|
||||
| 'setOne'
|
||||
export const apiPaths: Record<PathKeys, string> = {
|
||||
baseUrl: '/api/admin',
|
||||
baseSystemUrl: '/api/system',
|
||||
@@ -25,5 +28,9 @@ export const apiPaths: Record<PathKeys, string> = {
|
||||
// ======= PROFILE ======
|
||||
getProfile: '/api/admin/user/get_profile',
|
||||
// ======= APPLICATIONS ======
|
||||
getSystemTree: '/application/get_system_tree'
|
||||
getSystemTree: '/application/get_system_tree',
|
||||
// ======= ACCESS_LIST ======
|
||||
getById: '/access_list/get_by_id',
|
||||
setList: '/access_list/set_list',
|
||||
setOne: '/access_list/set_one'
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { createApi } from '@reduxjs/toolkit/query/react'
|
||||
|
||||
import { apiPaths } from '@constants/api/apiPaths.ts'
|
||||
|
||||
import { axiosBaseQuery } from '@utils/apiUtils.ts'
|
||||
|
||||
import {
|
||||
AccessListMethodType,
|
||||
AccessListSetListRequestType,
|
||||
AccessListSetListSetOneRequestType
|
||||
} from '@type/accessList.type.ts'
|
||||
|
||||
|
||||
const accessListApi = createApi({
|
||||
reducerPath: 'accessListApi',
|
||||
refetchOnFocus: true,
|
||||
tagTypes: ['AccessItems'],
|
||||
baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseSystemUrl }),
|
||||
endpoints: (builder) => ({
|
||||
getById: builder.query<AccessListMethodType[], { id: number }>({
|
||||
query: ({ id }) => ({ url: apiPaths.getById, data: { id } }),
|
||||
providesTags: () => ['AccessItems']
|
||||
}),
|
||||
setList: builder.mutation<AccessListMethodType[], AccessListSetListRequestType>({
|
||||
query: (data) => ({ url: apiPaths.setList, data }),
|
||||
invalidatesTags: () => ['AccessItems']
|
||||
}),
|
||||
setOne: builder.mutation<void, AccessListSetListSetOneRequestType>({
|
||||
query: (data) => ({ url: apiPaths.setOne, data }),
|
||||
invalidatesTags: () => ['AccessItems']
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
export default accessListApi
|
||||
@@ -3,6 +3,7 @@ import { theme } from 'antd'
|
||||
import { MapToken, SeedToken } from 'antd/es/theme/interface'
|
||||
import { createContext, Dispatch, SetStateAction } from 'react'
|
||||
|
||||
import accessListApi from '@services/accessListService.ts'
|
||||
import appApi from '@services/appService.ts'
|
||||
import roleApi from '@services/roleService.ts'
|
||||
|
||||
@@ -23,6 +24,7 @@ const rootReducer = combineReducers({
|
||||
profileReducer,
|
||||
[roleApi.reducerPath]: roleApi.reducer,
|
||||
[appApi.reducerPath]: appApi.reducer,
|
||||
[accessListApi.reducerPath]: accessListApi.reducer
|
||||
})
|
||||
|
||||
export const setupStore = () =>
|
||||
@@ -32,6 +34,7 @@ export const setupStore = () =>
|
||||
getDefaultMiddleware().concat(
|
||||
roleApi.middleware,
|
||||
appApi.middleware,
|
||||
accessListApi.middleware
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
export interface AccessListMethodType {
|
||||
method: string
|
||||
value: boolean
|
||||
}
|
||||
|
||||
export interface AccessListSetListRequestType {
|
||||
appId: number
|
||||
methods: AccessListMethodType[]
|
||||
removeOld?: boolean
|
||||
}
|
||||
|
||||
export interface AccessListSetListSetOneRequestType {
|
||||
appId: number
|
||||
method: string
|
||||
value: boolean
|
||||
}
|
||||
|
||||
export interface EndpointType {
|
||||
extra: Record<string, any>
|
||||
inner: boolean
|
||||
path: string
|
||||
userAuthRequired: boolean
|
||||
}
|
||||
|
||||
export type AddressType = {
|
||||
ip: string
|
||||
port: string
|
||||
}
|
||||
|
||||
export type RequiredModuleType = {
|
||||
name: string
|
||||
required: boolean
|
||||
}
|
||||
|
||||
export type RouteType = {
|
||||
address: AddressType
|
||||
endpoints: EndpointType[]
|
||||
libVersion: string
|
||||
moduleName: string
|
||||
requiredModules: RequiredModuleType[]
|
||||
version: string
|
||||
}
|
||||
|
||||
export interface RouteApiResponseType {
|
||||
originalResponse: RouteType[]
|
||||
moduleEndpoints: Record<string, EndpointType[]>
|
||||
allRouteMap: Record<string, EndpointType>
|
||||
}
|
||||
Reference in new issue
Block a user