| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 | package modelimport (	"fmt"	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow")type Calendar struct {	Id           int64                       `json:"id"`	PastureId    int64                       `json:"pastureId"`	Name         string                      `json:"name"`	CalendarType pasturePb.CalendarType_Kind `json:"calendarType"`	Count        int32                       `json:"count"`	StartDay     string                      `json:"startDay"`	EndDay       string                      `json:"endDay"`	IsShow       pasturePb.IsShow_Kind       `json:"isShow"`	Backup       string                      `json:"backup"`	CreatedAt    int64                       `json:"createdAt"`	UpdatedAt    int64                       `json:"updatedAt"`}func (w *Calendar) TableName() string {	return "calendar"}func NewCalendar(pastureId int64, name string, calendarType pasturePb.CalendarType_Kind, startDay, endDay string, count int32) *Calendar {	return &Calendar{		PastureId:    pastureId,		Name:         name,		Count:        count,		CalendarType: calendarType,		StartDay:     startDay,		EndDay:       endDay,		IsShow:       pasturePb.IsShow_Ok,	}}var CalendarTypeColorMap = map[pasturePb.CalendarType_Kind]string{	pasturePb.CalendarType_Immunisation:    "#00B42A",	pasturePb.CalendarType_PG:              "#722ED1",	pasturePb.CalendarType_RnGH:            "#722ED1",	pasturePb.CalendarType_Pregnancy_Check: "#F5319D",	pasturePb.CalendarType_WorkOrder:       "#5d6d7e",	pasturePb.CalendarType_Disease:         "#00B42A",	pasturePb.CalendarType_Calving:         "#F5319D",	pasturePb.CalendarType_Weaning:         "#F5319D",	pasturePb.CalendarType_Mating:          "#F5319D",	pasturePb.CalendarType_DryMilk:         "#165DFF",}var CalendarTypeEndDaysMap = map[pasturePb.CalendarType_Kind]int{	pasturePb.CalendarType_Immunisation:    7,	pasturePb.CalendarType_PG:              0,	pasturePb.CalendarType_RnGH:            0,	pasturePb.CalendarType_Pregnancy_Check: 7,	pasturePb.CalendarType_WorkOrder:       -1,	pasturePb.CalendarType_Disease:         -1,	pasturePb.CalendarType_Calving:         15,	pasturePb.CalendarType_Weaning:         7,	pasturePb.CalendarType_Mating:          0,	pasturePb.CalendarType_DryMilk:         15,}type CalendarSlice []*Calendarfunc (c CalendarSlice) ToPB() []*pasturePb.Calendar {	res := make([]*pasturePb.Calendar, len(c))	for i, v := range c {		res[i] = &pasturePb.Calendar{			Id:      int32(v.Id),			Title:   fmt.Sprintf("%s - %d", v.Name, v.Count),			GroupId: v.CalendarType,			Count:   v.Count,			Start:   v.StartDay,			End:     v.EndDay,			Color:   CalendarTypeColorMap[v.CalendarType],			ExtendedProps: &pasturePb.ExtendedProps{				StartDay: v.StartDay,				Backup:   v.Backup,			},		}	}	return res}type CompletedData struct {	Count            int32	CalendarTypeKind pasturePb.CalendarType_Kind	CalendarTypeName string}
 |