27 lines
861 B
JavaScript
27 lines
861 B
JavaScript
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(); |