| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 | package modelimport (	"strings"	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow")type EventAbortion struct {	Id                  int64                          `json:"id"`	PastureId           int64                          `json:"pastureId"`	CowId               int64                          `json:"cowId"`	EarNumber           string                         `json:"earNumber"`	Lact                int32                          `json:"lact"`	CowType             pasturePb.CowType_Kind         `json:"cowType"`	DayAge              int32                          `json:"dayAge"`	PregnantAge         int32                          `json:"pregnantAge"`	AbortionAt          int64                          `json:"abortionAt"`	IsAfterbirth        pasturePb.IsShow_Kind          `json:"isAfterbirth"`	IsLact              pasturePb.IsShow_Kind          `json:"isLact"`	Photos              string                         `json:"photos"`	AbortionReasons     pasturePb.AbortionReasons_Kind `json:"abortionReasons"`	AbortionReasonsName string                         `json:"abortionReasonsName"`	Remarks             string                         `json:"remarks"`	IsAppend            pasturePb.IsShow_Kind          `json:"isAppend"`	OperationId         int64                          `json:"operationId"`	OperationName       string                         `json:"operationName"`	CreatedAt           int64                          `json:"createdAt"`	UpdatedAt           int64                          `json:"updatedAt"`}func (e *EventAbortion) TableName() string {	return "event_abortion"}func NewEventAbortion(pastureId int64, cow *Cow, item *pasturePb.EventAbortionItem, isAppend pasturePb.IsShow_Kind) *EventAbortion {	return &EventAbortion{		PastureId:           pastureId,		CowId:               cow.Id,		EarNumber:           cow.EarNumber,		Lact:                cow.Lact,		CowType:             cow.CowType,		PregnantAge:         cow.GetDaysPregnant(),		DayAge:              cow.DayAge,		AbortionAt:          int64(item.AbortionAt),		IsAfterbirth:        item.IsAfterbirth,		IsLact:              item.IsLact,		Photos:              strings.Join(item.Photos, ","),		AbortionReasons:     item.AbortionReasons,		AbortionReasonsName: item.AbortionReasonsName,		Remarks:             item.Remarks,		IsAppend:            isAppend,		OperationId:         int64(item.OperationId),		OperationName:       item.OperationName,	}}type AbortionSlice []*EventAbortionfunc (a AbortionSlice) ToPB() []*pasturePb.EventAbortionItem {	res := make([]*pasturePb.EventAbortionItem, len(a))	for i, v := range a {		res[i] = &pasturePb.EventAbortionItem{			Id:                  int32(v.Id),			CowId:               int32(v.CowId),			EarNumber:           v.EarNumber,			DayAge:              v.DayAge,			Lact:                v.Lact,			AbortionAt:          int32(v.AbortionAt),			IsAfterbirth:        v.IsAfterbirth,			IsLact:              v.IsLact,			Photos:              strings.Split(v.Photos, ","),			AbortionReasons:     v.AbortionReasons,			AbortionReasonsName: v.AbortionReasonsName,			PregnancyAge:        v.PregnantAge,			Remarks:             v.Remarks,			OperationId:         int32(v.OperationId),			OperationName:       v.OperationName,			CreatedAt:           int32(v.CreatedAt),			UpdatedAt:           int32(v.UpdatedAt),		}	}	return res}
 |