From 676f8850f033795d8939d3ffb1e12339bdc3eae9 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Mon, 25 Nov 2024 09:58:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9E=81=E5=85=89=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dao/jpush_notice_dao.go | 1 + src/dao/jpush_record_dao.go | 1 + src/implement/jpush_notice_implement.go | 13 +++++++++++++ src/implement/jpush_record_implement.go | 13 +++++++++++++ 4 files changed, 28 insertions(+) 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 +}