forked from Sanders/TelegaBot
Add lastReadDate
This commit is contained in:
@@ -65,4 +65,7 @@ tasks.named('test') {
|
||||
|
||||
flyway {
|
||||
locations = ['classpath:db/migration']
|
||||
url = project.properties['DB_URL']
|
||||
user = project.properties['DB_USER']
|
||||
password = project.properties['DB_PASSWORD']
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@@ -48,4 +49,6 @@ public class BotUser {
|
||||
@OneToMany(mappedBy = "botUser", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
private List<Book> books;
|
||||
|
||||
private Date lastReadDate;
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import java.sql.Date;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
import static ru.cathub.telegabot.utils.BookFormatUtils.*;
|
||||
@@ -165,6 +166,9 @@ public class BookCreationServiceImpl implements BookCreationService {
|
||||
telegramClientService.sendMessageWithMarkdown(user, message + stats);
|
||||
|
||||
bookRepository.save(book);
|
||||
|
||||
user.setLastReadDate(new Date(System.currentTimeMillis()));
|
||||
userRepository.save(user);
|
||||
|
||||
try {
|
||||
String prompt = String.format("Придумай креативное поздравление с прочтением книги \"%s\" от автора \"%s\". Учитывай что пользователь поставил оценку %d/10. ", cache.getTitle(), cache.getAuthor(), cache.getRating());
|
||||
|
||||
@@ -8,13 +8,15 @@ spring.jpa.hibernate.ddl-auto=validate
|
||||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
|
||||
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
|
||||
spring.jpa.properties.hibernate.default_schema=telegabot
|
||||
|
||||
# Flyway Configuration
|
||||
spring.flyway.enabled=true
|
||||
spring.flyway.locations=classpath:db/migration
|
||||
spring.flyway.baseline-on-migrate=true
|
||||
spring.flyway.validate-on-migrate=true
|
||||
spring.flyway.Schemas=telegabot
|
||||
spring.flyway.schemas=telegabot
|
||||
spring.flyway.baselineOnMigrate=true
|
||||
spring.flyway.validateOnMigrate=true
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE bot_user
|
||||
ADD last_read_date date;
|
||||
Reference in New Issue
Block a user