Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop' of https://github.com/Here-You/here-you-backend
Browse files Browse the repository at this point in the history
…into develop
  • Loading branch information
JangYouJung committed Feb 12, 2024
2 parents fa90241 + 201f31b commit 018e7ad
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions src/rule/rule.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { S3UtilService} from "../utils/S3.service";
import { GetMemberListDto} from "./dto/get-member-list.dto";
import {UserService} from "../user/user.service";
import {GetRuleListDto, MemberPairDto} from "./dto/get-rule-list.dto";
import {Equal, LessThan, Like, Not} from "typeorm";
import { Equal, LessThan, Like, MoreThan, Not } from 'typeorm';
import {GetSearchMemberDto} from "./dto/get-search-member.dto";
import {UpdateRuleDto} from "./dto/update-rule.dto";
import {CursorPageOptionsDto} from "../mate/cursor-page/cursor-page-option.dto";
Expand Down Expand Up @@ -117,30 +117,16 @@ export class RuleService {

const cursorId: number = cursorPageOptionsDto.cursorId;

// (0) 초기값 가져오기
if(cursorPageOptionsDto.cursorId == 0){
const recentComment = await CommentEntity.findOne({
where: { rule: { id: ruleId } },
order: {
id: 'DESC' // id를 내림차순으로 정렬해서 가장 최근에 작성한 댓글 가져오기
}
});
cursorId = recentComment.id + 1;
}
else cursorId = cursorPageOptionsDto.cursorId;



// (1) 데이터 조회
const [comments, total] = await CommentEntity.findAndCount({
take: cursorPageOptionsDto.take,
where: {
rule: { id: ruleId },
id: cursorId ? LessThan(cursorId) : null,
id: cursorId ? MoreThan(cursorId) : null,
},
relations: {user:{profileImage: true}},
order: {
id: cursorPageOptionsDto.sort.toUpperCase() as any,
id: 'ASC'
},
});

Expand Down

0 comments on commit 018e7ad

Please sign in to comment.