diff options
author | GrailFinder <wohilas@gmail.com> | 2024-05-18 13:27:28 +0300 |
---|---|---|
committer | GrailFinder <wohilas@gmail.com> | 2024-05-18 13:27:28 +0300 |
commit | 2e9b18944eac3dcaf8a006594cb338d94c07a447 (patch) | |
tree | 7715140a6951407d13781e0a5bbf83a6e8f9dbe9 /internal/database/repos | |
parent | ff86222fc9ab85fb4c5c5e8a063083595b323761 (diff) |
Feat: auth; login; signup; migrate to sqlite
Diffstat (limited to 'internal/database/repos')
-rw-r--r-- | internal/database/repos/action.go | 10 | ||||
-rw-r--r-- | internal/database/repos/userscore.go | 4 |
2 files changed, 12 insertions, 2 deletions
diff --git a/internal/database/repos/action.go b/internal/database/repos/action.go index 6024dd5..49ad95e 100644 --- a/internal/database/repos/action.go +++ b/internal/database/repos/action.go @@ -5,6 +5,7 @@ import "apjournal/internal/models" type ActionRepo interface { DBActionCreate(req *models.Action) error DBActionList(username string) ([]models.Action, error) + DBActionGetByName(name string) (*models.Action, error) DBActionDone(name string) error DBActionsToReset() error } @@ -25,6 +26,15 @@ func (p *Provider) DBActionList(username string) ([]models.Action, error) { return resp, nil } +func (p *Provider) DBActionGetByName(name string) (*models.Action, error) { + resp := models.Action{} + query := "SELECT * FROM action WHERE name=$1;" + if err := p.db.Get(&resp, query, name); err != nil { + return nil, err + } + return &resp, nil +} + func (p *Provider) DBActionDone(name string) error { // should reset at burn time stmt := "UPDATE action SET done=true WHERE name=$1;" diff --git a/internal/database/repos/userscore.go b/internal/database/repos/userscore.go index 5c09004..2baf99f 100644 --- a/internal/database/repos/userscore.go +++ b/internal/database/repos/userscore.go @@ -10,8 +10,8 @@ type UserScoreRepo interface { func (p *Provider) DBUserScoreCreate(req *models.UserScore) error { _, err := p.db.NamedExec(` - INSERT INTO user_score(username, burn_time, score) - VALUES (:username, :burn_time, :score);`, req) + INSERT INTO user_score(username, burn_time, score, password) + VALUES (:username, :burn_time, :score, :password);`, req) return err } |