Skip to content

Commit

Permalink
fix bug of query builder
Browse files Browse the repository at this point in the history
  • Loading branch information
bahram1249 committed Jun 27, 2024
1 parent b172af3 commit 26494b6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ export class ProductCommentController {
async rejectComment(
@Param('id') commentId: bigint,
@GetUser() user: User,
@Body() dto: ConfirmCommentDto,
//@Body() dto: ConfirmCommentDto,
) {
return await this.service.rejectComment(commentId, user, dto);
return await this.service.rejectComment(commentId, user);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class ProductCommentService {
};
}

async rejectComment(commentId: bigint, user: User, dto: ConfirmCommentDto) {
async rejectComment(commentId: bigint, user: User) {
let comment = await this.repository.findOne(
new QueryOptionsBuilder()
.filter({ id: commentId })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class CalculateCommentScoreService {
);
}
// calculate score of factor, otherwise set 5 as default
const result = await this.factorRepository.findOne(
const result = await this.factorRepository.findAll(
new QueryOptionsBuilder()
.attributes([
[
Expand All @@ -64,8 +64,8 @@ export class CalculateCommentScoreService {
.raw(true)
.build(),
);
comment.score = result['score'];
comment.cntFactor = result['cntFactor'];
comment.score = result[0]['score'];
comment.cntFactor = result[0]['cntFactor'];
comment = await comment.save();
return await this.calcualteProductCommentScore(comment.entityId);
}
Expand All @@ -79,7 +79,7 @@ export class CalculateCommentScoreService {
'the product with this given id not founded!',
);
}
const comment = await this.repository.findOne(
const comment = await this.repository.findAll(
new QueryOptionsBuilder()
.attributes([
[
Expand All @@ -97,8 +97,8 @@ export class CalculateCommentScoreService {
.raw(true)
.build(),
);
product.score = comment['score'];
product.cntComment = comment['cntComment'];
product.score = comment[0]['score'];
product.cntComment = comment[0]['cntComment'];
return await product.save();
}
}

0 comments on commit 26494b6

Please sign in to comment.