Skip to content

Commit a5f508b

Browse files
committed
feat: add ReservaionEntity and ReservationRepository for reservation management
1 parent 28f54fe commit a5f508b

File tree

3 files changed

+98
-1
lines changed

3 files changed

+98
-1
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.example.SorokinSpringBoot;
2+
3+
import com.example.SorokinSpringBoot.models.ReservaionEntity;
4+
import org.springframework.data.jpa.repository.JpaRepository;
5+
6+
public interface ReservationRepository extends JpaRepository<ReservaionEntity, Long> {
7+
8+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package com.example.SorokinSpringBoot.models;
2+
3+
import com.example.SorokinSpringBoot.enums.ReservationStatus;
4+
import jakarta.persistence.*;
5+
6+
import java.time.LocalDate;
7+
8+
@Table(name = "reservations")
9+
@Entity
10+
public class ReservaionEntity {
11+
@Id
12+
@GeneratedValue(strategy = GenerationType.IDENTITY)
13+
private Long id;
14+
15+
@Column(name = "user_id")
16+
private Long userId;
17+
18+
@Column(name = "room_id")
19+
private Long roomId;
20+
21+
@Column(name = "start_date")
22+
private LocalDate startDate;
23+
24+
@Column(name = "end_date")
25+
private LocalDate endDate;
26+
27+
@Column(name = "status")
28+
private ReservationStatus status;
29+
30+
public ReservaionEntity() {
31+
}
32+
33+
public ReservaionEntity(Long id, Long userId, Long roomId, LocalDate startDate, LocalDate endDate, ReservationStatus status) {
34+
this.id = id;
35+
this.userId = userId;
36+
this.roomId = roomId;
37+
this.startDate = startDate;
38+
this.endDate = endDate;
39+
this.status = status;
40+
}
41+
42+
public void setId(Long id) {
43+
this.id = id;
44+
}
45+
46+
public Long getId() {
47+
return id;
48+
}
49+
50+
public Long getUserId() {
51+
return userId;
52+
}
53+
54+
public void setUserId(Long userId) {
55+
this.userId = userId;
56+
}
57+
58+
public Long getRoomId() {
59+
return roomId;
60+
}
61+
62+
public void setRoomId(Long roomId) {
63+
this.roomId = roomId;
64+
}
65+
66+
public LocalDate getStartDate() {
67+
return startDate;
68+
}
69+
70+
public void setStartDate(LocalDate startDate) {
71+
this.startDate = startDate;
72+
}
73+
74+
public LocalDate getEndDate() {
75+
return endDate;
76+
}
77+
78+
public void setEndDate(LocalDate endDate) {
79+
this.endDate = endDate;
80+
}
81+
82+
public ReservationStatus getStatus() {
83+
return status;
84+
}
85+
86+
public void setStatus(ReservationStatus status) {
87+
this.status = status;
88+
}
89+
}

src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
spring.application.name=SorokinSpringBoot
22

3-
spring.datasource.url=jdbc:postgresqpl:/localhost:5432/reservations
3+
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
44
spring.datasource.username=postgres
55
spring.datasource.password=jecna2024
66

0 commit comments

Comments
 (0)