123456789101112131415161718192021222324252627282930313233343536373839 |
- 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 AddSystemPasture(c *gin.Context) {
- var req operationPb.AddPastureRequest
- if err := c.BindJSON(&req); err != nil {
- apierr.AbortBadRequest(c, http.StatusBadRequest, err)
- return
- }
- if err := middleware.BackendOperation(c).OpsService.CreatePasture(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()))
- }
|