From 5bc0b3a5672e1d514224daab65ce09a92a2ddd3b Mon Sep 17 00:00:00 2001 From: snacktime Date: Fri, 6 Sep 2024 19:45:47 +0900 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20TT-414=20=EC=98=88=EC=83=81?= =?UTF-8?q?=EC=8B=9C=EA=B0=84=20=EC=A0=95=ED=99=95=EB=8F=84=20=EC=83=81?= =?UTF-8?q?=EC=8A=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 논문을 참고해 평균 SPM을 355로 적용 문장과 문장사이 1초의 텀을 둠 --- .../twentythree/peech/common/utils/ScriptUtils.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/twentythree/peech/common/utils/ScriptUtils.java b/src/main/java/com/twentythree/peech/common/utils/ScriptUtils.java index 3041091f..d44a7e0e 100644 --- a/src/main/java/com/twentythree/peech/common/utils/ScriptUtils.java +++ b/src/main/java/com/twentythree/peech/common/utils/ScriptUtils.java @@ -4,14 +4,14 @@ public class ScriptUtils { public static LocalTime calculateExpectedTime(String text) { + final int DEFAULT_SPM = 355; - final float DEFAULT_TIME_PER_WORD_SECOND = 1.75F; //LocalTime.of(0,0,1, 750000000); + long count = text.chars().filter(ch -> ch == '.').count(); - String[] words = text.split(" "); - int wordsCount = words.length; + String noSpaceText = text.replaceAll("[^가-힣]", ""); + int SyllableFromText = noSpaceText.length(); + float expectedTimeToSecond = (float) SyllableFromText / DEFAULT_SPM * 60 + count * 1; - float expectedTimeToSecond = wordsCount * DEFAULT_TIME_PER_WORD_SECOND; - expectedTimeToSecond /= 3f; LocalTime expectedTime = transferSeoondToLocalTime(expectedTimeToSecond); return expectedTime; From 127ccc14200ed1001187e154c52114728df8d77f Mon Sep 17 00:00:00 2001 From: snacktime Date: Sat, 7 Sep 2024 14:47:18 +0900 Subject: [PATCH 2/6] =?UTF-8?q?feat:=20TT-415=20feedback=20domain=20entity?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feedback id, feedback message와 사용자 정보를 가짐 --- .../peech/feedback/domain/FeedbackDomain.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/java/com/twentythree/peech/feedback/domain/FeedbackDomain.java diff --git a/src/main/java/com/twentythree/peech/feedback/domain/FeedbackDomain.java b/src/main/java/com/twentythree/peech/feedback/domain/FeedbackDomain.java new file mode 100644 index 00000000..f9ec225b --- /dev/null +++ b/src/main/java/com/twentythree/peech/feedback/domain/FeedbackDomain.java @@ -0,0 +1,29 @@ +package com.twentythree.peech.feedback.domain; + + +import com.twentythree.peech.user.value.*; +import lombok.*; + +import javax.annotation.Nullable; +import java.time.LocalDate; + +@Getter +@Setter(AccessLevel.PACKAGE) +@AllArgsConstructor(staticName = "of") +public class FeedbackDomain { + + private Long feedbackId; + private String feedbackMessage; + + private Long userId; + private AuthorizationServer authorizationServer; + private String firstName; + private String lastName; + private LocalDate birth; + private UserGender gender; + private String email; + private String nickName; + private UserRole role; + private SignUpFinished signUpFinished; + private UserStatus userStatus; +} From 5538380e04a114e5564fe94f5a3a99a07fc22739 Mon Sep 17 00:00:00 2001 From: snacktime Date: Sat, 7 Sep 2024 14:47:46 +0900 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20TT-415=20feedback=20db=20entity=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../peech/feedback/entity/Feedback.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/main/java/com/twentythree/peech/feedback/entity/Feedback.java diff --git a/src/main/java/com/twentythree/peech/feedback/entity/Feedback.java b/src/main/java/com/twentythree/peech/feedback/entity/Feedback.java new file mode 100644 index 00000000..d70a0aff --- /dev/null +++ b/src/main/java/com/twentythree/peech/feedback/entity/Feedback.java @@ -0,0 +1,30 @@ +package com.twentythree.peech.feedback.entity; + + +import com.twentythree.peech.user.entity.UserEntity; +import jakarta.persistence.*; +import lombok.*; + +@Getter +@Builder +@AllArgsConstructor(staticName = "of") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Table(name = "FEEDBACK") +@Entity +public class Feedback { + + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "feedback_id") + private Long feedbackId; + + @JoinColumn(name = "userId", nullable = false) + @ManyToOne(fetch = FetchType.LAZY) + private UserEntity user; + + @Column(name = "feedback_message", nullable = false) + private String feedbackMessage; + + public static Feedback ofJpa(UserEntity user, String feedbackMessage) { + return Feedback.builder().user(user).feedbackMessage(feedbackMessage).build(); + } +} From 5cedf1db507a70595a2cbd028457cbd3e9ef3b45 Mon Sep 17 00:00:00 2001 From: snacktime Date: Sat, 7 Sep 2024 14:48:47 +0900 Subject: [PATCH 4/6] =?UTF-8?q?feat:=20TT-415=20feedbackMapper=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feedback domain entity를 저장하는 feedback mapper 구현 --- .../peech/feedback/domain/FeedbackMapper.java | 6 ++++ .../infrastructure/FeedbackMapperImpl.java | 28 +++++++++++++++++++ .../infrastructure/JpaFeedbackRepository.java | 9 ++++++ 3 files changed, 43 insertions(+) create mode 100644 src/main/java/com/twentythree/peech/feedback/domain/FeedbackMapper.java create mode 100644 src/main/java/com/twentythree/peech/feedback/infrastructure/FeedbackMapperImpl.java create mode 100644 src/main/java/com/twentythree/peech/feedback/infrastructure/JpaFeedbackRepository.java diff --git a/src/main/java/com/twentythree/peech/feedback/domain/FeedbackMapper.java b/src/main/java/com/twentythree/peech/feedback/domain/FeedbackMapper.java new file mode 100644 index 00000000..c7263b64 --- /dev/null +++ b/src/main/java/com/twentythree/peech/feedback/domain/FeedbackMapper.java @@ -0,0 +1,6 @@ +package com.twentythree.peech.feedback.domain; + + +public interface FeedbackMapper { + void insertFeedback(FeedbackDomain feedbackDomain); +} diff --git a/src/main/java/com/twentythree/peech/feedback/infrastructure/FeedbackMapperImpl.java b/src/main/java/com/twentythree/peech/feedback/infrastructure/FeedbackMapperImpl.java new file mode 100644 index 00000000..ff915342 --- /dev/null +++ b/src/main/java/com/twentythree/peech/feedback/infrastructure/FeedbackMapperImpl.java @@ -0,0 +1,28 @@ +package com.twentythree.peech.feedback.infrastructure; + +import com.twentythree.peech.feedback.domain.FeedbackDomain; +import com.twentythree.peech.feedback.domain.FeedbackMapper; +import com.twentythree.peech.feedback.entity.Feedback; +import com.twentythree.peech.user.entity.UserEntity; +import com.twentythree.peech.user.repository.UserRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + + +@RequiredArgsConstructor +@Repository +public class FeedbackMapperImpl implements FeedbackMapper { + + private final JpaFeedbackRepository feedbackRepository; + private final UserRepository userRepository; + + @Override + @Transactional + public void insertFeedback(FeedbackDomain feedbackDomain) { + + UserEntity userEntity = userRepository.findById(feedbackDomain.getUserId()).orElseThrow(() -> new IllegalArgumentException("잘못된 사용자 입니다.")); + + feedbackRepository.save(Feedback.ofJpa(userEntity, feedbackDomain.getFeedbackMessage())); + } +} diff --git a/src/main/java/com/twentythree/peech/feedback/infrastructure/JpaFeedbackRepository.java b/src/main/java/com/twentythree/peech/feedback/infrastructure/JpaFeedbackRepository.java new file mode 100644 index 00000000..f1692293 --- /dev/null +++ b/src/main/java/com/twentythree/peech/feedback/infrastructure/JpaFeedbackRepository.java @@ -0,0 +1,9 @@ +package com.twentythree.peech.feedback.infrastructure; + +import com.twentythree.peech.feedback.entity.Feedback; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface JpaFeedbackRepository extends JpaRepository { +} From 8930be74c971a45b74d6eb92a85bc40699e48d20 Mon Sep 17 00:00:00 2001 From: snacktime Date: Sat, 7 Sep 2024 14:49:32 +0900 Subject: [PATCH 5/6] =?UTF-8?q?feat:=20TT-415=20feedback=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feedback message로 feedback을 생성하는 applicaiton 로직 --- .../feedback/application/FeedbackService.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/main/java/com/twentythree/peech/feedback/application/FeedbackService.java diff --git a/src/main/java/com/twentythree/peech/feedback/application/FeedbackService.java b/src/main/java/com/twentythree/peech/feedback/application/FeedbackService.java new file mode 100644 index 00000000..1337b452 --- /dev/null +++ b/src/main/java/com/twentythree/peech/feedback/application/FeedbackService.java @@ -0,0 +1,28 @@ +package com.twentythree.peech.feedback.application; + +import com.twentythree.peech.auth.service.SecurityContextHolder; +import com.twentythree.peech.feedback.domain.FeedbackDomain; +import com.twentythree.peech.feedback.domain.FeedbackMapper; +import com.twentythree.peech.script.service.ThemeService; +import com.twentythree.peech.user.entity.UserEntity; +import com.twentythree.peech.user.repository.UserRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@RequiredArgsConstructor +@Service +public class FeedbackService { + + private final FeedbackMapper feedbackMapper; + private final ThemeService themeService; + private final UserRepository userRepository; + + public void createFeedback(String message) { + Long userId = SecurityContextHolder.getUserId(); + UserEntity user = userRepository.findById(userId).orElseThrow(() -> new IllegalArgumentException("User not found")); + + FeedbackDomain feedbackDomain = FeedbackDomain.of(null, message, userId, user.getAuthorizationServer(), user.getFirstName(), user.getLastName(), user.getBirth(), user.getGender(), user.getEmail(), user.getNickName(), user.getRole(), user.getSignUpFinished(), user.getUserStatus()); + + feedbackMapper.insertFeedback(feedbackDomain); + } +} From 9707201d20a57d911b14f3a7ae5953ba3f23d4b5 Mon Sep 17 00:00:00 2001 From: snacktime Date: Sat, 7 Sep 2024 14:49:52 +0900 Subject: [PATCH 6/6] =?UTF-8?q?feat:=20TT-415=20feedback=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20endpoint=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feedback 생성을 위한 endpoint 개방 --- .../presentation/FeedbackController.java | 20 +++++++++++++++++++ .../request/CreateFeedbackRequestDTO.java | 12 +++++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/main/java/com/twentythree/peech/feedback/presentation/FeedbackController.java create mode 100644 src/main/java/com/twentythree/peech/feedback/value/request/CreateFeedbackRequestDTO.java diff --git a/src/main/java/com/twentythree/peech/feedback/presentation/FeedbackController.java b/src/main/java/com/twentythree/peech/feedback/presentation/FeedbackController.java new file mode 100644 index 00000000..958f2d75 --- /dev/null +++ b/src/main/java/com/twentythree/peech/feedback/presentation/FeedbackController.java @@ -0,0 +1,20 @@ +package com.twentythree.peech.feedback.presentation; + +import com.twentythree.peech.feedback.application.FeedbackService; +import com.twentythree.peech.feedback.value.request.CreateFeedbackRequestDTO; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +@RequiredArgsConstructor +@RestController +public class FeedbackController { + + private final FeedbackService feedbackService; + + @PostMapping("api/v1.1/users/feedbacks") + public void createFeedback(@RequestBody CreateFeedbackRequestDTO message) { + feedbackService.createFeedback(message.getMessage()); + } +} diff --git a/src/main/java/com/twentythree/peech/feedback/value/request/CreateFeedbackRequestDTO.java b/src/main/java/com/twentythree/peech/feedback/value/request/CreateFeedbackRequestDTO.java new file mode 100644 index 00000000..92f3d85d --- /dev/null +++ b/src/main/java/com/twentythree/peech/feedback/value/request/CreateFeedbackRequestDTO.java @@ -0,0 +1,12 @@ +package com.twentythree.peech.feedback.value.request; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +public class CreateFeedbackRequestDTO { + private String message; +}