|
|
@@ -0,0 +1,44 @@ |
|
|
|
package implement |
|
|
|
|
|
|
|
import ( |
|
|
|
"code.fnuoos.com/zhimeng/model.git/src/dao" |
|
|
|
"code.fnuoos.com/zhimeng/model.git/src/model" |
|
|
|
"strings" |
|
|
|
"xorm.io/xorm" |
|
|
|
) |
|
|
|
|
|
|
|
func NewAdminBindAgentDb(engine *xorm.Engine) dao.AdminBindAgentDao { |
|
|
|
return &AdminBindAgentDb{Db: engine} |
|
|
|
} |
|
|
|
|
|
|
|
type AdminBindAgentDb struct { |
|
|
|
Db *xorm.Engine |
|
|
|
} |
|
|
|
|
|
|
|
func (a AdminBindAgentDb) FindAll(adminId int) (list []model.AdminBindAgent) { |
|
|
|
sess := a.Db.Where("admin_id=?", adminId) |
|
|
|
err := sess.Find(&list) |
|
|
|
if err != nil { |
|
|
|
return nil |
|
|
|
} |
|
|
|
return |
|
|
|
} |
|
|
|
func (a AdminBindAgentDb) GetAdminByAgentId(adminId, agentId int) (list *model.AdminBindAgent) { |
|
|
|
sess := a.Db.Where("agent_id=? and admin_id=?", agentId, adminId) |
|
|
|
get, err := sess.Get(&list) |
|
|
|
if get == false || err != nil { |
|
|
|
return nil |
|
|
|
} |
|
|
|
return |
|
|
|
} |
|
|
|
func (a AdminBindAgentDb) FindAgentList(agentId string, adminId, page, limit int) (list []model.AdminBindAgent, total int64, err error) { |
|
|
|
sess := a.Db.Where("admin_id=?", adminId).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 |
|
|
|
} |