mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-08 08:01:16 +08:00
57 lines
1.4 KiB
Java
57 lines
1.4 KiB
Java
package com.openisle.model;
|
|
|
|
import jakarta.persistence.*;
|
|
import lombok.Getter;
|
|
import lombok.NoArgsConstructor;
|
|
import lombok.Setter;
|
|
import org.hibernate.annotations.SQLDelete;
|
|
import org.hibernate.annotations.Where;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
/** Point change history for a user. */
|
|
@Entity
|
|
@Getter
|
|
@Setter
|
|
@NoArgsConstructor
|
|
@Table(name = "point_histories")
|
|
@SQLDelete(sql = "UPDATE point_histories SET deleted_at = CURRENT_TIMESTAMP(6) WHERE id = ?")
|
|
@Where(clause = "deleted_at IS NULL")
|
|
public class PointHistory {
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
private Long id;
|
|
|
|
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
|
@JoinColumn(name = "user_id")
|
|
private User user;
|
|
|
|
@Enumerated(EnumType.STRING)
|
|
@Column(nullable = false)
|
|
private PointHistoryType type;
|
|
|
|
@Column(nullable = false)
|
|
private int amount;
|
|
|
|
@Column(nullable = false)
|
|
private int balance;
|
|
|
|
@ManyToOne(fetch = FetchType.LAZY)
|
|
@JoinColumn(name = "post_id")
|
|
private Post post;
|
|
|
|
@ManyToOne(fetch = FetchType.LAZY)
|
|
@JoinColumn(name = "comment_id")
|
|
private Comment comment;
|
|
|
|
@ManyToOne(fetch = FetchType.LAZY)
|
|
@JoinColumn(name = "from_user_id")
|
|
private User fromUser;
|
|
|
|
@Column(name = "created_at", nullable = false)
|
|
private LocalDateTime createdAt;
|
|
|
|
@Column(name = "deleted_at")
|
|
private LocalDateTime deletedAt;
|
|
}
|