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

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

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