2023-10-31 22:40:14 +00:00
|
|
|
package storage
|
|
|
|
|
|
|
|
var (
|
2023-11-05 01:58:00 +00:00
|
|
|
Repo *Repository
|
2023-10-31 22:40:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Storage interface {
|
|
|
|
Migrate(table interface{}, tableName string)
|
|
|
|
|
2023-12-13 22:52:16 +00:00
|
|
|
GetAllPersons() []*DB_Person
|
|
|
|
GetPersonsCount() int
|
2024-01-03 23:25:17 +00:00
|
|
|
TotalVBucks() int
|
|
|
|
|
2023-10-31 22:40:14 +00:00
|
|
|
GetPerson(personId string) *DB_Person
|
2023-11-03 23:48:50 +00:00
|
|
|
GetPersonByDisplay(displayName string) *DB_Person
|
2024-01-03 23:25:17 +00:00
|
|
|
GetPersonsByPartialDisplay(displayName string) []*DB_Person
|
2023-12-10 00:52:59 +00:00
|
|
|
GetPersonByDiscordID(discordId string) *DB_Person
|
2023-10-31 22:40:14 +00:00
|
|
|
SavePerson(person *DB_Person)
|
2023-12-13 22:52:16 +00:00
|
|
|
DeletePerson(personId string)
|
|
|
|
|
2024-01-29 23:46:22 +00:00
|
|
|
GetIncomingRelationships(personId string) []*DB_Relationship
|
|
|
|
GetOutgoingRelationships(personId string) []*DB_Relationship
|
|
|
|
SaveRelationship(relationship *DB_Relationship)
|
|
|
|
DeleteRelationship(relationship *DB_Relationship)
|
|
|
|
|
2023-11-05 01:58:00 +00:00
|
|
|
SaveProfile(profile *DB_Profile)
|
|
|
|
DeleteProfile(profileId string)
|
|
|
|
|
|
|
|
SaveItem(item *DB_Item)
|
2023-12-17 00:43:17 +00:00
|
|
|
BulkCreateItems(items *[]DB_Item)
|
2023-11-01 21:33:25 +00:00
|
|
|
DeleteItem(itemId string)
|
2023-11-05 01:58:00 +00:00
|
|
|
|
|
|
|
SaveVariant(variant *DB_VariantChannel)
|
2024-02-04 01:25:44 +00:00
|
|
|
BulkCreateVariants(variants *[]DB_VariantChannel)
|
2023-11-01 21:33:25 +00:00
|
|
|
DeleteVariant(variantId string)
|
2023-11-05 01:58:00 +00:00
|
|
|
|
|
|
|
SaveQuest(quest *DB_Quest)
|
2023-11-01 21:33:25 +00:00
|
|
|
DeleteQuest(questId string)
|
2023-11-05 01:58:00 +00:00
|
|
|
|
2024-02-04 02:05:31 +00:00
|
|
|
SaveLoot(loot *DB_GiftLoot)
|
2023-11-01 21:33:25 +00:00
|
|
|
DeleteLoot(lootId string)
|
2023-11-05 01:58:00 +00:00
|
|
|
|
|
|
|
SaveGift(gift *DB_Gift)
|
2023-11-01 21:33:25 +00:00
|
|
|
DeleteGift(giftId string)
|
2023-11-05 01:58:00 +00:00
|
|
|
|
2024-02-04 02:05:31 +00:00
|
|
|
SaveAttribute(attribute *DB_Attribute)
|
2023-11-01 21:33:25 +00:00
|
|
|
DeleteAttribute(attributeId string)
|
2023-11-20 21:20:26 +00:00
|
|
|
|
|
|
|
SaveLoadout(loadout *DB_Loadout)
|
|
|
|
DeleteLoadout(loadoutId string)
|
2023-12-10 00:52:59 +00:00
|
|
|
|
|
|
|
SaveDiscordPerson(person *DB_DiscordPerson)
|
|
|
|
DeleteDiscordPerson(personId string)
|
2023-10-31 22:40:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Repository struct {
|
|
|
|
Storage Storage
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewStorage(s Storage) *Repository {
|
|
|
|
return &Repository{
|
|
|
|
Storage: s,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-05 01:58:00 +00:00
|
|
|
func (r *Repository) GetPersonFromDB(personId string) *DB_Person {
|
2023-10-31 22:40:14 +00:00
|
|
|
storagePerson := r.Storage.GetPerson(personId)
|
|
|
|
if storagePerson != nil {
|
|
|
|
return storagePerson
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-11-05 01:58:00 +00:00
|
|
|
func (r *Repository) GetPersonByDisplayFromDB(displayName string) *DB_Person {
|
2023-11-03 23:48:50 +00:00
|
|
|
storagePerson := r.Storage.GetPersonByDisplay(displayName)
|
|
|
|
if storagePerson != nil {
|
|
|
|
return storagePerson
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2024-01-03 23:25:17 +00:00
|
|
|
func (r *Repository) GetPersonsByPartialDisplayFromDB(displayName string) []*DB_Person {
|
|
|
|
storagePerson := r.Storage.GetPersonsByPartialDisplay(displayName)
|
|
|
|
if storagePerson != nil {
|
|
|
|
return storagePerson
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-12-10 00:52:59 +00:00
|
|
|
func (r *Repository) GetPersonByDiscordIDFromDB(discordId string) *DB_Person {
|
|
|
|
storagePerson := r.Storage.GetPersonByDiscordID(discordId)
|
|
|
|
if storagePerson != nil {
|
|
|
|
return storagePerson
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2024-01-03 23:25:17 +00:00
|
|
|
func (r *Repository) TotalVBucks() int {
|
|
|
|
return r.Storage.TotalVBucks()
|
|
|
|
}
|
|
|
|
|
2023-10-31 22:40:14 +00:00
|
|
|
func (r *Repository) GetAllPersons() []*DB_Person {
|
|
|
|
return r.Storage.GetAllPersons()
|
|
|
|
}
|
|
|
|
|
2023-12-13 22:52:16 +00:00
|
|
|
func (r *Repository) GetPersonsCount() int {
|
|
|
|
return r.Storage.GetPersonsCount()
|
|
|
|
}
|
|
|
|
|
2023-10-31 22:40:14 +00:00
|
|
|
func (r *Repository) SavePerson(person *DB_Person) {
|
|
|
|
r.Storage.SavePerson(person)
|
2023-11-01 21:33:25 +00:00
|
|
|
}
|
|
|
|
|
2023-12-13 22:52:16 +00:00
|
|
|
func (r *Repository) DeletePerson(personId string) {
|
|
|
|
r.Storage.DeletePerson(personId)
|
|
|
|
}
|
|
|
|
|
2023-11-05 01:58:00 +00:00
|
|
|
func (r *Repository) SaveProfile(profile *DB_Profile) {
|
|
|
|
r.Storage.SaveProfile(profile)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Repository) DeleteProfile(profileId string) {
|
|
|
|
r.Storage.DeleteProfile(profileId)
|
|
|
|
}
|
|
|
|
|
2024-01-29 23:46:22 +00:00
|
|
|
func (r *Repository) GetIncomingRelationships(personId string) []*DB_Relationship {
|
|
|
|
return r.Storage.GetIncomingRelationships(personId)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Repository) GetOutgoingRelationships(personId string) []*DB_Relationship {
|
|
|
|
return r.Storage.GetOutgoingRelationships(personId)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Repository) SaveRelationship(relationship *DB_Relationship) {
|
|
|
|
r.Storage.SaveRelationship(relationship)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Repository) DeleteRelationship(relationship *DB_Relationship) {
|
|
|
|
r.Storage.DeleteRelationship(relationship)
|
|
|
|
}
|
|
|
|
|
2023-11-05 01:58:00 +00:00
|
|
|
func (r *Repository) SaveItem(item *DB_Item) {
|
|
|
|
r.Storage.SaveItem(item)
|
|
|
|
}
|
|
|
|
|
2023-12-17 00:43:17 +00:00
|
|
|
func (r *Repository) BulkCreateItems(items *[]DB_Item) {
|
|
|
|
r.Storage.BulkCreateItems(items)
|
|
|
|
}
|
|
|
|
|
2023-11-01 21:33:25 +00:00
|
|
|
func (r *Repository) DeleteItem(itemId string) {
|
|
|
|
r.Storage.DeleteItem(itemId)
|
|
|
|
}
|
|
|
|
|
2024-02-04 01:25:44 +00:00
|
|
|
func (r *Repository) BulkCreateVariants(variants *[]DB_VariantChannel) {
|
|
|
|
r.Storage.BulkCreateVariants(variants)
|
|
|
|
}
|
|
|
|
|
2023-11-05 01:58:00 +00:00
|
|
|
func (r *Repository) SaveVariant(variant *DB_VariantChannel) {
|
|
|
|
r.Storage.SaveVariant(variant)
|
|
|
|
}
|
|
|
|
|
2023-11-01 21:33:25 +00:00
|
|
|
func (r *Repository) DeleteVariant(variantId string) {
|
|
|
|
r.Storage.DeleteVariant(variantId)
|
|
|
|
}
|
|
|
|
|
2023-11-05 01:58:00 +00:00
|
|
|
func (r *Repository) SaveQuest(quest *DB_Quest) {
|
|
|
|
r.Storage.SaveQuest(quest)
|
|
|
|
}
|
|
|
|
|
2023-11-01 21:33:25 +00:00
|
|
|
func (r *Repository) DeleteQuest(questId string) {
|
|
|
|
r.Storage.DeleteQuest(questId)
|
|
|
|
}
|
|
|
|
|
2024-02-04 02:05:31 +00:00
|
|
|
func (r *Repository) SaveLoot(loot *DB_GiftLoot) {
|
2023-11-05 01:58:00 +00:00
|
|
|
r.Storage.SaveLoot(loot)
|
|
|
|
}
|
|
|
|
|
2023-11-01 21:33:25 +00:00
|
|
|
func (r *Repository) DeleteLoot(lootId string) {
|
|
|
|
r.Storage.DeleteLoot(lootId)
|
|
|
|
}
|
|
|
|
|
2023-11-05 01:58:00 +00:00
|
|
|
func (r *Repository) SaveGift(gift *DB_Gift) {
|
|
|
|
r.Storage.SaveGift(gift)
|
|
|
|
}
|
|
|
|
|
2023-11-01 21:33:25 +00:00
|
|
|
func (r *Repository) DeleteGift(giftId string) {
|
|
|
|
r.Storage.DeleteGift(giftId)
|
|
|
|
}
|
|
|
|
|
2024-02-04 02:05:31 +00:00
|
|
|
func (r *Repository) SaveAttribute(attribute *DB_Attribute) {
|
2023-11-05 01:58:00 +00:00
|
|
|
r.Storage.SaveAttribute(attribute)
|
|
|
|
}
|
|
|
|
|
2023-11-01 21:33:25 +00:00
|
|
|
func (r *Repository) DeleteAttribute(attributeId string) {
|
|
|
|
r.Storage.DeleteAttribute(attributeId)
|
2023-11-20 21:20:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Repository) SaveLoadout(loadout *DB_Loadout) {
|
|
|
|
r.Storage.SaveLoadout(loadout)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Repository) DeleteLoadout(loadoutId string) {
|
|
|
|
r.Storage.DeleteLoadout(loadoutId)
|
2023-12-10 00:52:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Repository) SaveDiscordPerson(person *DB_DiscordPerson) {
|
|
|
|
r.Storage.SaveDiscordPerson(person)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Repository) DeleteDiscordPerson(personId string) {
|
|
|
|
r.Storage.DeleteDiscordPerson(personId)
|
2023-10-31 22:40:14 +00:00
|
|
|
}
|