51 lines
1.1 KiB
JavaScript
51 lines
1.1 KiB
JavaScript
import {makeAutoObservable} from "mobx";
|
|
import {http} from "../utils/http";
|
|
|
|
export class Role {
|
|
page = null;
|
|
pageSize = null;
|
|
data = [];
|
|
total_data = 0
|
|
|
|
constructor(ctx) {
|
|
this.ctx = ctx;
|
|
makeAutoObservable(this);
|
|
}
|
|
|
|
async getData() {
|
|
try {
|
|
const response = await http.get(`/config/roles?page=${this.page}&pageSize=${this.pageSize}`);
|
|
this.data = response.body.data ?? []
|
|
this.total_data = response.body.total_data ?? 0
|
|
} catch (e) {
|
|
console.error(e);
|
|
}
|
|
}
|
|
|
|
async create(data) {
|
|
try {
|
|
return await http.post('/users').send(data)
|
|
} catch (e) {
|
|
console.error(e);
|
|
}
|
|
}
|
|
|
|
async update(id, data) {
|
|
try {
|
|
return await http.put('/users/' + id).send(data);
|
|
} catch (e) {
|
|
console.error(e);
|
|
}
|
|
}
|
|
|
|
async delete(id) {
|
|
try {
|
|
return await http.del('/users/' + id);
|
|
} catch (e) {
|
|
console.error(e);
|
|
}
|
|
}
|
|
}
|
|
|
|
|