260805_02_ENH: 외부 설문에서 리스트 관련 기능 사용시 prjctIdx가 아닌 prjctCd로 동작하게 변경 #15
@@ -7,6 +7,7 @@ import com.kri.contact.server.dto.list.ListUpdateRequestDto;
|
|||||||
import com.kri.contact.server.service.ListHeaderService;
|
import com.kri.contact.server.service.ListHeaderService;
|
||||||
import com.kri.contact.server.service.ListSearchService;
|
import com.kri.contact.server.service.ListSearchService;
|
||||||
import com.kri.contact.server.service.ListUpdateService;
|
import com.kri.contact.server.service.ListUpdateService;
|
||||||
|
import com.kri.contact.server.service.ProjectService;
|
||||||
import com.kri.contact.server.service.common.SystemEventLogService;
|
import com.kri.contact.server.service.common.SystemEventLogService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
@@ -32,14 +33,16 @@ public class ListExternalController {
|
|||||||
private final ListHeaderService listHeaderService;
|
private final ListHeaderService listHeaderService;
|
||||||
private final ListSearchService listSearchService;
|
private final ListSearchService listSearchService;
|
||||||
private final ListUpdateService listUpdateService;
|
private final ListUpdateService listUpdateService;
|
||||||
|
private final ProjectService projectService;
|
||||||
private final SystemEventLogService systemEventLogService;
|
private final SystemEventLogService systemEventLogService;
|
||||||
|
|
||||||
@Operation(summary = "리스트 헤더 조회")
|
@Operation(summary = "리스트 헤더 조회")
|
||||||
@GetMapping("/header/{prjctIdx}")
|
@GetMapping("/header/{prjctCd}")
|
||||||
public List<String> searchListHeader(
|
public List<String> searchListHeader(
|
||||||
@PathVariable Long prjctIdx,
|
@PathVariable String prjctCd,
|
||||||
RequestUserContext ctx
|
RequestUserContext ctx
|
||||||
) {
|
) {
|
||||||
|
Long prjctIdx = projectService.getProjectIdxByCode(prjctCd);
|
||||||
LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||||
List<String> headerNames = listHeaderService.getHeaderName(prjctIdx);
|
List<String> headerNames = listHeaderService.getHeaderName(prjctIdx);
|
||||||
systemEventLogService.writeSearchListHeaderFromExternal(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx);
|
systemEventLogService.writeSearchListHeaderFromExternal(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx);
|
||||||
@@ -48,27 +51,29 @@ public class ListExternalController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "리스트 정보 조회")
|
@Operation(summary = "리스트 정보 조회")
|
||||||
@GetMapping("/search/{prjctIdx}/{sid}")
|
@GetMapping("/search/{prjctCd}/{sid}")
|
||||||
public ListSearchExternalDto searchListWithSid(
|
public ListSearchExternalDto searchListWithSid(
|
||||||
@PathVariable Long prjctIdx,
|
@PathVariable String prjctCd,
|
||||||
@PathVariable String sid,
|
@PathVariable String sid,
|
||||||
RequestUserContext ctx
|
RequestUserContext ctx
|
||||||
) {
|
) {
|
||||||
|
Long prjctIdx = projectService.getProjectIdxByCode(prjctCd);
|
||||||
LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||||
ListSearchExternalDto listInfo = listSearchService.searchListWithSidFromExternal(prjctIdx, sid);
|
ListSearchExternalDto listInfo = listSearchService.searchListWithSidFromExternal(prjctIdx, prjctCd, sid);
|
||||||
systemEventLogService.writeSearchListFromExternal(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx, sid);
|
systemEventLogService.writeSearchListFromExternal(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx, sid);
|
||||||
|
|
||||||
return listInfo;
|
return listInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "리스트 수정 sid기반")
|
@Operation(summary = "리스트 수정 sid기반")
|
||||||
@PatchMapping("/update/{prjctIdx}/{sid}")
|
@PatchMapping("/update/{prjctCd}/{sid}")
|
||||||
public int updateListWithSid(
|
public int updateListWithSid(
|
||||||
@PathVariable Long prjctIdx,
|
@PathVariable String prjctCd,
|
||||||
@PathVariable String sid,
|
@PathVariable String sid,
|
||||||
@RequestBody Map<String, String> updateContents,
|
@RequestBody Map<String, String> updateContents,
|
||||||
RequestUserContext ctx
|
RequestUserContext ctx
|
||||||
) {
|
) {
|
||||||
|
Long prjctIdx = projectService.getProjectIdxByCode(prjctCd);
|
||||||
Map<Integer, String> contentsByHeaderId = listHeaderService.convertHeaderNamesToIds(
|
Map<Integer, String> contentsByHeaderId = listHeaderService.convertHeaderNamesToIds(
|
||||||
prjctIdx,
|
prjctIdx,
|
||||||
updateContents
|
updateContents
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ import lombok.Setter;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Schema(description = "외부에서 리스트 조회")
|
@Schema(description = "외부에서 리스트 조회")
|
||||||
public class ListSearchExternalDto {
|
public class ListSearchExternalDto {
|
||||||
@Schema(description = "프로젝트 고유키")
|
@Schema(description = "프로젝트 코드")
|
||||||
private Long prjctIdx;
|
private String prjctCd;
|
||||||
|
|
||||||
@Schema(description = "SID")
|
@Schema(description = "SID")
|
||||||
private String sid;
|
private String sid;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.kri.contact.server.persistence.repository;
|
|||||||
import com.kri.contact.server.persistence.entity.TPrjctEntity;
|
import com.kri.contact.server.persistence.entity.TPrjctEntity;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
import org.springframework.data.jpa.repository.Modifying;
|
import org.springframework.data.jpa.repository.Modifying;
|
||||||
@@ -16,6 +17,8 @@ public interface ProjectRepository extends JpaRepository<TPrjctEntity, Long>,
|
|||||||
|
|
||||||
TPrjctEntity findByPrjctIdxAndDelFalse(Long prjctIdx);
|
TPrjctEntity findByPrjctIdxAndDelFalse(Long prjctIdx);
|
||||||
|
|
||||||
|
Optional<TPrjctEntity> findByPrjctCdAndDelFalse(String prjctCd);
|
||||||
|
|
||||||
@Query("""
|
@Query("""
|
||||||
select distinct p.ownerDept
|
select distinct p.ownerDept
|
||||||
from TPrjctEntity p
|
from TPrjctEntity p
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class ListSearchService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public ListSearchExternalDto searchListWithSidFromExternal(Long prjctIdx, String sid) {
|
public ListSearchExternalDto searchListWithSidFromExternal(Long prjctIdx, String prjctCd, String sid) {
|
||||||
ListFilterDto filterDto = ListFilterDto.onlyOneSid(sid);
|
ListFilterDto filterDto = ListFilterDto.onlyOneSid(sid);
|
||||||
List<ListSearchBaseDto> result = createListSearchBase(
|
List<ListSearchBaseDto> result = createListSearchBase(
|
||||||
prjctIdx,
|
prjctIdx,
|
||||||
@@ -116,7 +116,7 @@ public class ListSearchService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return ListSearchExternalDto.builder()
|
return ListSearchExternalDto.builder()
|
||||||
.prjctIdx(list.getPrjctIdx())
|
.prjctCd(prjctCd)
|
||||||
.sid(list.getSid())
|
.sid(list.getSid())
|
||||||
.itemList(itemList)
|
.itemList(itemList)
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -91,6 +91,14 @@ public class ProjectService {
|
|||||||
return withSurveys(projectRepository.findByPrjctIdxAndDelFalse(prjctIdx));
|
return withSurveys(projectRepository.findByPrjctIdxAndDelFalse(prjctIdx));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(readOnly = true)
|
||||||
|
public Long getProjectIdxByCode(String prjctCd) {
|
||||||
|
return projectRepository.findByPrjctCdAndDelFalse(prjctCd)
|
||||||
|
.map(TPrjctEntity::getPrjctIdx)
|
||||||
|
.orElseThrow(() -> BusinessException.notFound("PROJECT_NOT_FOUND", "프로젝트를 찾을 수 없습니다.")
|
||||||
|
.with("prjctCd", prjctCd));
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public List<ProjectInfoDto> getTopProject(
|
public List<ProjectInfoDto> getTopProject(
|
||||||
int topCount,
|
int topCount,
|
||||||
|
|||||||
Reference in New Issue
Block a user