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

Commit

Permalink
fix : 규칙 생성, 조회, 수정 번호 정렬 (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
yewonahn authored Feb 12, 2024
2 parents 7a3d858 + 158a33a commit 7ab4bee
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/rule/rule.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,15 @@ export class RuleService {
dto.rulePairs.sort((a, b) => a.ruleNumber - b.ruleNumber);

// -2) rule 저장
const subs = await Promise.all(dto.rulePairs.map(async (pair) => {
for(const pair of dto.rulePairs) {
console.log('현재 저장하는 ruleNumber : ', pair.ruleNumber);
const sub = new RuleSubEntity();
sub.ruleTitle = pair.ruleTitle;
sub.ruleDetail = pair.ruleDetail;
sub.main = main;

await sub.save();
return sub;
}));
console.log(subs);

}

// -3) invitation 저장
const members = await Promise.all(dto.membersId.map(async (memberId) : Promise<RuleInvitationEntity> => {
Expand Down Expand Up @@ -111,6 +109,8 @@ export class RuleService {

return rulePair;
}));
dto.rulePairs.sort((a, b) => a.id - b.id);


// -3) 멤버 정보
dto.detailMembers = await Promise.all(invitations.map(async(invitation):Promise<DetailMemberDto> => {
Expand All @@ -128,6 +128,8 @@ export class RuleService {
}
return detailMember;
}));
dto.detailMembers.sort((a, b) => a.id - b.id);

return dto;
} catch (e) {
console.log('게시글 조회에 실패하였습니다');
Expand Down Expand Up @@ -512,6 +514,7 @@ export class RuleService {

// 새로운 세부 규칙 리스트
const updateSubsList = updateRuleDto.rulePairs;
updateSubsList.sort((a, b) => a.ruleNumber - b.ruleNumber);

// case1) 규칙 삭제
for(const sub of subs) {
Expand Down

0 comments on commit 7ab4bee

Please sign in to comment.