niki/repository/mysql/kind_box_req/scan.go

64 lines
1.3 KiB
Go
Raw Normal View History

package mysqlkindboxreq
import (
2024-02-12 07:56:28 +00:00
"database/sql"
"time"
2024-02-12 07:56:28 +00:00
"git.gocasts.ir/ebhomengo/niki/entity"
"git.gocasts.ir/ebhomengo/niki/repository/mysql"
)
func scanKindBoxReq(scanner mysql.Scanner) (entity.KindBoxReq, error) {
var kindBoxReq entity.KindBoxReq
var (
kindBoxType string
countAccepted sql.NullInt64
description sql.NullString
status string
senderAgentID sql.NullInt64
deliveredAt sql.NullTime
createdAt time.Time
updatedAt time.Time
deletedAt sql.NullTime
)
err := scanner.Scan(
&kindBoxReq.ID,
&kindBoxReq.BenefactorID,
&kindBoxType,
&kindBoxReq.CountRequested,
&countAccepted,
&description,
&status,
&kindBoxReq.DeliverReferTimeID,
&kindBoxReq.DeliverReferDate,
&kindBoxReq.DeliverAddressID,
&senderAgentID,
&deliveredAt,
&createdAt,
&updatedAt,
&deletedAt,
)
if err != nil {
return entity.KindBoxReq{}, err
2024-02-12 07:56:28 +00:00
}
kindBoxReq.KindBoxType = entity.MapToKindBoxType(kindBoxType)
if countAccepted.Valid {
kindBoxReq.CountAccepted = uint(countAccepted.Int64)
}
if description.Valid {
kindBoxReq.Description = description.String
}
kindBoxReq.Status = entity.MapToKindBoxReqStatus(status)
if senderAgentID.Valid {
kindBoxReq.SenderAgentID = uint(senderAgentID.Int64)
}
if deliveredAt.Valid {
kindBoxReq.DeliveredAt = deliveredAt.Time
}
2024-01-22 15:21:13 +00:00
return kindBoxReq, nil
}