event_sale_car.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package model
  2. import (
  3. "strings"
  4. pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  5. )
  6. type EventSaleCar struct {
  7. Id int64 `json:"id"`
  8. SaleId int64 `json:"saleId"`
  9. SaleAt int64 `json:"saleAt"`
  10. CarNumber string `json:"carNumber"`
  11. CowCount int32 `json:"cowCount"`
  12. CowIds string `json:"cowIds"`
  13. OutboundTicket string `json:"outbound_ticket"`
  14. WeighbridgePhotos string `json:"weighbridgePhotos"`
  15. CarPhotos string `json:"carPhotos"`
  16. CreatedAt int64 `json:"createdAt"`
  17. UpdatedAt int64 `json:"updatedAt"`
  18. }
  19. func (e *EventSaleCar) TableName() string {
  20. return "event_sale_car"
  21. }
  22. func NewEventSaleCar(saleId, saleAt int64, saleVehicleItem *pasturePb.SaleVehicleItem) *EventSaleCar {
  23. return &EventSaleCar{
  24. SaleId: saleId,
  25. SaleAt: saleAt,
  26. CarNumber: saleVehicleItem.CarNumber,
  27. CowCount: saleVehicleItem.CowCount,
  28. CowIds: "",
  29. OutboundTicket: saleVehicleItem.OutboundTicket,
  30. WeighbridgePhotos: strings.Join(saleVehicleItem.WeighbridgePhotos, ","),
  31. CarPhotos: strings.Join(saleVehicleItem.VehiclePhotos, ","),
  32. }
  33. }
  34. func NewEventSaleCarList(saleId, saleAt int64, req []*pasturePb.SaleVehicleItem) []*EventSaleCar {
  35. res := make([]*EventSaleCar, 0)
  36. for _, saleVehicleItem := range req {
  37. res = append(res, NewEventSaleCar(saleId, saleAt, saleVehicleItem))
  38. }
  39. return res
  40. }