robocanic commented on code in PR #1325:
URL: https://github.com/apache/dubbo-admin/pull/1325#discussion_r2365931424


##########
pkg/console/handler/tag_rule.go:
##########
@@ -20,66 +20,80 @@ package handler
 import (
        "fmt"
        "net/http"
-       "strconv"
        "strings"
 
+       "github.com/apache/dubbo-admin/pkg/core/manager"
+       meshresource 
"github.com/apache/dubbo-admin/pkg/core/resource/apis/mesh/v1alpha1"
+       coremodel "github.com/apache/dubbo-admin/pkg/core/resource/model"
+       "github.com/apache/dubbo-admin/pkg/core/store/index"
+       "github.com/duke-git/lancet/v2/strutil"
        "github.com/gin-gonic/gin"
 
-       meshproto "github.com/apache/dubbo-admin/api/mesh/v1alpha1"
        consolectx "github.com/apache/dubbo-admin/pkg/console/context"
        "github.com/apache/dubbo-admin/pkg/console/model"
        "github.com/apache/dubbo-admin/pkg/console/service"
        "github.com/apache/dubbo-admin/pkg/core/consts"
-       "github.com/apache/dubbo-admin/pkg/core/store"
 )
 
 func TagRuleSearch(ctx consolectx.Context) gin.HandlerFunc {
        return func(c *gin.Context) {
+
                req := model.NewSearchReq()
                if err := c.ShouldBindQuery(req); err != nil {
                        c.JSON(http.StatusBadRequest, 
model.NewErrorResp(err.Error()))
                        return
                }
-               resList := &mesh.TagRouteResourceList{}
-               if req.Keywords == "" {
-                       if err := ctx.ResourceManager().List(ctx.AppContext(), 
resList, store.ListByPage(req.PageSize, strconv.Itoa(req.PageOffset))); err != 
nil {
-                               c.JSON(http.StatusBadRequest, 
model.NewErrorResp(err.Error()))
-                               return
-                       }
+               var pageData *coremodel.PageData[*meshresource.TagRouteResource]
+               var err error
+               if strutil.IsBlank(req.Keywords) {
+                       pageData, err = 
manager.PageListByIndexes[*meshresource.TagRouteResource](
+                               ctx.ResourceManager(),
+                               meshresource.TagRouteKind,
+                               map[string]interface{}{
+                                       index.ByMeshIndex: req.Mesh,
+                               },
+                               req.PageReq)
+
                } else {
-                       if err := ctx.ResourceManager().List(ctx.AppContext(), 
resList, store.ListByNameContains(req.Keywords), store.ListByPage(req.PageSize, 
strconv.Itoa(req.PageOffset))); err != nil {
-                               c.JSON(http.StatusBadRequest, 
model.NewErrorResp(err.Error()))
-                               return
-                       }
+                       pageData, err = 
manager.PageSearchResourceByConditions[*meshresource.TagRouteResource](
+                               ctx.ResourceManager(),
+                               meshresource.TagRouteKind,
+                               []string{"name=" + req.Keywords},
+                               req.PageReq,
+                       )
+
+               }
+               if err != nil {
+                       c.JSON(http.StatusInternalServerError, 
model.NewErrorResp(err.Error()))
+                       return
                }
-               var respList []model.TagRuleSearchResp
-               for _, item := range resList.Items {
-                       time := item.Meta.GetCreationTime().String()
-                       name := item.Meta.GetName()
-                       respList = append(respList, model.TagRuleSearchResp{
-                               CreateTime: &time,
-                               Enabled:    &item.Spec.Enabled,
-                               RuleName:   &name,
+               resp := model.NewSearchPaginationResult()
+               var list []*model.TagRuleSearchResp
+               for _, item := range pageData.Data {
+                       list = append(list, &model.TagRuleSearchResp{
+                               CreateTime: "",

Review Comment:
   CreateTime is a todo. There is no datasource for CreateTime yet. Will be 
filled in next pull requests



##########
pkg/core/resource/model/page.go:
##########
@@ -17,16 +17,49 @@
 
 package model
 
-type PageQuery struct {
-       PageSize    uint32
-       CurrentPage uint32
-       Page        bool
+type PageReq struct {
+       PageOffset int `form:"pageOffset" json:"pageOffset"`
+       PageSize   int `form:"pageSize" json:"pageSize"`
 }
 

Review Comment:
   Will be added in next pull requests



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org
For additional commands, e-mail: notifications-h...@dubbo.apache.org

Reply via email to