|
@@ -255,3 +255,51 @@ func CreatedOrUpdateCowStatus(c *gin.Context) {
|
|
|
Data: &operationPb.Success{Success: true},
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+func SearchCowTypeList(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.SearchCowTypeList(c, &req, pagination)
|
|
|
+ if err != nil {
|
|
|
+ apierr.ClassifiedAbort(c, err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ ginutil.JSONResp(c, res)
|
|
|
+}
|
|
|
+
|
|
|
+// CreatedOrUpdateCowType 添加或者更新牛只分类
|
|
|
+func CreatedOrUpdateCowType(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.CreateOrUpdateCowType(c, &req); err != nil {
|
|
|
+ apierr.ClassifiedAbort(c, err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ ginutil.JSONResp(c, &operationPb.CommonOK{
|
|
|
+ Code: http.StatusOK,
|
|
|
+ Msg: "ok",
|
|
|
+ Data: &operationPb.Success{Success: true},
|
|
|
+ })
|
|
|
+}
|