2024-06-25 21:58:11 +00:00
|
|
|
package mysqlkindbox
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"git.gocasts.ir/ebhomengo/niki/entity"
|
|
|
|
"git.gocasts.ir/ebhomengo/niki/repository/mysql"
|
|
|
|
)
|
|
|
|
|
|
|
|
func scanKindBox(scanner mysql.Scanner) (entity.KindBox, error) {
|
|
|
|
var kindBox entity.KindBox
|
|
|
|
var (
|
|
|
|
kindBoxType string
|
|
|
|
amount sql.NullInt64
|
|
|
|
serialNumber sql.NullString
|
|
|
|
status string
|
|
|
|
senderAgentID sql.NullInt64
|
|
|
|
deliveredAt sql.NullTime
|
|
|
|
returnReferTimeID sql.NullInt64
|
|
|
|
returnReferDate sql.NullTime
|
|
|
|
returnAddressID sql.NullInt64
|
|
|
|
receiverAgentID sql.NullInt64
|
|
|
|
returnedAt sql.NullTime
|
|
|
|
createdAt time.Time
|
|
|
|
updatedAt time.Time
|
|
|
|
deletedAt sql.NullTime
|
|
|
|
)
|
|
|
|
|
|
|
|
err := scanner.Scan(
|
|
|
|
&kindBox.ID,
|
|
|
|
&kindBox.KindBoxReqID,
|
|
|
|
&kindBox.BenefactorID,
|
|
|
|
&kindBoxType,
|
|
|
|
&amount,
|
|
|
|
&serialNumber,
|
|
|
|
&status,
|
2024-07-21 13:38:54 +00:00
|
|
|
&kindBox.DeliverReferTimeID,
|
2024-06-25 21:58:11 +00:00
|
|
|
&kindBox.DeliverReferDate,
|
|
|
|
&kindBox.DeliverAddressID,
|
|
|
|
&kindBox.SenderAgentID,
|
|
|
|
&kindBox.DeliveredAt,
|
|
|
|
&returnReferTimeID,
|
|
|
|
&returnReferDate,
|
|
|
|
&returnAddressID,
|
|
|
|
&receiverAgentID,
|
|
|
|
&returnedAt,
|
|
|
|
&createdAt,
|
|
|
|
&updatedAt,
|
|
|
|
&deletedAt,
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return entity.KindBox{}, err
|
|
|
|
}
|
|
|
|
|
2024-07-03 17:18:06 +00:00
|
|
|
kindBox.KindBoxType = entity.MapToKindBoxType(kindBoxType)
|
2024-06-25 21:58:11 +00:00
|
|
|
if amount.Valid {
|
|
|
|
kindBox.Amount = uint(amount.Int64)
|
|
|
|
}
|
|
|
|
if serialNumber.Valid {
|
|
|
|
kindBox.SerialNumber = serialNumber.String
|
|
|
|
}
|
|
|
|
kindBox.Status = entity.MapToKindBoxStatus(status)
|
|
|
|
if senderAgentID.Valid {
|
|
|
|
kindBox.SenderAgentID = uint(senderAgentID.Int64)
|
|
|
|
}
|
|
|
|
if deliveredAt.Valid {
|
|
|
|
kindBox.DeliveredAt = deliveredAt.Time
|
|
|
|
}
|
|
|
|
if returnReferTimeID.Valid {
|
|
|
|
kindBox.ReturnReferTimeID = uint(returnReferTimeID.Int64)
|
|
|
|
}
|
|
|
|
if returnReferDate.Valid {
|
|
|
|
kindBox.ReturnReferDate = returnReferDate.Time
|
|
|
|
}
|
|
|
|
if returnAddressID.Valid {
|
|
|
|
kindBox.ReturnAddressID = uint(returnAddressID.Int64)
|
|
|
|
}
|
|
|
|
if receiverAgentID.Valid {
|
|
|
|
kindBox.ReceiverAgentID = uint(receiverAgentID.Int64)
|
|
|
|
}
|
|
|
|
if returnedAt.Valid {
|
|
|
|
kindBox.ReturnedAt = returnedAt.Time
|
|
|
|
}
|
|
|
|
|
|
|
|
return kindBox, nil
|
|
|
|
}
|