Converted more events

This commit is contained in:
2025-01-04 20:11:34 +01:00
parent 47ec425acf
commit 21f4c5328f
21 changed files with 113 additions and 102 deletions

View File

@ -3,7 +3,7 @@ import { UUID } from '#application/types'
import { Item } from '#entities/item'
class ItemRepository extends BaseRepository {
async getById(id: UUID): Promise<any> {
async getById(id: UUID): Promise<Item | null> {
try {
const repository = this.getEntityManager().getRepository(Item)
return await repository.findOne({ id })
@ -13,25 +13,23 @@ class ItemRepository extends BaseRepository {
}
}
async getByIds(ids: UUID[]): Promise<any> {
async getByIds(ids: UUID[]): Promise<Item[]> {
try {
const repository = this.getEntityManager().getRepository(Item)
return await repository.find({
id: ids
})
return await repository.find({ id: ids })
} catch (error: any) {
this.logger.error(`Failed to get items by IDs: ${error instanceof Error ? error.message : String(error)}`)
return null
return []
}
}
async getAll(): Promise<any> {
async getAll(): Promise<Item[]> {
try {
const repository = this.getEntityManager().getRepository(Item)
return await repository.findAll()
} catch (error: any) {
this.logger.error(`Failed to get all items: ${error instanceof Error ? error.message : String(error)}`)
return null
return []
}
}
}