Split room image ordering for room and room type
All checks were successful
build-and-deploy / build-deploy (push) Successful in 32s

This commit is contained in:
androidlover5842
2026-01-27 16:12:55 +05:30
parent 083909938a
commit 518a5bb359
4 changed files with 12 additions and 12 deletions

View File

@@ -58,8 +58,8 @@ class RoomImages(
@PathVariable roomId: UUID, @PathVariable roomId: UUID,
@AuthenticationPrincipal principal: MyPrincipal?, @AuthenticationPrincipal principal: MyPrincipal?,
@RequestParam("file") file: MultipartFile, @RequestParam("file") file: MultipartFile,
@RequestParam(required = false) sortOrder: Int?, @RequestParam(required = false) roomSortOrder: Int?,
@RequestParam(required = false) category: String?, @RequestParam(required = false) roomTypeSortOrder: Int?,
@RequestParam(required = false) tags: List<String>? @RequestParam(required = false) tags: List<String>?
): RoomImageResponse { ): RoomImageResponse {
requirePrincipal(principal) requirePrincipal(principal)
@@ -85,8 +85,8 @@ class RoomImages(
sizeBytes = stored.sizeBytes, sizeBytes = stored.sizeBytes,
roomTypeCode = room.roomType.code, roomTypeCode = room.roomType.code,
tags = tags?.toMutableSet() ?: mutableSetOf(), tags = tags?.toMutableSet() ?: mutableSetOf(),
sortOrder = sortOrder, roomSortOrder = roomSortOrder,
category = category roomTypeSortOrder = roomTypeSortOrder
) )
return roomImageRepo.save(image).toResponse(publicBaseUrl) return roomImageRepo.save(image).toResponse(publicBaseUrl)
} }
@@ -143,8 +143,8 @@ private fun RoomImage.toResponse(baseUrl: String): RoomImageResponse {
contentType = contentType, contentType = contentType,
sizeBytes = sizeBytes, sizeBytes = sizeBytes,
tags = tags.toSet(), tags = tags.toSet(),
sortOrder = sortOrder, roomSortOrder = roomSortOrder,
category = category, roomTypeSortOrder = roomTypeSortOrder,
createdAt = createdAt.toString() createdAt = createdAt.toString()
) )
} }

View File

@@ -40,8 +40,8 @@ data class RoomImageResponse(
val contentType: String, val contentType: String,
val sizeBytes: Long, val sizeBytes: Long,
val tags: Set<String>, val tags: Set<String>,
val sortOrder: Int?, val roomSortOrder: Int?,
val category: String?, val roomTypeSortOrder: Int?,
val createdAt: String val createdAt: String
) )

View File

@@ -45,10 +45,10 @@ class RoomImage(
var tags: MutableSet<String> = mutableSetOf(), var tags: MutableSet<String> = mutableSetOf(),
@Column(name = "sort_order") @Column(name = "sort_order")
var sortOrder: Int? = null, var roomSortOrder: Int? = null,
@Column @Column(name = "room_type_sort_order")
var category: String? = null, var roomTypeSortOrder: Int? = null,
@Column(name = "created_at", nullable = false, columnDefinition = "timestamptz") @Column(name = "created_at", nullable = false, columnDefinition = "timestamptz")
val createdAt: OffsetDateTime = OffsetDateTime.now() val createdAt: OffsetDateTime = OffsetDateTime.now()

View File

@@ -12,7 +12,7 @@ interface RoomImageRepo : JpaRepository<RoomImage, UUID> {
select ri select ri
from RoomImage ri from RoomImage ri
where ri.room.id = :roomId where ri.room.id = :roomId
order by (ri.sortOrder is null), ri.sortOrder asc, ri.createdAt desc order by (ri.roomSortOrder is null), ri.roomSortOrder asc, ri.createdAt desc
""" """
) )
fun findByRoomIdOrdered(@Param("roomId") roomId: UUID): List<RoomImage> fun findByRoomIdOrdered(@Param("roomId") roomId: UUID): List<RoomImage>