| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 | package modelimport pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"type EventDeath struct {	Id                   int64                           `json:"id"`	PastureId            int64                           `json:"pastureId"`	EarNumber            string                          `json:"earNumber"`	CowId                int64                           `json:"cowId"`	Lact                 int32                           `json:"lact"`	CowType              pasturePb.CowType_Kind          `json:"cowType"`	DayAge               int32                           `json:"dayAge"`	PregnancyAge         int32                           `json:"pregnancyAge"`	CalvingAge           int32                           `json:"calvingAge"`	AdmissionAge         int32                           `json:"admissionAge"`	DeathReasonKind      pasturePb.DeathReason_Kind      `json:"deathReasonKind"`	DeathReasonName      string                          `json:"deathReasonName"`	DeathDestinationKind pasturePb.DeathDestination_Kind `json:"deathDestinationKind"`	DeathDestinationName string                          `json:"deathDestinationName"`	DeathAt              int64                           `json:"deathAt"`	Remarks              string                          `json:"remarks"`	Weight               int32                           `json:"weight"`	OperationId          int64                           `json:"operationId"`	OperationName        string                          `json:"operationName"`	MessageId            int64                           `json:"messageId"`	MessageName          string                          `json:"messageName"`	CreatedAt            int64                           `json:"createdAt"`	UpdatedAt            int64                           `json:"updatedAt"`}func (e *EventDeath) TableName() string {	return "event_death"}func NewEventDeath(pastureId int64, cow *Cow, req *pasturePb.EventDeath, currentUser, operationUser *SystemUser) *EventDeath {	return &EventDeath{		PastureId:            pastureId,		CowId:                cow.Id,		EarNumber:            cow.EarNumber,		Lact:                 cow.Lact,		CowType:              cow.CowType,		DayAge:               cow.GetEventDayAge(int64(req.DeathAt)),		DeathAt:              int64(req.DeathAt),		DeathReasonKind:      req.DeathReasonKind,		DeathReasonName:      req.DeathReasonName,		Remarks:              req.Remarks,		Weight:               int32(req.Weight * 1000),		DeathDestinationKind: req.DeathDestinationKind,		DeathDestinationName: req.DeathDestinationName,		OperationId:          operationUser.Id,		OperationName:        operationUser.Name,		MessageId:            currentUser.Id,		MessageName:          currentUser.Name,	}}type EventDeathSlice []*EventDeathfunc (e EventDeathSlice) ToPB() []*pasturePb.EventDeath {	res := make([]*pasturePb.EventDeath, len(e))	for i, v := range e {		res[i] = &pasturePb.EventDeath{			Id:                   int32(v.Id),			EarNumber:            v.EarNumber,			DeathReasonKind:      v.DeathReasonKind,			DeathReasonName:      v.DeathReasonName,			DeathAt:              int32(v.DeathAt),			OperationId:          int32(v.OperationId),			OperationName:        v.OperationName,			Remarks:              v.Remarks,			Weight:               float32(v.Weight / 1000),			DeathDestinationKind: v.DeathDestinationKind,			DeathDestinationName: v.DeathDestinationName,			CreatedAt:            int32(v.CreatedAt),			UpdatedAt:            int32(v.UpdatedAt),		}	}	return res}type EventDeathModel struct {	Cow         *Cow	EventDeath  *EventDeath	NeckRing    *NeckRing	CalvingCalf *CalvingCalf}
 |