Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11edc18
commit 33e5f6c
Showing
6 changed files
with
69 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
repeated-dislikes/src/main/kotlin/org/jesperancinha/repeateddislikes/bad/dtos/Dtos.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.jesperancinha.repeateddislikes.bad.dtos | ||
|
||
import org.jesperancinha.repeateddislikes.bad.domain.User | ||
import java.util.* | ||
|
||
data class UserDTO( | ||
val id: UUID, | ||
val name: String, | ||
val receipts: List<UUID>, | ||
val shops: List<String> | ||
) | ||
|
||
data class ReceiptDTO( | ||
val id: UUID, | ||
val user: UserDTO, | ||
val shop: ShopDTO | ||
) | ||
|
||
|
||
data class ShopDTO( | ||
val id: UUID, | ||
val name: String, | ||
val receipts: List<ReceiptDTO> | ||
) | ||
|
||
|
||
fun User.toDto() = UserDTO ( | ||
id = id, | ||
name = name, | ||
receipts = receipts.map { it.id }, | ||
shops = shops.map { it.name } | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,24 @@ | ||
SELECT LOG(2); | ||
insert into BAD.USERS (ID, NAME) | ||
values (random_uuid(), 'Liking Cat 1'); | ||
insert into BAD.SHOPS (ID, NAME) | ||
values (random_uuid(), 'Cats Para Dice'); | ||
SET @receipt1=random_uuid(); | ||
SET @receipt2=random_uuid(); | ||
insert into BAD.RECEIPTS (ID, USER_ID, SHOP_ID) | ||
values (@receipt1, | ||
(select ID from BAD.USERS WHERE NAME = 'Liking Cat 1'), | ||
(select ID from BAD.SHOPS WHERE NAME = 'Cats Para Dice') | ||
); | ||
insert into BAD.BAD_DISLIKES_RELATIONS (ID, USER_ID, SHOP_ID, RECEIPT_ID) | ||
values (random_uuid(), | ||
(select ID from BAD.USERS WHERE NAME = 'Liking Cat 1'), | ||
(select ID from BAD.SHOPS WHERE NAME = 'Cats Para Dice'), | ||
@receipt1 | ||
); | ||
|
||
insert into BAD.BAD_DISLIKES_RELATIONS (ID, USER_ID, SHOP_ID, RECEIPT_ID) | ||
values (random_uuid(), | ||
(select ID from BAD.USERS WHERE NAME = 'Liking Cat 1'), | ||
(select ID from BAD.SHOPS WHERE NAME = 'Cats Para Dice'), | ||
@receipt2 | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters