diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 86397a0..5617ffa 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -18,27 +18,8 @@ jobs: uses: actions/setup-java@v4 with: distribution: temurin - java-version: 24 + java-version: 25 - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 - name: Build on ${{ matrix.os }} run: ./gradlew clean build test - - name: Generate JaCoCo Coverage Report - if: matrix.os == 'ubuntu-latest' - run: ./gradlew jacocoRootReport - - name: Upload Coverage Report - if: matrix.os == 'ubuntu-latest' - uses: actions/upload-artifact@v4 - with: - name: jacoco-report - path: | - build/reports/jacoco/jacocoRootReport/html/ - build/reports/jacoco/jacocoRootReport/jacocoRootReport.xml - - name: Upload Coverage to Codecov - if: matrix.os == 'ubuntu-latest' - uses: codecov/codecov-action@v5 - with: - file: build/reports/jacoco/jacocoRootReport/jacocoRootReport.xml - fail_ci_if_error: false - token: ${{ secrets.CODECOV_TOKEN }} - comment: true diff --git a/build.gradle.kts b/build.gradle.kts index 389e86d..c4c1ef3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -32,7 +32,7 @@ tasks { } test { - finalizedBy(rootProject.tasks.jacocoTestReport) + finalizedBy(jacocoTestReport) testLogging { events("passed", "skipped", "failed") } diff --git a/src/main/java/net/onelitefeather/vulpes/api/model/FontEntity.java b/src/main/java/net/onelitefeather/vulpes/api/model/FontEntity.java index 568fc5a..539ddf4 100644 --- a/src/main/java/net/onelitefeather/vulpes/api/model/FontEntity.java +++ b/src/main/java/net/onelitefeather/vulpes/api/model/FontEntity.java @@ -1,11 +1,13 @@ package net.onelitefeather.vulpes.api.model; -import jakarta.persistence.ElementCollection; +import jakarta.persistence.CascadeType; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; import net.onelitefeather.vulpes.api.generator.VulpesGenerator; +import net.onelitefeather.vulpes.api.model.font.FontLoreEntity; import java.util.List; import java.util.UUID; @@ -34,8 +36,8 @@ public class FontEntity implements VulpesModel { private String comment; private int height; private int ascent; - @ElementCollection - private List chars; + @OneToMany(mappedBy = "font", cascade = CascadeType.ALL) + private List chars; /** * Default constructor for JPA and Micronaut Data. @@ -60,7 +62,17 @@ public FontEntity() { * @param ascent the ascent of the font * @param chars the list of characters included in the font */ - public FontEntity(UUID id, String uiName, String variableName, String provider, String texturePath, String comment, int height, int ascent, List chars) { + public FontEntity( + UUID id, + String uiName, + String variableName, + String provider, + String texturePath, + String comment, + int height, + int ascent, + List chars + ) { this.id = id; this.uiName = uiName; this.variableName = variableName; @@ -181,7 +193,7 @@ public void setHeight(int height) { * * @return the list of characters in the font */ - public List getChars() { + public List getChars() { return chars; } @@ -190,7 +202,7 @@ public List getChars() { * * @param chars the list of characters to set */ - public void setChars(List chars) { + public void setChars(List chars) { this.chars = chars; } diff --git a/src/main/java/net/onelitefeather/vulpes/api/model/ItemEntity.java b/src/main/java/net/onelitefeather/vulpes/api/model/ItemEntity.java index a76a706..1db40f8 100644 --- a/src/main/java/net/onelitefeather/vulpes/api/model/ItemEntity.java +++ b/src/main/java/net/onelitefeather/vulpes/api/model/ItemEntity.java @@ -1,14 +1,17 @@ package net.onelitefeather.vulpes.api.model; -import jakarta.persistence.ElementCollection; +import jakarta.persistence.CascadeType; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; import net.onelitefeather.vulpes.api.generator.VulpesGenerator; +import net.onelitefeather.vulpes.api.model.item.ItemEnchantmentEntity; +import net.onelitefeather.vulpes.api.model.item.ItemFlagEntity; +import net.onelitefeather.vulpes.api.model.item.ItemLoreEntity; import java.util.List; -import java.util.Map; import java.util.UUID; /** @@ -36,12 +39,12 @@ public class ItemEntity implements VulpesModel { private String groupName; private int customModelData; private int amount; - @ElementCollection - private Map enchantments; - @ElementCollection - private List lore; - @ElementCollection - private List flags; + @OneToMany(mappedBy = "item", cascade = CascadeType.ALL) + private List enchantments; + @OneToMany(mappedBy = "item", cascade = CascadeType.ALL) + private List lore; + @OneToMany(mappedBy = "item", cascade = CascadeType.ALL) + private List flags; /** * Default constructor for JPA and Micronaut Data. @@ -69,7 +72,20 @@ public ItemEntity() { * @param lore the lore associated with the item * @param flags the flags associated with the item */ - public ItemEntity(UUID id, String uiName, String variableName, String comment, String displayName, String material, String groupName, int customModelData, int amount, Map enchantments, List lore, List flags) { + public ItemEntity( + UUID id, + String uiName, + String variableName, + String comment, + String displayName, + String material, + String groupName, + int customModelData, + int amount, + List enchantments, + List lore, + List flags + ) { this.id = id; this.uiName = uiName; this.variableName = variableName; @@ -158,7 +174,6 @@ public void setComment(String description) { this.comment = description; } - /** * Returns the display name of the item. * @@ -254,7 +269,7 @@ public void setAmount(int amount) { * * @return the enchantments of the item */ - public Map getEnchantments() { + public List getEnchantments() { return enchantments; } @@ -263,7 +278,7 @@ public Map getEnchantments() { * * @param enchantments the enchantments to set */ - public void setEnchantments(Map enchantments) { + public void setEnchantments(List enchantments) { this.enchantments = enchantments; } @@ -272,7 +287,7 @@ public void setEnchantments(Map enchantments) { * * @return the lore of the item */ - public List getLore() { + public List getLore() { return lore; } @@ -281,7 +296,7 @@ public List getLore() { * * @param lore the lore to set */ - public void setLore(List lore) { + public void setLore(List lore) { this.lore = lore; } @@ -290,7 +305,7 @@ public void setLore(List lore) { * * @return the flags of the item */ - public List getFlags() { + public List getFlags() { return flags; } @@ -299,7 +314,7 @@ public List getFlags() { * * @param flags the flags to set */ - public void setFlags(List flags) { + public void setFlags(List flags) { this.flags = flags; } diff --git a/src/main/java/net/onelitefeather/vulpes/api/model/font/FontLoreEntity.java b/src/main/java/net/onelitefeather/vulpes/api/model/font/FontLoreEntity.java new file mode 100644 index 0000000..5697977 --- /dev/null +++ b/src/main/java/net/onelitefeather/vulpes/api/model/font/FontLoreEntity.java @@ -0,0 +1,101 @@ +package net.onelitefeather.vulpes.api.model.font; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import net.onelitefeather.vulpes.api.generator.VulpesGenerator; +import net.onelitefeather.vulpes.api.model.FontEntity; + +import java.util.Objects; +import java.util.UUID; + +@Entity(name = "font_lore") +public final class FontLoreEntity implements Comparable { + @Id + @GeneratedValue(strategy = GenerationType.UUID) + @VulpesGenerator + private UUID id; + private String line; + @ManyToOne + @JoinColumn(name = "font_id", nullable = false) + private FontEntity font; + private int orderIndex; + + public FontLoreEntity() { + } + + public FontLoreEntity( + UUID id, + String line, + FontEntity font, + int orderIndex + ) { + this.id = id; + this.line = line; + this.font = font; + this.orderIndex = orderIndex; + } + + public void setId(UUID id) { + this.id = id; + } + + public UUID getId() { + return id; + } + + public void setLine(String line) { + this.line = line; + } + + public String getLine() { + return line; + } + + public void setFont(FontEntity font) { + this.font = font; + } + + public FontEntity getFont() { + return font; + } + + public void setOrderIndex(int orderIndex) { + this.orderIndex = orderIndex; + } + + public int getOrderIndex() { + return orderIndex; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) return true; + if (obj == null || obj.getClass() != this.getClass()) return false; + var that = (FontLoreEntity) obj; + return Objects.equals(this.id, that.id) && + Objects.equals(this.line, that.line) && + Objects.equals(this.font, that.font); + } + + @Override + public int hashCode() { + return Objects.hash(id, line, font); + } + + @Override + public String toString() { + return "FontLoreEntity[" + + "id=" + id + ", " + + "line=" + line + ", " + + "font=" + font + ']'; + } + + @Override + public int compareTo(FontLoreEntity o) { + return Integer.compare(this.orderIndex, o.orderIndex); + } +} diff --git a/src/main/java/net/onelitefeather/vulpes/api/model/item/ItemEnchantmentEntity.java b/src/main/java/net/onelitefeather/vulpes/api/model/item/ItemEnchantmentEntity.java new file mode 100644 index 0000000..6b0347a --- /dev/null +++ b/src/main/java/net/onelitefeather/vulpes/api/model/item/ItemEnchantmentEntity.java @@ -0,0 +1,100 @@ +package net.onelitefeather.vulpes.api.model.item; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import net.onelitefeather.vulpes.api.generator.VulpesGenerator; +import net.onelitefeather.vulpes.api.model.ItemEntity; + +import java.util.Objects; +import java.util.UUID; + +@Entity(name = "item_enchantments") +public final class ItemEnchantmentEntity { + @Id + @GeneratedValue(strategy = GenerationType.UUID) + @VulpesGenerator + private UUID id; + private String name; + private short level; + @ManyToOne + @JoinColumn(name = "item_id", nullable = false) + private ItemEntity item; + + public ItemEnchantmentEntity() { + + } + + public ItemEnchantmentEntity( + UUID id, + String name, + short level, + ItemEntity item + ) { + this.id = id; + this.name = name; + this.level = level; + this.item = item; + } + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public short getLevel() { + return level; + } + + public void setLevel(short level) { + this.level = level; + } + + public ItemEntity getItem() { + return item; + } + + public void setItem(ItemEntity item) { + this.item = item; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) return true; + if (obj == null || obj.getClass() != this.getClass()) return false; + var that = (ItemEnchantmentEntity) obj; + return Objects.equals(this.id, that.id) && + Objects.equals(this.name, that.name) && + this.level == that.level && + Objects.equals(this.item, that.item); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, level, item); + } + + @Override + public String toString() { + return "ItemEnchantmentEntity[" + + "id=" + id + ", " + + "name=" + name + ", " + + "level=" + level + ", " + + "item=" + item + ']'; + } + +} diff --git a/src/main/java/net/onelitefeather/vulpes/api/model/item/ItemFlagEntity.java b/src/main/java/net/onelitefeather/vulpes/api/model/item/ItemFlagEntity.java new file mode 100644 index 0000000..8afa309 --- /dev/null +++ b/src/main/java/net/onelitefeather/vulpes/api/model/item/ItemFlagEntity.java @@ -0,0 +1,96 @@ +package net.onelitefeather.vulpes.api.model.item; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import net.onelitefeather.vulpes.api.generator.VulpesGenerator; +import net.onelitefeather.vulpes.api.model.ItemEntity; + +import java.util.Objects; +import java.util.UUID; + +/** + * The {@link ItemFlagEntity} represents a flag or attribute that can be associated with an item in the system. + * + */ +@Entity(name = "item_flags") +public final class ItemFlagEntity { + @Id + @GeneratedValue(strategy = GenerationType.UUID) + @VulpesGenerator + private UUID id; + private String text; + @ManyToOne + @JoinColumn(name = "item_id") + private ItemEntity item; + + /** + * @param id the unique identifier of the item flag + * @param text the descriptive text of the item flag + */ + public ItemFlagEntity( + UUID id, + String text, + ItemEntity item + ) { + this.id = id; + this.text = text; + this.item = item; + } + + public ItemFlagEntity() { + + } + + public void setId(UUID id) { + this.id = id; + } + + public UUID getId() { + return id; + } + + public void setText(String text) { + this.text = text; + } + + public String getText() { + return text; + } + + public void setItem(ItemEntity item) { + this.item = item; + } + + public ItemEntity getItem() { + return item; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) return true; + if (obj == null || obj.getClass() != this.getClass()) return false; + var that = (ItemFlagEntity) obj; + return Objects.equals(this.id, that.id) && + Objects.equals(this.text, that.text) && + Objects.equals(this.item, that.item); + } + + @Override + public int hashCode() { + return Objects.hash(id, text, item); + } + + @Override + public String toString() { + return "ItemFlagEntity[" + + "id=" + id + ", " + + "text=" + text + ", " + + "item=" + item + ']'; + } + + +} diff --git a/src/main/java/net/onelitefeather/vulpes/api/model/item/ItemLoreEntity.java b/src/main/java/net/onelitefeather/vulpes/api/model/item/ItemLoreEntity.java new file mode 100644 index 0000000..85f6f1f --- /dev/null +++ b/src/main/java/net/onelitefeather/vulpes/api/model/item/ItemLoreEntity.java @@ -0,0 +1,110 @@ +package net.onelitefeather.vulpes.api.model.item; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import net.onelitefeather.vulpes.api.generator.VulpesGenerator; +import net.onelitefeather.vulpes.api.model.ItemEntity; + +import java.util.Objects; +import java.util.UUID; + +/** + * The {@link ItemLoreEntity} represents a lore entry associated with an item. + * + */ +@Entity(name = "item_lore") +public final class ItemLoreEntity implements Comparable { + @Id + @GeneratedValue(strategy = GenerationType.UUID) + @VulpesGenerator + private UUID id; + private String text; + @ManyToOne + @JoinColumn(name = "item_id", nullable = false) + private ItemEntity item; + private int orderIndex; + + + public ItemLoreEntity() { + } + + /** + * @param id the unique identifier of the lore entry + * @param text the lore text + */ + public ItemLoreEntity( + UUID id, + String text, + ItemEntity item, + int orderIndex + ) { + this.id = id; + this.text = text; + this.item = item; + this.orderIndex = orderIndex; + } + + public void setId(UUID id) { + this.id = id; + } + + public UUID getId() { + return id; + } + + public void setItem(ItemEntity item) { + this.item = item; + } + + public ItemEntity getItem() { + return item; + } + + public void setText(String text) { + this.text = text; + } + + public String getText() { + return text; + } + + public void setOrderIndex(int orderIndex) { + this.orderIndex = orderIndex; + } + + public int getOrderIndex() { + return orderIndex; + } + + @Override + public boolean equals(Object obj) { + if (obj == this) return true; + if (obj == null || obj.getClass() != this.getClass()) return false; + var that = (ItemLoreEntity) obj; + return Objects.equals(this.id, that.id) && + Objects.equals(this.text, that.text) && + Objects.equals(this.item, that.item); + } + + @Override + public int hashCode() { + return Objects.hash(id, text, item); + } + + @Override + public String toString() { + return "ItemLoreEntity[" + + "id=" + id + ", " + + "text=" + text + ", " + + "item=" + item + ']'; + } + + @Override + public int compareTo(ItemLoreEntity o) { + return Integer.compare(this.orderIndex, o.orderIndex); + } +} diff --git a/src/main/java/net/onelitefeather/vulpes/api/repository/FontRepository.java b/src/main/java/net/onelitefeather/vulpes/api/repository/FontRepository.java index f2d8621..41988a1 100644 --- a/src/main/java/net/onelitefeather/vulpes/api/repository/FontRepository.java +++ b/src/main/java/net/onelitefeather/vulpes/api/repository/FontRepository.java @@ -2,7 +2,6 @@ import io.micronaut.data.annotation.Query; import io.micronaut.data.annotation.Repository; -import io.micronaut.data.model.Pageable; import io.micronaut.data.repository.PageableRepository; import net.onelitefeather.vulpes.api.model.FontEntity; @@ -19,18 +18,6 @@ @Repository public interface FontRepository extends PageableRepository { - /** - * Retrieves the characters associated with a font by its ID. - * - * @param id the unique identifier of the font - * @return a list of characters associated with the font - */ - @Query( - value = "SELECT c FROM fonts f JOIN f.chars c WHERE f.id = :id", - countQuery = "SELECT COUNT(c) FROM fonts f JOIN f.chars c WHERE f.id = :id" - ) - List findCharsByFontId(UUID id, Pageable pageable); - /** * Retrieves all fonts along with their associated characters. * diff --git a/src/main/java/net/onelitefeather/vulpes/api/repository/ItemRepository.java b/src/main/java/net/onelitefeather/vulpes/api/repository/ItemRepository.java index eaa92e0..84e2402 100644 --- a/src/main/java/net/onelitefeather/vulpes/api/repository/ItemRepository.java +++ b/src/main/java/net/onelitefeather/vulpes/api/repository/ItemRepository.java @@ -7,7 +7,6 @@ import net.onelitefeather.vulpes.api.model.ItemEntity; import java.util.List; -import java.util.Map; import java.util.UUID; /** @@ -20,40 +19,6 @@ @Repository public interface ItemRepository extends PageableRepository { - /** - * Retrieves the enchantments associated with an item by its ID. - * - * @param id the unique identifier of the item - * @return a map of enchantment names and their levels associated with the item - */ - @Query(value = "SELECT e FROM items i JOIN i.enchantments e WHERE i.id = :id", - countQuery = "SELECT count(e) FROM items i JOIN i.enchantments e WHERE i.id = :id" - ) - Map findEnchantmentsById(UUID id, Pageable pageable); - - /** - * Retrieves the lore associated with an item by its ID. - * - * @param id the unique identifier of the item - * @return a list of lore strings associated with the item - */ - @Query(value = "SELECT l FROM items i JOIN i.lore l WHERE i.id = :id", - countQuery = "SELECT count(l) FROM items i JOIN i.lore l WHERE i.id = :id" - ) - List findLoreById(UUID id, Pageable pageable); - - /** - * Retrieves the flags associated with an item by its ID. - * - * @param id the unique identifier of the item - * @return a list of flags associated with the item - */ - @Query(value = "SELECT f FROM items i JOIN i.flags f WHERE i.id = :id", - countQuery = "SELECT count(f) FROM items i JOIN i.flags f WHERE i.id = :id" - ) - List findFlagsById(UUID id, Pageable pageable); - - /** * Retrieves all items along with their associated enchantments, lore, and flags. * diff --git a/src/main/java/net/onelitefeather/vulpes/api/repository/SoundFileSourceRepository.java b/src/main/java/net/onelitefeather/vulpes/api/repository/SoundFileSourceRepository.java index 4bad32e..460027c 100644 --- a/src/main/java/net/onelitefeather/vulpes/api/repository/SoundFileSourceRepository.java +++ b/src/main/java/net/onelitefeather/vulpes/api/repository/SoundFileSourceRepository.java @@ -7,7 +7,6 @@ import io.micronaut.data.repository.PageableRepository; import net.onelitefeather.vulpes.api.model.sound.SoundFileSource; -import java.util.List; import java.util.UUID; /** diff --git a/src/main/java/net/onelitefeather/vulpes/api/repository/font/FontLoreRepository.java b/src/main/java/net/onelitefeather/vulpes/api/repository/font/FontLoreRepository.java new file mode 100644 index 0000000..029cfc6 --- /dev/null +++ b/src/main/java/net/onelitefeather/vulpes/api/repository/font/FontLoreRepository.java @@ -0,0 +1,32 @@ +package net.onelitefeather.vulpes.api.repository.font; + +import io.micronaut.data.annotation.Query; +import io.micronaut.data.annotation.Repository; +import io.micronaut.data.model.Page; +import io.micronaut.data.model.Pageable; +import io.micronaut.data.repository.PageableRepository; +import net.onelitefeather.vulpes.api.model.font.FontLoreEntity; + +import java.util.UUID; + +/** + * Repository definition to manage {@link FontLoreRepository} entities. + * + * @version 1.0.0 + * @since 1.7.0 + * @author theEvilReaper + */ +@Repository +public interface FontLoreRepository extends PageableRepository { + + /** + * Retrieves the characters associated with a font by its ID. + * + * @param id the unique identifier of the font + * @return a list of characters associated with the font + */ + @Query(value = "SELECT f FROM font_lore f WHERE f.font.id = :id", + countQuery = "SELECT count(f) FROM font_lore f WHERE f.font.id = :id" + ) + Page findCharsByFontId(UUID id, Pageable pageable); +} diff --git a/src/main/java/net/onelitefeather/vulpes/api/repository/item/ItemEnchantmentRepository.java b/src/main/java/net/onelitefeather/vulpes/api/repository/item/ItemEnchantmentRepository.java new file mode 100644 index 0000000..edba898 --- /dev/null +++ b/src/main/java/net/onelitefeather/vulpes/api/repository/item/ItemEnchantmentRepository.java @@ -0,0 +1,32 @@ +package net.onelitefeather.vulpes.api.repository.item; + +import io.micronaut.data.annotation.Query; +import io.micronaut.data.annotation.Repository; +import io.micronaut.data.model.Page; +import io.micronaut.data.model.Pageable; +import io.micronaut.data.repository.PageableRepository; +import net.onelitefeather.vulpes.api.model.item.ItemEnchantmentEntity; + +import java.util.UUID; + +/** + * Repository definition to manage {@link ItemEnchantmentEntity} entities. + * + * @version 1.0.0 + * @since 1.7.0 + * @author theEvilReaper + */ +@Repository +public interface ItemEnchantmentRepository extends PageableRepository { + + /** + * Retrieves the enchantments associated with an item by its ID. + * + * @param id the unique identifier of the item + * @return a list of enchantments associated with the item + */ + @Query(value = "SELECT f FROM item_enchantments f WHERE f.item.id = :id", + countQuery = "SELECT count(f) FROM item_enchantments f WHERE f.item.id = :id" + ) + Page findEnchantmentsById(UUID id, Pageable pageable); +} diff --git a/src/main/java/net/onelitefeather/vulpes/api/repository/item/ItemFlagRepository.java b/src/main/java/net/onelitefeather/vulpes/api/repository/item/ItemFlagRepository.java new file mode 100644 index 0000000..b2864ec --- /dev/null +++ b/src/main/java/net/onelitefeather/vulpes/api/repository/item/ItemFlagRepository.java @@ -0,0 +1,32 @@ +package net.onelitefeather.vulpes.api.repository.item; + +import io.micronaut.data.annotation.Query; +import io.micronaut.data.annotation.Repository; +import io.micronaut.data.model.Page; +import io.micronaut.data.model.Pageable; +import io.micronaut.data.repository.PageableRepository; +import net.onelitefeather.vulpes.api.model.item.ItemFlagEntity; + +import java.util.UUID; + +/** + * Repository definition to manage {@link ItemFlagEntity} entities. + * + * @version 1.0.0 + * @since 1.7.0 + * @author theEvilReaper + */ +@Repository +public interface ItemFlagRepository extends PageableRepository { + + /** + * Retrieves the flags associated with an item by its ID. + * + * @param id the unique identifier of the item + * @return a list of flags associated with the item + */ + @Query(value = "SELECT f FROM item_flags f WHERE f.item.id = :id", + countQuery = "SELECT count(f) FROM item_flags f WHERE f.item.id = :id" + ) + Page findFlagsById(UUID id, Pageable pageable); +} diff --git a/src/main/java/net/onelitefeather/vulpes/api/repository/item/ItemLoreRepository.java b/src/main/java/net/onelitefeather/vulpes/api/repository/item/ItemLoreRepository.java new file mode 100644 index 0000000..fe37834 --- /dev/null +++ b/src/main/java/net/onelitefeather/vulpes/api/repository/item/ItemLoreRepository.java @@ -0,0 +1,32 @@ +package net.onelitefeather.vulpes.api.repository.item; + +import io.micronaut.data.annotation.Query; +import io.micronaut.data.annotation.Repository; +import io.micronaut.data.model.Page; +import io.micronaut.data.model.Pageable; +import io.micronaut.data.repository.PageableRepository; +import net.onelitefeather.vulpes.api.model.item.ItemLoreEntity; + +import java.util.UUID; + +/** + * Repository definition to manage {@link ItemLoreEntity} entities. + * + * @version 1.0.0 + * @since 1.7.0 + * @author theEvilReaper + */ +@Repository +public interface ItemLoreRepository extends PageableRepository { + + /** + * Retrieves the lore associated with an item by its ID. + * + * @param id the unique identifier of the item + * @return a list of lore strings associated with the item + */ + @Query(value = "SELECT f FROM item_lore f WHERE f.item.id = :id", + countQuery = "SELECT count(f) FROM item_lore f WHERE f.item.id = :id" + ) + Page findLoreById(UUID id, Pageable pageable); +}