|
@@ -17,6 +17,42 @@ import (
|
|
|
pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow"
|
|
|
)
|
|
|
|
|
|
+func (s *StoreEntry) Detail(ctx context.Context, req *pasturePb.SearchEventRequest) (*pasturePb.CowInfoResponse, error) {
|
|
|
+ currentUser, err := s.GetCurrentSystemUser(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return nil, xerr.Custom("当前用户信息错误,请退出重新登录")
|
|
|
+ }
|
|
|
+
|
|
|
+ cowInfo := make([]*model.Cow, 0)
|
|
|
+ pref := s.DB.Model(new(model.Cow)).Where("pasture_id = ?", currentUser.PastureId).Where("id = ?", req.CowId)
|
|
|
+ if req.NeckRingNumber != "" {
|
|
|
+ pref.Where("neck_ring_number = ?", req.NeckRingNumber)
|
|
|
+ }
|
|
|
+
|
|
|
+ if req.EarNumber != "" {
|
|
|
+ pref.Where("ear_number = ?", req.EarNumber)
|
|
|
+ }
|
|
|
+
|
|
|
+ if err = pref.Order("id desc").
|
|
|
+ Find(&cowInfo).Error; err != nil {
|
|
|
+ return nil, xerr.WithStack(err)
|
|
|
+ }
|
|
|
+
|
|
|
+ penMap := s.PenMap(ctx, currentUser.PastureId)
|
|
|
+ cowTypeMap := s.CowTypeMap()
|
|
|
+ breedStatusMap := s.CowBreedStatusMap()
|
|
|
+ cowKindMap := s.CowKindMap()
|
|
|
+ cowSourceMap := s.CowSourceMap()
|
|
|
+ admissionStatusMap := s.AdmissionStatusMap()
|
|
|
+ healthStatusMap := s.HealthStatusMap()
|
|
|
+
|
|
|
+ return &pasturePb.CowInfoResponse{
|
|
|
+ Code: http.StatusOK,
|
|
|
+ Msg: "ok",
|
|
|
+ Data: model.CowSlice(cowInfo).ToPB(penMap, cowTypeMap, breedStatusMap, cowKindMap, cowSourceMap, admissionStatusMap, healthStatusMap)[0],
|
|
|
+ }, nil
|
|
|
+}
|
|
|
+
|
|
|
func (s *StoreEntry) List(ctx context.Context, req *pasturePb.SearchEventRequest, pagination *pasturePb.PaginationModel) (*pasturePb.SearchCowListResponse, error) {
|
|
|
currentUser, err := s.GetCurrentSystemUser(ctx)
|
|
|
if err != nil {
|
|
@@ -97,7 +133,6 @@ func (s *StoreEntry) List(ctx context.Context, req *pasturePb.SearchEventRequest
|
|
|
Page: pagination.Page,
|
|
|
},
|
|
|
}, nil
|
|
|
-
|
|
|
}
|
|
|
|
|
|
func (s *StoreEntry) EventList(ctx context.Context, req *pasturePb.SearchCowEventListRequest, pagination *pasturePb.PaginationModel) (*pasturePb.CowEventListResponse, error) {
|