package model import ( "strings" pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow" ) type EventSaleCar struct { Id int64 `json:"id"` SaleId int64 `json:"saleId"` SaleAt int64 `json:"saleAt"` CarNumber string `json:"carNumber"` CowCount int32 `json:"cowCount"` CowIds string `json:"cowIds"` OutboundTicket string `json:"outbound_ticket"` WeighbridgePhotos string `json:"weighbridgePhotos"` CarPhotos string `json:"carPhotos"` CreatedAt int64 `json:"createdAt"` UpdatedAt int64 `json:"updatedAt"` } func (e *EventSaleCar) TableName() string { return "event_sale_car" } func NewEventSaleCar(saleId, saleAt int64, saleVehicleItem *pasturePb.SaleVehicleItem) *EventSaleCar { return &EventSaleCar{ SaleId: saleId, SaleAt: saleAt, CarNumber: saleVehicleItem.CarNumber, CowCount: saleVehicleItem.CowCount, CowIds: "", OutboundTicket: saleVehicleItem.OutboundTicket, WeighbridgePhotos: strings.Join(saleVehicleItem.WeighbridgePhotos, ","), CarPhotos: strings.Join(saleVehicleItem.VehiclePhotos, ","), } } func NewEventSaleCarList(saleId, saleAt int64, req []*pasturePb.SaleVehicleItem) []*EventSaleCar { res := make([]*EventSaleCar, 0) for _, saleVehicleItem := range req { res = append(res, NewEventSaleCar(saleId, saleAt, saleVehicleItem)) } return res }