1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- package model
- import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
- type EventEstrus struct {
- Id int64 `json:"id"`
- CowId int64 `json:"cowId"`
- DayAge int32 `json:"dayAge"`
- Lact int8 `json:"lact"`
- LactationDays int32 `json:"lactationDays"`
- EstrusAt int64 `json:"estrusAt"`
- Remarks string `json:"remarks"`
- 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 *EventEstrus) TableName() string {
- return "event_estrus"
- }
- func NewEventEstrus(cow *Cow, currentUser *SystemUser, req *pasturePb.EventEstrus) *EventEstrus {
- return &EventEstrus{
- CowId: cow.Id,
- DayAge: cow.GetDayAge(),
- Lact: int8(cow.Lact),
- LactationDays: cow.GetLactationDays(),
- EstrusAt: int64(req.EstrusAt),
- Remarks: req.Remarks,
- MessageId: currentUser.Id,
- MessageName: currentUser.Name,
- OperationId: int64(req.OperationId),
- OperationName: req.OperationName,
- }
- }
- type EstrusSlice []*EventEstrus
- func (e EstrusSlice) ToPB() []*pasturePb.SearchEstrusList {
- res := make([]*pasturePb.SearchEstrusList, len(e))
- for i, v := range e {
- res[i] = &pasturePb.SearchEstrusList{
- Id: int32(v.Id),
- CowId: int32(v.CowId),
- DayAge: v.DayAge,
- Lact: int32(v.Lact),
- EstrusAt: int32(v.EstrusAt),
- LactationDays: v.LactationDays,
- MessengerId: int32(v.MessageId),
- MessengerName: v.MessageName,
- Remarks: v.Remarks,
- OperationId: int32(v.OperationId),
- OperationName: v.OperationName,
- CreatedAt: int32(v.CreatedAt),
- UpdatedAt: int32(v.UpdatedAt),
- }
- }
- return res
- }
|