1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- package model
- import pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
- type EventFrozenSemen struct {
- Id int64 `json:"id"`
- ParentId int64 `json:"parent_id"`
- Producer string `json:"producer"`
- BullId string `json:"bull_id"`
- KindId pasturePb.CowKind_Kind `json:"kind_id"`
- KindName string `json:"kind_name"`
- FrozenSemenType pasturePb.FrozenSemenType_Kind `json:"frozen_semen_type"`
- Quantity int32 `json:"quantity"`
- Unit pasturePb.Unit_Kind `json:"unit"`
- Remarks string `json:"remarks"`
- OperationId int64 `json:"operation_id"`
- CreatedAt int64 `json:"created_at"`
- UpdatedAt int64 `json:"updated_at"`
- }
- func NewEventFrozenSemen(req *pasturePb.SearchFrozenSemenList, currentUser *SystemUser) *EventFrozenSemen {
- return &EventFrozenSemen{
- Producer: req.Producer,
- BullId: req.BullId,
- KindId: req.CowKind,
- KindName: req.CowKindName,
- FrozenSemenType: req.FrozenSemenType,
- Quantity: req.Quantity,
- Unit: req.Unit,
- Remarks: req.Remarks,
- OperationId: currentUser.Id,
- }
- }
- func (e *EventFrozenSemen) TableName() string {
- return "event_frozen_semen"
- }
- type EventFrozenSemenSlice []*EventFrozenSemen
- func (e EventFrozenSemenSlice) ToPB(
- frozenSemenTypeMap map[pasturePb.FrozenSemenType_Kind]string,
- unitMap map[pasturePb.Unit_Kind]string) []*pasturePb.SearchFrozenSemenList {
- res := make([]*pasturePb.SearchFrozenSemenList, len(e))
- for i, v := range e {
- res[i] = &pasturePb.SearchFrozenSemenList{
- Id: int32(v.Id),
- ParentId: int32(v.ParentId),
- Producer: v.Producer,
- BullId: v.BullId,
- CowKind: v.KindId,
- CowKindName: v.KindName,
- FrozenSemenType: v.FrozenSemenType,
- FrozenSemenTypeName: frozenSemenTypeMap[v.FrozenSemenType],
- Quantity: v.Quantity,
- Unit: v.Unit,
- UnitName: unitMap[v.Unit],
- Remarks: v.Remarks,
- OperationId: int32(v.OperationId),
- CreatedAt: int32(v.CreatedAt),
- UpdatedAt: int32(v.UpdatedAt),
- }
- }
- return res
- }
|