admin(ui-api): add 'include' parameter to all requests
This commit is contained in:
parent
e123367f40
commit
9532ecf867
24 changed files with 48 additions and 48 deletions
|
@ -1,11 +1,11 @@
|
|||
import http from '@/api/http';
|
||||
import { Role, rawDataToRole } from '@/api/admin/roles/getRoles';
|
||||
|
||||
export default (name: string, description?: string): Promise<Role> => {
|
||||
export default (name: string, description: string | null, include: string[] = []): Promise<Role> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.post('/api/application/roles', {
|
||||
name, description,
|
||||
})
|
||||
}, { params: { include: include.join(',') } })
|
||||
.then(({ data }) => resolve(rawDataToRole(data)))
|
||||
.catch(reject);
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import http from '@/api/http';
|
||||
import { Role, rawDataToRole } from '@/api/admin/roles/getRoles';
|
||||
|
||||
export default (id: number): Promise<Role> => {
|
||||
export default (id: number, include: string[] = []): Promise<Role> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.get(`/api/application/roles/${id}`)
|
||||
http.get(`/api/application/roles/${id}`, { params: { include: include.join(',') } })
|
||||
.then(({ data }) => resolve(rawDataToRole(data)))
|
||||
.catch(reject);
|
||||
});
|
||||
|
|
|
@ -12,9 +12,9 @@ export const rawDataToRole = ({ attributes }: FractalResponseData): Role => ({
|
|||
description: attributes.description,
|
||||
});
|
||||
|
||||
export default (): Promise<Role[]> => {
|
||||
export default (include: string[] = []): Promise<Role[]> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.get('/api/application/roles')
|
||||
http.get('/api/application/roles', { params: { include: include.join(',') } })
|
||||
.then(({ data }) => resolve((data.data || []).map(rawDataToRole)))
|
||||
.catch(reject);
|
||||
});
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import http from '@/api/http';
|
||||
import { Role, rawDataToRole } from '@/api/admin/roles/getRoles';
|
||||
|
||||
export default (id: number, name: string, description?: string): Promise<Role> => {
|
||||
export default (id: number, name: string, description: string | null, include: string[] = []): Promise<Role> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
http.patch(`/api/application/roles/${id}`, {
|
||||
name, description,
|
||||
})
|
||||
}, { params: { include: include.join(',') } })
|
||||
.then(({ data }) => resolve(rawDataToRole(data)))
|
||||
.catch(reject);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue