diff --git a/backend/src/main/java/aimo/backend/common/config/DataInitConfig.java b/backend/src/main/java/aimo/backend/common/config/DataInitConfig.java index 029f92a..bbf5ac6 100644 --- a/backend/src/main/java/aimo/backend/common/config/DataInitConfig.java +++ b/backend/src/main/java/aimo/backend/common/config/DataInitConfig.java @@ -55,8 +55,8 @@ public void initializeData(MemberRepository memberRepo, PrivatePostRepository pr for (int i = 1; i <= 3; i++) { Member member = Member.builder() .nickname("nickname" + i) - .email("email" + i + "@example.com") - .password(passwordEncoder.encode("password" + i)) + .email("a" + i + "@naver.com") + .password(passwordEncoder.encode("a" + i)) .memberRole(MemberRole.USER) .gender(Gender.MALE) .provider(Provider.AIMO) @@ -89,7 +89,8 @@ public void initializeData(MemberRepository memberRepo, PrivatePostRepository pr .judgement("Judgement " + i) .originType(OriginType.TEXT) .textRecord(textRecords.get(i-1)) - .faultRate(0.5) + .faultRatePlaintiff(50) + .faultRateDefendant(50) .published(true) .build(); diff --git a/backend/src/main/java/aimo/backend/common/mapper/AudioRecordMapper.java b/backend/src/main/java/aimo/backend/common/mapper/AudioRecordMapper.java index ee8dba5..fb120a9 100644 --- a/backend/src/main/java/aimo/backend/common/mapper/AudioRecordMapper.java +++ b/backend/src/main/java/aimo/backend/common/mapper/AudioRecordMapper.java @@ -1,7 +1,7 @@ package aimo.backend.common.mapper; -import aimo.backend.domains.privatePost.dto.SaveAudioSuccessRequest; -import aimo.backend.domains.privatePost.dto.SaveAudioSuccessResponse; +import aimo.backend.domains.privatePost.dto.request.SaveAudioSuccessRequest; +import aimo.backend.domains.privatePost.dto.response.SaveAudioSuccessResponse; import aimo.backend.domains.privatePost.entity.AudioRecord; public class AudioRecordMapper { diff --git a/backend/src/main/java/aimo/backend/common/mapper/MemberMapper.java b/backend/src/main/java/aimo/backend/common/mapper/MemberMapper.java index 35a556b..933a7fa 100644 --- a/backend/src/main/java/aimo/backend/common/mapper/MemberMapper.java +++ b/backend/src/main/java/aimo/backend/common/mapper/MemberMapper.java @@ -3,8 +3,8 @@ import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Component; -import aimo.backend.domains.member.dto.FindMyInfoResponse; -import aimo.backend.domains.member.dto.SignUpRequest; +import aimo.backend.domains.member.dto.response.FindMyInfoResponse; +import aimo.backend.domains.member.dto.request.SignUpRequest; import aimo.backend.domains.member.entity.Member; import aimo.backend.domains.member.model.MemberRole; import aimo.backend.domains.member.model.Provider; diff --git a/backend/src/main/java/aimo/backend/common/mapper/PrivatePostMapper.java b/backend/src/main/java/aimo/backend/common/mapper/PrivatePostMapper.java index 7d4e234..fa8a5f2 100644 --- a/backend/src/main/java/aimo/backend/common/mapper/PrivatePostMapper.java +++ b/backend/src/main/java/aimo/backend/common/mapper/PrivatePostMapper.java @@ -1,21 +1,22 @@ package aimo.backend.common.mapper; -import aimo.backend.domains.privatePost.dto.PrivatePostPreviewResponse; -import aimo.backend.domains.privatePost.dto.PrivatePostResponse; -import aimo.backend.domains.privatePost.dto.SummaryAndJudgementResponse; +import aimo.backend.domains.privatePost.dto.response.JudgementResponse; +import aimo.backend.domains.privatePost.dto.response.PrivatePostPreviewResponse; +import aimo.backend.domains.privatePost.dto.response.PrivatePostResponse; import aimo.backend.domains.privatePost.entity.PrivatePost; public class PrivatePostMapper { - public static PrivatePost toEntity(SummaryAndJudgementResponse summaryAndJudgementResponse) { + public static PrivatePost toEntity(JudgementResponse judgementResponse) { return PrivatePost.builder() - .title(summaryAndJudgementResponse.title()) - .stancePlaintiff(summaryAndJudgementResponse.stancePlaintiff()) - .stanceDefendant(summaryAndJudgementResponse.stanceDefendant()) - .summaryAi(summaryAndJudgementResponse.summaryAi()) - .judgement(summaryAndJudgementResponse.judgement()) - .faultRate(summaryAndJudgementResponse.faultRate()) - .originType(summaryAndJudgementResponse.originType()) + .title(judgementResponse.title()) + .stancePlaintiff(judgementResponse.stancePlaintiff()) + .stanceDefendant(judgementResponse.stanceDefendant()) + .summaryAi(judgementResponse.summary()) + .judgement(judgementResponse.judgement()) + .faultRatePlaintiff(judgementResponse.faultRatePlaintiff()) + .faultRateDefendant(judgementResponse.faultRateDefendant()) + .originType(judgementResponse.originType()) .build(); } @@ -30,8 +31,14 @@ public static String getPreview(String summaryAi, Integer length) { } public static PrivatePostResponse toResponse(PrivatePost privatePost) { - return new PrivatePostResponse(privatePost.getTitle(), privatePost.getSummaryAi(), - privatePost.getStancePlaintiff(), privatePost.getStanceDefendant(), privatePost.getJudgement(), - privatePost.getFaultRate(), privatePost.getPublished()); + return new PrivatePostResponse( + privatePost.getTitle(), + privatePost.getSummaryAi(), + privatePost.getStancePlaintiff(), + privatePost.getStanceDefendant(), + privatePost.getJudgement(), + privatePost.getFaultRatePlaintiff(), + privatePost.getFaultRateDefendant(), + privatePost.getPublished()); } } diff --git a/backend/src/main/java/aimo/backend/domains/comment/service/ParentCommentService.java b/backend/src/main/java/aimo/backend/domains/comment/service/ParentCommentService.java index 1de6f4e..5f7d513 100644 --- a/backend/src/main/java/aimo/backend/domains/comment/service/ParentCommentService.java +++ b/backend/src/main/java/aimo/backend/domains/comment/service/ParentCommentService.java @@ -59,6 +59,7 @@ public void validateAndUpdateParentComment(Member member, Long commentId, Update public void validateAndDeleteParentComment(Member member, Long commentId) { validateParentCommentAuthority(member, commentId); + parentCommentRepository.findById(commentId) .ifPresent(ParentComment::deleteParentCommentSoftly); } diff --git a/backend/src/main/java/aimo/backend/domains/member/controller/MemberController.java b/backend/src/main/java/aimo/backend/domains/member/controller/MemberController.java index 7746733..187c071 100644 --- a/backend/src/main/java/aimo/backend/domains/member/controller/MemberController.java +++ b/backend/src/main/java/aimo/backend/domains/member/controller/MemberController.java @@ -13,17 +13,17 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import aimo.backend.domains.member.dto.CreateProfileImageUrlRequest; -import aimo.backend.domains.member.dto.DeleteRequest; -import aimo.backend.domains.member.dto.FindMyInfoResponse; -import aimo.backend.domains.member.dto.LogOutRequest; -import aimo.backend.domains.member.dto.NicknameExistsResponse; -import aimo.backend.domains.member.dto.SendTemporaryPasswordRequest; -import aimo.backend.domains.member.dto.SignUpRequest; +import aimo.backend.domains.member.dto.request.CreateProfileImageUrlRequest; +import aimo.backend.domains.member.dto.request.DeleteRequest; +import aimo.backend.domains.member.dto.response.FindMyInfoResponse; +import aimo.backend.domains.member.dto.request.LogOutRequest; +import aimo.backend.domains.member.dto.response.NicknameExistsResponse; +import aimo.backend.domains.member.dto.request.SendTemporaryPasswordRequest; +import aimo.backend.domains.member.dto.request.SignUpRequest; import aimo.backend.common.dto.DataResponse; import aimo.backend.domains.auth.security.jwtFilter.JwtTokenProvider; -import aimo.backend.domains.member.dto.UpdateNicknameRequest; -import aimo.backend.domains.member.dto.UpdatePasswordRequest; +import aimo.backend.domains.member.dto.request.UpdateNicknameRequest; +import aimo.backend.domains.member.dto.request.UpdatePasswordRequest; import aimo.backend.infrastructure.s3.S3Service; import aimo.backend.infrastructure.s3.dto.CreatePresignedUrlResponse; import aimo.backend.infrastructure.s3.dto.SaveFileMetaDataRequest; diff --git a/backend/src/main/java/aimo/backend/domains/member/dto/SaveProfileImageMetaData.java b/backend/src/main/java/aimo/backend/domains/member/dto/SaveProfileImageMetaData.java deleted file mode 100644 index 8bb718c..0000000 --- a/backend/src/main/java/aimo/backend/domains/member/dto/SaveProfileImageMetaData.java +++ /dev/null @@ -1,9 +0,0 @@ -package aimo.backend.domains.member.dto; - -public record SaveProfileImageMetaData( - String filename, - String extension, - Long size, - String url -) { -} diff --git a/backend/src/main/java/aimo/backend/domains/member/dto/CreateProfileImageUrlRequest.java b/backend/src/main/java/aimo/backend/domains/member/dto/request/CreateProfileImageUrlRequest.java similarity index 63% rename from backend/src/main/java/aimo/backend/domains/member/dto/CreateProfileImageUrlRequest.java rename to backend/src/main/java/aimo/backend/domains/member/dto/request/CreateProfileImageUrlRequest.java index dd472ac..361bd7d 100644 --- a/backend/src/main/java/aimo/backend/domains/member/dto/CreateProfileImageUrlRequest.java +++ b/backend/src/main/java/aimo/backend/domains/member/dto/request/CreateProfileImageUrlRequest.java @@ -1,4 +1,4 @@ -package aimo.backend.domains.member.dto; +package aimo.backend.domains.member.dto.request; public record CreateProfileImageUrlRequest( String nickname, diff --git a/backend/src/main/java/aimo/backend/domains/member/dto/DeleteRequest.java b/backend/src/main/java/aimo/backend/domains/member/dto/request/DeleteRequest.java similarity index 50% rename from backend/src/main/java/aimo/backend/domains/member/dto/DeleteRequest.java rename to backend/src/main/java/aimo/backend/domains/member/dto/request/DeleteRequest.java index c55c267..449e737 100644 --- a/backend/src/main/java/aimo/backend/domains/member/dto/DeleteRequest.java +++ b/backend/src/main/java/aimo/backend/domains/member/dto/request/DeleteRequest.java @@ -1,4 +1,4 @@ -package aimo.backend.domains.member.dto; +package aimo.backend.domains.member.dto.request; public record DeleteRequest(String password) { } diff --git a/backend/src/main/java/aimo/backend/domains/member/dto/LogOutRequest.java b/backend/src/main/java/aimo/backend/domains/member/dto/request/LogOutRequest.java similarity index 61% rename from backend/src/main/java/aimo/backend/domains/member/dto/LogOutRequest.java rename to backend/src/main/java/aimo/backend/domains/member/dto/request/LogOutRequest.java index 8127e90..8a2a825 100644 --- a/backend/src/main/java/aimo/backend/domains/member/dto/LogOutRequest.java +++ b/backend/src/main/java/aimo/backend/domains/member/dto/request/LogOutRequest.java @@ -1,4 +1,4 @@ -package aimo.backend.domains.member.dto; +package aimo.backend.domains.member.dto.request; public record LogOutRequest( String accessToken, diff --git a/backend/src/main/java/aimo/backend/domains/member/dto/request/SaveProfileImageMetaDataRequest.java b/backend/src/main/java/aimo/backend/domains/member/dto/request/SaveProfileImageMetaDataRequest.java new file mode 100644 index 0000000..9b2fbd5 --- /dev/null +++ b/backend/src/main/java/aimo/backend/domains/member/dto/request/SaveProfileImageMetaDataRequest.java @@ -0,0 +1,9 @@ +package aimo.backend.domains.member.dto.request; + +public record SaveProfileImageMetaDataRequest( + String filename, + String extension, + Long size, + String url +) { +} diff --git a/backend/src/main/java/aimo/backend/domains/member/dto/SendTemporaryPasswordRequest.java b/backend/src/main/java/aimo/backend/domains/member/dto/request/SendTemporaryPasswordRequest.java similarity index 77% rename from backend/src/main/java/aimo/backend/domains/member/dto/SendTemporaryPasswordRequest.java rename to backend/src/main/java/aimo/backend/domains/member/dto/request/SendTemporaryPasswordRequest.java index db4599f..51fef4d 100644 --- a/backend/src/main/java/aimo/backend/domains/member/dto/SendTemporaryPasswordRequest.java +++ b/backend/src/main/java/aimo/backend/domains/member/dto/request/SendTemporaryPasswordRequest.java @@ -1,4 +1,4 @@ -package aimo.backend.domains.member.dto; +package aimo.backend.domains.member.dto.request; import jakarta.validation.constraints.Email; diff --git a/backend/src/main/java/aimo/backend/domains/member/dto/SignUpRequest.java b/backend/src/main/java/aimo/backend/domains/member/dto/request/SignUpRequest.java similarity index 93% rename from backend/src/main/java/aimo/backend/domains/member/dto/SignUpRequest.java rename to backend/src/main/java/aimo/backend/domains/member/dto/request/SignUpRequest.java index d121a7a..d9dd321 100644 --- a/backend/src/main/java/aimo/backend/domains/member/dto/SignUpRequest.java +++ b/backend/src/main/java/aimo/backend/domains/member/dto/request/SignUpRequest.java @@ -1,4 +1,4 @@ -package aimo.backend.domains.member.dto; +package aimo.backend.domains.member.dto.request; import java.time.LocalDate; diff --git a/backend/src/main/java/aimo/backend/domains/member/dto/UpdateNicknameRequest.java b/backend/src/main/java/aimo/backend/domains/member/dto/request/UpdateNicknameRequest.java similarity index 55% rename from backend/src/main/java/aimo/backend/domains/member/dto/UpdateNicknameRequest.java rename to backend/src/main/java/aimo/backend/domains/member/dto/request/UpdateNicknameRequest.java index 6d07188..397f115 100644 --- a/backend/src/main/java/aimo/backend/domains/member/dto/UpdateNicknameRequest.java +++ b/backend/src/main/java/aimo/backend/domains/member/dto/request/UpdateNicknameRequest.java @@ -1,4 +1,4 @@ -package aimo.backend.domains.member.dto; +package aimo.backend.domains.member.dto.request; public record UpdateNicknameRequest(String newNickname) { } diff --git a/backend/src/main/java/aimo/backend/domains/member/dto/UpdatePasswordRequest.java b/backend/src/main/java/aimo/backend/domains/member/dto/request/UpdatePasswordRequest.java similarity index 84% rename from backend/src/main/java/aimo/backend/domains/member/dto/UpdatePasswordRequest.java rename to backend/src/main/java/aimo/backend/domains/member/dto/request/UpdatePasswordRequest.java index d132449..798d301 100644 --- a/backend/src/main/java/aimo/backend/domains/member/dto/UpdatePasswordRequest.java +++ b/backend/src/main/java/aimo/backend/domains/member/dto/request/UpdatePasswordRequest.java @@ -1,4 +1,4 @@ -package aimo.backend.domains.member.dto; +package aimo.backend.domains.member.dto.request; import jakarta.validation.constraints.NotNull; diff --git a/backend/src/main/java/aimo/backend/domains/member/dto/ValidateDuplicateNicknameRequest.java b/backend/src/main/java/aimo/backend/domains/member/dto/request/ValidateDuplicateNicknameRequest.java similarity index 58% rename from backend/src/main/java/aimo/backend/domains/member/dto/ValidateDuplicateNicknameRequest.java rename to backend/src/main/java/aimo/backend/domains/member/dto/request/ValidateDuplicateNicknameRequest.java index c33605d..345d3f6 100644 --- a/backend/src/main/java/aimo/backend/domains/member/dto/ValidateDuplicateNicknameRequest.java +++ b/backend/src/main/java/aimo/backend/domains/member/dto/request/ValidateDuplicateNicknameRequest.java @@ -1,4 +1,4 @@ -package aimo.backend.domains.member.dto; +package aimo.backend.domains.member.dto.request; public record ValidateDuplicateNicknameRequest(String nickname) { } diff --git a/backend/src/main/java/aimo/backend/domains/member/dto/FindMyInfoResponse.java b/backend/src/main/java/aimo/backend/domains/member/dto/response/FindMyInfoResponse.java similarity index 65% rename from backend/src/main/java/aimo/backend/domains/member/dto/FindMyInfoResponse.java rename to backend/src/main/java/aimo/backend/domains/member/dto/response/FindMyInfoResponse.java index d70c665..6b5dcc8 100644 --- a/backend/src/main/java/aimo/backend/domains/member/dto/FindMyInfoResponse.java +++ b/backend/src/main/java/aimo/backend/domains/member/dto/response/FindMyInfoResponse.java @@ -1,4 +1,4 @@ -package aimo.backend.domains.member.dto; +package aimo.backend.domains.member.dto.response; public record FindMyInfoResponse( String nickname, diff --git a/backend/src/main/java/aimo/backend/domains/member/dto/NicknameExistsResponse.java b/backend/src/main/java/aimo/backend/domains/member/dto/response/NicknameExistsResponse.java similarity index 53% rename from backend/src/main/java/aimo/backend/domains/member/dto/NicknameExistsResponse.java rename to backend/src/main/java/aimo/backend/domains/member/dto/response/NicknameExistsResponse.java index 7fab330..0e4aca6 100644 --- a/backend/src/main/java/aimo/backend/domains/member/dto/NicknameExistsResponse.java +++ b/backend/src/main/java/aimo/backend/domains/member/dto/response/NicknameExistsResponse.java @@ -1,4 +1,4 @@ -package aimo.backend.domains.member.dto; +package aimo.backend.domains.member.dto.response; public record NicknameExistsResponse(boolean exists) { } diff --git a/backend/src/main/java/aimo/backend/domains/member/dto/SendTemporaryPasswordResponse.java b/backend/src/main/java/aimo/backend/domains/member/dto/response/SendTemporaryPasswordResponse.java similarity index 68% rename from backend/src/main/java/aimo/backend/domains/member/dto/SendTemporaryPasswordResponse.java rename to backend/src/main/java/aimo/backend/domains/member/dto/response/SendTemporaryPasswordResponse.java index 6f22d81..4bb37eb 100644 --- a/backend/src/main/java/aimo/backend/domains/member/dto/SendTemporaryPasswordResponse.java +++ b/backend/src/main/java/aimo/backend/domains/member/dto/response/SendTemporaryPasswordResponse.java @@ -1,4 +1,4 @@ -package aimo.backend.domains.member.dto; +package aimo.backend.domains.member.dto.response; public record SendTemporaryPasswordResponse( String to, diff --git a/backend/src/main/java/aimo/backend/domains/member/entity/Member.java b/backend/src/main/java/aimo/backend/domains/member/entity/Member.java index 50729a8..7acf22b 100644 --- a/backend/src/main/java/aimo/backend/domains/member/entity/Member.java +++ b/backend/src/main/java/aimo/backend/domains/member/entity/Member.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.List; +import aimo.backend.domains.comment.entity.ChildComment; import aimo.backend.domains.privatePost.entity.PrivatePost; import aimo.backend.domains.member.model.Gender; import aimo.backend.domains.member.model.MemberRole; @@ -78,6 +79,9 @@ public class Member extends BaseEntity { @OneToMany(mappedBy = "member") private List parentComments = new ArrayList<>(); + @OneToMany(mappedBy = "member") + private List childComments = new ArrayList<>(); + public void updateProfileImage(ProfileImage profileImage) { this.profileImage = profileImage; } diff --git a/backend/src/main/java/aimo/backend/domains/member/service/MemberService.java b/backend/src/main/java/aimo/backend/domains/member/service/MemberService.java index 3167d87..9dd1818 100644 --- a/backend/src/main/java/aimo/backend/domains/member/service/MemberService.java +++ b/backend/src/main/java/aimo/backend/domains/member/service/MemberService.java @@ -2,20 +2,20 @@ import aimo.backend.common.exception.ApiException; import aimo.backend.common.exception.ErrorCode; -import aimo.backend.domains.member.dto.DeleteRequest; -import aimo.backend.domains.member.dto.FindMyInfoResponse; -import aimo.backend.domains.member.dto.LogOutRequest; -import aimo.backend.domains.member.dto.SendTemporaryPasswordRequest; -import aimo.backend.domains.member.dto.SignUpRequest; -import aimo.backend.domains.member.dto.UpdateNicknameRequest; -import aimo.backend.domains.member.dto.UpdatePasswordRequest; +import aimo.backend.domains.member.dto.request.DeleteRequest; +import aimo.backend.domains.member.dto.response.FindMyInfoResponse; +import aimo.backend.domains.member.dto.request.LogOutRequest; +import aimo.backend.domains.member.dto.request.SendTemporaryPasswordRequest; +import aimo.backend.domains.member.dto.request.SignUpRequest; +import aimo.backend.domains.member.dto.request.UpdateNicknameRequest; +import aimo.backend.domains.member.dto.request.UpdatePasswordRequest; import aimo.backend.domains.member.entity.Member; import aimo.backend.domains.member.entity.ProfileImage; import aimo.backend.domains.member.entity.RefreshToken; import aimo.backend.common.mapper.MemberMapper; import aimo.backend.domains.member.repository.MemberRepository; import aimo.backend.domains.member.repository.ProfileImageRepository; -import aimo.backend.domains.privatePost.dto.CreateResourceUrl; +import aimo.backend.domains.privatePost.dto.request.CreateResourceUrlRequest; import aimo.backend.infrastructure.s3.S3Service; import aimo.backend.infrastructure.s3.dto.SaveFileMetaDataRequest; import aimo.backend.infrastructure.s3.model.PresignedUrlPrefix; @@ -95,15 +95,15 @@ public void saveProfileImageMetaData(SaveFileMetaDataRequest request) { deleteProfileImage(); } - CreateResourceUrl createResourceUrl = new CreateResourceUrl(PresignedUrlPrefix.IMAGE.getValue(), - request.filename(), request.extension()); + CreateResourceUrlRequest createResourceUrlRequest = + new CreateResourceUrlRequest(PresignedUrlPrefix.IMAGE.getValue(), request.filename(), request.extension()); ProfileImage profileImage = ProfileImage.builder() .member(memberLoader.getMember()) .filename(request.filename()) .size(request.size()) .extension(request.extension()) - .url(s3Service.getResourceUrl(createResourceUrl)) + .url(s3Service.getResourceUrl(createResourceUrlRequest)) .build(); profileImageRepository.save(profileImage); diff --git a/backend/src/main/java/aimo/backend/domains/post/dto/SinglePostResponse.java b/backend/src/main/java/aimo/backend/domains/post/dto/response/SinglePostResponse.java similarity index 84% rename from backend/src/main/java/aimo/backend/domains/post/dto/SinglePostResponse.java rename to backend/src/main/java/aimo/backend/domains/post/dto/response/SinglePostResponse.java index 8a2ede8..48a2e3e 100644 --- a/backend/src/main/java/aimo/backend/domains/post/dto/SinglePostResponse.java +++ b/backend/src/main/java/aimo/backend/domains/post/dto/response/SinglePostResponse.java @@ -1,10 +1,9 @@ -package aimo.backend.domains.post.dto; +package aimo.backend.domains.post.dto.response; import java.time.LocalDateTime; import java.util.List; import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; import aimo.backend.domains.comment.dto.response.CommentResponse; diff --git a/backend/src/main/java/aimo/backend/domains/post/service/PostService.java b/backend/src/main/java/aimo/backend/domains/post/service/PostService.java index 14a8c5d..5e3fb62 100644 --- a/backend/src/main/java/aimo/backend/domains/post/service/PostService.java +++ b/backend/src/main/java/aimo/backend/domains/post/service/PostService.java @@ -23,8 +23,6 @@ import aimo.backend.domains.post.entity.Post; import aimo.backend.domains.post.model.PostType; import aimo.backend.domains.post.repository.PostRepository; -import aimo.backend.domains.privatePost.dto.PrivatePostResponse; -import aimo.backend.domains.privatePost.entity.PrivatePost; import aimo.backend.domains.privatePost.service.PrivatePostService; import aimo.backend.util.memberLoader.MemberLoader; import lombok.RequiredArgsConstructor; diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/controller/PrivatePostController.java b/backend/src/main/java/aimo/backend/domains/privatePost/controller/PrivatePostController.java index ae25d89..023fcec 100644 --- a/backend/src/main/java/aimo/backend/domains/privatePost/controller/PrivatePostController.java +++ b/backend/src/main/java/aimo/backend/domains/privatePost/controller/PrivatePostController.java @@ -19,16 +19,19 @@ import aimo.backend.common.dto.DataResponse; -import aimo.backend.domains.privatePost.dto.ChatRecordRequest; -import aimo.backend.domains.privatePost.dto.PrivatePostPreviewResponse; -import aimo.backend.domains.privatePost.dto.PrivatePostResponse; -import aimo.backend.domains.privatePost.dto.SaveAudioSuccessRequest; -import aimo.backend.domains.privatePost.dto.SaveAudioSuccessResponse; -import aimo.backend.domains.privatePost.dto.SpeachToTextRequest; -import aimo.backend.domains.privatePost.dto.SpeachToTextResponse; - -import aimo.backend.domains.privatePost.dto.SummaryAndJudgementResponse; -import aimo.backend.domains.privatePost.dto.TextRecordRequest; +import aimo.backend.domains.privatePost.dto.request.ChatRecordRequest; +import aimo.backend.domains.privatePost.dto.request.JudgementToAiRequest; +import aimo.backend.domains.privatePost.dto.request.SummaryAndJudgementRequest; +import aimo.backend.domains.privatePost.dto.response.JudgementResponse; +import aimo.backend.domains.privatePost.dto.response.PrivatePostPreviewResponse; +import aimo.backend.domains.privatePost.dto.response.PrivatePostResponse; +import aimo.backend.domains.privatePost.dto.request.SaveAudioSuccessRequest; +import aimo.backend.domains.privatePost.dto.response.SaveAudioSuccessResponse; +import aimo.backend.domains.privatePost.dto.request.SpeachToTextRequest; +import aimo.backend.domains.privatePost.dto.response.SpeachToTextResponse; + +import aimo.backend.domains.privatePost.dto.response.JudgementFromAiResponse; +import aimo.backend.domains.privatePost.dto.request.TextRecordRequest; import aimo.backend.domains.privatePost.service.AudioRecordService; import aimo.backend.domains.privatePost.service.ChatRecordService; import aimo.backend.domains.privatePost.service.PrivatePostService; @@ -38,7 +41,6 @@ import jakarta.validation.Valid; import aimo.backend.domains.privatePost.service.TextRecordService; -import aimo.backend.util.memberLoader.MemberLoader; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -55,9 +57,9 @@ public class PrivatePostController { // 판결 @PostMapping("/judgement") - public ResponseEntity> judgement(@Valid @RequestBody TextRecordRequest textRecordRequest) { + public ResponseEntity> summaryAndJudgment(@Valid @RequestBody JudgementToAiRequest judgementToAiRequest) { - SummaryAndJudgementResponse summaryAndJudgementResponse = privatePostService.serveScriptToAi(textRecordRequest); + JudgementResponse summaryAndJudgementResponse = privatePostService.serveScriptToAi(judgementToAiRequest); privatePostService.save(summaryAndJudgementResponse); diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/dto/CreateResourceUrl.java b/backend/src/main/java/aimo/backend/domains/privatePost/dto/CreateResourceUrl.java deleted file mode 100644 index a7b55c0..0000000 --- a/backend/src/main/java/aimo/backend/domains/privatePost/dto/CreateResourceUrl.java +++ /dev/null @@ -1,10 +0,0 @@ -package aimo.backend.domains.privatePost.dto; - -import aimo.backend.infrastructure.s3.model.PresignedUrlPrefix; - -public record CreateResourceUrl( - String prefix, - String filename, - String extension -) { -} diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/dto/JudgementFromAIResponse.java b/backend/src/main/java/aimo/backend/domains/privatePost/dto/JudgementFromAIResponse.java deleted file mode 100644 index a3f254d..0000000 --- a/backend/src/main/java/aimo/backend/domains/privatePost/dto/JudgementFromAIResponse.java +++ /dev/null @@ -1,10 +0,0 @@ -package aimo.backend.domains.privatePost.dto; - -public record JudgementFromAIResponse( - String title, - String stancePlaintiff, - String stanceDefendant, - String stanceAi, - String judgement, - String faultRate -) {} diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/dto/TextRecordRequest.java b/backend/src/main/java/aimo/backend/domains/privatePost/dto/TextRecordRequest.java deleted file mode 100644 index 5ef4d76..0000000 --- a/backend/src/main/java/aimo/backend/domains/privatePost/dto/TextRecordRequest.java +++ /dev/null @@ -1,11 +0,0 @@ -package aimo.backend.domains.privatePost.dto; - -import jakarta.validation.constraints.NotNull; - -public record TextRecordRequest( - @NotNull(message = "제목을 입력하세요.") - String title, - @NotNull(message = "내용을 입력하세요.") - String script -) { -} diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/dto/AudioRecordPresignedRequest.java b/backend/src/main/java/aimo/backend/domains/privatePost/dto/request/AudioRecordPresignedRequest.java similarity index 68% rename from backend/src/main/java/aimo/backend/domains/privatePost/dto/AudioRecordPresignedRequest.java rename to backend/src/main/java/aimo/backend/domains/privatePost/dto/request/AudioRecordPresignedRequest.java index a9e85a2..d6b50be 100644 --- a/backend/src/main/java/aimo/backend/domains/privatePost/dto/AudioRecordPresignedRequest.java +++ b/backend/src/main/java/aimo/backend/domains/privatePost/dto/request/AudioRecordPresignedRequest.java @@ -1,6 +1,5 @@ -package aimo.backend.domains.privatePost.dto; +package aimo.backend.domains.privatePost.dto.request; -import jakarta.validation.Valid; import jakarta.validation.constraints.NotNull; public record AudioRecordPresignedRequest( diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/dto/ChatRecordRequest.java b/backend/src/main/java/aimo/backend/domains/privatePost/dto/request/ChatRecordRequest.java similarity index 81% rename from backend/src/main/java/aimo/backend/domains/privatePost/dto/ChatRecordRequest.java rename to backend/src/main/java/aimo/backend/domains/privatePost/dto/request/ChatRecordRequest.java index 047e8d7..7676a4e 100644 --- a/backend/src/main/java/aimo/backend/domains/privatePost/dto/ChatRecordRequest.java +++ b/backend/src/main/java/aimo/backend/domains/privatePost/dto/request/ChatRecordRequest.java @@ -1,4 +1,4 @@ -package aimo.backend.domains.privatePost.dto; +package aimo.backend.domains.privatePost.dto.request; import org.springframework.web.multipart.MultipartFile; diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/dto/request/CreateResourceUrlRequest.java b/backend/src/main/java/aimo/backend/domains/privatePost/dto/request/CreateResourceUrlRequest.java new file mode 100644 index 0000000..b40c8e3 --- /dev/null +++ b/backend/src/main/java/aimo/backend/domains/privatePost/dto/request/CreateResourceUrlRequest.java @@ -0,0 +1,8 @@ +package aimo.backend.domains.privatePost.dto.request; + +public record CreateResourceUrlRequest( + String prefix, + String filename, + String extension +) { +} diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/dto/request/JudgementToAiRequest.java b/backend/src/main/java/aimo/backend/domains/privatePost/dto/request/JudgementToAiRequest.java new file mode 100644 index 0000000..071c4ec --- /dev/null +++ b/backend/src/main/java/aimo/backend/domains/privatePost/dto/request/JudgementToAiRequest.java @@ -0,0 +1,15 @@ +package aimo.backend.domains.privatePost.dto.request; + +import aimo.backend.domains.privatePost.model.OriginType; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.validation.constraints.NotNull; + +public record JudgementToAiRequest( + @NotNull(message = "대화록이 비었습니다.") + String content, + @Enumerated(EnumType.STRING) + @NotNull(message = "원본 타입이 비었습니다.") + OriginType originType +) { +} diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/dto/SaveAudioSuccessRequest.java b/backend/src/main/java/aimo/backend/domains/privatePost/dto/request/SaveAudioSuccessRequest.java similarity index 78% rename from backend/src/main/java/aimo/backend/domains/privatePost/dto/SaveAudioSuccessRequest.java rename to backend/src/main/java/aimo/backend/domains/privatePost/dto/request/SaveAudioSuccessRequest.java index bcb410e..9281716 100644 --- a/backend/src/main/java/aimo/backend/domains/privatePost/dto/SaveAudioSuccessRequest.java +++ b/backend/src/main/java/aimo/backend/domains/privatePost/dto/request/SaveAudioSuccessRequest.java @@ -1,6 +1,4 @@ -package aimo.backend.domains.privatePost.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; +package aimo.backend.domains.privatePost.dto.request; import jakarta.validation.constraints.NotNull; diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/dto/SpeachToTextRequest.java b/backend/src/main/java/aimo/backend/domains/privatePost/dto/request/SpeachToTextRequest.java similarity index 73% rename from backend/src/main/java/aimo/backend/domains/privatePost/dto/SpeachToTextRequest.java rename to backend/src/main/java/aimo/backend/domains/privatePost/dto/request/SpeachToTextRequest.java index 07a5184..2ccbd6a 100644 --- a/backend/src/main/java/aimo/backend/domains/privatePost/dto/SpeachToTextRequest.java +++ b/backend/src/main/java/aimo/backend/domains/privatePost/dto/request/SpeachToTextRequest.java @@ -1,4 +1,4 @@ -package aimo.backend.domains.privatePost.dto; +package aimo.backend.domains.privatePost.dto.request; import jakarta.validation.constraints.NotNull; diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/dto/SummaryAndJudgementRequest.java b/backend/src/main/java/aimo/backend/domains/privatePost/dto/request/SummaryAndJudgementRequest.java similarity index 80% rename from backend/src/main/java/aimo/backend/domains/privatePost/dto/SummaryAndJudgementRequest.java rename to backend/src/main/java/aimo/backend/domains/privatePost/dto/request/SummaryAndJudgementRequest.java index e84a664..837232d 100644 --- a/backend/src/main/java/aimo/backend/domains/privatePost/dto/SummaryAndJudgementRequest.java +++ b/backend/src/main/java/aimo/backend/domains/privatePost/dto/request/SummaryAndJudgementRequest.java @@ -1,12 +1,10 @@ -package aimo.backend.domains.privatePost.dto; +package aimo.backend.domains.privatePost.dto.request; import java.time.LocalDate; import aimo.backend.domains.member.model.Gender; import jakarta.validation.constraints.NotNull; public record SummaryAndJudgementRequest( - @NotNull(message = "제목이 비었습니다.") - String title, @NotNull(message = "대화록이 비었습니다.") String script, @NotNull(message = "유저명이 비었습니다.") diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/dto/request/TextRecordRequest.java b/backend/src/main/java/aimo/backend/domains/privatePost/dto/request/TextRecordRequest.java new file mode 100644 index 0000000..635b772 --- /dev/null +++ b/backend/src/main/java/aimo/backend/domains/privatePost/dto/request/TextRecordRequest.java @@ -0,0 +1,17 @@ +package aimo.backend.domains.privatePost.dto.request; + +import aimo.backend.domains.privatePost.model.OriginType; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.validation.constraints.NotNull; + +public record TextRecordRequest( + @NotNull(message = "제목을 입력하세요.") + String title, + @NotNull(message = "내용을 입력하세요.") + String script, + @Enumerated(EnumType.STRING) + @NotNull(message = "원본 타입을 입력하세요. (TEXT, CHAT, VOICE)") + OriginType originalType +) { +} diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/dto/AudioRecordPresignedResponse.java b/backend/src/main/java/aimo/backend/domains/privatePost/dto/response/AudioRecordPresignedResponse.java similarity index 62% rename from backend/src/main/java/aimo/backend/domains/privatePost/dto/AudioRecordPresignedResponse.java rename to backend/src/main/java/aimo/backend/domains/privatePost/dto/response/AudioRecordPresignedResponse.java index 90e1e3c..90d48e8 100644 --- a/backend/src/main/java/aimo/backend/domains/privatePost/dto/AudioRecordPresignedResponse.java +++ b/backend/src/main/java/aimo/backend/domains/privatePost/dto/response/AudioRecordPresignedResponse.java @@ -1,4 +1,4 @@ -package aimo.backend.domains.privatePost.dto; +package aimo.backend.domains.privatePost.dto.response; public record AudioRecordPresignedResponse( String presignedUrl, diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/dto/SummaryAndJudgementResponse.java b/backend/src/main/java/aimo/backend/domains/privatePost/dto/response/JudgementFromAiResponse.java similarity index 54% rename from backend/src/main/java/aimo/backend/domains/privatePost/dto/SummaryAndJudgementResponse.java rename to backend/src/main/java/aimo/backend/domains/privatePost/dto/response/JudgementFromAiResponse.java index 064c54f..4699668 100644 --- a/backend/src/main/java/aimo/backend/domains/privatePost/dto/SummaryAndJudgementResponse.java +++ b/backend/src/main/java/aimo/backend/domains/privatePost/dto/response/JudgementFromAiResponse.java @@ -1,12 +1,9 @@ -package aimo.backend.domains.privatePost.dto; +package aimo.backend.domains.privatePost.dto.response; -import com.fasterxml.jackson.annotation.JsonProperty; - -import aimo.backend.domains.privatePost.model.OriginType; import jakarta.validation.constraints.NotNull; -public record SummaryAndJudgementResponse( - @NotNull(message = "제목이 비었습니다.") +public record JudgementFromAiResponse( + @NotNull(message = "글 제목이 비었습니다.") String title, @NotNull(message = "원고가 비었습니다.") String stancePlaintiff, @@ -17,7 +14,5 @@ public record SummaryAndJudgementResponse( @NotNull(message = "판결문이 비었습니다.") String judgement, @NotNull(message = "과실 비율이 비었습니다.") - Double faultRate, - @NotNull(message = "원본 타입이 비었습니다.") - OriginType originType + Double faultRate ) { } diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/dto/response/JudgementResponse.java b/backend/src/main/java/aimo/backend/domains/privatePost/dto/response/JudgementResponse.java new file mode 100644 index 0000000..a8b7976 --- /dev/null +++ b/backend/src/main/java/aimo/backend/domains/privatePost/dto/response/JudgementResponse.java @@ -0,0 +1,18 @@ +package aimo.backend.domains.privatePost.dto.response; + +import aimo.backend.domains.privatePost.model.OriginType; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; + +public record JudgementResponse( + String title, + String summary, + String stancePlaintiff, + String stanceDefendant, + String judgement, + Integer faultRatePlaintiff, + Integer faultRateDefendant, + @Enumerated(EnumType.STRING) + OriginType originType +) { +} diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/dto/PrivatePostPreviewResponse.java b/backend/src/main/java/aimo/backend/domains/privatePost/dto/response/PrivatePostPreviewResponse.java similarity index 82% rename from backend/src/main/java/aimo/backend/domains/privatePost/dto/PrivatePostPreviewResponse.java rename to backend/src/main/java/aimo/backend/domains/privatePost/dto/response/PrivatePostPreviewResponse.java index 664b9eb..f859aef 100644 --- a/backend/src/main/java/aimo/backend/domains/privatePost/dto/PrivatePostPreviewResponse.java +++ b/backend/src/main/java/aimo/backend/domains/privatePost/dto/response/PrivatePostPreviewResponse.java @@ -1,10 +1,8 @@ -package aimo.backend.domains.privatePost.dto; +package aimo.backend.domains.privatePost.dto.response; import java.time.LocalDateTime; import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; import aimo.backend.domains.privatePost.model.OriginType; import jakarta.validation.constraints.NotNull; diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/dto/PrivatePostResponse.java b/backend/src/main/java/aimo/backend/domains/privatePost/dto/response/PrivatePostResponse.java similarity index 68% rename from backend/src/main/java/aimo/backend/domains/privatePost/dto/PrivatePostResponse.java rename to backend/src/main/java/aimo/backend/domains/privatePost/dto/response/PrivatePostResponse.java index 56496f0..6b39e1c 100644 --- a/backend/src/main/java/aimo/backend/domains/privatePost/dto/PrivatePostResponse.java +++ b/backend/src/main/java/aimo/backend/domains/privatePost/dto/response/PrivatePostResponse.java @@ -1,4 +1,4 @@ -package aimo.backend.domains.privatePost.dto; +package aimo.backend.domains.privatePost.dto.response; import jakarta.validation.constraints.NotNull; @@ -13,8 +13,10 @@ public record PrivatePostResponse( String stanceDefendant, @NotNull(message = "판단이 비었습니다.") String judgement, - @NotNull(message = "판결이 비었습니다.") - Double faultRate, + @NotNull(message = "원고 측 판결이 비었습니다.") + Integer faultRatePlaintiff, + @NotNull(message = "피고 측 판결이 비었습니다.") + Integer faultRateDefendant, @NotNull(message = "발행이 비었습니다.") Boolean published ) { diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/dto/SaveAudioSuccessResponse.java b/backend/src/main/java/aimo/backend/domains/privatePost/dto/response/SaveAudioSuccessResponse.java similarity index 61% rename from backend/src/main/java/aimo/backend/domains/privatePost/dto/SaveAudioSuccessResponse.java rename to backend/src/main/java/aimo/backend/domains/privatePost/dto/response/SaveAudioSuccessResponse.java index fb8f976..19df2d9 100644 --- a/backend/src/main/java/aimo/backend/domains/privatePost/dto/SaveAudioSuccessResponse.java +++ b/backend/src/main/java/aimo/backend/domains/privatePost/dto/response/SaveAudioSuccessResponse.java @@ -1,4 +1,4 @@ -package aimo.backend.domains.privatePost.dto; +package aimo.backend.domains.privatePost.dto.response; public record SaveAudioSuccessResponse( String url, diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/dto/SpeachToTextResponse.java b/backend/src/main/java/aimo/backend/domains/privatePost/dto/response/SpeachToTextResponse.java similarity index 57% rename from backend/src/main/java/aimo/backend/domains/privatePost/dto/SpeachToTextResponse.java rename to backend/src/main/java/aimo/backend/domains/privatePost/dto/response/SpeachToTextResponse.java index ecaeefa..3fee23a 100644 --- a/backend/src/main/java/aimo/backend/domains/privatePost/dto/SpeachToTextResponse.java +++ b/backend/src/main/java/aimo/backend/domains/privatePost/dto/response/SpeachToTextResponse.java @@ -1,4 +1,4 @@ -package aimo.backend.domains.privatePost.dto; +package aimo.backend.domains.privatePost.dto.response; public record SpeachToTextResponse( String title, diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/entity/PrivatePost.java b/backend/src/main/java/aimo/backend/domains/privatePost/entity/PrivatePost.java index 3fae3ae..be78999 100644 --- a/backend/src/main/java/aimo/backend/domains/privatePost/entity/PrivatePost.java +++ b/backend/src/main/java/aimo/backend/domains/privatePost/entity/PrivatePost.java @@ -64,7 +64,10 @@ public class PrivatePost extends BaseEntity { private OriginType originType; @Column(nullable = false) - private Double faultRate; + private Integer faultRatePlaintiff; + + @Column(nullable = false) + private Integer faultRateDefendant; @Column(nullable = false) private Boolean published; @@ -88,8 +91,10 @@ private PrivatePost( AudioRecord audioRecord, TextRecord textRecord, OriginType originType, - Double faultRate, + Integer faultRatePlaintiff, + Integer faultRateDefendant, Boolean published) { + this.title = title; this.member = member; this.stancePlaintiff = stancePlaintiff; @@ -99,7 +104,8 @@ private PrivatePost( this.audioRecord = audioRecord; this.textRecord = textRecord; this.originType = originType; - this.faultRate = faultRate; + this.faultRatePlaintiff = faultRatePlaintiff; + this.faultRateDefendant = faultRateDefendant; this.published = published; } } diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/model/OriginType.java b/backend/src/main/java/aimo/backend/domains/privatePost/model/OriginType.java index 0272dec..3fcd956 100644 --- a/backend/src/main/java/aimo/backend/domains/privatePost/model/OriginType.java +++ b/backend/src/main/java/aimo/backend/domains/privatePost/model/OriginType.java @@ -2,7 +2,8 @@ public enum OriginType { TEXT("text"), - VOICE("voice"); + VOICE("voice"), + CHAT("chat"); private String value; diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/service/AudioRecordService.java b/backend/src/main/java/aimo/backend/domains/privatePost/service/AudioRecordService.java index 72e79df..16b263e 100644 --- a/backend/src/main/java/aimo/backend/domains/privatePost/service/AudioRecordService.java +++ b/backend/src/main/java/aimo/backend/domains/privatePost/service/AudioRecordService.java @@ -6,16 +6,14 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.reactive.function.client.WebClient; -import aimo.backend.common.dto.DataResponse; import aimo.backend.common.exception.ApiException; import aimo.backend.common.exception.ErrorCode; import aimo.backend.common.mapper.AudioRecordMapper; import aimo.backend.common.properties.AiServerProperties; -import aimo.backend.domains.privatePost.dto.SaveAudioSuccessRequest; -import aimo.backend.domains.privatePost.dto.SaveAudioSuccessResponse; -import aimo.backend.domains.privatePost.dto.SpeachToTextRequest; -import aimo.backend.domains.privatePost.dto.SpeachToTextResponse; -import aimo.backend.domains.privatePost.dto.SummaryAndJudgementResponse; +import aimo.backend.domains.privatePost.dto.request.SaveAudioSuccessRequest; +import aimo.backend.domains.privatePost.dto.response.SaveAudioSuccessResponse; +import aimo.backend.domains.privatePost.dto.request.SpeachToTextRequest; +import aimo.backend.domains.privatePost.dto.response.SpeachToTextResponse; import aimo.backend.domains.privatePost.entity.AudioRecord; import aimo.backend.domains.privatePost.repository.AudioRecordRepository; import aimo.backend.infrastructure.s3.S3Service; diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/service/ChatRecordService.java b/backend/src/main/java/aimo/backend/domains/privatePost/service/ChatRecordService.java index 2aa0ac2..9ecafb8 100644 --- a/backend/src/main/java/aimo/backend/domains/privatePost/service/ChatRecordService.java +++ b/backend/src/main/java/aimo/backend/domains/privatePost/service/ChatRecordService.java @@ -1,21 +1,18 @@ package aimo.backend.domains.privatePost.service; import java.io.IOException; -import java.lang.reflect.Array; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.List; import java.util.Objects; -import java.util.stream.Collectors; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StreamUtils; -import org.springframework.web.multipart.MultipartFile; import aimo.backend.common.exception.ApiException; import aimo.backend.common.exception.ErrorCode; -import aimo.backend.domains.privatePost.dto.ChatRecordRequest; +import aimo.backend.domains.privatePost.dto.request.ChatRecordRequest; import aimo.backend.domains.privatePost.entity.ChatRecord; import aimo.backend.domains.privatePost.repository.ChatRecordRepository; import lombok.RequiredArgsConstructor; diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/service/PrivatePostService.java b/backend/src/main/java/aimo/backend/domains/privatePost/service/PrivatePostService.java index c642d42..0a768eb 100644 --- a/backend/src/main/java/aimo/backend/domains/privatePost/service/PrivatePostService.java +++ b/backend/src/main/java/aimo/backend/domains/privatePost/service/PrivatePostService.java @@ -2,15 +2,8 @@ import static aimo.backend.common.exception.ErrorCode.*; -import java.util.List; -import java.util.stream.Collectors; - -import org.springframework.core.ParameterizedTypeReference; import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.data.web.PageableDefault; import org.springframework.http.HttpStatusCode; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -21,11 +14,13 @@ import aimo.backend.common.mapper.PrivatePostMapper; import aimo.backend.common.properties.AiServerProperties; import aimo.backend.domains.member.entity.Member; -import aimo.backend.domains.privatePost.dto.PrivatePostPreviewResponse; -import aimo.backend.domains.privatePost.dto.PrivatePostResponse; -import aimo.backend.domains.privatePost.dto.SummaryAndJudgementRequest; -import aimo.backend.domains.privatePost.dto.SummaryAndJudgementResponse; -import aimo.backend.domains.privatePost.dto.TextRecordRequest; +import aimo.backend.domains.privatePost.dto.request.JudgementToAiRequest; +import aimo.backend.domains.privatePost.dto.response.JudgementResponse; +import aimo.backend.domains.privatePost.dto.response.PrivatePostPreviewResponse; +import aimo.backend.domains.privatePost.dto.response.PrivatePostResponse; +import aimo.backend.domains.privatePost.dto.request.SummaryAndJudgementRequest; +import aimo.backend.domains.privatePost.dto.response.JudgementFromAiResponse; +import aimo.backend.domains.privatePost.dto.request.TextRecordRequest; import aimo.backend.domains.privatePost.entity.PrivatePost; import aimo.backend.domains.privatePost.repository.PrivatePostRepository; import aimo.backend.util.memberLoader.MemberLoader; @@ -42,11 +37,13 @@ public class PrivatePostService { private final MemberLoader memberLoader; @Transactional(rollbackFor = ApiException.class) - public SummaryAndJudgementResponse serveScriptToAi(TextRecordRequest textRecordRequest) { + public JudgementResponse serveScriptToAi(JudgementToAiRequest judgementToAiRequest) { Member member = memberLoader.getMember(); SummaryAndJudgementRequest summaryAndJudgementRequest = new SummaryAndJudgementRequest( - textRecordRequest.title(), textRecordRequest.script(), member.getNickname(), member.getGender(), + judgementToAiRequest.content(), + member.getNickname(), + member.getGender(), member.getBirthDate()); return webClient.post() @@ -59,13 +56,26 @@ public SummaryAndJudgementResponse serveScriptToAi(TextRecordRequest textRecordR .onStatus(HttpStatusCode::is5xxServerError, clientResponse -> { throw ApiException.from(ErrorCode.AI_SEVER_ERROR); }) - .bodyToMono(new ParameterizedTypeReference() { + .bodyToMono(JudgementFromAiResponse.class) + .map(judgementFromAi -> { + int faultRateDefendant = judgementFromAi.faultRate().intValue(), + faultRatePlaintiff = 100 - faultRateDefendant; + + return new JudgementResponse( + judgementFromAi.title(), + judgementFromAi.summaryAi(), + judgementFromAi.stancePlaintiff(), + judgementFromAi.stanceDefendant(), + judgementFromAi.judgement(), + faultRatePlaintiff, + faultRateDefendant, + judgementToAiRequest.originType()); }) .block(); } @Transactional(rollbackFor = ApiException.class) - public PrivatePost save(SummaryAndJudgementResponse summaryAndJudgementResponse) { + public PrivatePost save(JudgementResponse summaryAndJudgementResponse) { PrivatePost privatePost = PrivatePostMapper.toEntity(summaryAndJudgementResponse); if (!isValid(memberLoader.getMember().getId(), privatePost)) { diff --git a/backend/src/main/java/aimo/backend/domains/privatePost/service/TextRecordService.java b/backend/src/main/java/aimo/backend/domains/privatePost/service/TextRecordService.java index 8c09a31..4ea4e94 100644 --- a/backend/src/main/java/aimo/backend/domains/privatePost/service/TextRecordService.java +++ b/backend/src/main/java/aimo/backend/domains/privatePost/service/TextRecordService.java @@ -1,12 +1,9 @@ package aimo.backend.domains.privatePost.service; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import aimo.backend.common.dto.DataResponse; -import aimo.backend.domains.privatePost.dto.TextRecordRequest; +import aimo.backend.domains.privatePost.dto.request.TextRecordRequest; import aimo.backend.domains.privatePost.entity.TextRecord; import aimo.backend.domains.privatePost.repository.TextRecordRepository; import lombok.RequiredArgsConstructor; diff --git a/backend/src/main/java/aimo/backend/infrastructure/s3/S3Service.java b/backend/src/main/java/aimo/backend/infrastructure/s3/S3Service.java index 47efcbf..857935b 100644 --- a/backend/src/main/java/aimo/backend/infrastructure/s3/S3Service.java +++ b/backend/src/main/java/aimo/backend/infrastructure/s3/S3Service.java @@ -8,14 +8,13 @@ import com.amazonaws.HttpMethod; import com.amazonaws.services.s3.AmazonS3; -import com.amazonaws.services.s3.AmazonS3Client; import com.amazonaws.services.s3.Headers; import com.amazonaws.services.s3.model.CannedAccessControlList; import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest; import aimo.backend.common.properties.S3Properties; -import aimo.backend.domains.member.dto.CreateProfileImageUrlRequest; -import aimo.backend.domains.privatePost.dto.CreateResourceUrl; +import aimo.backend.domains.member.dto.request.CreateProfileImageUrlRequest; +import aimo.backend.domains.privatePost.dto.request.CreateResourceUrlRequest; import aimo.backend.infrastructure.s3.dto.CreatePresignedUrlRequest; import aimo.backend.infrastructure.s3.dto.CreatePresignedUrlResponse; import aimo.backend.infrastructure.s3.model.PresignedUrlPrefix; @@ -54,8 +53,8 @@ private String createGeneratePresignedUrlRequest(String path) { return url.toString(); } - public String getResourceUrl(CreateResourceUrl createResourceUrl) { - String key = createResourceUrl.prefix() + "/" + createResourceUrl.filename() + "." + createResourceUrl.extension(); + public String getResourceUrl(CreateResourceUrlRequest createResourceUrlRequest) { + String key = createResourceUrlRequest.prefix() + "/" + createResourceUrlRequest.filename() + "." + createResourceUrlRequest.extension(); return amazonS3Client.getUrl(s3Properties.getBucketName(), key).toString(); } diff --git a/backend/src/main/java/aimo/backend/infrastructure/smtp/MailService.java b/backend/src/main/java/aimo/backend/infrastructure/smtp/MailService.java index 748475c..7599d17 100644 --- a/backend/src/main/java/aimo/backend/infrastructure/smtp/MailService.java +++ b/backend/src/main/java/aimo/backend/infrastructure/smtp/MailService.java @@ -7,15 +7,11 @@ import org.springframework.mail.javamail.MimeMessageHelper; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.ui.freemarker.SpringTemplateLoader; import org.thymeleaf.context.Context; import org.thymeleaf.spring6.SpringTemplateEngine; -import aimo.backend.domains.member.dto.SendTemporaryPasswordRequest; -import aimo.backend.domains.member.dto.SendTemporaryPasswordResponse; -import aimo.backend.domains.member.dto.UpdatePasswordRequest; -import aimo.backend.domains.member.entity.Member; -import aimo.backend.domains.member.service.MemberService; +import aimo.backend.domains.member.dto.request.SendTemporaryPasswordRequest; +import aimo.backend.domains.member.dto.response.SendTemporaryPasswordResponse; import aimo.backend.infrastructure.smtp.model.Notice; import jakarta.mail.MessagingException; import jakarta.mail.internet.MimeMessage;