-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from hyein0514/category
Category
- Loading branch information
Showing
5 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const categoryService = require('./category.service'); | ||
const { errResponse } = require('../../config/response'); | ||
|
||
// 전체 카테고리 가져오기 | ||
exports.getAllCategories = async (req, res, next) => { | ||
try { | ||
// 카테고리 서비스를 호출하여 전체 카테고리를 가져옵니다. | ||
const categories = await categoryService.getAllCategories(); | ||
|
||
// 성공적으로 카테고리를 가져온 경우 응답을 보냅니다. | ||
res.status(200).json({ | ||
success: true, | ||
message: "전체 카테고리를 성공적으로 불러왔습니다.", | ||
data: categories | ||
}); | ||
} catch (error) { | ||
// 오류가 발생한 경우 오류 응답을 보냅니다. | ||
console.error('Error fetching categories:', error); | ||
res.status(500).json(errResponse({ code: 500, message: "카테고리를 불러오는 데 실패했습니다." })); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const Category = require('../../models/category'); | ||
|
||
// 데이터베이스에서 전체 카테고리 가져오기 | ||
exports.getAllCategories = async () => { | ||
try { | ||
// 데이터베이스에서 모든 카테고리를 조회합니다. | ||
const categories = await Category.find(); | ||
return categories; | ||
} catch (error) { | ||
throw error; | ||
} | ||
}; | ||
|
||
// 다른 DAO 메서드들도 추가할 수 있습니다. |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const categoryDao = require('./category.dao'); | ||
|
||
// 전체 카테고리 가져오기 비즈니스 로직 | ||
exports.getAllCategories = async () => { | ||
try { | ||
// DAO를 통해 전체 카테고리를 가져옵니다. | ||
const categories = await categoryDao.getAllCategories(); | ||
return categories; | ||
} catch (error) { | ||
throw error; | ||
} | ||
}; | ||
|
||
// 다른 서비스 메서드들도 추가할 수 있습니다. |