Skip to content

Commit

Permalink
Merge pull request #55 from KTB16Team/feature/44-mypage
Browse files Browse the repository at this point in the history
feat: private post 과실 비율 세분화 및 로직 추가
  • Loading branch information
mng990 authored Nov 5, 2024
2 parents 7aefbfd + 7792075 commit 555da50
Show file tree
Hide file tree
Showing 50 changed files with 215 additions and 182 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}

Expand All @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package aimo.backend.domains.member.dto;
package aimo.backend.domains.member.dto.request;

public record CreateProfileImageUrlRequest(
String nickname,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package aimo.backend.domains.member.dto;
package aimo.backend.domains.member.dto.request;

public record DeleteRequest(String password) {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package aimo.backend.domains.member.dto;
package aimo.backend.domains.member.dto.request;

public record LogOutRequest(
String accessToken,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package aimo.backend.domains.member.dto.request;

public record SaveProfileImageMetaDataRequest(
String filename,
String extension,
Long size,
String url
) {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package aimo.backend.domains.member.dto;
package aimo.backend.domains.member.dto.request;

import jakarta.validation.constraints.Email;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package aimo.backend.domains.member.dto;
package aimo.backend.domains.member.dto.request;

import java.time.LocalDate;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package aimo.backend.domains.member.dto;
package aimo.backend.domains.member.dto.request;

public record UpdateNicknameRequest(String newNickname) {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package aimo.backend.domains.member.dto;
package aimo.backend.domains.member.dto.request;

import jakarta.validation.constraints.NotNull;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package aimo.backend.domains.member.dto;
package aimo.backend.domains.member.dto.request;

public record ValidateDuplicateNicknameRequest(String nickname) {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package aimo.backend.domains.member.dto;
package aimo.backend.domains.member.dto.response;

public record FindMyInfoResponse(
String nickname,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package aimo.backend.domains.member.dto;
package aimo.backend.domains.member.dto.response;

public record NicknameExistsResponse(boolean exists) {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package aimo.backend.domains.member.dto;
package aimo.backend.domains.member.dto.response;

public record SendTemporaryPasswordResponse(
String to,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -78,6 +79,9 @@ public class Member extends BaseEntity {
@OneToMany(mappedBy = "member")
private List<ParentComment> parentComments = new ArrayList<>();

@OneToMany(mappedBy = "member")
private List<ChildComment> childComments = new ArrayList<>();

public void updateProfileImage(ProfileImage profileImage) {
this.profileImage = profileImage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -55,9 +57,9 @@ public class PrivatePostController {

// 판결
@PostMapping("/judgement")
public ResponseEntity<DataResponse<Void>> judgement(@Valid @RequestBody TextRecordRequest textRecordRequest) {
public ResponseEntity<DataResponse<Void>> summaryAndJudgment(@Valid @RequestBody JudgementToAiRequest judgementToAiRequest) {

SummaryAndJudgementResponse summaryAndJudgementResponse = privatePostService.serveScriptToAi(textRecordRequest);
JudgementResponse summaryAndJudgementResponse = privatePostService.serveScriptToAi(judgementToAiRequest);

privatePostService.save(summaryAndJudgementResponse);

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package aimo.backend.domains.privatePost.dto;
package aimo.backend.domains.privatePost.dto.request;

import org.springframework.web.multipart.MultipartFile;

Expand Down
Loading

0 comments on commit 555da50

Please sign in to comment.