Parcourir la source

warning: estrusItems update

Yi il y a 4 jours
Parent
commit
01409f007e

+ 1 - 1
go.mod

@@ -3,7 +3,7 @@ module kpt-pasture
 go 1.17
 
 require (
-	gitee.com/xuyiping_admin/go_proto v0.0.0-20250909031528-0279ad4ad300
+	gitee.com/xuyiping_admin/go_proto v0.0.0-20250911063919-b4f2c741a7be
 	gitee.com/xuyiping_admin/pkg v0.0.0-20250613101634-36c36a2d27d0
 	github.com/dgrijalva/jwt-go v3.2.0+incompatible
 	github.com/eclipse/paho.mqtt.golang v1.4.3

+ 2 - 0
go.sum

@@ -1361,6 +1361,8 @@ gitee.com/xuyiping_admin/go_proto v0.0.0-20250908022339-e9d9f19403e8 h1:UgJCyRGD
 gitee.com/xuyiping_admin/go_proto v0.0.0-20250908022339-e9d9f19403e8/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
 gitee.com/xuyiping_admin/go_proto v0.0.0-20250909031528-0279ad4ad300 h1:PnxMhAEkE3tEOnoj+CEhjZoauRXmUDwlndiJeKkfAZM=
 gitee.com/xuyiping_admin/go_proto v0.0.0-20250909031528-0279ad4ad300/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20250911063919-b4f2c741a7be h1:xeWwbWkT8lnJhSnVVLhRDnl9csnq4vV1R2ynYckMO+k=
+gitee.com/xuyiping_admin/go_proto v0.0.0-20250911063919-b4f2c741a7be/go.mod h1:BKrFW6YLDectlQcQk3FYKBeXvjEiodAKJ5rq7O/QiPE=
 gitee.com/xuyiping_admin/pkg v0.0.0-20250613101634-36c36a2d27d0 h1:ZCOqEAnGm6+DTAhACigzWKbwMKtleb8/7OzP2xfHG7g=
 gitee.com/xuyiping_admin/pkg v0.0.0-20250613101634-36c36a2d27d0/go.mod h1:8tF25X6pE9WkFCczlNAC0K2mrjwKvhhp02I7o0HtDxY=
 github.com/BurntSushi/toml v0.3.0/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=

+ 2 - 1
http/handler/system/user.go

@@ -30,7 +30,8 @@ func Login(c *gin.Context) {
 		return
 	}
 
-	res, err := middleware.Dependency(c).StoreEventHub.OpsService.Login(c, &req)
+	platform := c.GetHeader("Platform")
+	res, err := middleware.Dependency(c).StoreEventHub.OpsService.Login(c, platform, &req)
 	if err != nil {
 		apierr.ClassifiedAbort(c, err)
 		return

+ 7 - 5
model/neck_ring_estrus_warning.go

@@ -110,11 +110,13 @@ func (n NeckRingEstrusWarningSlice) ToPB(
 					break
 				}
 			}
-		} else {
+		}
+
+		if matingWindowPeriodKind > pasturePb.MatingWindowPeriod_Invalid {
 			found = isIPeriod(matingWindowPeriodKind, nowTime, optimumMatingStartTime, optimumMatingEndTime)
 		}
 
-		if !found {
+		if found {
 			continue
 		}
 
@@ -155,11 +157,11 @@ func (n NeckRingEstrusWarningSlice) ToPB(
 func isIPeriod(periodKind pasturePb.MatingWindowPeriod_Kind, nowTime, optimumMatingStartTime, optimumMatingEndTime time.Time) bool {
 	switch periodKind {
 	case pasturePb.MatingWindowPeriod_Front:
-		return nowTime.Before(optimumMatingStartTime)
+		return !nowTime.Before(optimumMatingStartTime)
 	case pasturePb.MatingWindowPeriod_Middle:
-		return nowTime.After(optimumMatingStartTime) && nowTime.Before(optimumMatingEndTime)
+		return !(nowTime.After(optimumMatingStartTime) && nowTime.Before(optimumMatingEndTime))
 	case pasturePb.MatingWindowPeriod_Behind:
-		return nowTime.After(optimumMatingEndTime)
+		return !(nowTime.After(optimumMatingEndTime))
 	default:
 		return false
 	}

+ 1 - 1
module/backend/interface.go

@@ -67,7 +67,7 @@ type KptService interface {
 //go:generate mockgen -destination mock/SystemService.go -package kptservicemock kpt-pasture/module/backend SystemService
 type SystemService interface {
 	// Login 系统用户相关
-	Login(ctx context.Context, req *pasturePb.SearchUserRequest) (*pasturePb.SystemUserResponse, error)
+	Login(ctx context.Context, platform string, req *pasturePb.SearchUserRequest) (*pasturePb.SystemUserResponse, error)
 	SearchSystemUserList(ctx context.Context, req *pasturePb.SearchUserRequest, pagination *pasturePb.PaginationModel) (*pasturePb.SearchUserResponse, error)
 	IsShowSystemUser(ctx context.Context, userId int64) error
 	DeleteSystemUser(ctx context.Context, userId int64) error

+ 7 - 1
module/backend/system_service.go

@@ -30,7 +30,7 @@ const (
 )
 
 // Login 用户登录
-func (s *StoreEntry) Login(ctx context.Context, req *pasturePb.SearchUserRequest) (*pasturePb.SystemUserResponse, error) {
+func (s *StoreEntry) Login(ctx context.Context, platform string, req *pasturePb.SearchUserRequest) (*pasturePb.SystemUserResponse, error) {
 	i18nTemplate, err := s.GetI18nTemplate(ctx)
 	if err != nil {
 		return nil, xerr.WithStack(err)
@@ -116,6 +116,11 @@ func (s *StoreEntry) Login(ctx context.Context, req *pasturePb.SearchUserRequest
 		roleNameList = append(roleNameList, role.Name)
 	}
 
+	userId := int32(0)
+	if platform == "h5" {
+		userId = int32(systemUser.Id)
+	}
+
 	return &pasturePb.SystemUserResponse{
 		Code: http.StatusOK,
 		Msg:  "ok",
@@ -128,6 +133,7 @@ func (s *StoreEntry) Login(ctx context.Context, req *pasturePb.SearchUserRequest
 			Avatar:       systemUser.Avatar,
 			FarmId:       farmList[0].FarmId,
 			FarmName:     farmList[0].Name,
+			UserId:       userId,
 		},
 	}, nil
 }