Skip to content
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

Merged
merged 27 commits into from
Aug 5, 2024
Merged

impl fnd 001 002 003 api #500

merged 27 commits into from
Aug 5, 2024

Conversation

wjeongchoi
Copy link
Contributor

@wjeongchoi wjeongchoi commented Jul 27, 2024

요약 *

It closes #474

이렇게 복잡한 api를 짜는건 처음이라 이 방식이 맞는지 확신이 없습니다..
코드가 많이 길지만 꼼꼼히 봐주시면 감사하겠습니다

스크린샷

이후 Task *

  • 없음

@wjeongchoi wjeongchoi added new feature 새로운 기능을 추가하는 경우입니다 back-end labels Jul 27, 2024
@wjeongchoi wjeongchoi self-assigned this Jul 27, 2024
@wjeongchoi wjeongchoi linked an issue Jul 27, 2024 that may be closed by this pull request
2 tasks
Copy link

netlify bot commented Jul 27, 2024

Deploy Preview for jazzy-klepon-c756b5 ready!

Name Link
🔨 Latest commit f41c8e2
🔍 Latest deploy log https://app.netlify.com/sites/jazzy-klepon-c756b5/deploys/66b0c6b6cf611a0008399e32
😎 Deploy Preview https://deploy-preview-500--jazzy-klepon-c756b5.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 80
Accessibility: 100
Best Practices: 100
SEO: 92
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@wjeongchoi wjeongchoi marked this pull request as ready for review August 2, 2024 17:18
Comment on lines +48 to +57
const tradeEvidenceFileIds =
await this.fundingRepository.selectTradeEvidenceFileIdsByFundingId(
param.id,
);

const tradeEvidenceFiles = await Promise.all(
tradeEvidenceFileIds.map(async id =>
this.filePublicService.getFileInfoById(id.toString()),
),
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

질문: 이런식으로 id를 fundingRepository에서 받아오고 filePublicService에서 그걸 이용해서 파일을 가져오는데 맞는 방식인지 궁금합니다

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

맞습니다! 다만 dlfjaus 쿼리가 많아져서 성능 하락이 있을수 있는데, 최종 테스트시 크게 느려보이지 않는다면 미래의 최적화 todo가 될거 같아요 주석 정도 달아주시면 감사하겠습니다

Comment on lines 189 to 208
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,
};
}),
);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

transportationPassengers가 StudentT에서 student_id를 가져오길래 이렇게 했는데 맞는 방법인지 확인 필요

Copy link
Contributor

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];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

result[0]하면 되는거 맞나요

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❗ 뭔가 이상한 거 같아요

  1. 메소드명이 selectStudentIdByStudentTId 인데 select 조건은 StudentId입니다.
  2. 질문에 대한 대답은 studentId(또는 studentTId)가 매치하는 row가 없다면 result가 길이 0의 배열일 수 있으므로, 이 selection을 호출하는 서비스또는 이 메소드에서 이러한 케이스를 예외로 처리하는것이 안전하다고 생각합니다.

Comment on lines 106 to 127
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,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이렇게 하나씩 다 써줘야하는게 진짜 맞는지..?

Copy link
Contributor

@Engineer-JJHaMa Engineer-JJHaMa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

일단 보이는거 위주로 했어유

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 로직자체는 깔끔합니다. Public Service인 만큼 jsDoc만 달면 좋을거 같아요. ClubPublicService에 예시가 몇개 있을 것 같습니다.

Copy link
Contributor

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];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❗ 뭔가 이상한 거 같아요

  1. 메소드명이 selectStudentIdByStudentTId 인데 select 조건은 StudentId입니다.
  2. 질문에 대한 대답은 studentId(또는 studentTId)가 매치하는 row가 없다면 result가 길이 0의 배열일 수 있으므로, 이 selection을 호출하는 서비스또는 이 메소드에서 이러한 케이스를 예외로 처리하는것이 안전하다고 생각합니다.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❗ 인증 구현이 완료되었으니 mockId 대신 연결해야 할 것 같아요

Comment on lines 29 to 32
const user = await this.userRepository.findStudentById(studentId);
if (!user) {
throw new HttpException("Student not found", HttpStatus.NOT_FOUND);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❗ 학생이 해당 동아리 대표자인지 확인이 필요합니다. 다른 서비스도 AuthZ가 필요한지 검토해 주세요

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❗ 추가로 제출 양식에 맞게 제출하였는지 확인하고 예외를 발생시키거나, 조건에 맞지 않는 제출을 일부 지우는 로직이 필요할 것 같아요

Comment on lines +48 to +57
const tradeEvidenceFileIds =
await this.fundingRepository.selectTradeEvidenceFileIdsByFundingId(
param.id,
);

const tradeEvidenceFiles = await Promise.all(
tradeEvidenceFileIds.map(async id =>
this.filePublicService.getFileInfoById(id.toString()),
),
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

맞습니다! 다만 dlfjaus 쿼리가 많아져서 성능 하락이 있을수 있는데, 최종 테스트시 크게 느려보이지 않는다면 미래의 최적화 todo가 될거 같아요 주석 정도 달아주시면 감사하겠습니다

Comment on lines 189 to 208
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,
};
}),
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❗ UserPublicService를 통해 가져오면 됩니당

Copy link
Contributor

@Engineer-JJHaMa Engineer-JJHaMa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

엄청 큰 API여서 귀찮았을텐데 잘 짜주셔서 감사합니다 👍 👍

Comment on lines 26 to 45
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];
}
Copy link
Contributor

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인지 한번 조사하면 좋을듯 합니다(💊 이니 제안정도임!)

@wjeongchoi wjeongchoi merged commit dae3864 into dev Aug 5, 2024
4 checks passed
@wjeongchoi wjeongchoi deleted the 474-impl-fnd-001-002-003-api branch August 5, 2024 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
back-end new feature 새로운 기능을 추가하는 경우입니다
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Impl FND 001 002 003 api
2 participants