Додані повідомлення та перепрацьована структура застосунку та api
This commit is contained in:
@@ -45,7 +45,7 @@ class SheepsController {
|
||||
}
|
||||
|
||||
async getListStand(req, res) {
|
||||
if (req.possibilities.can_view_stand) {
|
||||
if (req.possibilities.can_view_stand) {
|
||||
const result = await SheepsService.getListStand(req.mode);
|
||||
|
||||
if (result) {
|
||||
@@ -86,7 +86,7 @@ class SheepsController {
|
||||
const data = req.body;
|
||||
|
||||
if (req.mode == 2) {
|
||||
let result = await SheepsService.updateSheep(data);
|
||||
let result = await SheepsService.updateSheep(data, 2);
|
||||
|
||||
if (result) {
|
||||
return res.status(200).send(result);
|
||||
@@ -95,10 +95,24 @@ class SheepsController {
|
||||
message: 'Unable update sheep.',
|
||||
});
|
||||
}
|
||||
} if (req.possibilities.can_manager_sheeps) {
|
||||
if (Number(data.mode) == 2) {
|
||||
return res.status(403).send({ message: 'The sheep does not have enough rights.' });
|
||||
} else {
|
||||
let result = await SheepsService.updateSheep(data, 1);
|
||||
|
||||
if (result) {
|
||||
return res.status(200).send(result);
|
||||
} else {
|
||||
return res.status(500).send({
|
||||
message: 'Unable update sheep.',
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return res
|
||||
.status(403)
|
||||
.send({ message: 'Sheep not foundThe sheep does not have enough rights.' });
|
||||
.send({ message: 'The sheep does not have enough rights.' });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user