260109_01_ENH : RequestBody에 Valid 누락 추가 및 PageResponse, PageRequest Common으로 이동
This commit is contained in:
@@ -36,7 +36,7 @@ public class IntranetExtensionApiClient {
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
public SearchLoginInfoResponseDto searchLoginInfo(LoginRequestDto request) {
|
||||
String url = String.format("%s/api/v1/user/login-info", intranetExtensionBaseUrl);
|
||||
String url = String.format("%s/user/login-info", intranetExtensionBaseUrl);
|
||||
// 요구사항: ExternalApiClient.post() 사용 (시그니처: post(url, headers, body))
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put(apiKeyHeaderName, apiKey);
|
||||
@@ -51,7 +51,7 @@ public class IntranetExtensionApiClient {
|
||||
}
|
||||
|
||||
public List<String> getUserIdArray() {
|
||||
String url = String.format("%s/api/v1/user/user-id-list", intranetExtensionBaseUrl);
|
||||
String url = String.format("%s/user/user-id-list", intranetExtensionBaseUrl);
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
headers.put(apiKeyHeaderName, apiKey);
|
||||
try {
|
||||
|
||||
@@ -36,7 +36,11 @@ public class AssignController {
|
||||
|
||||
@Operation(summary = "컨택원/면접원 배정")
|
||||
@PutMapping("/prjct-fieldwork/{prjctIdx}")
|
||||
public void upsertPrjctFieldworkAssign(@PathVariable Long prjctIdx, @RequestBody List<String> assignUserIdList, RequestUserContext ctx) {
|
||||
public void upsertPrjctFieldworkAssign(
|
||||
@PathVariable Long prjctIdx,
|
||||
@Valid @RequestBody List<String> assignUserIdList,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
assignService.upsertPrjctFieldworkAssign(prjctIdx, assignUserIdList, ctx.getUserId(), now);
|
||||
systemEventLogService.writeAssignUserProject(ctx.getUserId(), now, ctx.getClientIp(), prjctIdx, assignUserIdList);
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.kri.contact.server.service.AuthService;
|
||||
import com.kri.contact.server.service.SystemEventLogService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -23,7 +24,10 @@ public class AuthController {
|
||||
|
||||
@Operation(summary = "로그인 요청")
|
||||
@PostMapping("/login")
|
||||
public LoginResponseDto tryLogin(@RequestBody LoginRequestDto request, RequestUserContext ctx) {
|
||||
public LoginResponseDto tryLogin(
|
||||
@Valid @RequestBody LoginRequestDto request,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
|
||||
LoginResponseDto response = authService.tryLogin(request);
|
||||
|
||||
@@ -2,8 +2,8 @@ package com.kri.contact.server.controller;
|
||||
|
||||
import com.kri.common.datetime.DateTimeUtil;
|
||||
import com.kri.common.webmvc.RequestUserContext;
|
||||
import com.kri.common.webmvc.page.PageResponseDto;
|
||||
import com.kri.contact.server.dto.*;
|
||||
import com.kri.contact.server.dto.common.PageResponseDto;
|
||||
import com.kri.contact.server.service.FileService;
|
||||
import com.kri.contact.server.service.ProjectService;
|
||||
import com.kri.contact.server.service.SystemEventLogService;
|
||||
@@ -46,7 +46,7 @@ public class ProjectController {
|
||||
@Operation(summary = "프로젝트 목록 조회")
|
||||
@PostMapping("/list")
|
||||
public PageResponseDto<ProjectInfoDto> searchProject(
|
||||
@RequestBody ProjectSearchRequestDto req,
|
||||
@Valid @RequestBody ProjectSearchRequestDto req,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
return projectService.searchProject(req, ctx.getUserId(), ctx.getUserRole());
|
||||
|
||||
@@ -84,7 +84,10 @@ public class UserController {
|
||||
|
||||
@Operation(summary = "사용자 생성")
|
||||
@PutMapping
|
||||
public void createUser(@Valid @RequestBody UserInfoDto userInfo, RequestUserContext ctx) {
|
||||
public void createUser(
|
||||
@Valid @RequestBody UserInfoDto userInfo,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
String regId = ctx.getUserId();
|
||||
String clientIp = ctx.getClientIp();
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
@@ -132,7 +135,10 @@ public class UserController {
|
||||
|
||||
@Operation(summary = "사용자 정보 수정")
|
||||
@PatchMapping()
|
||||
public void updateUser(@Valid @RequestBody UserInfoDto dto, RequestUserContext ctx) {
|
||||
public void updateUser(
|
||||
@Valid @RequestBody UserInfoDto dto,
|
||||
RequestUserContext ctx
|
||||
) {
|
||||
String modId = ctx.getUserId();
|
||||
String clientIp = ctx.getClientIp();
|
||||
final LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.kri.contact.server.dto;
|
||||
|
||||
import com.kri.common.webmvc.page.PageRequestDto;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -19,13 +20,5 @@ public class ProjectSearchRequestDto {
|
||||
@Schema(description = "담당 실사 리스트")
|
||||
private List<String> ownerFwList; // in ('jspark','jhchae')
|
||||
|
||||
@Schema(description = "페이지 번호")
|
||||
private int pageIndex = 0; // 0-base
|
||||
@Schema(description = "페이지 크기")
|
||||
private int pageSize = 10;
|
||||
|
||||
@Schema(description = "정렬 기준")
|
||||
private String sortBy = "prjctIdx"; // 가변
|
||||
@Schema(description = "오름차순/내림차순")
|
||||
private String sortDir = "desc"; // asc/desc
|
||||
private PageRequestDto pageRequest;
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.kri.contact.server.dto.common;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class PageResponseDto <T> {
|
||||
private List<T> content;
|
||||
private long totalElements;
|
||||
private int totalPages;
|
||||
private int pageIndex;
|
||||
private int pageSize;
|
||||
private int numberOfElements;
|
||||
private boolean first;
|
||||
private boolean last;
|
||||
private boolean empty;
|
||||
|
||||
public static <T> PageResponseDto<T> from(Page<T> page) {
|
||||
return PageResponseDto.<T>builder()
|
||||
.content(page.getContent())
|
||||
.totalElements(page.getTotalElements())
|
||||
.totalPages(page.getTotalPages())
|
||||
.pageIndex(page.getNumber()) // ✅ 현재 페이지 index(0-base)
|
||||
.pageSize(page.getSize())
|
||||
.numberOfElements(page.getNumberOfElements())
|
||||
.first(page.isFirst())
|
||||
.last(page.isLast())
|
||||
.empty(page.isEmpty())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.kri.contact.server.service;
|
||||
|
||||
import com.kri.common.file.FileUtil;
|
||||
import com.kri.common.web.BusinessException;
|
||||
import com.kri.common.util.CommonUtil;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
@@ -45,7 +45,7 @@ public class FileService {
|
||||
ext = original.substring(dot);
|
||||
}
|
||||
|
||||
String newName = UUID.randomUUID().toString().replace("-", "") + ext;
|
||||
String newName = CommonUtil.uuid32() + ext;
|
||||
|
||||
Path tempDir = getTempDir(prjctCd);
|
||||
Files.createDirectories(tempDir);
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.kri.contact.server.service;
|
||||
|
||||
import com.kri.common.datetime.DateTimeUtil;
|
||||
import com.kri.common.web.BusinessException;
|
||||
import com.kri.common.webmvc.page.*;
|
||||
import com.kri.contact.server.common.consts.ContactConstant;
|
||||
import com.kri.contact.server.dto.*;
|
||||
import com.kri.contact.server.dto.common.PageResponseDto;
|
||||
import com.kri.contact.server.dto.*;;
|
||||
import com.kri.contact.server.persistence.entity.TPrjctEntity;
|
||||
import com.kri.contact.server.persistence.query.ProjectSorts;
|
||||
import com.kri.contact.server.persistence.query.ProjectSpecs;
|
||||
@@ -93,11 +92,8 @@ public class ProjectService {
|
||||
spec = spec.and(ProjectSpecs.assignedToUserAndNotExcluded(userId));
|
||||
}
|
||||
|
||||
Pageable pageable = PageRequest.of(
|
||||
req.getPageIndex(),
|
||||
req.getPageSize(),
|
||||
ProjectSorts.toSort(req.getSortBy(), req.getSortDir())
|
||||
);
|
||||
PageRequestDto pageReq = req.getPageRequest();
|
||||
Pageable pageable = Pageables.of(pageReq, TPrjctEntity.class);
|
||||
|
||||
Page<ProjectInfoDto> page = projectRepository.findAll(spec, pageable)
|
||||
.map(ProjectInfoDto::from);
|
||||
|
||||
Reference in New Issue
Block a user