From 5527f6386afb0cf37cc893f8a2cfde3b90dfefbe Mon Sep 17 00:00:00 2001 From: wanghaima Date: Sun, 7 May 2023 18:47:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96API=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/service/dto/sys_api.go | 5 ++--- app/admin/service/sys_api.go | 13 ++++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/admin/service/dto/sys_api.go b/app/admin/service/dto/sys_api.go index 5e53d071..d26034ee 100644 --- a/app/admin/service/dto/sys_api.go +++ b/app/admin/service/dto/sys_api.go @@ -11,8 +11,9 @@ type SysApiGetPageReq struct { dto.Pagination `search:"-"` Title string `form:"title" search:"type:contains;column:title;table:sys_api" comment:"标题"` Path string `form:"path" search:"type:contains;column:path;table:sys_api" comment:"地址"` - Action string `form:"action" search:"type:exact;column:action;table:sys_api" comment:"类型"` + Action string `form:"action" search:"type:exact;column:action;table:sys_api" comment:"请求方式"` ParentId string `form:"parentId" search:"type:exact;column:parent_id;table:sys_api" comment:"按钮id"` + Type string `form:"type" search:"-" comment:"类型"` SysApiOrder } @@ -84,7 +85,6 @@ func (s *SysApiGetReq) GetId() interface{} { return s.Id } - // SysApiDeleteReq 功能删除请求参数 type SysApiDeleteReq struct { Ids []int `json:"ids"` @@ -93,4 +93,3 @@ type SysApiDeleteReq struct { func (s *SysApiDeleteReq) GetId() interface{} { return s.Ids } - diff --git a/app/admin/service/sys_api.go b/app/admin/service/sys_api.go index 1818a887..d8d6c350 100644 --- a/app/admin/service/sys_api.go +++ b/app/admin/service/sys_api.go @@ -23,13 +23,20 @@ func (e *SysApi) GetPage(c *dto.SysApiGetPageReq, p *actions.DataPermission, lis var err error var data models.SysApi - err = e.Orm.Debug().Model(&data). + orm := e.Orm.Debug().Model(&data). Scopes( cDto.MakeCondition(c.GetNeedSearch()), cDto.Paginate(c.GetPageSize(), c.GetPageIndex()), actions.Permission(data.TableName(), p), - ). - Find(list).Limit(-1).Offset(-1). + ) + if c.Type != "" { + qType := c.Type + if qType == "暂无" { + qType = "" + } + orm = orm.Where("`type` = ?", qType) + } + err = orm.Find(list).Limit(-1).Offset(-1). Count(count).Error if err != nil { e.Log.Errorf("Service GetSysApiPage error:%s", err)