260914_02_ENH: 신청자 전체 목록 반환 구현

This commit is contained in:
2026-09-14 15:07:41 +09:00
parent d415ca4621
commit 3697acf6dd
5 changed files with 32 additions and 118 deletions

View File

@@ -45,6 +45,12 @@ public class AssignController {
return assignService.findMonitoringApplyUsers(performanceId);
}
@Operation(summary = "전체 공연 모니터링 신청자 목록 조회")
@GetMapping("/monitoring/apply-users")
public List<MonitoringApplyUserDto> findAllMonitoringApplyUsers() {
return assignService.findAllMonitoringApplyUsers();
}
@Operation(summary = "공연별 모니터링 신청자 수 조회")
@GetMapping("/monitoring/apply-users/count")
public List<PerformanceApplyCountDto> findMonitoringApplyUsersCount() {

View File

@@ -17,4 +17,8 @@ public interface KonMapper {
@Param("surveyType") String surveyType,
@Param("performanceId") String performanceId
);
List<PerformanceApplyUserDto> findAllPerformanceApplyUsers(
@Param("surveyType") String surveyType
);
}

View File

@@ -78,6 +78,17 @@ public class AssignService {
public List<MonitoringApplyUserDto> findMonitoringApplyUsers(String performanceId) {
List<PerformanceApplyUserDto> applyUsers = findKonPerformanceApplyUser(performanceId);
return createMonitoringApplyUsers(applyUsers);
}
@Transactional(readOnly = true, transactionManager = "konTransactionManager")
public List<MonitoringApplyUserDto> findAllMonitoringApplyUsers() {
return createMonitoringApplyUsers(konMapper.findAllPerformanceApplyUsers(surveyType));
}
private List<MonitoringApplyUserDto> createMonitoringApplyUsers(
List<PerformanceApplyUserDto> applyUsers
) {
if (applyUsers.isEmpty()) {
return Collections.emptyList();
}
@@ -104,7 +115,7 @@ public class AssignService {
.map(applyUser -> {
TUserEntity user = userMap.get(applyUser.getUserId());
return MonitoringApplyUserDto.builder()
.performanceId(performanceId)
.performanceId(applyUser.getPerformanceId())
.userId(applyUser.getUserId())
.user(user == null
? null

View File

@@ -37,4 +37,13 @@
WHERE performance_id = #{performanceId}
GROUP BY performance_id, IDKEY
</select>
</mapper>
<select id="findAllPerformanceApplyUsers" resultType="PerformanceApplyUserDto">
WITH Base AS (
<include refid="BaseDataSelect"/>
)
SELECT performance_id, IDKEY AS user_id
FROM Base
GROUP BY performance_id, IDKEY
</select>
</mapper>

View File

@@ -1,116 +0,0 @@
package com.kri.kmusical.manage.back.service;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.kri.common.feature.web.BusinessException;
import com.kri.kmusical.manage.back.dto.performance.PerformanceAssignDto;
import com.kri.kmusical.manage.back.persistence.entity.TPerformanceAssignEntity;
import com.kri.kmusical.manage.back.persistence.entity.id.TPerformanceAssignEntityId;
import com.kri.kmusical.manage.back.persistence.mapper.kon.KonMapper;
import com.kri.kmusical.manage.back.persistence.repository.PerformanceAssignRepository;
import com.kri.kmusical.manage.back.persistence.repository.PerformanceRepository;
import com.kri.kmusical.manage.back.persistence.repository.PerformanceReviewRepository;
import com.kri.kmusical.manage.back.persistence.repository.PerformanceReviewSlotRepository;
import com.kri.kmusical.manage.back.persistence.repository.UserDetailRepository;
import com.kri.kmusical.manage.back.persistence.repository.UserRepository;
import java.time.LocalDateTime;
import java.util.Optional;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
@ExtendWith(MockitoExtension.class)
class AssignServiceTest {
@Mock private PerformanceAssignRepository assignRepository;
@Mock private PerformanceReviewRepository reviewRepository;
@Mock private PerformanceReviewSlotRepository reviewSlotRepository;
@Mock private KonMapper konMapper;
@Mock private PerformanceRepository performanceRepository;
@Mock private UserRepository userRepository;
@Mock private UserDetailRepository userDetailRepository;
private AssignService assignService;
@BeforeEach
void setUp() {
assignService = new AssignService(
assignRepository,
reviewRepository,
reviewSlotRepository,
konMapper,
performanceRepository,
userRepository,
userDetailRepository
);
}
@Test
void confirmsUserForReviewSlot() {
LocalDateTime now = LocalDateTime.of(2026, 9, 8, 12, 0);
when(performanceRepository.existsById("PF-001")).thenReturn(true);
when(reviewSlotRepository.existsById(2)).thenReturn(true);
when(userRepository.existsByUserId("reviewer")).thenReturn(true);
when(assignRepository.findByIdPerformanceIdAndIdReviewSlot("PF-001", 2))
.thenReturn(Optional.empty());
when(assignRepository.save(any(TPerformanceAssignEntity.class)))
.thenAnswer(invocation -> invocation.getArgument(0));
PerformanceAssignDto result = assignService.confirmAssign(
"PF-001", 2, "reviewer", "admin", now
);
assertThat(result.getPerformanceId()).isEqualTo("PF-001");
assertThat(result.getReviewSlot()).isEqualTo(2);
assertThat(result.getAssignUser()).isEqualTo("reviewer");
assertThat(result.getAssignStatus()).isEqualTo((short) 1);
}
@Test
void rejectsReplacementAfterReviewStarted() {
TPerformanceAssignEntity current = assignment("PF-001", 2, "old-reviewer");
when(performanceRepository.existsById("PF-001")).thenReturn(true);
when(reviewSlotRepository.existsById(2)).thenReturn(true);
when(userRepository.existsByUserId("new-reviewer")).thenReturn(true);
when(assignRepository.findByIdPerformanceIdAndIdReviewSlot("PF-001", 2))
.thenReturn(Optional.of(current));
when(reviewRepository.existsByIdPerformanceIdAndIdReviewSlot("PF-001", 2))
.thenReturn(true);
assertThatThrownBy(() -> assignService.confirmAssign(
"PF-001", 2, "new-reviewer", "admin", LocalDateTime.now()
)).isInstanceOf(BusinessException.class);
verify(assignRepository, never()).save(any());
}
@Test
void cancelsSlotAssignmentBeforeReviewStarts() {
TPerformanceAssignEntity current = assignment("PF-001", 2, "reviewer");
when(assignRepository.findByIdPerformanceIdAndIdReviewSlot("PF-001", 2))
.thenReturn(Optional.of(current));
assignService.cancelAssign("PF-001", 2);
verify(assignRepository).delete(current);
}
private TPerformanceAssignEntity assignment(
String performanceId,
Integer reviewSlot,
String assignUser
) {
TPerformanceAssignEntity entity = new TPerformanceAssignEntity();
entity.setId(new TPerformanceAssignEntityId(performanceId, reviewSlot));
entity.setAssignUser(assignUser);
entity.setAssignStatus((short) 1);
return entity;
}
}