forked from ebhomengo/niki
1
0
Fork 0
niki/repository/mysql/kind_box/get.go

35 lines
991 B
Go

package mysqlkindbox
import (
"context"
"database/sql"
"git.gocasts.ir/ebhomengo/niki/entity"
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
)
func (d DB) GetKindBox(ctx context.Context, kindBoxID uint) (entity.KindBox, error) {
const op = "mysqlkindbox.GetKindBox"
query := `SELECT * FROM kind_boxes WHERE id = ? AND deleted_at IS NULL`
row := d.conn.Conn().QueryRowContext(ctx, query, kindBoxID)
k, err := scanKindBox(row)
if err != nil {
if err == sql.ErrNoRows {
return entity.KindBox{}, richerror.New(op).WithErr(err).
WithMessage(errmsg.ErrorMsgNotFound).WithKind(richerror.KindNotFound)
}
return entity.KindBox{}, richerror.New(op).WithErr(err).
WithMessage(errmsg.ErrorMsgCantScanQueryResult).WithKind(richerror.KindUnexpected)
}
return k, nil
}
func (d DB) GetAllKindBox(ctx context.Context, benefactorID uint) ([]entity.KindBox, error) {
// TODO implement me
panic("implement me")
}