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 +}