Skip to content
Snippets Groups Projects
Commit 0888fe4b authored by Lee WooChang's avatar Lee WooChang
Browse files

feat: 실제 유저가 가지고 있는 부품만을 필터로 반환

parent 7bdca999
Branches
No related tags found
1 merge request!10Parts 추가
Pipeline #10580 passed
......@@ -32,10 +32,11 @@ const PartRepository = {
async getFilterDataByTypeAndColumn(type, column) {
const query = `
SELECT DISTINCT ${column}
FROM part_info_${type}
WHERE ${column} IS NOT NULL
ORDER BY ${column}
SELECT DISTINCT p.${column}
FROM relations r
JOIN part_info_${type} p ON r.part_id = p.part_id -- id 대신 part_id 사용
WHERE p.${column} IS NOT NULL
ORDER BY p.${column}
`;
const resp = await pool.query(query);
return resp.rows.map((row) => row[column]);
......
......@@ -9,9 +9,7 @@ partRouter.get(
'/',
wrapAsync(async (req, res) => {
const { partType, filters } = req.query;
const parts = await PartService.getParts(partType, filters);
return res.sendResponse('', 200, { parts });
})
);
......
......@@ -52,7 +52,7 @@ const PartService = {
async getParts(partType, filters) {
if (!partType) {
throw new Error('파트 타입이 필요합니다.');
throw new ReportableError(400, '파트 타입이 필요합니다.');
}
let parsedFilters;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment