Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into develop
  • Loading branch information
kimyeoungrok committed May 23, 2024
2 parents dcd1a6b + b87ca2e commit dcc8242
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 16 deletions.
1 change: 0 additions & 1 deletion README.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public record AnnouncementDetailResponse(
String detailContents,
Integer likes,
Boolean memberIsLiked,
Boolean memberIsStored
Boolean memberIsStored,
String applyLink
) {
public static AnnouncementDetailResponse of(Long scholarshipId, String scholarShipImage, String scholarShipName, String scholarShipFoundation, Long remainingDay,
String applyPossible,
Expand All @@ -26,12 +27,13 @@ public static AnnouncementDetailResponse of(Long scholarshipId, String scholarSh
String detailContents,
Integer likes,
Boolean memberIsLiked,
Boolean memberIsStored) {
Boolean memberIsStored,
String applyLink) {

return new AnnouncementDetailResponse(scholarshipId, scholarShipImage,
scholarShipName, scholarShipFoundation, remainingDay, applyPossible,
supportAmount, applicationPeriod, hashTag, applyCondition,
detailContents, likes, memberIsLiked, memberIsStored
detailContents, likes, memberIsLiked, memberIsStored, applyLink
);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import lombok.*;

import java.time.LocalDate;
import java.time.LocalDateTime;

@NoArgsConstructor
@AllArgsConstructor
@Getter
Expand All @@ -10,14 +13,17 @@
public class MyCoverLetterListEntry {
private Long coverLetterId;
private String title;
private LocalDateTime localDateTime;

public static MyCoverLetterListEntry of(
Long coverLetterId,
String title
){
String title,
LocalDateTime localDateTime
) {
return MyCoverLetterListEntry.builder()
.coverLetterId(coverLetterId)
.title(title)
.localDateTime(localDateTime)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public AnnouncementDetailResponse getAnnouncement(Long announcementId, MemberInf
return AnnouncementDetailResponse.of(ae.getId(), ae.getScholarShipImage(), ae.getScholarShipName(), ae.getScholarShipFoundation(),
remainingDay, applyPossible, supportAmount, ae.getApplicationPeriod(),
ae.getHashTag(), applyCondition, ae.getDetailContents(), likesCount,
isLikedByMember, isStoredByMember);
isLikedByMember, isStoredByMember, ae.getFoundationLink());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public ApplyListDetailResponse getApplyListDetail(MemberInfoObject mio, Long app
Long id = coverLetterEntity.getId();
String title = coverLetterEntity.getTitle();

MyCoverLetterListEntry myCoverLetterListEntry = MyCoverLetterListEntry.of(id, title);
MyCoverLetterListEntry myCoverLetterListEntry = MyCoverLetterListEntry.of(id, title, coverLetterEntity.getCreatedAt());
myCoverLetterList.add(myCoverLetterListEntry);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

public interface ApplyJpaRepository extends JpaRepository<ApplyEntity, Long> {
List<ApplyEntity> findAllByMember(Member member);
void deleteApplyEntityByMemberAndId(Member member, Long id);

void deleteByMemberAndAnnouncementEntity(Member member, AnnouncementEntity announcementEntity);
ApplyEntity findByMemberAndAnnouncementEntity(Member member, AnnouncementEntity announcementEntity);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class CoverLetterEntity {
public class CoverLetterEntity extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
@RequestMapping("/members")
public class MemberApi {
private final MemberService memberService;
@DeleteMapping("/application/{id}")
@DeleteMapping("/application/{applicationId}")
public ApiResponse<GeneralResponse> deleteMemberApplication(@MemberInfo MemberInfoObject mio,
@PathVariable(name = "id") Long id){
return ApiResponse.onSuccess(memberService.deleteMemberApplication(mio, id));
@PathVariable(name = "applicationId") Long applicationId){
return ApiResponse.onSuccess(memberService.deleteMemberApplication(mio, applicationId));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package backend.univfit.domain.member.application;

import backend.univfit.domain.apply.entity.AnnouncementEntity;
import backend.univfit.domain.apply.exception.AnnouncementException;
import backend.univfit.domain.apply.repository.AnnouncementJpaRepository;
import backend.univfit.domain.apply.repository.ApplyJpaRepository;
import backend.univfit.domain.member.entity.Member;
import backend.univfit.domain.member.repository.MemberJpaRepository;
Expand All @@ -10,18 +13,22 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import static backend.univfit.global.error.status.ErrorStatus.ANNOUNCEMENT_NOT_FOUND;

@Service
@Slf4j
@RequiredArgsConstructor
public class MemberService {
private final MemberJpaRepository memberJpaRepository;
private final ApplyJpaRepository applyJpaRepository;
private final AnnouncementJpaRepository announcementJpaRepository;

@Transactional
public GeneralResponse deleteMemberApplication(MemberInfoObject mio, Long id) {
public GeneralResponse deleteMemberApplication(MemberInfoObject mio, Long applicationId) {
Member member = memberJpaRepository.findById(mio.getMemberId()).get();
AnnouncementEntity announcement = announcementJpaRepository.findById(applicationId).orElseThrow(() -> new AnnouncementException(ANNOUNCEMENT_NOT_FOUND));

applyJpaRepository.deleteApplyEntityByMemberAndId(member, id);
applyJpaRepository.deleteByMemberAndAnnouncementEntity(member, announcement);
return GeneralResponse.of();
}
}

0 comments on commit dcc8242

Please sign in to comment.