| 
					
				 | 
			
			
				@@ -2,6 +2,7 @@ package model 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	"fmt" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	"time" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 ) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -9,25 +10,25 @@ import ( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const ShardTableNumber = 6 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 type EventCowLog struct { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	Id               int64                        `json:"id"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	PastureId        int64                        `json:"pastureId"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	CowId            int64                        `json:"cowId"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	DayAge           int32                        `json:"dayAge"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	Lact             int32                        `json:"lact"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	PenId            int32                        `json:"penId"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	PenName          string                       `json:"penName"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	CowType          pasturePb.CowType_Kind       `json:"cowType"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	CowTypeName      string                       `json:"cowTypeName"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	EventCategoryId  pasturePb.EventCategory_Kind `json:"eventCategoryId"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	EventType        pasturePb.EventType_Kind     `json:"eventType"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	EventTypeName    string                       `json:"eventTypeName"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	EventDescription string                       `json:"eventDescription"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	OperationId      int64                        `json:"operationId"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	OperationName    string                       `json:"operationName"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	EventAt          int64                        `json:"eventAt"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	Remarks          string                       `json:"remarks"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	CreatedAt        int64                        `json:"createdAt"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	UpdatedAt        int64                        `json:"updatedAt"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	Id                int64                        `json:"id"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	PastureId         int64                        `json:"pastureId"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	CowId             int64                        `json:"cowId"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	DayAge            int32                        `json:"dayAge"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	Lact              int32                        `json:"lact"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	PenId             int32                        `json:"penId"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	PenName           string                       `json:"penName"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	CowType           pasturePb.CowType_Kind       `json:"cowType"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	CowTypeName       string                       `json:"cowTypeName"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	EventCategoryKind pasturePb.EventCategory_Kind `json:"eventCategoryId"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	EventType         pasturePb.EventType_Kind     `json:"eventType"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	EventTypeName     string                       `json:"eventTypeName"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	EventDescription  string                       `json:"eventDescription"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	OperationId       int64                        `json:"operationId"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	OperationName     string                       `json:"operationName"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	EventAt           int64                        `json:"eventAt"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	Remarks           string                       `json:"remarks"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	CreatedAt         int64                        `json:"createdAt"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	UpdatedAt         int64                        `json:"updatedAt"` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 func (e *EventCowLog) UnShardTableName() string { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -40,18 +41,18 @@ func (e *EventCowLog) TableName() string { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 type EventCowLogModel struct { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	Cow              *Cow 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	EventType        pasturePb.EventType_Kind 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	OperationUser    *SystemUser 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	CurrentUser      *SystemUser 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	EventAt          int64 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	ExposeEstrusType pasturePb.ExposeEstrusType_Kind 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	EventCategoryId  pasturePb.EventCategory_Kind 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	PenName          string 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	Remarks          string 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	CowTypeName      string 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	EventTypeName    string 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	Description      string 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	Cow               *Cow 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	EventType         pasturePb.EventType_Kind 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	OperationUser     *SystemUser 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	CurrentUser       *SystemUser 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	EventAt           int64 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	ExposeEstrusType  pasturePb.ExposeEstrusType_Kind 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	EventCategoryKind pasturePb.EventCategory_Kind 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	PenName           string 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	Remarks           string 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	CowTypeName       string 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	EventTypeName     string 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	Description       string 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 func NewEventCowLog(req *EventCowLogModel) *EventCowLog { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -62,21 +63,47 @@ func NewEventCowLog(req *EventCowLogModel) *EventCowLog { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		operationName = req.OperationUser.Name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	return &EventCowLog{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		PastureId:        req.Cow.PastureId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		CowId:            req.Cow.Id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		DayAge:           req.Cow.GetDayAge(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Lact:             req.Cow.Lact, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		PenId:            req.Cow.PenId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		PenName:          req.PenName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		CowType:          req.Cow.CowType, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		CowTypeName:      req.CowTypeName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		EventCategoryId:  req.EventCategoryId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		EventType:        req.EventType, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		EventTypeName:    req.EventTypeName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		EventDescription: req.Description, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		OperationId:      operationId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		OperationName:    operationName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		EventAt:          req.EventAt, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		Remarks:          req.Remarks, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		PastureId:         req.Cow.PastureId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		CowId:             req.Cow.Id, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		DayAge:            req.Cow.GetDayAge(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Lact:              req.Cow.Lact, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		PenId:             req.Cow.PenId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		PenName:           req.PenName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		CowType:           req.Cow.CowType, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		CowTypeName:       req.CowTypeName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		EventCategoryKind: req.EventCategoryKind, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		EventType:         req.EventType, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		EventTypeName:     req.EventTypeName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		EventDescription:  req.Description, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		OperationId:       operationId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		OperationName:     operationName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		EventAt:           req.EventAt, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		Remarks:           req.Remarks, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+type EventCowLogSlice []*EventCowLog 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+func (e EventCowLogSlice) ToPB(eventCategoryMap map[pasturePb.EventCategory_Kind]string) []*pasturePb.CowEvent { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	res := make([]*pasturePb.CowEvent, len(e)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	for i, v := range e { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		res[i] = &pasturePb.CowEvent{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			Id:                int32(v.Id), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			PastureId:         int32(v.PastureId), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			CowId:             int32(v.CowId), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			Lact:              v.Lact, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			DayAge:            v.DayAge, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			PenName:           v.PenName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			CowTypeName:       v.CowTypeName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			EventTypeName:     v.EventTypeName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			EventDescription:  v.EventDescription, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			OperationName:     v.OperationName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			Remarks:           v.Remarks, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			EventAtFormat:     time.Unix(v.EventAt, 0).Format(LayoutDate2), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			EventCategoryKind: v.EventCategoryKind, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			EventCategoryName: eventCategoryMap[v.EventCategoryKind], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	return res 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 |