This commit is contained in:
2025-09-09 00:10:53 +03:00
parent 38f2a05107
commit 204fc092d7
239 changed files with 22447 additions and 9536 deletions

View File

@@ -2,11 +2,11 @@ const SheepsService = require('../services/sheeps.service');
class SheepsController {
async getSheep(req, res) {
const { uuid } = req.query;
const { id } = req.query;
if (uuid) {
if (req.sheepRole) {
const result = await SheepsService.getSheep(uuid, req.sheepRole);
if (id) {
if (req.possibilities.can_view_sheeps) {
const result = await SheepsService.getSheep(id, req.mode);
if (result) {
return res.status(200).send(result);
} else {
@@ -27,8 +27,8 @@ class SheepsController {
}
async getList(req, res) {
if (req.sheepRole) {
const result = await SheepsService.getList(req.sheepRole);
if (req.possibilities.can_view_sheeps) {
const result = await SheepsService.getList(req.mode);
if (result) {
return res.status(200).send(result);
@@ -40,14 +40,14 @@ class SheepsController {
} else {
return res
.status(404)
.send({ message: 'Users not found.' });
.send({ message: 'The sheep does not have enough rights.' });
}
}
async createSheep(req, res) {
const data = req.body;
if (req.sheepRole && (req.sheepRole == "administrator" || req.moderator.can_add_sheeps)) {
if (req.possibilities.can_add_sheeps) {
let result = await SheepsService.createSheep(data);
if (result) {
@@ -65,12 +65,9 @@ class SheepsController {
}
async updateSheep(req, res) {
const { uuid } = req.query;
const data = req.body;
console.log("data", data);
if (req.sheepRole == "administrator") {
if (req.mode == 2) {
let result = await SheepsService.updateSheep(data);
if (result) {
@@ -90,7 +87,7 @@ class SheepsController {
async deleteSheep(req, res) {
const data = req.body;
if (req.sheepRole == "administrator") {
if (req.mode == 2) {
let result = await SheepsService.deleteSheep(data);
if (result) {
return res.status(200).send(result);