Ignore:
Timestamp:
12/26/23 18:50:43 (11 months ago)
Author:
gjoko kostadinov <gjokokostadinov@…>
Branches:
master
Children:
1413ee2
Parents:
950fa0d
Message:

Add entire code

Location:
src/main/java/edu/gjoko/schedlr/entity
Files:
3 added
8 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/edu/gjoko/schedlr/entity/Appointment.java

    • Property mode changed from 100644 to 100755
    r950fa0d r77205be  
    11package edu.gjoko.schedlr.entity;
    22
    3 import lombok.AllArgsConstructor;
    4 import lombok.Getter;
    5 import lombok.NoArgsConstructor;
    6 import lombok.Setter;
     3import com.fasterxml.jackson.annotation.JsonBackReference;
     4import lombok.*;
    75import org.springframework.data.annotation.LastModifiedDate;
    86import org.springframework.data.jpa.domain.support.AuditingEntityListener;
     
    1412@EntityListeners(AuditingEntityListener.class)
    1513@Table(name = "appointment")
    16 @Getter
    17 @Setter
     14@Data
    1815@NoArgsConstructor
    1916@AllArgsConstructor
     
    3027    private LocalDateTime endTime;
    3128
    32     @OneToOne
    33     @JoinColumn(name = "customer_id", referencedColumnName = "id")
     29    @ManyToOne
     30    @JoinColumn(name = "stakeholder_id")
     31    @JsonBackReference(value = "customerAppointments")
    3432    private Stakeholder customer;
    3533
    3634    @ManyToOne
    37     @JoinColumn(name = "business_id")
    38     private Business business;
     35    @JoinColumn(name = "service_id")
     36    @JsonBackReference(value = "serviceAppointments")
     37    private Service service;
    3938
    40     @ManyToOne
    41     @JoinColumn(name = "service_id")
    42     private Service service;
     39    @Column(name = "appointment_status", length = 32, columnDefinition = "varchar(32) default 'NEW'")
     40    @Enumerated(EnumType.STRING)
     41    private AppointmentStatus appointmentStatus = AppointmentStatus.NEW;
    4342
    4443    @Column(name = "created")
     
    4948    @LastModifiedDate
    5049    private LocalDateTime modified;
     50
     51    public String getTimePeriod() {
     52        return startTime + " - " + endTime;
     53    }
     54
    5155}
  • src/main/java/edu/gjoko/schedlr/entity/Business.java

    • Property mode changed from 100644 to 100755
    r950fa0d r77205be  
    3737    private BusinessType businessType;
    3838
    39     @ManyToOne()
     39    @OneToOne(cascade = CascadeType.PERSIST)
    4040    @JoinColumn(name = "owner_id", referencedColumnName = "id", nullable = false)
    4141    @JsonProperty("owner")
     
    4343
    4444    @OneToMany(mappedBy = "business", cascade = CascadeType.PERSIST)
    45     @JsonManagedReference
     45    @JsonManagedReference(value = "services")
    4646    private List<Service> services;
    4747
  • src/main/java/edu/gjoko/schedlr/entity/BusinessStatus.java

    • Property mode changed from 100644 to 100755
  • src/main/java/edu/gjoko/schedlr/entity/BusinessType.java

    • Property mode changed from 100644 to 100755
  • src/main/java/edu/gjoko/schedlr/entity/Service.java

    • Property mode changed from 100644 to 100755
    r950fa0d r77205be  
    33import com.fasterxml.jackson.annotation.JsonBackReference;
    44import com.fasterxml.jackson.annotation.JsonIgnore;
     5import com.fasterxml.jackson.annotation.JsonManagedReference;
    56import lombok.AllArgsConstructor;
    67import lombok.Getter;
     
    1314import javax.persistence.*;
    1415import java.time.LocalDateTime;
     16import java.util.List;
    1517
    1618@Entity
     
    3335    private Integer price;
    3436
    35     @OneToOne(cascade = CascadeType.PERSIST)
     37    @Column(name = "cumulated_rating")
     38    private Float rating = 0.0f;
     39
     40    @Column(name = "reviews_count")
     41    private Integer reviewsCount = 0;
     42
     43    @OneToOne(cascade = CascadeType.MERGE)
    3644    @JoinColumn(name = "service_type_id", referencedColumnName = "id")
    3745    private ServiceType serviceType;
     
    3947    @ManyToOne
    4048    @JoinColumn(name = "business_id")
    41     @JsonBackReference
     49    @JsonBackReference(value = "services")
    4250    private Business business;
     51
     52    @OneToMany(mappedBy="service")
     53    @JsonManagedReference(value = "serviceAppointments")
     54    private List<Appointment> appointments;
    4355
    4456    @Column(name = "created")
  • src/main/java/edu/gjoko/schedlr/entity/ServiceType.java

    • Property mode changed from 100644 to 100755
  • src/main/java/edu/gjoko/schedlr/entity/Stakeholder.java

    • Property mode changed from 100644 to 100755
    r950fa0d r77205be  
    22
    33import com.fasterxml.jackson.annotation.JsonIgnore;
     4import com.fasterxml.jackson.annotation.JsonManagedReference;
    45import lombok.AllArgsConstructor;
    56import lombok.Getter;
     
    1213import javax.persistence.*;
    1314import java.time.LocalDateTime;
     15import java.util.List;
    1416
    1517@Entity
     
    3941    private String email;
    4042
     43    @Column(name = "phone_number")
     44    private String phoneNumber;
     45
    4146    @Column(name = "username")
    4247    private String username;
     
    4449    @Column(name = "password")
    4550    private String password;
     51
     52    @OneToMany(mappedBy = "customer")
     53    @JsonManagedReference(value = "customerAppointments")
     54    private List<Appointment> appointments;
    4655
    4756    @Column(name = "created")
     
    5463    @JsonIgnore
    5564    private LocalDateTime modified;
     65
     66    public String getFullName() {
     67        return firstName + " " + lastName;
     68    }
    5669}
  • src/main/java/edu/gjoko/schedlr/entity/StakeholderType.java

    • Property mode changed from 100644 to 100755
Note: See TracChangeset for help on using the changeset viewer.