v1.0.0
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user