package model

import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"

type EventBodyScore struct {
	Id            int64  `json:"id"`
	CowId         int64  `json:"cowId"`
	EarNumber     string `json:"earNumber"`
	Score         int32  `json:"score"`
	Lact          int32  `json:"lact"`
	DayAge        int32  `json:"dayAge"`
	ScoreAt       int64  `json:"scoreAt"`
	Remarks       string `json:"remarks"`
	MessageId     int64  `json:"messageId"`
	MessageName   string `json:"messageName"`
	OperationId   int64  `json:"operationId"`
	OperationName string `json:"operationName"`
	CreatedAt     int64  `json:"createdAt"`
	UpdatedAt     int64  `json:"updatedAt"`
}

func (e *EventBodyScore) TableName() string {
	return "event_body_score"
}

func NewEventBodyScore(cow *Cow, currentSystemUser *SystemUser, req *pasturePb.BodyScoreEventRequest) *EventBodyScore {
	return &EventBodyScore{
		CowId:         cow.Id,
		EarNumber:     cow.EarNumber,
		Score:         req.Score,
		Lact:          cow.Lact,
		DayAge:        cow.GetDayAge(),
		ScoreAt:       int64(req.ScoreAt),
		Remarks:       req.Remarks,
		MessageId:     currentSystemUser.Id,
		MessageName:   currentSystemUser.Name,
		OperationId:   int64(req.OperationId),
		OperationName: req.OperationName,
	}
}