Added more stuff.

This commit is contained in:
Andrew Lalis 2023-01-20 08:53:15 +01:00
parent f3aec7b2a2
commit 4eb0ddc259
8 changed files with 135 additions and 12 deletions

View File

@ -0,0 +1,25 @@
package nl.andrewlalis.gymboard_api.model;
import jakarta.persistence.*;
import org.hibernate.annotations.CreationTimestamp;
import java.time.LocalDateTime;
@Entity
@Table(name = "gym_exercise_submission")
public class ExerciseSubmission {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@CreationTimestamp
private LocalDateTime createdAt;
@Column(nullable = false, updatable = false, length = 63)
private String submitterName;
@ManyToOne(optional = false, fetch = FetchType.LAZY)
private Gym gym;
}

View File

@ -0,0 +1,38 @@
package nl.andrewlalis.gymboard_api.model;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import org.hibernate.annotations.CreationTimestamp;
import java.time.LocalDateTime;
@Entity
@Table(name = "gym")
public class Gym {
@EmbeddedId
private GymId id;
@CreationTimestamp
private LocalDateTime createdAt;
public GymId getId() {
return id;
}
public String getName() {
return id.getName();
}
public String getCityId() {
return id.getCityId();
}
public String getCountryId() {
return id.getCountryId();
}
public LocalDateTime getCreatedAt() {
return createdAt;
}
}

View File

@ -0,0 +1,56 @@
package nl.andrewlalis.gymboard_api.model;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import java.io.Serializable;
import java.util.Objects;
/**
* Compound primary key used to identify a single {@link Gym}.
*/
@Embeddable
public class GymId implements Serializable {
@Column(nullable = false, length = 127)
private String name;
@Column(nullable = false, length = 127)
private String cityId;
@Column(nullable = false, length = 2)
private String countryId;
public GymId() {}
public GymId(String name, String cityId, String countryId) {
this.name = name;
this.cityId = cityId;
this.countryId = countryId;
}
public String getName() {
return name;
}
public String getCityId() {
return cityId;
}
public String getCountryId() {
return countryId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o instanceof GymId gymId) {
return getName().equals(gymId.getName()) &&
getCityId().equals(gymId.getCityId()) &&
getCountryId().equals(gymId.getCountryId());
}
return false;
}
@Override
public int hashCode() {
return Objects.hash(getName(), getCityId(), getCountryId());
}
}

View File

@ -1 +1 @@
spring.jpa.open-in-view=false

View File

@ -28,8 +28,8 @@
> >
Pages Pages
</q-item-label> </q-item-label>
<q-item clickable>First Page</q-item> <q-item clickable>Gyms</q-item>
<q-item clickable>Second Page</q-item> <q-item clickable>Global Leaderboard</q-item>
</q-list> </q-list>
</q-drawer> </q-drawer>

View File

@ -1,16 +1,17 @@
<template> <template>
<q-page> <q-page>
Hello Gym Page Hello Gym Page
<p>
Leaderboard total
</p>
</q-page> </q-page>
</template> </template>
<script> <script setup lang="ts">
import { defineComponent } from 'vue'; import { defineComponent, onMounted, ref } from 'vue';
const mountCount = ref(0);
export default defineComponent({ onMounted(() => {
name: 'GymPage', console.log("mounted");
setup() {
return {};
}
}); });
</script> </script>

View File

@ -1,7 +1,10 @@
<template> <template>
<q-page> <q-page>
Index Index
<router-link to="/gyms/a">Test</router-link> <router-link to="/g/nl/groningen/trainmore-munnekeholm">Test</router-link>
<p>
Search bar for gyms.
</p>
</q-page> </q-page>
</template> </template>

View File

@ -13,7 +13,7 @@ const routes: RouteRecordRaw[] = [
component: IndexPage component: IndexPage
}, },
{ {
path: 'gyms/:id', path: 'g/:countryId/:cityId/:gymName',
component: GymPage component: GymPage
} }
], ],