|
@@ -0,0 +1,35 @@ |
|
|
|
|
|
package implement |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
|
"code.fnuoos.com/zhimeng/model.git/src/dao" |
|
|
|
|
|
"code.fnuoos.com/zhimeng/model.git/src/model" |
|
|
|
|
|
"xorm.io/xorm" |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func NewAdminBindMediumDb(engine *xorm.Engine) dao.AdminBindMediumDao { |
|
|
|
|
|
return &AdminBindMediumDb{Db: engine} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type AdminBindMediumDb struct { |
|
|
|
|
|
Db *xorm.Engine |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (a AdminBindMediumDb) FindAll(adminId int) (list []model.AdminBindMedium) { |
|
|
|
|
|
sess := a.Db.Where("admin_id=?", adminId) |
|
|
|
|
|
err := sess.Find(&list) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil |
|
|
|
|
|
} |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
func (a AdminBindMediumDb) FindMediumList(mediumId []int, adminId, page, limit int) (list []model.AdminBindMedium, total int64, err error) { |
|
|
|
|
|
sess := a.Db.Where("admin_id=?", adminId).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 |
|
|
|
|
|
} |