package platform.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.UUID;
@Entity
public class CodeShare {
@Id
@GeneratedValue(generator = "uuid2")
@GenericGenerator(name = "uuid2", strategy = "org.hibernate.id.UUIDGenerator")
@JsonIgnore
private String id;
@Column(name = "code")
@Lob // Use the @Lob annotation to indicate CLOB
private String code;
@JsonIgnore
private String date;
private Long time;
private Long views;
private LocalDateTime localDateTime;
@JsonIgnore
private Long initialTime;
@JsonIgnore
private Long initialViews;
@JsonIgnore
@Column(name = "code_size")
private double size;
public CodeShare(String code, String date, Long time) {
this.id = UUID.randomUUID().toString();
this.code = code;
this.date = date;
this.time = time;
this.localDateTime = LocalDateTime.parse(date);
initialTime = time;
initialViews = this.views;
}
public CodeShare() {
}
public long getTime() {
return time;
}
public void setTime(Long time) {
this.time = time;
}
public void setViews(Long views) {
this.views = views;
}
public Long getViews() {
return views;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
@JsonSerialize(using = ToStringSerializer.class)
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Long getInitialTime() {
return initialTime;
}
public void setInitialTime(Long initialTime) {
this.initialTime = initialTime;
}
public Long getInitialViews() {
return initialViews;
}
public void setInitialViews(Long initialViews) {
this.initialViews = initialViews;
}
public LocalDateTime getLocalDateTime() {
return localDateTime;
}
public void setLocalDateTime(LocalDateTime localDateTime) {
this.localDateTime = localDateTime;
}
public double getSize() {
return size;
}
public void setSize(double size) {
this.size = size;
}
@Override
public String toString() {
return "CodeShare{" +
"id='" + id + '\'' +
", code='" + code + '\'' +
", date='" + date + '\'' +
", time=" + time +
", views=" + views +
", localDateTime=" + localDateTime +
'}';
}
}