added category

This commit is contained in:
2024-10-27 05:35:36 +03:00
parent 76e7349ce5
commit 3388da7280
6 changed files with 92 additions and 1 deletions

View File

@@ -0,0 +1,27 @@
import CategoryService from "../services/category.js";
import log
from "../utils/log.js";
const TAG = "controllers/category.js";
class CategoryController {
async create(req, res) {
try {
const { localId, categoryName, groupId } = req.body;
await CategoryService.create(groupId, localId, categoryName);
return res.status(200).send("Success");
} catch (e) { return res.status(500).send(log.unknownError(`${TAG}/create: ${e}`)); }
}
async update(req, res) {
try {
const { localId, groupId, name } = req.body;
await CategoryService.update(groupId, localId, name);
return res.status(200).send("Success");
} catch (e) { return res.status(500).send(log.unknownError(`${TAG}/update: ${e}`)); }
}
};
export default new CategoryController();