Skip to content

Commit c6b16b1

Browse files
committed
"10/28/24"
1 parent 56e8db1 commit c6b16b1

5 files changed

Lines changed: 73 additions & 41 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package org.launchcode.codingevents.models;
2+
3+
import jakarta.persistence.GeneratedValue;
4+
import jakarta.persistence.Id;
5+
import jakarta.persistence.MappedSuperclass;
6+
7+
import java.util.Objects;
8+
9+
@MappedSuperclass
10+
public abstract class AbstractEntity {
11+
@Id
12+
@GeneratedValue
13+
private int id;
14+
15+
public int getId() {
16+
return id;
17+
}
18+
19+
@Override
20+
public boolean equals(Object o) {
21+
if (this == o) return true;
22+
if (o == null || getClass() != o.getClass()) return false;
23+
AbstractEntity entity = (AbstractEntity) o;
24+
return id == entity.id;
25+
}
26+
27+
@Override
28+
public int hashCode() {
29+
return Objects.hash(id);
30+
}
31+
32+
}

src/main/java/org/launchcode/codingevents/models/Event.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
* Created by Chris Bay
1414
*/
1515
@Entity
16-
public class Event {
16+
public class Event extends AbstractEntity {
1717

18-
@Id
19-
@GeneratedValue
20-
private int id;
18+
// @Id
19+
// @GeneratedValue
20+
// private int id;
2121

2222
@NotBlank(message = "Name is required")
2323
@Size(min = 3, max = 50, message = "Name must be between 3 and 50 characters")
@@ -73,25 +73,25 @@ public void setType(EventType type) {
7373
this.type = type;
7474
}
7575

76-
public int getId() {
77-
return id;
78-
}
76+
// public int getId() {
77+
// return id;
78+
// }
7979

8080
@Override
8181
public String toString() {
8282
return name;
8383
}
8484

85-
@Override
86-
public boolean equals(Object o) {
87-
if (this == o) return true;
88-
if (o == null || getClass() != o.getClass()) return false;
89-
Event event = (Event) o;
90-
return id == event.id;
91-
}
92-
93-
@Override
94-
public int hashCode() {
95-
return Objects.hash(id);
96-
}
85+
// @Override
86+
// public boolean equals(Object o) {
87+
// if (this == o) return true;
88+
// if (o == null || getClass() != o.getClass()) return false;
89+
// Event event = (Event) o;
90+
// return id == event.id;
91+
// }
92+
//
93+
// @Override
94+
// public int hashCode() {
95+
// return Objects.hash(id);
96+
// }
9797
}

src/main/java/org/launchcode/codingevents/models/EventCategory.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
* Created by Chris Bay
1212
*/
1313
@Entity
14-
public class EventCategory {
14+
public class EventCategory extends AbstractEntity {
1515

16-
@Id
17-
@GeneratedValue
18-
private int id;
16+
// @Id
17+
// @GeneratedValue
18+
// private int id;
1919

2020
@Size(min=3, message="Name must be at least 3 characters long")
2121
private String name;
@@ -34,26 +34,26 @@ public void setName(String name) {
3434
this.name = name;
3535
}
3636

37-
public int getId() {
38-
return id;
39-
}
37+
// public int getId() {
38+
// return id;
39+
// }
4040

4141
@Override
4242
public String toString() {
4343
return name;
4444
}
4545

46-
@Override
47-
public boolean equals(Object o) {
48-
if (this == o) return true;
49-
if (o == null || getClass() != o.getClass()) return false;
50-
EventCategory that = (EventCategory) o;
51-
return id == that.id;
52-
}
53-
54-
@Override
55-
public int hashCode() {
56-
return Objects.hash(id);
57-
}
46+
// @Override
47+
// public boolean equals(Object o) {
48+
// if (this == o) return true;
49+
// if (o == null || getClass() != o.getClass()) return false;
50+
// Event event = (Event) o;
51+
// return id == event.id;
52+
// }
53+
//
54+
// @Override
55+
// public int hashCode() {
56+
// return Objects.hash(id);
57+
// }
5858
}
5959

src/main/resources/application.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Database connection settings
22
spring.datasource.url=jdbc:mysql://localhost:3306/coding_events
3-
spring.datasource.username=user
4-
spring.datasource.password=password
3+
spring.datasource.username=coding_events
4+
spring.datasource.password=@11Launch_Code_0123!
55

66
# Specify the DBMS
77
spring.jpa.database = MYSQL

src/main/resources/templates/events/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<td th:text="${event.name}"></td>
2121
<td th:text="${event.description}"></td>
2222
<td th:text="${event.contactEmail}"></td>
23-
<td th:text="${event.type.displayName}"></td>
23+
<td th:text="${event.type}"></td>
2424
</tr>
2525
</table>
2626

0 commit comments

Comments
 (0)