Refactor: 중복 DTO 제거
This commit is contained in:
parent
02d79e77ed
commit
3d70a75a6b
@ -22,17 +22,17 @@ public class DetailImageResponse {
|
||||
private String imageUrl;
|
||||
|
||||
@Schema(description = "폴리곤 데이터", example = "PENDING 상태라면 data null")
|
||||
private String dataPath;
|
||||
private String data;
|
||||
|
||||
@Schema(description = "이미지 상태", example = "PENDING")
|
||||
private LabelStatus status;
|
||||
|
||||
public static DetailImageResponse from(final Image image) {
|
||||
public static DetailImageResponse from(final Image image, final String data) {
|
||||
return new DetailImageResponse(
|
||||
image.getId(),
|
||||
image.getTitle(),
|
||||
image.getImagePath(),
|
||||
image.getDataPath(),
|
||||
data,
|
||||
image.getStatus()
|
||||
);
|
||||
}
|
||||
|
@ -53,8 +53,8 @@ public class ImageService {
|
||||
@Transactional(readOnly = true)
|
||||
public DetailImageResponse getImageById(final Integer projectId, final Integer folderId, final Long imageId, final Integer memberId) {
|
||||
Image image = getImageByIdAndFolderIdAndFolderProjectId(folderId, imageId, projectId); // 이미지가 해당 프로젝트에 속하는지 확인
|
||||
// String data = s3UploadService.getData(image.getDataPath());
|
||||
return DetailImageResponse.from(image);
|
||||
String data = s3UploadService.getData(image.getDataPath());
|
||||
return DetailImageResponse.from(image, data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,15 +1,12 @@
|
||||
package com.worlabel.domain.member.controller;
|
||||
|
||||
import com.worlabel.domain.member.entity.dto.MemberResponse;
|
||||
import com.worlabel.domain.member.entity.dto.SearchMemberResponse;
|
||||
import com.worlabel.domain.member.entity.dto.MemberDetailResponse;
|
||||
import com.worlabel.domain.member.service.MemberService;
|
||||
import com.worlabel.domain.workspace.entity.dto.WorkspaceResponse;
|
||||
import com.worlabel.global.annotation.CurrentUser;
|
||||
import com.worlabel.global.config.swagger.SwaggerApiError;
|
||||
import com.worlabel.global.config.swagger.SwaggerApiSuccess;
|
||||
import com.worlabel.global.exception.ErrorCode;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
@ -31,7 +28,7 @@ public class MemberController {
|
||||
@SwaggerApiSuccess(description = "keyword가 포함된 사용자를 검색합니다.")
|
||||
@SwaggerApiError({ErrorCode.BAD_REQUEST, ErrorCode.NOT_AUTHOR, ErrorCode.SERVER_ERROR})
|
||||
@GetMapping
|
||||
public List<SearchMemberResponse> getWorkspace(
|
||||
public List<MemberDetailResponse> getWorkspace(
|
||||
@CurrentUser final Integer memberId,
|
||||
@Param("keyword") final String keyword
|
||||
) {
|
||||
|
@ -2,17 +2,14 @@ package com.worlabel.domain.member.entity.dto;
|
||||
|
||||
import com.worlabel.domain.member.entity.Member;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@Schema(name = "멤버 검색 DTO", description = "이메일 검색에 대한 응답 DTO")
|
||||
public class SearchMemberResponse {
|
||||
@Schema(name = "멤버 상세 DTO", description = "멤버 상세 응답 DTO")
|
||||
public class MemberDetailResponse {
|
||||
@Schema(description = "ID", example = "1")
|
||||
private Integer id;
|
||||
|
||||
@ -25,7 +22,7 @@ public class SearchMemberResponse {
|
||||
@Schema(description = "이메일", example = "xxx@gmail.com")
|
||||
private String email;
|
||||
|
||||
public static SearchMemberResponse of(final Member member) {
|
||||
return new SearchMemberResponse(member.getId(), member.getNickname(), member.getProfileImage(), member.getEmail());
|
||||
public static MemberDetailResponse of(final Member member) {
|
||||
return new MemberDetailResponse(member.getId(), member.getNickname(), member.getProfileImage(), member.getEmail());
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ package com.worlabel.domain.member.service;
|
||||
|
||||
import com.worlabel.domain.member.entity.Member;
|
||||
import com.worlabel.domain.member.entity.dto.MemberResponse;
|
||||
import com.worlabel.domain.member.entity.dto.SearchMemberResponse;
|
||||
import com.worlabel.domain.member.entity.dto.MemberDetailResponse;
|
||||
import com.worlabel.domain.member.repository.MemberRepository;
|
||||
import com.worlabel.global.exception.CustomException;
|
||||
import com.worlabel.global.exception.ErrorCode;
|
||||
@ -32,10 +32,10 @@ public class MemberService {
|
||||
return MemberResponse.of(member);
|
||||
}
|
||||
|
||||
public List<SearchMemberResponse> getSearchMember(final Integer memberId, final String keyword) {
|
||||
public List<MemberDetailResponse> getSearchMember(final Integer memberId, final String keyword) {
|
||||
return memberRepository.findAllByKeyword(memberId, keyword.isEmpty() ? null : keyword)
|
||||
.stream()
|
||||
.map(SearchMemberResponse::of)
|
||||
.map(MemberDetailResponse::of)
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.worlabel.domain.review.entity.dto;
|
||||
|
||||
import com.worlabel.domain.image.entity.dto.ImageResponse;
|
||||
import com.worlabel.domain.member.entity.Member;
|
||||
import com.worlabel.domain.member.entity.dto.MemberResponse;
|
||||
import com.worlabel.domain.member.entity.dto.MemberDetailResponse;
|
||||
import com.worlabel.domain.review.entity.Review;
|
||||
import com.worlabel.domain.review.entity.ReviewStatus;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@ -41,10 +41,10 @@ public class ReviewDetailResponse {
|
||||
private LocalDateTime updateAt;
|
||||
|
||||
@Schema(description = "작성자 정보", example = "")
|
||||
private MemberResponse author;
|
||||
private MemberDetailResponse author;
|
||||
|
||||
@Schema(description = "리뷰어 정보", example = "")
|
||||
private MemberResponse reviewer;
|
||||
private MemberDetailResponse reviewer;
|
||||
|
||||
public static ReviewDetailResponse of(final Review review, final List<ImageResponse> images) {
|
||||
Member writer = review.getMember();
|
||||
@ -57,8 +57,8 @@ public class ReviewDetailResponse {
|
||||
images,
|
||||
review.getCreatedAt(),
|
||||
review.getUpdatedAt(),
|
||||
MemberResponse.of(writer),
|
||||
Optional.ofNullable(reviewer).map(MemberResponse::of).orElse(null)
|
||||
MemberDetailResponse.of(writer),
|
||||
Optional.ofNullable(reviewer).map(MemberDetailResponse::of).orElse(null)
|
||||
);
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.worlabel.domain.review.entity.dto;
|
||||
|
||||
import com.worlabel.domain.member.entity.dto.MemberDetailResponse;
|
||||
import com.worlabel.domain.review.entity.Review;
|
||||
import com.worlabel.domain.review.entity.ReviewStatus;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@ -29,11 +30,8 @@ public class ReviewResponse {
|
||||
@Schema(description = "리뷰 상태", example = "요청")
|
||||
private ReviewStatus status;
|
||||
|
||||
@Schema(description = "작성자 닉네임", example = "javajoha")
|
||||
private String nickname;
|
||||
|
||||
@Schema(description = "작성자 이메일", example = "jaa@naver.com")
|
||||
private String email;
|
||||
@Schema(description = "작성자 정보", example = "")
|
||||
private MemberDetailResponse author;
|
||||
|
||||
@Schema(description = "리뷰 작성일", example = "")
|
||||
private LocalDateTime createAt;
|
||||
@ -48,8 +46,7 @@ public class ReviewResponse {
|
||||
review.getTitle(),
|
||||
review.getContent(),
|
||||
review.getReviewStatus(),
|
||||
review.getMember().getNickname(),
|
||||
review.getMember().getEmail(),
|
||||
MemberDetailResponse.of(review.getMember()),
|
||||
review.getCreatedAt(),
|
||||
review.getUpdatedAt());
|
||||
}
|
||||
|
@ -1,10 +1,8 @@
|
||||
package com.worlabel.domain.workspace.controller;
|
||||
|
||||
import com.worlabel.domain.member.entity.dto.MemberResponse;
|
||||
import com.worlabel.domain.project.entity.dto.ProjectMemberResponse;
|
||||
import com.worlabel.domain.review.entity.dto.ReviewResponse;
|
||||
import com.worlabel.domain.review.entity.dto.ReviewStatusRequest;
|
||||
import com.worlabel.domain.workspace.entity.dto.WorkspaceMemberResponse;
|
||||
import com.worlabel.domain.workspace.entity.dto.WorkspaceRequest;
|
||||
import com.worlabel.domain.workspace.entity.dto.WorkspaceResponse;
|
||||
import com.worlabel.domain.workspace.entity.dto.WorkspaceResponses;
|
||||
|
@ -6,12 +6,10 @@ import com.worlabel.domain.member.repository.MemberRepository;
|
||||
import com.worlabel.domain.participant.entity.WorkspaceParticipant;
|
||||
import com.worlabel.domain.participant.repository.WorkspaceParticipantRepository;
|
||||
import com.worlabel.domain.review.entity.Review;
|
||||
import com.worlabel.domain.review.entity.ReviewStatus;
|
||||
import com.worlabel.domain.review.entity.dto.ReviewResponse;
|
||||
import com.worlabel.domain.review.entity.dto.ReviewStatusRequest;
|
||||
import com.worlabel.domain.review.repository.ReviewRepository;
|
||||
import com.worlabel.domain.workspace.entity.Workspace;
|
||||
import com.worlabel.domain.workspace.entity.dto.WorkspaceMemberResponse;
|
||||
import com.worlabel.domain.workspace.entity.dto.WorkspaceRequest;
|
||||
import com.worlabel.domain.workspace.entity.dto.WorkspaceResponse;
|
||||
import com.worlabel.domain.workspace.repository.WorkspaceRepository;
|
||||
|
Loading…
Reference in New Issue
Block a user