|
@@ -62,9 +62,18 @@ export class MomentsService {
|
|
|
return page
|
|
return page
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- async findById(id: number): Promise<Moments> {
|
|
|
|
|
|
|
+ async findById(id: number, userId: number): Promise<Moments> {
|
|
|
const moments = await this.momentsRepository.findOneBy({ id: +id })
|
|
const moments = await this.momentsRepository.findOneBy({ id: +id })
|
|
|
const chatRole = await this.chatRoleService.findById(moments.userId)
|
|
const chatRole = await this.chatRoleService.findById(moments.userId)
|
|
|
|
|
+ const likes = await this.likesRepository.findOneBy({
|
|
|
|
|
+ userId: +userId,
|
|
|
|
|
+ targetId: id,
|
|
|
|
|
+ type: 1,
|
|
|
|
|
+ isValid: true
|
|
|
|
|
+ })
|
|
|
|
|
+ if (likes) {
|
|
|
|
|
+ moments.isLiked = true
|
|
|
|
|
+ }
|
|
|
moments.chatRole = chatRole
|
|
moments.chatRole = chatRole
|
|
|
return moments
|
|
return moments
|
|
|
}
|
|
}
|