add server dao
This commit is contained in:
@@ -43,7 +43,7 @@ func (p FacebookImpl) UpdatePost(fb *pubmodel.FacebookPage, postID string) (err
|
||||
// GetByID -
|
||||
func (p FacebookImpl) GetByID(id string) (fb pubmodel.FacebookPage, exists bool, err error) {
|
||||
exists = true
|
||||
fb := pubmodel.FacebookPage{}
|
||||
fb = pubmodel.FacebookPage{}
|
||||
query := `
|
||||
select "id", "last_post", "ctime", "mtime"
|
||||
from "public"."facebook_page"
|
||||
@@ -106,7 +106,7 @@ func (p FacebookImpl) GetChannels(id string) (list []dsmodel.Channel, err error)
|
||||
`
|
||||
err = x.Select(&list, query, id)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"database/sql"
|
||||
dsmodel "dorisbot/database/models/discord"
|
||||
pubmodel "dorisbot/database/models/public"
|
||||
"errors"
|
||||
|
||||
sq "github.com/elgris/sqrl"
|
||||
)
|
||||
@@ -29,7 +30,7 @@ func (i InstagramImpl) Create(ig *pubmodel.Instagram) (err error) {
|
||||
|
||||
// UpdatePost -
|
||||
func (i InstagramImpl) UpdatePost(ig *pubmodel.Instagram, postID string) (err error) {
|
||||
query, args, err := sq.Update(`"public"."instagram"`).Set("last_post", postID).Set("mtime", sq.Expr("now()")).Where(sq.Eq{"id", ig.ID}).ToSql()
|
||||
query, args, err := sq.Update(`"public"."instagram"`).Set("last_post", postID).Set("mtime", sq.Expr("now()")).Where(sq.Eq{"id": ig.ID}).ToSql()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -53,7 +54,7 @@ func (i *InstagramImpl) GetByID(id string) (pubmodel.Instagram, bool, error) {
|
||||
|
||||
err = x.Get(&ig, query, args...)
|
||||
if err != nil {
|
||||
exists = true
|
||||
exists := true
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
exists = false
|
||||
err = nil
|
||||
|
||||
Reference in New Issue
Block a user