|
@@ -14,7 +14,7 @@ import (
|
|
|
)
|
|
|
|
|
|
func SearchBarnList(c *gin.Context) {
|
|
|
- var req pasturePb.SearchBarnRequest
|
|
|
+ var req pasturePb.SearchNameRequest
|
|
|
if err := ginutil.BindProto(c, &req); err != nil {
|
|
|
apierr.AbortBadRequest(c, http.StatusBadRequest, err)
|
|
|
return
|
|
@@ -63,3 +63,51 @@ func CreatedOrUpdateBarn(c *gin.Context) {
|
|
|
Data: &operationPb.Success{Success: true},
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+func SearchBarnTypeList(c *gin.Context) {
|
|
|
+ var req pasturePb.SearchNameRequest
|
|
|
+ if err := ginutil.BindProto(c, &req); err != nil {
|
|
|
+ apierr.AbortBadRequest(c, http.StatusBadRequest, err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ pagination := &pasturePb.PaginationModel{
|
|
|
+ Page: int32(c.GetInt(middleware.Page)),
|
|
|
+ PageSize: int32(c.GetInt(middleware.PageSize)),
|
|
|
+ PageOffset: int32(c.GetInt(middleware.PageOffset)),
|
|
|
+ }
|
|
|
+
|
|
|
+ res, err := middleware.Dependency(c).StoreEventHub.OpsService.SearchBarnTypeList(c, &req, pagination)
|
|
|
+ if err != nil {
|
|
|
+ apierr.ClassifiedAbort(c, err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ ginutil.JSONResp(c, res)
|
|
|
+}
|
|
|
+
|
|
|
+// CreatedOrUpdateBarnType 添加或者更新栏舍类型
|
|
|
+func CreatedOrUpdateBarnType(c *gin.Context) {
|
|
|
+ var req pasturePb.SearchBaseConfigList
|
|
|
+ if err := ginutil.BindProto(c, &req); err != nil {
|
|
|
+ apierr.AbortBadRequest(c, http.StatusBadRequest, err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if err := valid.ValidateStruct(&req,
|
|
|
+ valid.Field(&req.Name, valid.Required),
|
|
|
+ ); err != nil {
|
|
|
+ apierr.AbortBadRequest(c, http.StatusBadRequest, err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if err := middleware.BackendOperation(c).OpsService.CreateOrUpdateBarnType(c, &req); err != nil {
|
|
|
+ apierr.ClassifiedAbort(c, err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ ginutil.JSONResp(c, &operationPb.CommonOK{
|
|
|
+ Code: http.StatusOK,
|
|
|
+ Msg: "ok",
|
|
|
+ Data: &operationPb.Success{Success: true},
|
|
|
+ })
|
|
|
+}
|