@@ -39,12 +39,6 @@ public class ComplaintEntity {
|
|||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private Violation violation;
|
private Violation violation;
|
||||||
|
|
||||||
@OneToOne(cascade = CascadeType.ALL)
|
|
||||||
@JoinColumn(name = "law_case_id")
|
|
||||||
@ToString.Exclude
|
|
||||||
@JsonIgnore
|
|
||||||
private LawCase lawCase;
|
|
||||||
|
|
||||||
@Column(name = "created_at", updatable = false)
|
@Column(name = "created_at", updatable = false)
|
||||||
@CreatedDate
|
@CreatedDate
|
||||||
private LocalDateTime createdAt;
|
private LocalDateTime createdAt;
|
||||||
@@ -55,4 +49,12 @@ public class ComplaintEntity {
|
|||||||
|
|
||||||
@Column(name = "not_moderated_file")
|
@Column(name = "not_moderated_file")
|
||||||
private Boolean not_moderated_file;
|
private Boolean not_moderated_file;
|
||||||
|
|
||||||
|
@PrePersist
|
||||||
|
public void prePersist() {
|
||||||
|
if (this.createdAt == null) {
|
||||||
|
this.createdAt = LocalDateTime.now();
|
||||||
|
}
|
||||||
|
this.updatedAt = LocalDateTime.now();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class Notification {
|
|||||||
|
|
||||||
@Column(name = "created_at", updatable = false)
|
@Column(name = "created_at", updatable = false)
|
||||||
@CreatedDate
|
@CreatedDate
|
||||||
private LocalDateTime createdAt;
|
private LocalDateTime createdAt = LocalDateTime.now();
|
||||||
|
|
||||||
@LastModifiedDate
|
@LastModifiedDate
|
||||||
@Column(name = "updated_at")
|
@Column(name = "updated_at")
|
||||||
@@ -46,4 +46,13 @@ public class Notification {
|
|||||||
@JoinColumn(name = "user_id")
|
@JoinColumn(name = "user_id")
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private User user;
|
private User user;
|
||||||
|
|
||||||
|
@PrePersist
|
||||||
|
public void prePersist() {
|
||||||
|
if (this.createdAt == null) {
|
||||||
|
this.createdAt = LocalDateTime.now();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updatedAt = LocalDateTime.now();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,4 +61,13 @@ public class Payment {
|
|||||||
@JoinColumn(name = "tariff_id")
|
@JoinColumn(name = "tariff_id")
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private Tariff tariff;
|
private Tariff tariff;
|
||||||
|
|
||||||
|
|
||||||
|
@PrePersist
|
||||||
|
public void prePersist() {
|
||||||
|
if (this.createdAt == null) {
|
||||||
|
this.createdAt = LocalDateTime.now();
|
||||||
|
}
|
||||||
|
this.updatedAt = LocalDateTime.now();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -41,4 +41,12 @@ public class UserVerification {
|
|||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
@Column(name = "status")
|
@Column(name = "status")
|
||||||
private ModerationStatus moderationStatus;
|
private ModerationStatus moderationStatus;
|
||||||
|
|
||||||
|
@PrePersist
|
||||||
|
public void prePersist() {
|
||||||
|
if (this.createdAt == null) {
|
||||||
|
this.createdAt = LocalDateTime.now();
|
||||||
|
}
|
||||||
|
this.updatedAt = LocalDateTime.now();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,4 +43,12 @@ public class ViolationNotion {
|
|||||||
|
|
||||||
@Column(name = "message")
|
@Column(name = "message")
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
|
@PrePersist
|
||||||
|
public void prePersist() {
|
||||||
|
if (this.createdAt == null) {
|
||||||
|
this.createdAt = LocalDateTime.now();
|
||||||
|
}
|
||||||
|
this.updatedAt = LocalDateTime.now();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import ru.soune.nocopy.entity.notification.NotificationStatus;
|
|||||||
import ru.soune.nocopy.entity.notification.NotificationType;
|
import ru.soune.nocopy.entity.notification.NotificationType;
|
||||||
import ru.soune.nocopy.entity.user.User;
|
import ru.soune.nocopy.entity.user.User;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface NotificationRepository extends JpaRepository<Notification, Long> {
|
public interface NotificationRepository extends JpaRepository<Notification, Long> {
|
||||||
@@ -29,12 +30,13 @@ public interface NotificationRepository extends JpaRepository<Notification, Long
|
|||||||
long countByUserAndStatus(User user, NotificationStatus status);
|
long countByUserAndStatus(User user, NotificationStatus status);
|
||||||
|
|
||||||
@Modifying
|
@Modifying
|
||||||
@Query("UPDATE Notification n SET n.status = :newStatus WHERE n.id IN :ids AND n.user = :user AND " +
|
@Query("UPDATE Notification n SET n.status = :newStatus , n.updatedAt = :updateTime WHERE n.id IN :ids AND n.user = :user AND " +
|
||||||
"n.status = :oldStatus")
|
"n.status = :oldStatus")
|
||||||
int updateStatus(@Param("ids") List<Long> ids,
|
int updateStatus(@Param("ids") List<Long> ids,
|
||||||
@Param("user") User user,
|
@Param("user") User user,
|
||||||
@Param("oldStatus") NotificationStatus oldStatus,
|
@Param("oldStatus") NotificationStatus oldStatus,
|
||||||
@Param("newStatus") NotificationStatus newStatus);
|
@Param("newStatus") NotificationStatus newStatus,
|
||||||
|
@Param("updateTime") LocalDateTime updateTime);
|
||||||
|
|
||||||
Page<Notification> getNotificationsByUser(User user, Pageable pageable);
|
Page<Notification> getNotificationsByUser(User user, Pageable pageable);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import ru.soune.nocopy.repository.NotificationRepository;
|
|||||||
import ru.soune.nocopy.repository.UserRepository;
|
import ru.soune.nocopy.repository.UserRepository;
|
||||||
import ru.soune.nocopy.service.user.UserService;
|
import ru.soune.nocopy.service.user.UserService;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@@ -39,6 +40,7 @@ public class NotificationService {
|
|||||||
|
|
||||||
Notification notification = Notification.builder()
|
Notification notification = Notification.builder()
|
||||||
.notificationType(notificationType)
|
.notificationType(notificationType)
|
||||||
|
.createdAt(LocalDateTime.now())
|
||||||
.user(userRepository.findById(userId).orElseThrow())
|
.user(userRepository.findById(userId).orElseThrow())
|
||||||
.status(NotificationStatus.NEW)
|
.status(NotificationStatus.NEW)
|
||||||
.message(message)
|
.message(message)
|
||||||
@@ -110,7 +112,8 @@ public class NotificationService {
|
|||||||
if (notificationIds == null || notificationIds.isEmpty()) {
|
if (notificationIds == null || notificationIds.isEmpty()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return notificationRepository.updateStatus(notificationIds, user, NotificationStatus.NEW,
|
return notificationRepository.updateStatus(notificationIds, user, NotificationStatus.NEW,
|
||||||
NotificationStatus.READIED);
|
NotificationStatus.READIED, LocalDateTime.now());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user