package analysis import ( "kpt-pasture/http/middleware" "net/http" "gitee.com/xuyiping_admin/pkg/valid" pasturePb "gitee.com/xuyiping_admin/go_proto/proto/go/backend/cow" "gitee.com/xuyiping_admin/pkg/apierr" "gitee.com/xuyiping_admin/pkg/ginutil" "github.com/gin-gonic/gin" ) func GrowthCurve(c *gin.Context) { var req pasturePb.SearchGrowthCurvesRequest if err := ginutil.BindProto(c, &req); err != nil { apierr.AbortBadRequest(c, http.StatusBadRequest, err) return } res, err := middleware.Dependency(c).StoreEventHub.OpsService.GrowthCurve(c, &req) if err != nil { apierr.ClassifiedAbort(c, err) return } ginutil.JSONResp(c, res) } func WeightRange(c *gin.Context) { var req pasturePb.WeightRangeRequest if err := ginutil.BindProto(c, &req); err != nil { apierr.AbortBadRequest(c, http.StatusBadRequest, err) return } if err := valid.ValidateStruct(&req, valid.Field(&req.MaxWeight, valid.Required), ); err != nil { apierr.AbortBadRequest(c, http.StatusBadRequest, err) return } res, err := middleware.Dependency(c).StoreEventHub.OpsService.WeightRange(c, &req) if err != nil { apierr.ClassifiedAbort(c, err) return } ginutil.JSONResp(c, res) } func MatingTimeLy(c *gin.Context) { var req pasturePb.MatingTimelyRequest if err := ginutil.BindProto(c, &req); err != nil { apierr.AbortBadRequest(c, http.StatusBadRequest, err) return } if err := valid.ValidateStruct(&req, valid.Field(&req.StartDayAt, valid.Required), valid.Field(&req.EndDayAt, valid.Required), valid.Field(&req.CowType, valid.Required), ); err != nil { apierr.AbortBadRequest(c, http.StatusBadRequest, err) return } res, err := middleware.Dependency(c).StoreEventHub.OpsService.MatingTimely(c, &req) if err != nil { apierr.ClassifiedAbort(c, err) return } c.JSON(http.StatusOK, res) } func PenWeight(c *gin.Context) { var req pasturePb.PenWeightRequest if err := ginutil.BindProto(c, &req); err != nil { apierr.AbortBadRequest(c, http.StatusBadRequest, err) return } res, err := middleware.Dependency(c).StoreEventHub.OpsService.PenWeight(c, &req) if err != nil { apierr.ClassifiedAbort(c, err) return } ginutil.JSONResp(c, res) }