From 0a49428505ebbdfe1c463312f723b86fe83846f5 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Tue, 12 Nov 2024 17:02:48 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E6=9F=A5=E8=AF=A2=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../egg_energy_available_energy_flow_dao.go | 3 +++ ..._energy_available_energy_flow_implement.go | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/dao/egg_energy_available_energy_flow_dao.go b/src/dao/egg_energy_available_energy_flow_dao.go index 077ab9e..2513759 100644 --- a/src/dao/egg_energy_available_energy_flow_dao.go +++ b/src/dao/egg_energy_available_energy_flow_dao.go @@ -1,5 +1,8 @@ package dao +import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + type EggEnergyAvailableEnergyFlowDao interface { //TODO:: You can add specific method definitions here + EggEnergyAvailableEnergyFlowFindAndCount(kind, page, pageSize int, startAt, endAt string) ([]*model.EggEnergyAvailableEnergyFlow, int64, error) } diff --git a/src/implement/egg_energy_available_energy_flow_implement.go b/src/implement/egg_energy_available_energy_flow_implement.go index 76d52fe..607224c 100644 --- a/src/implement/egg_energy_available_energy_flow_implement.go +++ b/src/implement/egg_energy_available_energy_flow_implement.go @@ -2,6 +2,8 @@ import ( "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" + "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" "xorm.io/xorm" ) @@ -12,3 +14,22 @@ func NewEggEnergyAvailableEnergyFlowDb(engine *xorm.Engine) dao.EggEnergyAvailab type EggEnergyAvailableEnergyFlowDb struct { Db *xorm.Engine } + +func (e EggEnergyAvailableEnergyFlowDb) EggEnergyAvailableEnergyFlowFindAndCount(kind, page, pageSize int, startAt, endAt string) ([]*model.EggEnergyAvailableEnergyFlow, int64, error) { + var m []*model.EggEnergyAvailableEnergyFlow + session := e.Db.Where("") + if kind > 0 { + session = session.And("kind = ?", kind) + } + if startAt != "" { + session = session.Where("create_time > ?", startAt) + } + if endAt != "" { + session = session.Where("create_time < ?", endAt) + } + total, err := session.Limit(pageSize, (page-1)*pageSize).Desc("create_time").FindAndCount(&m) + if err != nil { + return nil, 0, zhios_order_relate_logx.Error(err.Error()) + } + return m, total, nil +}