Browse Source

event: matingCreateCheck validate update

Yi 6 days ago
parent
commit
fb2021ffe1
1 changed files with 24 additions and 5 deletions
  1. 24 5
      module/backend/event_check.go

+ 24 - 5
module/backend/event_check.go

@@ -102,23 +102,42 @@ func (s *StoreEntry) MatingCreateCheck(ctx context.Context, pastureId int64, req
 		}
 
 		if int64(v.MatingAt) < cowInfo.LastMatingAt {
-			return nil, xerr.Customf("牛只: %s,最近一次配种时间: %d,不能小于本次配种时间: %d", cowInfo.EarNumber, cowInfo.LastMatingAt, v.MatingAt)
+			return nil, xerr.Customf("牛只: %s,最近一次配种时间: %s,不能小于本次配种时间: %d",
+				cowInfo.EarNumber,
+				time.Unix(cowInfo.LastMatingAt, 0).Format(model.LayoutDate2),
+				time.Unix(int64(v.MatingAt), 0).Format(model.LayoutDate2),
+			)
 		}
 
 		if int64(v.MatingAt) < cowInfo.LastPregnantCheckAt {
-			return nil, xerr.Customf("牛只: %s,最近一次孕检时间: %d,不能小于本次配种时间: %d", cowInfo.EarNumber, cowInfo.LastPregnantCheckAt, v.MatingAt)
+			return nil, xerr.Customf("牛只: %s,最近一次孕检时间: %s,不能小于本次配种时间: %s",
+				cowInfo.EarNumber,
+				time.Unix(cowInfo.LastPregnantCheckAt, 0).Format(model.LayoutDate2),
+				time.Unix(int64(v.MatingAt), 0).Format(model.LayoutDate2),
+			)
 		}
 
 		if int64(v.MatingAt) < cowInfo.LastAbortionAt {
-			return nil, xerr.Customf("牛只: %s,最近一次流产时间: %d,不能小于本次配种时间: %d", cowInfo.EarNumber, cowInfo.LastAbortionAt, v.MatingAt)
+			return nil, xerr.Customf("牛只: %s,最近一次流产时间: %d,不能小于本次配种时间: %d",
+				cowInfo.EarNumber,
+				cowInfo.LastAbortionAt,
+				v.MatingAt,
+			)
 		}
 
 		if int64(v.MatingAt) < cowInfo.BirthAt {
-			return nil, xerr.Customf("牛只: %s,出生时间: %d,不能小于本次配种时间: %d", cowInfo.EarNumber, cowInfo.BirthAt, v.MatingAt)
+			return nil, xerr.Customf("牛只: %s,出生时间: %d,不能小于本次配种时间: %d",
+				cowInfo.EarNumber,
+				time.Unix(cowInfo.BirthAt, 0).Format(model.LayoutDate2),
+				time.Unix(int64(v.MatingAt), 0).Format(model.LayoutDate2),
+			)
 		}
 
 		if cowInfo.BreedStatus == pasturePb.BreedStatus_Pregnant || cowInfo.BreedStatus == pasturePb.BreedStatus_No_Mating {
-			return nil, xerr.Customf("牛只: %s,当前状态为: %s,不能进行配种", cowInfo.EarNumber, cowInfo.BreedStatus.String())
+			return nil, xerr.Customf("牛只: %s,当前状态为: %s,不能进行配种",
+				cowInfo.EarNumber,
+				cowInfo.BreedStatus.String(),
+			)
 		}
 		eventMatingCheckBatchModelList = append(eventMatingCheckBatchModelList, &model.EventMatingCheckBatchModel{
 			Cow:              cowInfo,