|
@@ -40,6 +40,17 @@ type MatingTimes struct {
|
|
|
EventMatingId int64
|
|
|
}
|
|
|
|
|
|
+func (s *StoreEntry) EnterCheck(ctx context.Context, req *pasturePb.EventEnterRequest) error {
|
|
|
+ var count int64
|
|
|
+ if err := s.DB.Model(new(model.Cow)).Where("ear_number = ?", req.EarNumber).Count(&count).Error; err != nil {
|
|
|
+ return xerr.WithStack(err)
|
|
|
+ }
|
|
|
+ if count > 0 {
|
|
|
+ return xerr.Custom("该牛只已存在")
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
func (s *StoreEntry) MatingCreateCheck(ctx context.Context, req *pasturePb.EventMating) (*EventCheckBatchModel, error) {
|
|
|
if len(req.CowIds) <= 0 {
|
|
|
return nil, xerr.Custom("请选择相关牛只")
|