forked from ebhomengo/niki
21 lines
640 B
Go
21 lines
640 B
Go
|
package mysqlrefertime
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"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) Get(ctx context.Context, referTimeID uint) (entity.ReferTime, error) {
|
||
|
const op = richerror.Op("mysqlrefertime.Get")
|
||
|
|
||
|
row := d.conn.Conn().QueryRowContext(ctx, `select * from refer_times where id = ?`, referTimeID)
|
||
|
r, err := scanReferTime(row)
|
||
|
if err != nil {
|
||
|
return entity.ReferTime{}, richerror.New(op).WithErr(err).
|
||
|
WithMessage(errmsg.ErrorMsgCantScanQueryResult).WithKind(richerror.KindUnexpected)
|
||
|
}
|
||
|
return r, nil
|
||
|
}
|