added category
This commit is contained in:
		
							
								
								
									
										27
									
								
								src/controllers/category.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/controllers/category.js
									
									
									
									
									
										Normal 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();
 | 
			
		||||
		Reference in New Issue
	
	Block a user