package pasture import ( "kpt-tmr-group/http/middleware" "kpt-tmr-group/pkg/apierr" "kpt-tmr-group/pkg/apiok" operationPb "kpt-tmr-group/proto/go/backend/operation" "net/http" "github.com/gin-gonic/gin" ) func AddPasture(c *gin.Context) { req := make([]*operationPb.AddPastureRequest, 0) if err := c.BindJSON(&req); err != nil { apierr.AbortBadRequest(c, http.StatusBadRequest, err) return } if err := middleware.BackendOperation(c).OpsService.CreatePastureList(c, req); err != nil { apierr.ClassifiedAbort(c, err) return } c.JSON(http.StatusOK, apiok.CommonResponse(apiok.NewApiOk(true))) } func SearchPastureList(c *gin.Context) { req := &operationPb.SearchPastureRequest{} if err := c.BindJSON(req); err != nil { apierr.AbortBadRequest(c, http.StatusBadRequest, err) return } res, err := middleware.BackendOperation(c).OpsService.SearchPastureList(c, req) if err != nil { apierr.ClassifiedAbort(c, err) return } c.JSON(http.StatusOK, apiok.CommonResponse(res.ToPB())) }