-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
impl fnd 001 002 003 api #500
Conversation
✅ Deploy Preview for jazzy-klepon-c756b5 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
const tradeEvidenceFileIds = | ||
await this.fundingRepository.selectTradeEvidenceFileIdsByFundingId( | ||
param.id, | ||
); | ||
|
||
const tradeEvidenceFiles = await Promise.all( | ||
tradeEvidenceFileIds.map(async id => | ||
this.filePublicService.getFileInfoById(id.toString()), | ||
), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
질문: 이런식으로 id를 fundingRepository에서 받아오고 filePublicService에서 그걸 이용해서 파일을 가져오는데 맞는 방식인지 궁금합니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
맞습니다! 다만 dlfjaus 쿼리가 많아져서 성능 하락이 있을수 있는데, 최종 테스트시 크게 느려보이지 않는다면 미래의 최적화 todo가 될거 같아요 주석 정도 달아주시면 감사하겠습니다
const transportationPassengerTIds = | ||
await this.fundingRepository.selectPassengerStudentIdsByFundingId( | ||
param.id, | ||
); | ||
|
||
const transportationPassengerIds = await Promise.all( | ||
transportationPassengerTIds.map(async id => | ||
this.studentRepository.selectStudentIdByStudentTId(id), | ||
), | ||
); | ||
|
||
const transportationPassengers = await Promise.all( | ||
transportationPassengerIds.map(async id => { | ||
const student = await this.userRepository.findStudentById(id.id)[0]; | ||
return { | ||
name: student.name, | ||
studentNumber: student.studentNumber, | ||
}; | ||
}), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transportationPassengers가 StudentT에서 student_id를 가져오길래 이렇게 했는데 맞는 방법인지 확인 필요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❗ UserPublicService를 통해 가져오면 됩니당
.from(Student) | ||
.where(and(eq(Student.id, studentId), isNull(StudentT.deletedAt))); | ||
|
||
return result[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
result[0]하면 되는거 맞나요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❗ 뭔가 이상한 거 같아요
- 메소드명이
selectStudentIdByStudentTId
인데 select 조건은 StudentId입니다. - 질문에 대한 대답은 studentId(또는 studentTId)가 매치하는 row가 없다면 result가 길이 0의 배열일 수 있으므로, 이 selection을 호출하는 서비스또는 이 메소드에서 이러한 케이스를 예외로 처리하는것이 안전하다고 생각합니다.
const [fundingInsertResult] = await tx.insert(FundingOrder).values({ | ||
clubId: contents.clubId, | ||
purposeId: contents.purposeId, | ||
// TODO: semesterId 받아오기 | ||
semesterId: 1, | ||
fundingOrderStatusEnumId: Number(FundingOrderStatusEnum.Applied), | ||
name: contents.name, | ||
expenditureDate: contents.expenditureDate, | ||
expenditureAmount: contents.expenditureAmount, | ||
tradeDetailExplanation: contents.tradeDetailExplanation, | ||
clubSuppliesName: contents.clubSuppliesName, | ||
clubSuppliesEvidenceEnumId: contents.clubSuppliesEvidenceEnumId, | ||
clubSuppliesClassEnumId: contents.clubSuppliesClassEnumId, | ||
clubSuppliesPurpose: contents.clubSuppliesPurpose, | ||
clubSuppliesSoftwareEvidence: contents.clubSuppliesSoftwareEvidence, | ||
numberOfClubSupplies: contents.numberOfClubSupplies, | ||
priceOfClubSupplies: contents.priceOfClubSupplies, | ||
isFixture: contents.isFixture, | ||
fixtureName: contents.fixtureName, | ||
fixtureEvidenceEnumId: contents.fixtureEvidenceEnumId, | ||
fixtureClassEnumId: contents.fixtureClassEnumId, | ||
fixturePurpose: contents.fixturePurpose, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이렇게 하나씩 다 써줘야하는게 진짜 맞는지..?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
일단 보이는거 위주로 했어유
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 로직자체는 깔끔합니다. Public Service인 만큼 jsDoc만 달면 좋을거 같아요. ClubPublicService에 예시가 몇개 있을 것 같습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ 추가로, getSignedUrl
함수는 예외 컨트롤을 안해도 되는지가 궁금한 부분인데, @pbc1017 께서 수정하실때 확인해주세요
.from(Student) | ||
.where(and(eq(Student.id, studentId), isNull(StudentT.deletedAt))); | ||
|
||
return result[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❗ 뭔가 이상한 거 같아요
- 메소드명이
selectStudentIdByStudentTId
인데 select 조건은 StudentId입니다. - 질문에 대한 대답은 studentId(또는 studentTId)가 매치하는 row가 없다면 result가 길이 0의 배열일 수 있으므로, 이 selection을 호출하는 서비스또는 이 메소드에서 이러한 케이스를 예외로 처리하는것이 안전하다고 생각합니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❗ 인증 구현이 완료되었으니 mockId 대신 연결해야 할 것 같아요
const user = await this.userRepository.findStudentById(studentId); | ||
if (!user) { | ||
throw new HttpException("Student not found", HttpStatus.NOT_FOUND); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❗ 학생이 해당 동아리 대표자인지 확인이 필요합니다. 다른 서비스도 AuthZ가 필요한지 검토해 주세요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❗ 추가로 제출 양식에 맞게 제출하였는지 확인하고 예외를 발생시키거나, 조건에 맞지 않는 제출을 일부 지우는 로직이 필요할 것 같아요
const tradeEvidenceFileIds = | ||
await this.fundingRepository.selectTradeEvidenceFileIdsByFundingId( | ||
param.id, | ||
); | ||
|
||
const tradeEvidenceFiles = await Promise.all( | ||
tradeEvidenceFileIds.map(async id => | ||
this.filePublicService.getFileInfoById(id.toString()), | ||
), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
맞습니다! 다만 dlfjaus 쿼리가 많아져서 성능 하락이 있을수 있는데, 최종 테스트시 크게 느려보이지 않는다면 미래의 최적화 todo가 될거 같아요 주석 정도 달아주시면 감사하겠습니다
const transportationPassengerTIds = | ||
await this.fundingRepository.selectPassengerStudentIdsByFundingId( | ||
param.id, | ||
); | ||
|
||
const transportationPassengerIds = await Promise.all( | ||
transportationPassengerTIds.map(async id => | ||
this.studentRepository.selectStudentIdByStudentTId(id), | ||
), | ||
); | ||
|
||
const transportationPassengers = await Promise.all( | ||
transportationPassengerIds.map(async id => { | ||
const student = await this.userRepository.findStudentById(id.id)[0]; | ||
return { | ||
name: student.name, | ||
studentNumber: student.studentNumber, | ||
}; | ||
}), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❗ UserPublicService를 통해 가져오면 됩니당
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
엄청 큰 API여서 귀찮았을텐데 잘 짜주셔서 감사합니다 👍 👍
async getStudentByTId(studentT: { id: number }) { | ||
const studentIds = await this.studentRepository.selectStudentIdByStudentTId( | ||
studentT.id, | ||
); | ||
|
||
const students = await Promise.all( | ||
studentIds.map(async student => | ||
this.studentRepository.selectStudentById(student.studentId), | ||
), | ||
); | ||
|
||
if (students.length > 1) | ||
throw new HttpException("unreachable", HttpStatus.INTERNAL_SERVER_ERROR); | ||
|
||
if (students.length === 0) { | ||
return undefined; | ||
} | ||
|
||
return students[0][0]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💊 똑같이 PublicService이기에 JSDoc 달려있으면 좋을것같고, studentTId 로 select 후 배열 길이가 1인지 한번 조사하면 좋을듯 합니다(💊 이니 제안정도임!)
요약 *
It closes #474
이렇게 복잡한 api를 짜는건 처음이라 이 방식이 맞는지 확신이 없습니다..
코드가 많이 길지만 꼼꼼히 봐주시면 감사하겠습니다
스크린샷
이후 Task *