package model

import (
	"kpt-pasture/util"
	"time"

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

type EventWeaning struct {
	Id            int64                 `json:"id"`
	CowId         int64                 `json:"cowId"`
	PlanDay       int64                 `json:"planDay"`
	EndDay        int64                 `json:"endDay"`
	RealityDay    int64                 `json:"realityDay"`
	Status        pasturePb.IsShow_Kind `json:"status"`
	BeforePenId   int32                 `json:"beforePenId"`
	AfterPenId    int32                 `json:"afterPenId"`
	Remarks       string                `json:"remarks"`
	OperationId   int32                 `json:"operationId"`
	OperationName string                `json:"operationName"`
	CreatedAt     int64                 `json:"createdAt"`
	UpdatedAt     int64                 `json:"updatedAt"`
}

func (c *EventWeaning) TableName() string {
	return "event_weaning"
}

func NewEventWeaning(cowId int64, penId int32) *EventWeaning {
	return &EventWeaning{
		CowId:       cowId,
		PlanDay:     util.TimeParseLocalUnix(time.Now().Format(LayoutDate2)),
		EndDay:      util.TimeParseLocalEndUnix(time.Now().Format(LayoutDate2)),
		Status:      pasturePb.IsShow_No,
		BeforePenId: penId,
	}
}

func NewEventWeaningList(cowList []*Cow) []*EventWeaning {
	var weaningList = make([]*EventWeaning, 0)
	for _, cow := range cowList {
		weaningList = append(weaningList, NewEventWeaning(cow.Id, cow.PenId))
	}
	return weaningList
}