Skip to content

Commit

Permalink
πŸš€ :: 1.2.18
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyoil2 committed Nov 17, 2024
2 parents 5db630a + e2aac97 commit 33297bd
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ public class DeleteApplicationUseCase {
private final SecurityPort securityPort;

public void execute(Long applicationId) {

Student student = securityPort.getCurrentStudent();
Application application = queryApplicationPort.getByIdOrThrow(applicationId);

application.checkIsDeletable(student);

commandApplicationPort.deleteAllByApplicationId(applicationId);
commandApplicationPort.delete(application);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class CreateNoticeUseCase {

public void execute(CreateNoticeRequest request) {
List<NoticeAttachment> attachments = request.getAttachments().stream()
.filter(attachment -> attachment.getUrl() != null && attachment.getType() != null) // URLκ³Ό Type이 null이 μ•„λ‹Œ 경우만 필터링
.filter(attachment -> attachment.getUrl() != null && attachment.getType() != null)
.map(attachment -> new NoticeAttachment(attachment.getUrl(), attachment.getType()))
.toList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,7 @@ public void saveAll(List<Application> applications) {

@Override
public void deleteAllByApplicationId(Long applicationId) {
queryFactory.delete(applicationAttachmentEntity)
.where(applicationAttachmentEntity.application.id.eq(applicationId))
.execute();
applicationJpaRepository.deleteAttachmentsByApplicationId(applicationId);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import team.retum.jobis.domain.application.model.ApplicationStatus;
import team.retum.jobis.domain.notice.persistence.entity.NoticeAttachmentEntity;
import team.retum.jobis.domain.recruitment.persistence.entity.RecruitmentEntity;
import team.retum.jobis.domain.student.persistence.entity.StudentEntity;
import team.retum.jobis.global.entity.BaseTimeEntity;
Expand Down Expand Up @@ -64,7 +65,7 @@ public class ApplicationEntity extends BaseTimeEntity {
@JoinColumn(name = "recruitment_id", nullable = false)
private RecruitmentEntity recruitment;

@OneToMany(mappedBy = "application", cascade = CascadeType.ALL, orphanRemoval = true)
@OneToMany(mappedBy = "application", cascade = CascadeType.ALL)
private List<ApplicationAttachmentEntity> applicationAttachments = new ArrayList<>();

@LastModifiedDate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package team.retum.jobis.domain.application.persistence.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import team.retum.jobis.domain.application.model.ApplicationStatus;
import team.retum.jobis.domain.application.persistence.entity.ApplicationEntity;

import java.util.List;
Expand All @@ -14,6 +14,10 @@ public interface ApplicationJpaRepository extends JpaRepository<ApplicationEntit

void deleteByIdIn(List<Long> applicationIds);

@Modifying
@Query("delete from ApplicationAttachmentEntity a where a.application.id = ?1")
void deleteAttachmentsByApplicationId(Long applicationId);

@Query("select a from ApplicationEntity a join fetch a.applicationAttachments where a.id=?1")
Optional<ApplicationEntity> findByIdFetch(Long applicationId);
}

0 comments on commit 33297bd

Please sign in to comment.