2024-01-22 08:14:57 +00:00
|
|
|
package mysqlkindboxreq
|
|
|
|
|
|
|
|
import (
|
2024-02-12 07:56:28 +00:00
|
|
|
"database/sql"
|
2024-05-17 20:16:28 +00:00
|
|
|
"time"
|
2024-02-12 07:56:28 +00:00
|
|
|
|
2024-01-22 08:14:57 +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
|
2024-05-17 20:16:28 +00:00
|
|
|
var (
|
|
|
|
kindBoxType string
|
|
|
|
countAccepted sql.NullInt64
|
|
|
|
description sql.NullString
|
|
|
|
status string
|
|
|
|
senderAgentID sql.NullInt64
|
|
|
|
deliveredAt sql.NullTime
|
|
|
|
createdAt time.Time
|
|
|
|
updatedAt time.Time
|
|
|
|
)
|
2024-01-22 08:14:57 +00:00
|
|
|
|
2024-05-17 20:16:28 +00:00
|
|
|
err := scanner.Scan(
|
|
|
|
&kindBoxReq.ID,
|
|
|
|
&kindBoxReq.BenefactorID,
|
|
|
|
&kindBoxType,
|
|
|
|
&kindBoxReq.CountRequested,
|
|
|
|
&countAccepted,
|
|
|
|
&description,
|
|
|
|
&status,
|
|
|
|
&kindBoxReq.DeliverReferDate,
|
|
|
|
&kindBoxReq.DeliverAddressID,
|
|
|
|
&senderAgentID,
|
|
|
|
&deliveredAt,
|
|
|
|
&createdAt,
|
|
|
|
&updatedAt,
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return entity.KindBoxReq{}, err
|
2024-02-12 07:56:28 +00:00
|
|
|
}
|
2024-05-17 20:16:28 +00:00
|
|
|
|
2024-01-22 08:14:57 +00:00
|
|
|
kindBoxReq.KindBoxType = entity.MapToKindBoxType(kindBoxType)
|
2024-05-17 20:16:28 +00:00
|
|
|
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
|
|
|
|
2024-05-17 20:16:28 +00:00
|
|
|
return kindBoxReq, nil
|
2024-01-22 08:14:57 +00:00
|
|
|
}
|