Adding entities
This commit is contained in:
parent
451334a811
commit
6bcb203243
4
pom.xml
4
pom.xml
@ -69,6 +69,10 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
package ir.chaarfasl.back.api.core.dataAccess.entity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "ATTRACTIONS")
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class Attraction extends Point {
|
||||
|
||||
@Column(name = "BEST_TIME")
|
||||
protected String bestTime;
|
||||
@Column(name = "HARDNESS_DEGREE")
|
||||
protected Float hardnessDegree;
|
||||
|
||||
|
||||
|
||||
public Attraction(String name, String description, Double latitude, Double longitude, PointStatus pointStatus, Province province, String bestTime, Float hardness) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
this.pointStatus = pointStatus;
|
||||
this.province = province;
|
||||
this.hardnessDegree = hardness;
|
||||
this.bestTime = bestTime;
|
||||
}
|
||||
|
||||
public Attraction(Long id, String name, String description, Double latitude, Double longitude, PointStatus pointStatus, Province province, String bestTime, Float hardness) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
this.pointStatus = pointStatus;
|
||||
this.province = province;
|
||||
this.hardnessDegree = hardness;
|
||||
this.bestTime = bestTime;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package ir.chaarfasl.back.api.core.dataAccess.entity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "ATTRACTION_COMMENTS")
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class AttractionComment extends Comment {
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package ir.chaarfasl.back.api.core.dataAccess.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "ATTRACTION_RATES")
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class AttractionRates extends Rates {
|
||||
// todo: complete it
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.SEQUENCE)
|
||||
@Column(name = "id", nullable = false)
|
||||
private Long id;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
package ir.chaarfasl.back.api.core.dataAccess.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@MappedSuperclass
|
||||
@AllArgsConstructor
|
||||
public class Comment implements Cloneable {
|
||||
@Id
|
||||
@GeneratedValue()
|
||||
@Column(name = "ID", nullable = false)
|
||||
protected Long id;
|
||||
|
||||
@Column(name = "POINT_ID", nullable = false)
|
||||
protected Long pointId;
|
||||
|
||||
@Column(name = "USER_ID", nullable = false)
|
||||
protected String userId;
|
||||
|
||||
@Column(name = "Title", nullable = false)
|
||||
protected String title;
|
||||
|
||||
@Column(name = "CONTEXT", nullable = false)
|
||||
protected String context;
|
||||
|
||||
@Column(name = "REJECTED_DESCRIPTION", nullable = true)
|
||||
protected String rejectedDescription;
|
||||
|
||||
@Column(name = "INSERT_DATETIME")
|
||||
protected LocalDateTime insertDateTime;
|
||||
|
||||
@Column(name = "CHANGE_STATUS_DATETIME")
|
||||
protected LocalDateTime changeStatusDateTime;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "COMMENT_STATUS_id")
|
||||
protected CommentStatus commentStatus;
|
||||
|
||||
@PrePersist
|
||||
public void saveTime() {
|
||||
insertDateTime = LocalDateTime.now();
|
||||
}
|
||||
|
||||
@PreUpdate
|
||||
public void saveUpdateTime() {
|
||||
changeStatusDateTime = LocalDateTime.now();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (id != null) {
|
||||
return id.hashCode();
|
||||
}
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
package ir.chaarfasl.back.api.core.dataAccess.entity;
|
||||
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "COMMENT_STATUSES")
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class CommentStatus {
|
||||
|
||||
@Id
|
||||
private Integer id;
|
||||
private String name;
|
||||
private Integer statusValue;
|
||||
private String description;
|
||||
private short isActive;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
package ir.chaarfasl.back.api.core.dataAccess.entity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "EATING_PLACES")
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class EatingPlace extends Point{
|
||||
|
||||
public EatingPlace(String name, String description, Double latitude, Double longitude, PointStatus pointStatus, Province province) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
this.pointStatus = pointStatus;
|
||||
this.province = province;
|
||||
}
|
||||
|
||||
public EatingPlace(Long id, String name, String description, Double latitude, Double longitude, PointStatus pointStatus, Province province) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
this.pointStatus = pointStatus;
|
||||
this.province = province;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package ir.chaarfasl.back.api.core.dataAccess.entity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "EATINGPLACE_COMMENTS")
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class EatingPlaceComment extends Comment {
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package ir.chaarfasl.back.api.core.dataAccess.entity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "EATING_PLACE_RATES")
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class EatingPlaceRates extends Rates {
|
||||
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package ir.chaarfasl.back.api.core.dataAccess.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "KEYWORDS")
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class Keywords {
|
||||
@Id
|
||||
@GeneratedValue()
|
||||
@Column(name = "id", nullable = false)
|
||||
private Long id;
|
||||
|
||||
//todo:
|
||||
// @UniqueConstraint("name")
|
||||
private String name;
|
||||
|
||||
public Keywords(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (id != null) {
|
||||
return id.hashCode();
|
||||
}
|
||||
return super.hashCode();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
package ir.chaarfasl.back.api.core.dataAccess.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@MappedSuperclass
|
||||
public class Point implements Cloneable{
|
||||
@Id
|
||||
@GeneratedValue()
|
||||
@Column(name = "ID", nullable = false)
|
||||
protected Long id;
|
||||
|
||||
@Column(name = "NAME", nullable = false)
|
||||
protected String name;
|
||||
|
||||
@Column(name = "DESCRIPTION", nullable = false)
|
||||
protected String description;
|
||||
|
||||
@Column(name = "LATITUDE", nullable = false)
|
||||
protected Double latitude;
|
||||
|
||||
@Column(name = "LONGITUDE", nullable = false)
|
||||
protected Double longitude;
|
||||
|
||||
@Column(name = "IMAGESNAME")
|
||||
protected String imagesName;
|
||||
|
||||
@Column(name = "RATE",columnDefinition="Float default '0'")
|
||||
protected Float rate;
|
||||
|
||||
@Column(name = "INSERT_DATETIME")
|
||||
protected LocalDateTime insertDateTime;
|
||||
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "POINT_STATUSES_id", nullable = false)
|
||||
protected PointStatus pointStatus;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "PROVINCES_code", nullable = false)
|
||||
protected Province province;
|
||||
|
||||
@PrePersist
|
||||
public void saveTime() {
|
||||
insertDateTime = LocalDateTime.now();
|
||||
if (rate == null || rate.compareTo(0F) == 0)
|
||||
rate = 0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (id != null) {
|
||||
return id.hashCode();
|
||||
}
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package ir.chaarfasl.back.api.core.dataAccess.entity;
|
||||
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "POINT_STATUSES")
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class PointStatus {
|
||||
|
||||
@Id
|
||||
private Integer id;
|
||||
private String name;
|
||||
private Integer statusValue;
|
||||
private String description;
|
||||
private short isActive;
|
||||
|
||||
/*@OneToMany(mappedBy = "pointStatus")
|
||||
private Set<Attraction> attractions;*/
|
||||
|
||||
/* public PointStatus(Integer id, String name, Integer value, String description, short isActive) {
|
||||
this.id= id;
|
||||
this.name = name;
|
||||
this.statusValue = value;
|
||||
this.description = description;
|
||||
this.isActive = isActive;
|
||||
}*/
|
||||
|
||||
/* @Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof PointStatus)) {
|
||||
return false; // null or other class
|
||||
}
|
||||
PointStatus other = (PointStatus) obj;
|
||||
|
||||
if (id != null) {
|
||||
return id.equals(other.id);
|
||||
}
|
||||
return super.equals(other);
|
||||
}*/
|
||||
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
package ir.chaarfasl.back.api.core.dataAccess.entity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "PROVINCES")
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class Province {
|
||||
|
||||
|
||||
@Id
|
||||
private Integer code;
|
||||
private Integer nationalIdentifier;
|
||||
private String name;
|
||||
|
||||
/* @OneToMany(mappedBy = "province")
|
||||
private Set<Attraction> attractions;*/
|
||||
/*
|
||||
public Province(Integer code, Integer nationalIdentifier, String name) {
|
||||
this.code = code;
|
||||
this.nationalIdentifier = nationalIdentifier;
|
||||
this.name = name;
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Province province = (Province) o;
|
||||
return Objects.equals(nationalIdentifier, province.nationalIdentifier);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package ir.chaarfasl.back.api.core.dataAccess.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@MappedSuperclass
|
||||
public class Rates implements Cloneable {
|
||||
@Id
|
||||
@GeneratedValue()
|
||||
@Column(name = "id", nullable = false)
|
||||
protected Long id;
|
||||
|
||||
@Column(name = "POINT_ID", nullable = false)
|
||||
protected Long pointId;
|
||||
|
||||
@Column(name = "USER_ID", nullable = false)
|
||||
protected String userId;
|
||||
|
||||
@Column(name = "VALUE", nullable = false)
|
||||
protected String value;
|
||||
|
||||
@Column(name = "COUNTED", nullable = false)
|
||||
protected Boolean counted;
|
||||
|
||||
@Column(name = "INSERT_DATETIME")
|
||||
protected LocalDateTime insertDateTime;
|
||||
|
||||
@PrePersist
|
||||
public void saveTime() {
|
||||
insertDateTime = LocalDateTime.now();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (id != null) {
|
||||
return id.hashCode();
|
||||
}
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
package ir.chaarfasl.back.api.core.dataAccess.entity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "RESIDENCE")
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class Residence extends Point{
|
||||
|
||||
// protected String bestTime;
|
||||
// protected Integer hardness;
|
||||
|
||||
public Residence(String name, String description, Double latitude, Double longitude, PointStatus pointStatus, Province province) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
this.pointStatus = pointStatus;
|
||||
this.province = province;
|
||||
// this.hardness = hardness;
|
||||
// this.bestTime = bestTime;
|
||||
}
|
||||
|
||||
public Residence(Long id, String name, String description, Double latitude, Double longitude, PointStatus pointStatus, Province province) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
this.pointStatus = pointStatus;
|
||||
this.province = province;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package ir.chaarfasl.back.api.core.dataAccess.entity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "RESIDENCE_COMMENTS")
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class ResidenceComment extends Comment {
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package ir.chaarfasl.back.api.core.dataAccess.entity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "RESIDENCE_RATES")
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class ResidenceRates extends Rates {
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package ir.chaarfasl.back.api.core.dataAccess.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
@Table(name = "SEARCH")
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class Search {
|
||||
@Id
|
||||
@GeneratedValue()
|
||||
@Column(name = "id", nullable = false)
|
||||
private Long id;
|
||||
private long keywordId;
|
||||
private long pointId;
|
||||
private String pointType;
|
||||
private Double latitude;
|
||||
private Double longitude;
|
||||
private Integer index;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "PROVINCES_code", nullable = false)
|
||||
private Province province;
|
||||
|
||||
public Search(long keywordId, long pointId, String pointType, Double latitude, Double longitude, Province province, Integer index) {
|
||||
this.keywordId = keywordId;
|
||||
this.pointId = pointId;
|
||||
this.pointType = pointType;
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
this.province = province;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (id != null) {
|
||||
return id.hashCode();
|
||||
}
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user