From 4741e43ec53ab92bca722e518cf039c8e784aa77 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Wed, 13 Nov 2024 11:50:31 +0800 Subject: [PATCH] update and add total data --- src/dao/egg_energy_fund_data_dao.go | 3 ++ src/dao/egg_energy_fund_data_records_dao.go | 3 ++ src/dao/egg_energy_price_dao.go | 8 +++++ ..._energy_available_energy_flow_implement.go | 4 +-- .../egg_energy_basic_setting_implement.go | 2 +- ...gg_energy_community_dividends_implement.go | 8 ++--- .../egg_energy_fund_data_implement.go | 21 +++++++++++++ .../egg_energy_fund_data_records_implement.go | 11 +++++++ src/implement/egg_energy_price_implement.go | 30 +++++++++++++++++++ .../user_virtual_coin_flow_implement.go | 2 +- src/model/egg_energy_price.go | 8 +++++ 11 files changed, 92 insertions(+), 8 deletions(-) create mode 100644 src/dao/egg_energy_price_dao.go create mode 100644 src/implement/egg_energy_price_implement.go create mode 100644 src/model/egg_energy_price.go diff --git a/src/dao/egg_energy_fund_data_dao.go b/src/dao/egg_energy_fund_data_dao.go index 23f49c6..f02051d 100644 --- a/src/dao/egg_energy_fund_data_dao.go +++ b/src/dao/egg_energy_fund_data_dao.go @@ -1,5 +1,8 @@ package dao +import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + type EggEnergyFundDataDao interface { //TODO:: You can add specific method definitions here + EggEnergyFundDataFindAndCount(page, limit, kind int, startAt, endAt string) ([]model.EggEnergyFundData, int64, error) } diff --git a/src/dao/egg_energy_fund_data_records_dao.go b/src/dao/egg_energy_fund_data_records_dao.go index d00fb08..9257e26 100644 --- a/src/dao/egg_energy_fund_data_records_dao.go +++ b/src/dao/egg_energy_fund_data_records_dao.go @@ -1,5 +1,8 @@ package dao +import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + type EggEnergyFundDataRecordsDao interface { //TODO:: You can add specific method definitions here + EggEnergyFundDataRecordsFindAndCount(page, limit int, recordsID int) ([]model.EggEnergyFundDataRecords, int64, error) } diff --git a/src/dao/egg_energy_price_dao.go b/src/dao/egg_energy_price_dao.go new file mode 100644 index 0000000..3eeedb4 --- /dev/null +++ b/src/dao/egg_energy_price_dao.go @@ -0,0 +1,8 @@ +package dao + +import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + +type EggEnergyPriceDao interface { + //TODO:: You can add specific method definitions here + EggEnergyPriceList(startAt string, endAt string, hour string) ([]model.EggEnergyPrice, error) +} diff --git a/src/implement/egg_energy_available_energy_flow_implement.go b/src/implement/egg_energy_available_energy_flow_implement.go index e39029d..d9367a7 100644 --- a/src/implement/egg_energy_available_energy_flow_implement.go +++ b/src/implement/egg_energy_available_energy_flow_implement.go @@ -30,10 +30,10 @@ func (e EggEnergyAvailableEnergyFlowDb) EggEnergyAvailableEnergyFlowFindAndCount session = session.And("kind = ?", kind) } if startAt != "" { - session = session.Where("create_time > ?", startAt) + session = session.Where("create_time >= ?", startAt) } if endAt != "" { - session = session.Where("create_time < ?", endAt) + session = session.Where("create_time <= ?", endAt) } total, err := session.Limit(pageSize, (page-1)*pageSize).Desc("create_time").FindAndCount(&m) if err != nil { diff --git a/src/implement/egg_energy_basic_setting_implement.go b/src/implement/egg_energy_basic_setting_implement.go index af077e3..b324d1e 100644 --- a/src/implement/egg_energy_basic_setting_implement.go +++ b/src/implement/egg_energy_basic_setting_implement.go @@ -43,7 +43,7 @@ func (e EggEnergyBasicSettingDb) EggEnergyBasicSettingGetOneByParams(params map[ func (e EggEnergyBasicSettingDb) EggEnergyBasicSettingGetOne() (*model.EggEnergyBasicSetting, error) { var m *model.EggEnergyBasicSetting - _, err := e.Db.Where("id > ?", 1).Get(&m) + _, err := e.Db.Where("id >= ?", 1).Get(&m) if err != nil { return nil, zhios_order_relate_logx.Error(err.Error()) } diff --git a/src/implement/egg_energy_community_dividends_implement.go b/src/implement/egg_energy_community_dividends_implement.go index c83c58d..dc1c473 100644 --- a/src/implement/egg_energy_community_dividends_implement.go +++ b/src/implement/egg_energy_community_dividends_implement.go @@ -27,16 +27,16 @@ func (e EggEnergyCommunityDividendsDb) EggEnergyCommunityDividendsFindAndCount(p var m []*model.EggEnergyCommunityDividends session := e.Db.Where("") if startAt != "" { - session = session.And("create_at > ?", startAt) + session = session.And("create_at >= ?", startAt) } if endAt != "" { - session = session.And("create_at < ?", endAt) + session = session.And("create_at <= ?", endAt) } if startNums != 0 { - session = session.And("nums > ?", startNums) + session = session.And("nums >= ?", startNums) } if endNums != 0 { - session = session.And("nums < ?", endNums) + session = session.And("nums <= ?", endNums) } total, err := session.Limit(limit, (page-1)*limit).FindAndCount(&m) if err != nil { diff --git a/src/implement/egg_energy_fund_data_implement.go b/src/implement/egg_energy_fund_data_implement.go index a012990..eb48f4a 100644 --- a/src/implement/egg_energy_fund_data_implement.go +++ b/src/implement/egg_energy_fund_data_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 NewEggEnergyFundDataDb(engine *xorm.Engine) dao.EggEnergyFundDataDao { type EggEnergyFundDataDb struct { Db *xorm.Engine } + +func (e EggEnergyFundDataDb) EggEnergyFundDataFindAndCount(page, limit, kind int, startAt, endAt string) ([]model.EggEnergyFundData, int64, error) { + var m []model.EggEnergyFundData + session := e.Db.Where("") + if kind > 0 { + session = session.Where("kind = ?", kind) + } + if startAt != "" { + session = session.Where("start_at >= ?", startAt) + } + if endAt != "" { + session = session.Where("end_at <= ?", endAt) + } + total, err := session.Limit(limit, (page-1)*limit).FindAndCount(&m) + if err != nil { + return nil, 0, zhios_order_relate_logx.Error(err.Error()) + } + return m, total, nil +} diff --git a/src/implement/egg_energy_fund_data_records_implement.go b/src/implement/egg_energy_fund_data_records_implement.go index b2abb89..f0585e0 100644 --- a/src/implement/egg_energy_fund_data_records_implement.go +++ b/src/implement/egg_energy_fund_data_records_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,12 @@ func NewEggEnergyFundDataRecordsDb(engine *xorm.Engine) dao.EggEnergyFundDataRec type EggEnergyFundDataRecordsDb struct { Db *xorm.Engine } + +func (e EggEnergyFundDataRecordsDb) EggEnergyFundDataRecordsFindAndCount(page, limit int, recordsID int) ([]model.EggEnergyFundDataRecords, int64, error) { + var m []model.EggEnergyFundDataRecords + total, err := e.Db.Where("records_id = ?", recordsID).Limit(limit, (page-1)*limit).FindAndCount(&m) + if err != nil { + return nil, 0, zhios_order_relate_logx.Error(err.Error()) + } + return m, total, nil +} diff --git a/src/implement/egg_energy_price_implement.go b/src/implement/egg_energy_price_implement.go new file mode 100644 index 0000000..0a70eeb --- /dev/null +++ b/src/implement/egg_energy_price_implement.go @@ -0,0 +1,30 @@ +package implement + +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" + "errors" + "xorm.io/xorm" +) + +func NewEggEnergyPriceDb(engine *xorm.Engine) dao.EggEnergyPriceDao { + return &EggEnergyPriceDb{Db: engine} +} + +type EggEnergyPriceDb struct { + Db *xorm.Engine +} + +func (e EggEnergyPriceDb) EggEnergyPriceList(startAt string, endAt string, hour string) ([]model.EggEnergyPrice, error) { + if startAt == "" || endAt == "" { + return nil, zhios_order_relate_logx.Error(errors.New("startAt or endAt can not be empty").Error()) + } + + var m []model.EggEnergyPrice + err := e.Db.Where("date >= ?", startAt).And("date <= ?", endAt).And("hour = ?", hour).Find(&m) + if err != nil { + return nil, zhios_order_relate_logx.Error(err.Error()) + } + return m, nil +} diff --git a/src/implement/user_virtual_coin_flow_implement.go b/src/implement/user_virtual_coin_flow_implement.go index ae5a095..a49edfc 100644 --- a/src/implement/user_virtual_coin_flow_implement.go +++ b/src/implement/user_virtual_coin_flow_implement.go @@ -24,7 +24,7 @@ func (u UserVirtualCoinFlowDb) UserVirtualCoinFlowInsertBySession(session *xorm. func (u UserVirtualCoinFlowDb) UserVirtualCoinFlowFindByCoinAndUser(page, pageSize int, coinID int, uid int64, startAt string, endAt string, direction int) ([]model.UserVirtualCoinFlow, int64, error) { var m []model.UserVirtualCoinFlow - session := u.Db.Where("uid = ?", uid).And("coin_id = ?", coinID).And("create_at > ?", startAt).And("create_at < ?", endAt) + session := u.Db.Where("uid = ?", uid).And("coin_id = ?", coinID).And("create_at >= ?", startAt).And("create_at <= ?", endAt) if direction != 0 { session = session.And("direction = ?", direction) } diff --git a/src/model/egg_energy_price.go b/src/model/egg_energy_price.go new file mode 100644 index 0000000..75fa1db --- /dev/null +++ b/src/model/egg_energy_price.go @@ -0,0 +1,8 @@ +package model + +type EggEnergyPrice struct { + Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` + Price string `json:"price" xorm:"not null default 0.0000000000 comment('价格') DECIMAL(28,10)"` + Date string `json:"date" xorm:"not null default '0000-00-00' comment('日期') CHAR(50)"` + Hour string `json:"hour" xorm:"not null default '00' comment('小时') CHAR(50)"` +}