-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 한 아이디로 하루 10회 초과 점역 요청 시 예외 발생 (#142)
* feat: 한 아이디당 10회씩 점역 가능하도록 한계 설정 * fix: 세션 아이디 파라미터로 검사하는 로직 제거 (#143) * feat: Login ID에 unique 제약조건 설정 (#145) * fix: logout 에러 수정 (#146) * feat: 10회 초과 시 예외 발생
- Loading branch information
Showing
7 changed files
with
85 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
server/src/main/java/sunflower/server/application/MemberTranscriptionsLogService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package sunflower.server.application; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import sunflower.server.entity.MemberTranscriptionsLog; | ||
import sunflower.server.repository.MemberTranscriptionsLogRepository; | ||
|
||
import java.time.LocalDate; | ||
import java.util.Optional; | ||
|
||
@RequiredArgsConstructor | ||
@Service | ||
public class MemberTranscriptionsLogService { | ||
|
||
private final MemberTranscriptionsLogRepository memberTranscriptionsLogRepository; | ||
|
||
public int count(final Long memberId) { | ||
final Optional<MemberTranscriptionsLog> log = memberTranscriptionsLogRepository.findByMemberIdAndDate(memberId, LocalDate.now()); | ||
if (log.isEmpty()) { | ||
final MemberTranscriptionsLog newLog = memberTranscriptionsLogRepository.save(MemberTranscriptionsLog.of(memberId)); | ||
return newLog.count(); | ||
} | ||
return log.get().count(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
server/src/main/java/sunflower/server/entity/MemberTranscriptionsLog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package sunflower.server.entity; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.Id; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDate; | ||
|
||
import static jakarta.persistence.GenerationType.IDENTITY; | ||
|
||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Getter | ||
@Entity | ||
public class MemberTranscriptionsLog { | ||
|
||
@Id | ||
@GeneratedValue(strategy = IDENTITY) | ||
private Long id; | ||
|
||
private Long memberId; | ||
private Integer transcriptionCount; | ||
private LocalDate date; | ||
|
||
public static MemberTranscriptionsLog of(final Long memberId) { | ||
return new MemberTranscriptionsLog(null, memberId, 0, LocalDate.now()); | ||
} | ||
|
||
public Integer count() { | ||
this.transcriptionCount++; | ||
return this.transcriptionCount; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
server/src/main/java/sunflower/server/repository/MemberTranscriptionsLogRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package sunflower.server.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import sunflower.server.entity.MemberTranscriptionsLog; | ||
|
||
import java.time.LocalDate; | ||
import java.util.Optional; | ||
|
||
public interface MemberTranscriptionsLogRepository extends JpaRepository<MemberTranscriptionsLog, Long> { | ||
|
||
Optional<MemberTranscriptionsLog> findByMemberId(final Long memberId); | ||
|
||
Optional<MemberTranscriptionsLog> findByMemberIdAndDate(Long memberId, LocalDate today); | ||
} |
11 changes: 0 additions & 11 deletions
11
server/src/test/java/sunflower/server/repository/TranslationsRepositoryTest.java
This file was deleted.
Oops, something went wrong.