Skip to content

Commit

Permalink
fix: proposal & 파일 연관관계 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
jcy0308 committed Feb 7, 2025
1 parent 960b15f commit 93da9a9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/scg/stop/file/domain/File.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,8 @@ public void setEventNotice(EventNotice eventNotice) {
public void setGallery(Gallery gallery) {
this.gallery = gallery;
}

public void connectProposal(Proposal proposal) {
this.proposal = proposal;
}
}
11 changes: 9 additions & 2 deletions src/main/java/com/scg/stop/proposal/domain/Proposal.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private Proposal(User user, String title, String projectTypes, String email, Str
this.isAnonymous = isAnonymous;
this.isVisible = isVisible;
this.user = user;
this.files = files;
changeFileMapping(files);
}

public static Proposal createProposal(User user, String title, String projectTypes, String email, String website,
Expand Down Expand Up @@ -110,7 +110,7 @@ public void update(String title,
this.content = content;
this.isAnonymous = isAnonymous;
this.isVisible = isVisible;
this.files = files;
changeFileMapping(files);
}

public void setUser(User user) {
Expand Down Expand Up @@ -163,4 +163,11 @@ public boolean isAuthorized(User requestUser) {
if (user.getId() == null) return false;
return requestUser.getUserType() == UserType.ADMIN || this.user.getId().equals(requestUser.getId());
}

private void changeFileMapping(List<File> files) {
for(File file: files) {
file.connectProposal(this);
}
this.files.addAll(files);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public ProposalDetailResponse getProposalDetail(Long proposalId, User requestUse
@Transactional
public ProposalDetailResponse createProposal(User user, CreateProposalRequest proposalCreateRequest) {
List<File> files = fileRepository.findByIdIn(proposalCreateRequest.getFileIds());
System.out.println(files.get(0).getId());
Proposal proposal = Proposal.createProposal(
user,
proposalCreateRequest.getTitle(),
Expand All @@ -83,6 +84,7 @@ public ProposalDetailResponse createProposal(User user, CreateProposalRequest pr
proposalCreateRequest.getIsAnonymous(),
files
);
System.out.println(proposal.getFiles().get(0).getId());
proposalRepository.save(proposal);
//TODO: 이메일 형식 정하기 & 과제 제안메일은 어드민 이메일로만 보내면 되는지?
emailService.sendEmail(proposal.getEmail(), proposal.getTitle(), proposal.getContent());
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/scg/stop/user/domain/UserType.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ public enum UserType {
ADMIN,
INACTIVE_PROFESSOR,
INACTIVE_COMPANY,
OTHERS
OTHERS,
EXTERNAL
}

0 comments on commit 93da9a9

Please sign in to comment.