2024-05-31 12:36:48 +00:00
|
|
|
package mysqlrefertime
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-31 12:36:48 +00:00
|
|
|
"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)
|
|
|
|
}
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-31 12:36:48 +00:00
|
|
|
return r, nil
|
|
|
|
}
|