
order
async findOneMarket(marketId: number) {
const market = await this.marketsRepository.findOne({
where: { id: marketId },
});
if (!market) {
throw new NotFoundException({ message: '판매글이 존재하지 않습니다.' });
}
await this.marketsRepository.update(
{ id: market.id },
{ view: +market.view + 1 },
);
const updateMarket = await this.marketsRepository.findOne({
where: { id: marketId },
});
return updateMarket;
}
async findAllMarket(shoesId: number) {
const shoes = await this.shoesRepository.findOne({
where: { id: shoesId },
select: ['name', 'brand', 'shoeCode', 'imgUrl'],
});
const shoesInfo = {
name: shoes.name,
brand: shoes.brand,
shoeCode: shoes.shoeCode,
imageUrl: shoes.imgUrl['imageUrl'],
};
const posts = await this.marketsRepository.find({
where: { shoesId },
order: {
saleStatus: 'ASC',
view: 'DESC',
},
});
return { shoesInfo, posts };
}