Skip to content

Commit

Permalink
API: allphotocard API ver 별로 나눠서 응답 보내기
Browse files Browse the repository at this point in the history
  • Loading branch information
urimJ committed Dec 9, 2023
1 parent b3a7ad6 commit faaa3e3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion db.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ Post.init(
timestamps: false
}
);
await sequelize.sync();
// await sequelize.sync();

// 릴레이션
// 회원 : 도안 = 일대다
Expand Down
27 changes: 26 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -906,8 +906,33 @@ app.get('/mypage/myCollection/:albumName/allPhotocard', verifyToken, async (req,
`;
con.query(sql, [albumName], (err, result, fields)=>{
if(err) throw err;

const result1 = [];
const result2 = [];
const result3 = [];
for(let i=0;i<result.length; i++){
if(result[i].version === "a"){
result1.push(result[i]);
}else if(result[i].version === "b"){
result2.push(result[i]);
}else if(result[i].version === "c"){
result3.push(result[i]);
}
}
const r1 = {
verA: result1
}
const r2 = {
verB: result2
}
const r3 = {
verC: result3
}
const re = {
...r1, ...r2, ...r3
}
const r = {
collectionPhotocardList: result
collectionPhotocardList: re
}
res.status(200).send(r);
})
Expand Down

0 comments on commit faaa3e3

Please sign in to comment.