Skip to content

Commit 238cd60

Browse files
committed
chore(repositories): improve repository definitions
1 parent 128e5b0 commit 238cd60

6 files changed

Lines changed: 130 additions & 48 deletions

File tree

src/main/java/net/onelitefeather/vulpes/api/repository/FontRepository.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import io.micronaut.data.annotation.Query;
44
import io.micronaut.data.annotation.Repository;
5-
import io.micronaut.data.model.Pageable;
65
import io.micronaut.data.repository.PageableRepository;
76
import net.onelitefeather.vulpes.api.model.FontEntity;
87

@@ -19,18 +18,6 @@
1918
@Repository
2019
public interface FontRepository extends PageableRepository<FontEntity, UUID> {
2120

22-
/**
23-
* Retrieves the characters associated with a font by its ID.
24-
*
25-
* @param id the unique identifier of the font
26-
* @return a list of characters associated with the font
27-
*/
28-
@Query(
29-
value = "SELECT c FROM fonts f JOIN f.chars c WHERE f.id = :id",
30-
countQuery = "SELECT COUNT(c) FROM fonts f JOIN f.chars c WHERE f.id = :id"
31-
)
32-
List<String> findCharsByFontId(UUID id, Pageable pageable);
33-
3421
/**
3522
* Retrieves all fonts along with their associated characters.
3623
*

src/main/java/net/onelitefeather/vulpes/api/repository/ItemRepository.java

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import net.onelitefeather.vulpes.api.model.ItemEntity;
88

99
import java.util.List;
10-
import java.util.Map;
1110
import java.util.UUID;
1211

1312
/**
@@ -20,40 +19,6 @@
2019
@Repository
2120
public interface ItemRepository extends PageableRepository<ItemEntity, UUID> {
2221

23-
/**
24-
* Retrieves the enchantments associated with an item by its ID.
25-
*
26-
* @param id the unique identifier of the item
27-
* @return a map of enchantment names and their levels associated with the item
28-
*/
29-
@Query(value = "SELECT e FROM items i JOIN i.enchantments e WHERE i.id = :id",
30-
countQuery = "SELECT count(e) FROM items i JOIN i.enchantments e WHERE i.id = :id"
31-
)
32-
Map<String, Short> findEnchantmentsById(UUID id, Pageable pageable);
33-
34-
/**
35-
* Retrieves the lore associated with an item by its ID.
36-
*
37-
* @param id the unique identifier of the item
38-
* @return a list of lore strings associated with the item
39-
*/
40-
@Query(value = "SELECT l FROM items i JOIN i.lore l WHERE i.id = :id",
41-
countQuery = "SELECT count(l) FROM items i JOIN i.lore l WHERE i.id = :id"
42-
)
43-
List<String> findLoreById(UUID id, Pageable pageable);
44-
45-
/**
46-
* Retrieves the flags associated with an item by its ID.
47-
*
48-
* @param id the unique identifier of the item
49-
* @return a list of flags associated with the item
50-
*/
51-
@Query(value = "SELECT f FROM items i JOIN i.flags f WHERE i.id = :id",
52-
countQuery = "SELECT count(f) FROM items i JOIN i.flags f WHERE i.id = :id"
53-
)
54-
List<String> findFlagsById(UUID id, Pageable pageable);
55-
56-
5722
/**
5823
* Retrieves all items along with their associated enchantments, lore, and flags.
5924
*
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package net.onelitefeather.vulpes.api.repository.font;
2+
3+
import io.micronaut.data.annotation.Query;
4+
import io.micronaut.data.annotation.Repository;
5+
import io.micronaut.data.model.Page;
6+
import io.micronaut.data.model.Pageable;
7+
import io.micronaut.data.repository.PageableRepository;
8+
import net.onelitefeather.vulpes.api.model.font.FontLoreEntity;
9+
import net.onelitefeather.vulpes.api.model.item.ItemEnchantmentEntity;
10+
11+
import java.util.UUID;
12+
13+
/**
14+
* Repository definition to manage {@link FontLoreRepository} entities.
15+
*
16+
* @version 1.0.0
17+
* @since 1.7.0
18+
* @author theEvilReaper
19+
*/
20+
@Repository
21+
public interface FontLoreRepository extends PageableRepository<ItemEnchantmentEntity, UUID> {
22+
23+
/**
24+
* Retrieves the characters associated with a font by its ID.
25+
*
26+
* @param id the unique identifier of the font
27+
* @return a list of characters associated with the font
28+
*/
29+
@Query(value = "SELECT f FROM font_lore f WHERE f.font.id = :id",
30+
countQuery = "SELECT count(f) FROM font_lore f WHERE f.font.id = :id"
31+
)
32+
Page<FontLoreEntity> findCharsByFontId(UUID id, Pageable pageable);
33+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package net.onelitefeather.vulpes.api.repository.item;
2+
3+
import io.micronaut.data.annotation.Query;
4+
import io.micronaut.data.annotation.Repository;
5+
import io.micronaut.data.model.Page;
6+
import io.micronaut.data.model.Pageable;
7+
import io.micronaut.data.repository.PageableRepository;
8+
import net.onelitefeather.vulpes.api.model.item.ItemEnchantmentEntity;
9+
10+
import java.util.UUID;
11+
12+
/**
13+
* Repository definition to manage {@link ItemEnchantmentEntity} entities.
14+
*
15+
* @version 1.0.0
16+
* @since 1.7.0
17+
* @author theEvilReaper
18+
*/
19+
@Repository
20+
public interface ItemEnchantmentRepository extends PageableRepository<ItemEnchantmentEntity, UUID> {
21+
22+
/**
23+
* Retrieves the enchantments associated with an item by its ID.
24+
*
25+
* @param id the unique identifier of the item
26+
* @return a list of enchantments associated with the item
27+
*/
28+
@Query(value = "SELECT f FROM item_enchantments f WHERE f.item.id = :id",
29+
countQuery = "SELECT count(f) FROM item_enchantments f WHERE f.item.id = :id"
30+
)
31+
Page<ItemEnchantmentEntity> findEnchantmentsById(UUID id, Pageable pageable);
32+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package net.onelitefeather.vulpes.api.repository.item;
2+
3+
import io.micronaut.data.annotation.Query;
4+
import io.micronaut.data.annotation.Repository;
5+
import io.micronaut.data.model.Page;
6+
import io.micronaut.data.model.Pageable;
7+
import io.micronaut.data.repository.PageableRepository;
8+
import net.onelitefeather.vulpes.api.model.item.ItemEnchantmentEntity;
9+
import net.onelitefeather.vulpes.api.model.item.ItemFlagEntity;
10+
11+
import java.util.UUID;
12+
13+
/**
14+
* Repository definition to manage {@link ItemFlagEntity} entities.
15+
*
16+
* @version 1.0.0
17+
* @since 1.7.0
18+
* @author theEvilReaper
19+
*/
20+
@Repository
21+
public interface ItemFlagRepository extends PageableRepository<ItemFlagEntity, UUID> {
22+
23+
/**
24+
* Retrieves the flags associated with an item by its ID.
25+
*
26+
* @param id the unique identifier of the item
27+
* @return a list of flags associated with the item
28+
*/
29+
@Query(value = "SELECT f FROM item_flags f WHERE f.item.id = :id",
30+
countQuery = "SELECT count(f) FROM item_flags f WHERE f.item.id = :id"
31+
)
32+
Page<ItemFlagEntity> findFlagsById(UUID id, Pageable pageable);
33+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package net.onelitefeather.vulpes.api.repository.item;
2+
3+
import io.micronaut.data.annotation.Query;
4+
import io.micronaut.data.annotation.Repository;
5+
import io.micronaut.data.model.Page;
6+
import io.micronaut.data.model.Pageable;
7+
import io.micronaut.data.repository.PageableRepository;
8+
import net.onelitefeather.vulpes.api.model.item.ItemLoreEntity;
9+
10+
import java.util.UUID;
11+
12+
/**
13+
* Repository definition to manage {@link ItemLoreEntity} entities.
14+
*
15+
* @version 1.0.0
16+
* @since 1.7.0
17+
* @author theEvilReaper
18+
*/
19+
@Repository
20+
public interface ItemLoreRepository extends PageableRepository<ItemLoreEntity, UUID> {
21+
22+
/**
23+
* Retrieves the lore associated with an item by its ID.
24+
*
25+
* @param id the unique identifier of the item
26+
* @return a list of lore strings associated with the item
27+
*/
28+
@Query(value = "SELECT f FROM item_lore f WHERE f.item.id = :id",
29+
countQuery = "SELECT count(f) FROM item_lore f WHERE f.item.id = :id"
30+
)
31+
Page<ItemLoreEntity> findLoreById(UUID id, Pageable pageable);
32+
}

0 commit comments

Comments
 (0)