Додана сторінка "Стенд"
Додане повідомлення про оновлення застосунку Оновлен Service Worker Перероблен WebSocket APІ
This commit is contained in:
@@ -2,26 +2,20 @@ const HomesteadsService = require('../services/homesteads.service');
|
||||
|
||||
class HomesteadsController {
|
||||
async getList(req, res) {
|
||||
const { mode } = req.query;
|
||||
const { mode, sheep_id } = req.query;
|
||||
|
||||
if (req.possibilities.can_view_territory) {
|
||||
let group_id = 0;
|
||||
let sheepName = false;
|
||||
let id = null;
|
||||
|
||||
// if (req.mode == 2) {
|
||||
// group_id = 0;
|
||||
// } else if (req.mode == 1) {
|
||||
// group_id = req.group_id;
|
||||
// }
|
||||
|
||||
if (mode == "sheep") {
|
||||
group_id = req.group_id;
|
||||
sheepName = req.sheepName;
|
||||
} else if (mode == "group"){
|
||||
group_id = req.group_id;
|
||||
if (mode == "admin" && req.possibilities.can_manager_territory) {
|
||||
id = sheep_id;
|
||||
} else if (mode == "sheep") {
|
||||
id = req.sheepId;
|
||||
} else if (mode == "group") {
|
||||
id = req.group_id;
|
||||
}
|
||||
|
||||
let result = await HomesteadsService.getList(group_id, sheepName);
|
||||
let result = await HomesteadsService.getList(mode, id);
|
||||
if (result) {
|
||||
return res
|
||||
.status(200)
|
||||
|
||||
@@ -22,26 +22,20 @@ class HousesController {
|
||||
}
|
||||
|
||||
async getList(req, res) {
|
||||
const { mode } = req.query;
|
||||
const { mode, sheep_id } = req.query;
|
||||
|
||||
if (req.possibilities.can_view_territory) {
|
||||
let group_id = 0;
|
||||
let sheepName = false;
|
||||
let id = null;
|
||||
|
||||
// if (req.mode == 2) {
|
||||
// group_id = 0;
|
||||
// } else if (req.mode == 1) {
|
||||
// group_id = req.group_id;
|
||||
// }
|
||||
|
||||
if (mode == "sheep") {
|
||||
group_id = req.group_id;
|
||||
sheepName = req.sheepName;
|
||||
} else if (mode == "group"){
|
||||
group_id = req.group_id;
|
||||
if (mode == "admin" && req.possibilities.can_manager_territory) {
|
||||
id = sheep_id;
|
||||
} else if (mode == "sheep") {
|
||||
id = req.sheepId;
|
||||
} else if (mode == "group") {
|
||||
id = req.group_id;
|
||||
}
|
||||
|
||||
let result = await HousesService.getList(group_id, sheepName);
|
||||
|
||||
let result = await HousesService.getList(mode, id);
|
||||
if (result) {
|
||||
return res
|
||||
.status(200)
|
||||
|
||||
@@ -4,7 +4,26 @@ class StandController {
|
||||
async getStand(req, res) {
|
||||
const { stand_id } = req.params;
|
||||
|
||||
return res.status(200).send({ stand_id });
|
||||
if (stand_id) {
|
||||
if (req.possibilities.can_view_stand) {
|
||||
const result = await StandService.getStand(stand_id);
|
||||
if (result) {
|
||||
return res.status(200).send(result);
|
||||
} else {
|
||||
return res.status(404).send({
|
||||
message: 'Stand not found.'
|
||||
});
|
||||
}
|
||||
} else {
|
||||
return res
|
||||
.status(403)
|
||||
.send({ message: 'The sheep does not have enough rights.' });
|
||||
}
|
||||
} else {
|
||||
return res
|
||||
.status(401)
|
||||
.send({ message: 'Stand not found.' });
|
||||
}
|
||||
}
|
||||
|
||||
async getList(req, res) {
|
||||
@@ -23,7 +42,6 @@ class StandController {
|
||||
.status(404)
|
||||
.send({ message: 'The sheep does not have enough rights.' });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async createStand(req, res) {
|
||||
@@ -130,7 +148,29 @@ class StandController {
|
||||
}
|
||||
|
||||
async getScheduleList(req, res) {
|
||||
return res.status(200).send({});
|
||||
const { stand_id } = req.params;
|
||||
|
||||
if (stand_id) {
|
||||
if (req.possibilities.can_view_stand) {
|
||||
const result = await StandService.getScheduleList(stand_id);
|
||||
|
||||
if (result) {
|
||||
return res.status(200).send(result);
|
||||
} else {
|
||||
return res
|
||||
.status(404)
|
||||
.send({ message: 'Schedule not found.' });
|
||||
}
|
||||
} else {
|
||||
return res
|
||||
.status(404)
|
||||
.send({ message: 'The sheep does not have enough rights.' });
|
||||
}
|
||||
} else {
|
||||
return res
|
||||
.status(401)
|
||||
.send({ message: 'Stand id not found.' });
|
||||
}
|
||||
}
|
||||
|
||||
async getScheduleHistory(req, res) {
|
||||
|
||||
Reference in New Issue
Block a user