From 2a209e73d216ae9a14bfdf1efc3b5064cb0f0f8f Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Mon, 4 Nov 2024 14:21:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dao/agent_dao.go | 2 ++ src/implement/agent_implement.go | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/dao/agent_dao.go b/src/dao/agent_dao.go index 27866b6..885b41b 100644 --- a/src/dao/agent_dao.go +++ b/src/dao/agent_dao.go @@ -16,6 +16,8 @@ type AgentDao interface { FindAgentRolePermissionGroup(id int) (list []*AgentWithRolePermissionGroup, total int64, err error) GetSuperAdmin(agentId int) (list *model.Agent) GetSuperAgentByUsername(username string) (agent *model.Agent, err error) + FindSuperAdminByAgebtId(agentId string, page, limit int) (list []model.Agent, total int64, err error) + FindAllSuperAdmin() (list *[]model.Agent) } type AgentWithRolePermissionGroup struct { diff --git a/src/implement/agent_implement.go b/src/implement/agent_implement.go index 8d9ec6a..283866f 100644 --- a/src/implement/agent_implement.go +++ b/src/implement/agent_implement.go @@ -5,6 +5,7 @@ import ( "code.fnuoos.com/zhimeng/model.git/src/model" zhios_order_relate_logx "code.fnuoos.com/zhimeng/model.git/utils/logx" "reflect" + "strings" "xorm.io/xorm" ) @@ -118,3 +119,23 @@ func (a AgentDb) GetSuperAgentByUsername(username string) (agent *model.Agent, e } return agent, nil } +func (a AgentDb) FindSuperAdminByAgebtId(agentId string, page, limit int) (list []model.Agent, total int64, err error) { + sess := a.Db.Where("is_super_administrator=1").Desc("id").Limit(limit, (page-1)*limit) + if agentId != "" { + sess.In("agent_id", strings.Split(agentId, ",")) + } + total, err = sess.FindAndCount(&list) + if err != nil { + return nil, 0, err + } + return +} +func (a AgentDb) FindAllSuperAdmin() (list *[]model.Agent) { + list = &[]model.Agent{} + sess := a.Db.Where("is_super_administrator=1") + err := sess.Find(list) + if err != nil { + return nil + } + return list +}