Attach room type code and tags to room images
All checks were successful
build-and-deploy / build-deploy (push) Successful in 31s

This commit is contained in:
androidlover5842
2026-01-27 16:09:54 +05:30
parent 7934b7efd5
commit 083909938a
3 changed files with 19 additions and 1 deletions

View File

@@ -59,7 +59,8 @@ class RoomImages(
@AuthenticationPrincipal principal: MyPrincipal?,
@RequestParam("file") file: MultipartFile,
@RequestParam(required = false) sortOrder: Int?,
@RequestParam(required = false) category: String?
@RequestParam(required = false) category: String?,
@RequestParam(required = false) tags: List<String>?
): RoomImageResponse {
requirePrincipal(principal)
propertyAccess.requireMember(propertyId, principal!!.userId)
@@ -82,6 +83,8 @@ class RoomImages(
thumbnailPath = stored.thumbnailPath,
contentType = stored.contentType,
sizeBytes = stored.sizeBytes,
roomTypeCode = room.roomType.code,
tags = tags?.toMutableSet() ?: mutableSetOf(),
sortOrder = sortOrder,
category = category
)
@@ -134,10 +137,12 @@ private fun RoomImage.toResponse(baseUrl: String): RoomImageResponse {
id = id,
propertyId = property.id!!,
roomId = room.id!!,
roomTypeCode = roomTypeCode,
url = "$baseUrl/properties/${property.id}/rooms/${room.id}/images/$id/file",
thumbnailUrl = "$baseUrl/properties/${property.id}/rooms/${room.id}/images/$id/file?size=thumb",
contentType = contentType,
sizeBytes = sizeBytes,
tags = tags.toSet(),
sortOrder = sortOrder,
category = category,
createdAt = createdAt.toString()

View File

@@ -34,10 +34,12 @@ data class RoomImageResponse(
val id: UUID,
val propertyId: UUID,
val roomId: UUID,
val roomTypeCode: String?,
val url: String,
val thumbnailUrl: String,
val contentType: String,
val sizeBytes: Long,
val tags: Set<String>,
val sortOrder: Int?,
val category: String?,
val createdAt: String

View File

@@ -33,6 +33,17 @@ class RoomImage(
@Column(name = "size_bytes", nullable = false)
var sizeBytes: Long,
@Column(name = "room_type_code")
var roomTypeCode: String? = null,
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(
name = "room_image_tag",
joinColumns = [JoinColumn(name = "room_image_id")]
)
@Column(name = "tag", nullable = false)
var tags: MutableSet<String> = mutableSetOf(),
@Column(name = "sort_order")
var sortOrder: Int? = null,