2020-12-28 17:08:08 +00:00
|
|
|
import http from '@/api/http';
|
2021-01-06 23:38:39 +00:00
|
|
|
import { Role, rawDataToRole } from '@/api/admin/roles/getRoles';
|
2020-12-28 17:08:08 +00:00
|
|
|
|
|
|
|
export default (name: string, description?: string): Promise<Role> => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
http.post('/api/application/roles', {
|
|
|
|
name, description,
|
|
|
|
})
|
2021-01-06 23:38:39 +00:00
|
|
|
.then(({ data }) => resolve(rawDataToRole(data)))
|
2020-12-28 17:08:08 +00:00
|
|
|
.catch(reject);
|
|
|
|
});
|
|
|
|
};
|