sale_dealer.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package model
  2. import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
  3. type SaleDealer struct {
  4. Id int32 `json:"id"`
  5. PastureId int64 `json:"pastureId"`
  6. Name string `json:"name"`
  7. Contacts string `json:"contacts"`
  8. Phone string `json:"phone"`
  9. Address string `json:"address"`
  10. Remarks string `json:"remarks"`
  11. IsShow pasturePb.IsShow_Kind `json:"isShow"`
  12. CreatedAt int64 `json:"createdAt"`
  13. UpdatedAt int64 `json:"updatedAt"`
  14. }
  15. func (s *SaleDealer) TableName() string {
  16. return "sale_dealer"
  17. }
  18. func NewSaleDealer(pastureId int64, name, phone string) *SaleDealer {
  19. return &SaleDealer{
  20. PastureId: pastureId,
  21. Name: name,
  22. Contacts: "",
  23. Phone: phone,
  24. Address: "",
  25. Remarks: "",
  26. IsShow: pasturePb.IsShow_Ok,
  27. }
  28. }
  29. type SaleDealerSlice []*SaleDealer
  30. func (s SaleDealerSlice) ToPB() []*pasturePb.DealerItem {
  31. res := make([]*pasturePb.DealerItem, len(s))
  32. for i, v := range s {
  33. res[i] = &pasturePb.DealerItem{
  34. Id: v.Id,
  35. Name: v.Name,
  36. Contacts: v.Contacts,
  37. Address: v.Address,
  38. Phone: v.Phone,
  39. IsShow: v.IsShow,
  40. Remarks: v.Remarks,
  41. }
  42. }
  43. return res
  44. }