Draft: feat login
This commit is contained in:
15
utils/initDB.go
Normal file
15
utils/initDB.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.konchin.com/ytshih/inp2025/game/models"
|
||||
"github.com/uptrace/bun"
|
||||
)
|
||||
|
||||
func InitDB(ctx context.Context, db *bun.DB) error {
|
||||
return db.ResetModel(ctx,
|
||||
(*models.User)(nil),
|
||||
(*models.UserStatus)(nil),
|
||||
)
|
||||
}
|
||||
23
utils/readConfig.go
Normal file
23
utils/readConfig.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.konchin.com/ytshih/inp2025/game/tracing"
|
||||
"github.com/spf13/viper"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func ReadConfig(ctx context.Context) {
|
||||
viper.SetConfigName("config")
|
||||
viper.SetConfigType("yaml")
|
||||
viper.AddConfigPath(".")
|
||||
if err := viper.ReadInConfig(); err != nil {
|
||||
if _, ok := err.(viper.ConfigFileNotFoundError); !ok {
|
||||
tracing.Logger.Ctx(ctx).
|
||||
Panic("failed to read config file",
|
||||
zap.Error(err))
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
14
utils/tick.go
Normal file
14
utils/tick.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gitea.konchin.com/ytshih/inp2025/game/types"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
)
|
||||
|
||||
func Tick(d time.Duration) tea.Cmd {
|
||||
return tea.Tick(d, func(t time.Time) tea.Msg {
|
||||
return types.TickMsg(t)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user