liuxiran commented on a change in pull request #432:
URL: https://github.com/apache/apisix-dashboard/pull/432#discussion_r481901228



##########
File path: api/service/route_group.go
##########
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package service
+
+import (
+       "encoding/json"
+       "github.com/apisix/manager-api/conf"
+       "github.com/apisix/manager-api/errno"
+       uuid "github.com/satori/go.uuid"
+)
+
+type RouteGroupDao struct {
+       Base
+       Name        string `json:"name"`
+       Description string `json:"description,omitempty"`
+}
+
+func (RouteGroupDao) TableName() string {
+       return "route_group"
+}
+
+func (rd *RouteGroupDao) CreateRouteGroup() error {
+       return conf.DB().Create(&rd).Error
+}
+
+func (rd *RouteGroupDao) FindRouteGroup(id string) (error, int) {
+       var count int
+       if err := conf.DB().Table("route_group").Where("id=?", 
id).Count(&count).Error; err != nil {
+               return err, 0
+       }
+       conf.DB().Table("route_group").Where("id=?", id).First(&rd)
+       return nil, count
+}
+
+func (rd *RouteGroupDao) GetRouteGroupList(routeGroupList *[]RouteGroupDao, 
search string, page, size int) (error, int) {
+       db := conf.DB()
+       db = db.Table(rd.TableName())
+       if len(search) != 0 {
+               db = db.Where("name like ? or description like ? ", search, 
search)
+       }
+       var count int
+       if err := db.Order("update_time desc").Offset((page - 1) * 
size).Limit(size).Find(&routeGroupList).Error; err != nil {
+               return err, 0
+       } else {
+               if err := db.Count(&count).Error; err != nil {
+                       return err, 0
+               }
+               return nil, count
+       }
+}
+
+func (rd *RouteGroupDao) UpdateRouteGroup() error {
+       db := conf.DB()
+       return db.Model(&RouteGroupDao{}).Update(rd).Error
+}
+
+func (rd *RouteGroupDao) DeleteRouteGroup() error {
+       return conf.DB().Delete(&rd).Error

Review comment:
       this check has been put in the route before, and tansfered to the 
service after updated :)




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to