API 1.0.31 sports

This commit is contained in:
Bossanyi Tibor
2021-04-20 09:28:43 +02:00
parent d71fb9e6d5
commit a5f6dc1bd8
15 changed files with 234 additions and 47 deletions
@@ -25,6 +25,8 @@ data class Customer (
@Expose var fitnessLevel: String = "beginner",
@Expose var bodyType: String? = null,
@Expose var firebaseUid: String? = null,
@Expose var sportId: Int? = null,
@Expose var emailSubscription: Int? = 0,
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Expose var customerId: Long = 0
)
@@ -0,0 +1,18 @@
package com.aitrainer.api.model
import com.google.gson.annotations.Expose
import org.hibernate.annotations.Fetch
import org.hibernate.annotations.FetchMode
import org.springframework.lang.NonNull
import javax.persistence.*
@Entity
data class Sport (
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var sportId: Long = 0,
@Expose @get: NonNull var name: String = "",
) {
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "sport")
@Fetch(value = FetchMode.SUBSELECT)
@Expose val translations: List<SportTranslation> = mutableListOf<SportTranslation>().toList()
}
@@ -0,0 +1,20 @@
package com.aitrainer.api.model
import com.fasterxml.jackson.annotation.JsonIgnore
import com.google.gson.annotations.Expose
import javax.persistence.*
import javax.validation.constraints.NotBlank
@Entity
data class SportTranslation (
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) val translationId: Long = 0,
@Expose @get: NotBlank var languageCode: String?,
@Expose @get: NotBlank var sportName: String = "",
) {
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "sportId", nullable = false)
@JsonIgnore
val sport: Sport? = null
}