diff --git a/src/dao/medium_dao.go b/src/dao/medium_dao.go index d497dc6..c0f7d5c 100644 --- a/src/dao/medium_dao.go +++ b/src/dao/medium_dao.go @@ -15,6 +15,7 @@ type MediumDao interface { GetMedium(id int) (m *model.Medium, err error) FindMediumRolePermissionGroup(id int) (list []*MediumWithRolePermissionGroup, total int64, err error) FindSuperAdmin(username, memo string, page, limit int) (list []model.Medium, total int64, err error) + FindSuperAdminByMediumId(mediumId []int, page, limit int) (list []model.Medium, total int64, err error) GetSuperAdmin(mediumId int) (list *model.Medium) } diff --git a/src/implement/medium_implement.go b/src/implement/medium_implement.go index 1d31a5c..bf7e1cf 100644 --- a/src/implement/medium_implement.go +++ b/src/implement/medium_implement.go @@ -112,6 +112,17 @@ func (m MediumDb) FindSuperAdmin(username, memo string, page, limit int) (list [ } return } +func (m MediumDb) FindSuperAdminByMediumId(mediumId []int, page, limit int) (list []model.Medium, total int64, err error) { + sess := m.Db.Where("is_super_administrator=1").Desc("id").Limit(limit, (page-1)*limit) + if len(mediumId) > 0 { + sess.In("medium_id", mediumId) + } + total, err = sess.FindAndCount(&list) + if err != nil { + return nil, 0, err + } + return +} func (m MediumDb) GetSuperAdmin(mediumId int) (list *model.Medium) { list = new(model.Medium) sess := m.Db.Where("is_super_administrator=1 and medium_id=?", mediumId)