feat
This commit is contained in:
parent
76d28d0170
commit
148ae646b1
1 changed files with 8 additions and 8 deletions
|
|
@ -2,12 +2,12 @@ package handlers
|
|||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
oapi "nyanimedb/api"
|
||||
sqlc "nyanimedb/sql"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ func (s Server) GetTagsByTitleId(ctx context.Context, id int64) (oapi.Tags, erro
|
|||
|
||||
sqlc_title_tags, err := s.db.GetTitleTags(ctx, id)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
if err == pgx.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, fmt.Errorf("query GetTitleTags: %v", err)
|
||||
|
|
@ -82,14 +82,14 @@ func (s Server) GetTagsByTitleId(ctx context.Context, id int64) (oapi.Tags, erro
|
|||
|
||||
func (s Server) GetImage(ctx context.Context, id int64) (*oapi.Image, error) {
|
||||
|
||||
var oapi_image *oapi.Image
|
||||
var oapi_image oapi.Image
|
||||
|
||||
sqlc_image, err := s.db.GetImageByID(ctx, id)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
if err == pgx.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
return oapi_image, fmt.Errorf("query GetImageByID: %v", err)
|
||||
return &oapi_image, fmt.Errorf("query GetImageByID: %v", err)
|
||||
}
|
||||
|
||||
//can cast and dont use brain cause all this fields required in image table
|
||||
|
|
@ -98,7 +98,7 @@ func (s Server) GetImage(ctx context.Context, id int64) (*oapi.Image, error) {
|
|||
storageTypeStr := string(sqlc_image.StorageType)
|
||||
oapi_image.StorageType = &storageTypeStr
|
||||
|
||||
return oapi_image, nil
|
||||
return &oapi_image, nil
|
||||
}
|
||||
|
||||
func (s Server) GetStudio(ctx context.Context, id int64) (*oapi.Studio, error) {
|
||||
|
|
@ -107,7 +107,7 @@ func (s Server) GetStudio(ctx context.Context, id int64) (*oapi.Studio, error) {
|
|||
|
||||
sqlc_studio, err := s.db.GetStudioByID(ctx, id)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
if err == pgx.ErrNoRows {
|
||||
return nil, nil
|
||||
}
|
||||
return &oapi_studio, fmt.Errorf("query GetStudioByID: %v", err)
|
||||
|
|
@ -195,7 +195,7 @@ func (s Server) GetTitleTitleId(ctx context.Context, request oapi.GetTitleTitleI
|
|||
|
||||
sqlc_title, err := s.db.GetTitleByID(ctx, request.TitleId)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
if err == pgx.ErrNoRows {
|
||||
return oapi.GetTitleTitleId204Response{}, nil
|
||||
}
|
||||
log.Errorf("%v", err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue