added backend implementation
This commit is contained in:
79
backend/controller/checklistSolutions.js
Normal file
79
backend/controller/checklistSolutions.js
Normal file
@ -0,0 +1,79 @@
|
||||
//import functions from checklist solutions model
|
||||
import {
|
||||
insertChecklistSolutionTodo,
|
||||
getChecklistSolutionTodosById,
|
||||
getChecklistSolutionTodosByAsset,
|
||||
updateChecklistSolutionTodoById,
|
||||
deleteAllChecklistSolutionTodosSolutionID,
|
||||
deleteChecklistSolutionTodo,
|
||||
} from "../models/checklistSolutionsModel.js";
|
||||
|
||||
//create new checklist solution todo
|
||||
export const createChecklistSolutionTodos = (req, res) => {
|
||||
const data = req.body;
|
||||
insertChecklistSolutionTodo(data, (err, results) => {
|
||||
if (err) {
|
||||
res.send(err);
|
||||
} else {
|
||||
res.json(results);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//get single checklist solution todos by id
|
||||
export const showChecklistSolutionTodosById = (req, res) => {
|
||||
getChecklistSolutionTodosById(req.params.id, (err, results) => {
|
||||
if (err) {
|
||||
res.send(err);
|
||||
} else {
|
||||
res.json(results);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//get single checklist solution todos by asset
|
||||
export const showChecklistSolutionTodosByAsset = (req, res) => {
|
||||
getChecklistSolutionTodosByAsset(req.params.id, (err, results) => {
|
||||
if (err) {
|
||||
res.send(err);
|
||||
} else {
|
||||
res.json(results);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Update checklist solution todo
|
||||
export const updateChecklistSolutionTodo = (req, res) => {
|
||||
const data = req.body;
|
||||
updateChecklistSolutionTodoById(data, (err, results) => {
|
||||
if (err) {
|
||||
res.send(err);
|
||||
} else {
|
||||
res.json(results);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Delete checklist solution todos by solution ID
|
||||
export const deleteChecklistSolutionTodosSolutionID = (req, res) => {
|
||||
const id = req.params.id;
|
||||
deleteAllChecklistSolutionTodosSolutionID(id, (err, results) => {
|
||||
if (err) {
|
||||
res.send(err);
|
||||
} else {
|
||||
res.json(results);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Delete checklist solution todos by primaryID
|
||||
export const deleteChecklistSolutionTodos = (req, res) => {
|
||||
const id = req.params.id;
|
||||
deleteChecklistSolutionTodo(id, (err, results) => {
|
||||
if (err) {
|
||||
res.send(err);
|
||||
} else {
|
||||
res.json(results);
|
||||
}
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user