diff --git a/src/dao/jpush_notice_dao.go b/src/dao/jpush_notice_dao.go index 1a3b7a3..860503c 100644 --- a/src/dao/jpush_notice_dao.go +++ b/src/dao/jpush_notice_dao.go @@ -5,4 +5,5 @@ import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" type JpushNoticeDao interface { GetJpushNotice(id string) (m *model.JpushNotice, err error) FindJpushNotice(page, limit, types string) (*[]model.JpushNotice, error) + FindJpushNoticeAndTotal(page, limit, types string) (*[]model.JpushNotice, int64, error) } diff --git a/src/dao/jpush_record_dao.go b/src/dao/jpush_record_dao.go index 0721136..d4d390e 100644 --- a/src/dao/jpush_record_dao.go +++ b/src/dao/jpush_record_dao.go @@ -5,4 +5,5 @@ import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" type JpushRecordDao interface { GetJpushRecord(id string) (m *model.JpushRecord, err error) FindJpushRecord(page, limit, title string) (*[]model.JpushRecord, error) + FindJpushRecordAndTotal(page, limit, title string) (*[]model.JpushRecord, int64, error) } diff --git a/src/implement/jpush_notice_implement.go b/src/implement/jpush_notice_implement.go index 5784739..11c6158 100644 --- a/src/implement/jpush_notice_implement.go +++ b/src/implement/jpush_notice_implement.go @@ -40,3 +40,16 @@ func (j JpushNoticeDb) FindJpushNotice(page, limit, types string) (*[]model.Jpus } return &m, nil } +func (j JpushNoticeDb) FindJpushNoticeAndTotal(page, limit, types string) (*[]model.JpushNotice, int64, error) { + var m []model.JpushNotice + sess := j.Db.Where("1=1") + start := (zhios_order_relate_utils.StrToInt(page) - 1) * zhios_order_relate_utils.StrToInt(limit) + if types != "" { + sess.In("type", strings.Split(types, ",")) + } + count, err := sess.Limit(zhios_order_relate_utils.StrToInt(limit), start).FindAndCount(&m) + if err != nil { + return nil, count, zhios_order_relate_logx.Error(err) + } + return &m, count, nil +} diff --git a/src/implement/jpush_record_implement.go b/src/implement/jpush_record_implement.go index 182c0a9..9920438 100644 --- a/src/implement/jpush_record_implement.go +++ b/src/implement/jpush_record_implement.go @@ -39,3 +39,16 @@ func (j JpushRecordDb) FindJpushRecord(page, limit, title string) (*[]model.Jpus } return &m, nil } +func (j JpushRecordDb) FindJpushRecordAndTotal(page, limit, title string) (*[]model.JpushRecord, int64, error) { + var m []model.JpushRecord + sess := j.Db.Where("1=1") + start := (zhios_order_relate_utils.StrToInt(page) - 1) * zhios_order_relate_utils.StrToInt(limit) + if title != "" { + sess.And("title like ?", "%"+title+"%") + } + count, err := sess.Limit(zhios_order_relate_utils.StrToInt(limit), start).FindAndCount(&m) + if err != nil { + return nil, count, zhios_order_relate_logx.Error(err) + } + return &m, count, nil +}