Skip to content

Commit

Permalink
rename db to database
Browse files Browse the repository at this point in the history
  • Loading branch information
sekaiwish committed Oct 28, 2024
1 parent d5bb0ac commit 67a5dc4
Show file tree
Hide file tree
Showing 26 changed files with 113 additions and 113 deletions.
6 changes: 3 additions & 3 deletions internal/service/character.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"erupe-ce/config"
"erupe-ce/server/channelserver/compression/nullcomp"
"erupe-ce/utils/bfutil"
"erupe-ce/utils/db"
"erupe-ce/utils/database"
"erupe-ce/utils/logger"
"erupe-ce/utils/stringsupport"
"fmt"
Expand Down Expand Up @@ -120,7 +120,7 @@ func getPointers() map[SavePointer]int {
}

func GetCharacterSaveData(charID uint32) (*CharacterSaveData, error) {
db, err := db.GetDB()
db, err := database.GetDB()
logger := logger.Get()
if err != nil {
logger.Fatal(fmt.Sprintf("Failed to get database instance: %s", err))
Expand Down Expand Up @@ -169,7 +169,7 @@ type SessionCharacter interface {
}

func (save *CharacterSaveData) Save(s SessionCharacter) {
db, err := db.GetDB()
db, err := database.GetDB()
logger := logger.Get()

if err != nil {
Expand Down
28 changes: 14 additions & 14 deletions internal/service/guild.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"errors"
"erupe-ce/config"
"erupe-ce/internal/model"
"erupe-ce/utils/db"
"erupe-ce/utils/database"
"erupe-ce/utils/logger"
"fmt"
"time"
Expand Down Expand Up @@ -106,7 +106,7 @@ func (g *Guild) Rank() uint16 {
}

func (guild *Guild) Save() error {
db, err := db.GetDB()
db, err := database.GetDB()
logger := logger.Get()

if err != nil {
Expand All @@ -127,7 +127,7 @@ func (guild *Guild) Save() error {
}

func (guild *Guild) CreateApplication(charID uint32, applicationType model.GuildApplicationType, transaction *sql.Tx, actorId uint32) error {
db, err := db.GetDB()
db, err := database.GetDB()
logger := logger.Get()

if err != nil {
Expand Down Expand Up @@ -158,7 +158,7 @@ func (guild *Guild) CreateApplication(charID uint32, applicationType model.Guild
}

func (guild *Guild) Disband(charID uint32) error {
db, err := db.GetDB()
db, err := database.GetDB()
logger := logger.Get()

if err != nil {
Expand Down Expand Up @@ -224,7 +224,7 @@ func (guild *Guild) Disband(charID uint32) error {
}

func (guild *Guild) RemoveCharacter(charID uint32) error {
db, err := db.GetDB()
db, err := database.GetDB()
logger := logger.Get()

if err != nil {
Expand All @@ -247,7 +247,7 @@ func (guild *Guild) RemoveCharacter(charID uint32) error {
}

func (guild *Guild) AcceptApplication(charID uint32) error {
db, err := db.GetDB()
db, err := database.GetDB()
logger := logger.Get()

if err != nil {
Expand Down Expand Up @@ -298,7 +298,7 @@ func (guild *Guild) AcceptApplication(charID uint32) error {
// This is relying on the fact that invitation ID is also character ID right now
// if invitation ID changes, this will break.
func (guild *Guild) CancelInvitation(charID uint32) error {
db, err := db.GetDB()
db, err := database.GetDB()
logger := logger.Get()

if err != nil {
Expand All @@ -323,7 +323,7 @@ func (guild *Guild) CancelInvitation(charID uint32) error {
}

func (guild *Guild) RejectApplication(charID uint32) error {
db, err := db.GetDB()
db, err := database.GetDB()
logger := logger.Get()

if err != nil {
Expand All @@ -348,7 +348,7 @@ func (guild *Guild) RejectApplication(charID uint32) error {
}

func (guild *Guild) ArrangeCharacters(charIDs []uint32) error {
db, err := db.GetDB()
db, err := database.GetDB()
logger := logger.Get()

if err != nil {
Expand Down Expand Up @@ -386,7 +386,7 @@ func (guild *Guild) ArrangeCharacters(charIDs []uint32) error {
}

func (guild *Guild) GetApplicationForCharID(charID uint32, applicationType model.GuildApplicationType) (*model.GuildApplication, error) {
db, err := db.GetDB()
db, err := database.GetDB()
logger := logger.Get()

if err != nil {
Expand Down Expand Up @@ -418,7 +418,7 @@ func (guild *Guild) GetApplicationForCharID(charID uint32, applicationType model
}

func (guild *Guild) HasApplicationForCharID(charID uint32) (bool, error) {
db, err := db.GetDB()
db, err := database.GetDB()
logger := logger.Get()

if err != nil {
Expand Down Expand Up @@ -487,7 +487,7 @@ SELECT
`

func CreateGuild(guildName string, charID uint32) (int32, error) {
db, err := db.GetDB()
db, err := database.GetDB()
logger := logger.Get()

if err != nil {
Expand Down Expand Up @@ -557,7 +557,7 @@ func CreateGuild(guildName string, charID uint32) (int32, error) {
}

func GetGuildInfoByID(guildID uint32) (*Guild, error) {
db, err := db.GetDB()
db, err := database.GetDB()
logger := logger.Get()

if err != nil {
Expand Down Expand Up @@ -586,7 +586,7 @@ func GetGuildInfoByID(guildID uint32) (*Guild, error) {
}

func GetGuildInfoByCharacterId(charID uint32) (*Guild, error) {
db, err := db.GetDB()
db, err := database.GetDB()
logger := logger.Get()

if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/service/guild_alliance.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package service

import (
"erupe-ce/utils/db"
"erupe-ce/utils/database"
"erupe-ce/utils/logger"
"fmt"
"time"
Expand Down Expand Up @@ -43,7 +43,7 @@ FROM guild_alliances ga
`

func GetAllianceData(AllianceID uint32) (*GuildAlliance, error) {
db, err := db.GetDB()
db, err := database.GetDB()
logger := logger.Get()

if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions internal/service/guild_member.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package service

import (
"erupe-ce/utils/db"
"erupe-ce/utils/database"
"erupe-ce/utils/logger"
"fmt"
"time"
Expand Down Expand Up @@ -48,7 +48,7 @@ func (gm *GuildMember) IsSubLeader() bool {
}

func (gm *GuildMember) Save() error {
db, err := db.GetDB()
db, err := database.GetDB()
logger := logger.Get()

if err != nil {
Expand Down Expand Up @@ -95,7 +95,7 @@ SELECT * FROM (
`

func GetGuildMembers(guildID uint32, applicants bool) ([]*GuildMember, error) {
db, err := db.GetDB()
db, err := database.GetDB()
logger := logger.Get()

if err != nil {
Expand Down Expand Up @@ -129,7 +129,7 @@ func GetGuildMembers(guildID uint32, applicants bool) ([]*GuildMember, error) {
}

func GetCharacterGuildData(charID uint32) (*GuildMember, error) {
db, err := db.GetDB()
db, err := database.GetDB()
logger := logger.Get()

if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions internal/service/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"erupe-ce/network/binpacket"
"erupe-ce/network/mhfpacket"
"erupe-ce/utils/byteframe"
"erupe-ce/utils/db"
"erupe-ce/utils/database"

"erupe-ce/utils/logger"
"fmt"
Expand Down Expand Up @@ -34,7 +34,7 @@ type Mail struct {
}

func (m *Mail) Send(transaction *sql.Tx) error {
db, err := db.GetDB()
db, err := database.GetDB()
logger := logger.Get()

if err != nil {
Expand Down Expand Up @@ -71,7 +71,7 @@ func (m *Mail) Send(transaction *sql.Tx) error {
}

func (m *Mail) MarkRead() error {
db, err := db.GetDB()
db, err := database.GetDB()
logger := logger.Get()
if err != nil {
logger.Fatal(fmt.Sprintf("Failed to get database instance: %s", err))
Expand All @@ -93,7 +93,7 @@ func (m *Mail) MarkRead() error {
}

func GetMailListForCharacter(charID uint32) ([]Mail, error) {
db, err := db.GetDB()
db, err := database.GetDB()
logger := logger.Get()
if err != nil {
logger.Fatal(fmt.Sprintf("Failed to get database instance: %s", err))
Expand Down Expand Up @@ -146,7 +146,7 @@ func GetMailListForCharacter(charID uint32) ([]Mail, error) {
}

func GetMailByID(ID int) (*Mail, error) {
db, err := db.GetDB()
db, err := database.GetDB()
logger := logger.Get()

if err != nil {
Expand Down Expand Up @@ -217,7 +217,7 @@ func SendMailNotification(s SessionMail, m *Mail, recipient SessionMail) {
}

func getCharacterName(charID uint32) string {
db, err := db.GetDB()
db, err := database.GetDB()
logger := logger.Get()

if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"erupe-ce/server/discordbot"
"erupe-ce/server/entrance"
"erupe-ce/server/sign"
"erupe-ce/utils/db"
"erupe-ce/utils/database"
"erupe-ce/utils/logger"

"erupe-ce/utils/gametime"
Expand Down Expand Up @@ -61,7 +61,7 @@ func main() {

discordBot := initializeDiscordBot()

database, err := db.InitDB(config)
database, err := database.InitDB(config)
if err != nil {
mainLogger.Fatal(fmt.Sprintf("Database initialization failed: %s", err))
}
Expand Down
18 changes: 9 additions & 9 deletions server/api/dbutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package api
import (
"context"
"database/sql"
"erupe-ce/utils/db"
"erupe-ce/utils/database"
"erupe-ce/utils/token"
"fmt"
"time"
Expand All @@ -22,7 +22,7 @@ func (s *APIServer) createNewUser(ctx context.Context, username string, password
id uint32
rights uint32
)
database, err := db.GetDB()
database, err := database.GetDB()
if err != nil {
s.logger.Fatal(fmt.Sprintf("Failed to get database instance: %s", err))
}
Expand All @@ -40,7 +40,7 @@ func (s *APIServer) createNewUser(ctx context.Context, username string, password
func (s *APIServer) createLoginToken(ctx context.Context, uid uint32) (uint32, string, error) {
loginToken := token.Generate(16)
var tid uint32
database, err := db.GetDB()
database, err := database.GetDB()
if err != nil {
s.logger.Fatal(fmt.Sprintf("Failed to get database instance: %s", err))
}
Expand All @@ -53,7 +53,7 @@ func (s *APIServer) createLoginToken(ctx context.Context, uid uint32) (uint32, s

func (s *APIServer) userIDFromToken(ctx context.Context, token string) (uint32, error) {
var userID uint32
database, err := db.GetDB()
database, err := database.GetDB()
if err != nil {
s.logger.Fatal(fmt.Sprintf("Failed to get database instance: %s", err))
}
Expand All @@ -68,7 +68,7 @@ func (s *APIServer) userIDFromToken(ctx context.Context, token string) (uint32,

func (s *APIServer) createCharacter(ctx context.Context, userID uint32) (Character, error) {
var character Character
database, err := db.GetDB()
database, err := database.GetDB()
if err != nil {
s.logger.Fatal(fmt.Sprintf("Failed to get database instance: %s", err))
}
Expand Down Expand Up @@ -97,7 +97,7 @@ func (s *APIServer) createCharacter(ctx context.Context, userID uint32) (Charact

func (s *APIServer) deleteCharacter(ctx context.Context, userID uint32, charID uint32) error {
var isNew bool
database, err := db.GetDB()
database, err := database.GetDB()
if err != nil {
s.logger.Fatal(fmt.Sprintf("Failed to get database instance: %s", err))
}
Expand All @@ -115,7 +115,7 @@ func (s *APIServer) deleteCharacter(ctx context.Context, userID uint32, charID u

func (s *APIServer) getCharactersForUser(ctx context.Context, uid uint32) ([]Character, error) {
var characters []Character
database, err := db.GetDB()
database, err := database.GetDB()
if err != nil {
s.logger.Fatal(fmt.Sprintf("Failed to get database instance: %s", err))
}
Expand All @@ -134,7 +134,7 @@ func (s *APIServer) getCharactersForUser(ctx context.Context, uid uint32) ([]Cha

func (s *APIServer) getReturnExpiry(uid uint32) time.Time {
var returnExpiry, lastLogin time.Time
database, err := db.GetDB()
database, err := database.GetDB()
if err != nil {
s.logger.Fatal(fmt.Sprintf("Failed to get database instance: %s", err))
}
Expand All @@ -154,7 +154,7 @@ func (s *APIServer) getReturnExpiry(uid uint32) time.Time {
}

func (s *APIServer) exportSave(ctx context.Context, uid uint32, cid uint32) (map[string]interface{}, error) {
database, err := db.GetDB()
database, err := database.GetDB()
if err != nil {
s.logger.Fatal(fmt.Sprintf("Failed to get database instance: %s", err))
}
Expand Down
4 changes: 2 additions & 2 deletions server/api/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"encoding/xml"
"errors"
"erupe-ce/config"
"erupe-ce/utils/db"
"erupe-ce/utils/database"
"erupe-ce/utils/gametime"
"fmt"
"image"
Expand Down Expand Up @@ -138,7 +138,7 @@ func (s *APIServer) Login(w http.ResponseWriter, r *http.Request) {
userRights uint32
password string
)
database, err := db.GetDB()
database, err := database.GetDB()
if err != nil {
s.logger.Fatal(fmt.Sprintf("Failed to get database instance: %s", err))
}
Expand Down
Loading

0 comments on commit 67a5dc4

Please sign in to comment.