Removes redundant DB data fields and adds photo submission endpoint along with MinIO support for image storage
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
package net.halfbinary.scavengerhuntapi.model
|
||||
|
||||
enum class PhotoStatus {
|
||||
SUBMITTED,
|
||||
APPROVED,
|
||||
REJECTED,
|
||||
REMOVED
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package net.halfbinary.scavengerhuntapi.model
|
||||
|
||||
import java.util.*
|
||||
|
||||
typealias FoundId = UUID
|
||||
typealias HuntId = UUID
|
||||
typealias HunterId = UUID
|
||||
typealias ItemId = UUID
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package net.halfbinary.scavengerhuntapi.model.converter
|
||||
|
||||
import net.halfbinary.scavengerhuntapi.model.domain.Photo
|
||||
import net.halfbinary.scavengerhuntapi.model.record.PhotoRecord
|
||||
import net.halfbinary.scavengerhuntapi.model.response.PhotoResponse
|
||||
|
||||
fun Photo.toRecord() = PhotoRecord(
|
||||
id = id,
|
||||
itemId = itemId,
|
||||
huntId = huntId,
|
||||
hunterId = hunterId,
|
||||
foundDateTime = foundDateTime,
|
||||
status = status,
|
||||
statusChangeDateTime = statusChangeDateTime
|
||||
)
|
||||
|
||||
fun Photo.toResponse() = PhotoResponse(
|
||||
id = id,
|
||||
hunterId = hunterId,
|
||||
photoUploadDateTime = foundDateTime,
|
||||
photoStatus = status,
|
||||
photoStatusChangeDateTime = statusChangeDateTime
|
||||
)
|
||||
@@ -0,0 +1,19 @@
|
||||
package net.halfbinary.scavengerhuntapi.model.domain
|
||||
|
||||
import net.halfbinary.scavengerhuntapi.model.HuntId
|
||||
import net.halfbinary.scavengerhuntapi.model.HunterId
|
||||
import net.halfbinary.scavengerhuntapi.model.ItemId
|
||||
import net.halfbinary.scavengerhuntapi.model.PhotoId
|
||||
import net.halfbinary.scavengerhuntapi.model.PhotoStatus
|
||||
import java.time.LocalDateTime
|
||||
import java.util.UUID
|
||||
|
||||
data class Photo(
|
||||
val id: PhotoId = UUID.randomUUID(),
|
||||
val itemId: ItemId,
|
||||
val huntId: HuntId,
|
||||
val hunterId: HunterId,
|
||||
val foundDateTime: LocalDateTime,
|
||||
val status: PhotoStatus,
|
||||
val statusChangeDateTime: LocalDateTime
|
||||
)
|
||||
@@ -3,25 +3,25 @@ package net.halfbinary.scavengerhuntapi.model.record
|
||||
import jakarta.persistence.Entity
|
||||
import jakarta.persistence.Id
|
||||
import jakarta.persistence.Table
|
||||
import net.halfbinary.scavengerhuntapi.model.FoundId
|
||||
import net.halfbinary.scavengerhuntapi.model.FoundStatus
|
||||
import net.halfbinary.scavengerhuntapi.model.HuntId
|
||||
import net.halfbinary.scavengerhuntapi.model.HunterId
|
||||
import net.halfbinary.scavengerhuntapi.model.ItemId
|
||||
import net.halfbinary.scavengerhuntapi.model.PhotoId
|
||||
import net.halfbinary.scavengerhuntapi.model.PhotoStatus
|
||||
import java.time.LocalDateTime
|
||||
|
||||
/**
|
||||
* Represents a found Item for a Hunt by a Hunter
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "found")
|
||||
data class FoundRecord(
|
||||
@Table(name = "photo")
|
||||
data class PhotoRecord(
|
||||
@Id
|
||||
val id: FoundId,
|
||||
val id: PhotoId,
|
||||
val itemId: ItemId,
|
||||
val huntId: HuntId,
|
||||
val hunterId: HunterId,
|
||||
val foundDateTime: LocalDateTime,
|
||||
val imageName: String,
|
||||
val status: FoundStatus
|
||||
val status: PhotoStatus,
|
||||
val statusChangeDateTime: LocalDateTime,
|
||||
)
|
||||
@@ -1,10 +1,14 @@
|
||||
package net.halfbinary.scavengerhuntapi.model.response
|
||||
|
||||
import net.halfbinary.scavengerhuntapi.model.HunterId
|
||||
import net.halfbinary.scavengerhuntapi.model.PhotoId
|
||||
import net.halfbinary.scavengerhuntapi.model.PhotoStatus
|
||||
import java.time.LocalDateTime
|
||||
|
||||
data class PhotoResponse(
|
||||
val id: PhotoId,
|
||||
val hunterName: String,
|
||||
val photoUploadDateTime: LocalDateTime
|
||||
val hunterId: HunterId,
|
||||
val photoUploadDateTime: LocalDateTime,
|
||||
val photoStatus: PhotoStatus,
|
||||
val photoStatusChangeDateTime: LocalDateTime,
|
||||
)
|
||||
|
||||
@@ -2,10 +2,11 @@ package net.halfbinary.scavengerhuntapi.model.response
|
||||
|
||||
import net.halfbinary.scavengerhuntapi.model.FoundStatus
|
||||
import net.halfbinary.scavengerhuntapi.model.ItemId
|
||||
import java.time.LocalDateTime
|
||||
|
||||
data class TeamItemResponse(
|
||||
val id: ItemId,
|
||||
val itemName: String,
|
||||
val hunterName: String,
|
||||
val itemFoundStatus: FoundStatus
|
||||
val hunterName: String?,
|
||||
val itemFoundStatus: FoundStatus,
|
||||
val itemStatusChangeDateTime: LocalDateTime,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user