@@ -1,5 +1,8 @@ | |||||
package dao | |||||
package dao | |||||
import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" | |||||
type EggEnergyFundDataDao interface { | type EggEnergyFundDataDao interface { | ||||
//TODO:: You can add specific method definitions here | //TODO:: You can add specific method definitions here | ||||
EggEnergyFundDataFindAndCount(page, limit, kind int, startAt, endAt string) ([]model.EggEnergyFundData, int64, error) | |||||
} | } |
@@ -1,5 +1,8 @@ | |||||
package dao | |||||
package dao | |||||
import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" | |||||
type EggEnergyFundDataRecordsDao interface { | type EggEnergyFundDataRecordsDao interface { | ||||
//TODO:: You can add specific method definitions here | //TODO:: You can add specific method definitions here | ||||
EggEnergyFundDataRecordsFindAndCount(page, limit int, recordsID int) ([]model.EggEnergyFundDataRecords, int64, error) | |||||
} | } |
@@ -1,5 +1,8 @@ | |||||
package dao | |||||
package dao | |||||
import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" | |||||
type EggEnergyPriceDao interface { | type EggEnergyPriceDao interface { | ||||
//TODO:: You can add specific method definitions here | //TODO:: You can add specific method definitions here | ||||
EggEnergyPriceList(startAt string, endAt string, hour string) ([]model.EggEnergyPrice, error) | |||||
} | } |
@@ -1,4 +1,4 @@ | |||||
package implement | |||||
package implement | |||||
import ( | import ( | ||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | ||||
@@ -30,10 +30,10 @@ func (e EggEnergyAvailableEnergyFlowDb) EggEnergyAvailableEnergyFlowFindAndCount | |||||
session = session.And("kind = ?", kind) | session = session.And("kind = ?", kind) | ||||
} | } | ||||
if startAt != "" { | if startAt != "" { | ||||
session = session.Where("create_time > ?", startAt) | |||||
session = session.Where("create_time >= ?", startAt) | |||||
} | } | ||||
if endAt != "" { | 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) | total, err := session.Limit(pageSize, (page-1)*pageSize).Desc("create_time").FindAndCount(&m) | ||||
if err != nil { | if err != nil { | ||||
@@ -1,4 +1,4 @@ | |||||
package implement | |||||
package implement | |||||
import ( | import ( | ||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | ||||
@@ -43,7 +43,7 @@ func (e EggEnergyBasicSettingDb) EggEnergyBasicSettingGetOneByParams(params map[ | |||||
func (e EggEnergyBasicSettingDb) EggEnergyBasicSettingGetOne() (*model.EggEnergyBasicSetting, error) { | func (e EggEnergyBasicSettingDb) EggEnergyBasicSettingGetOne() (*model.EggEnergyBasicSetting, error) { | ||||
var m *model.EggEnergyBasicSetting | var m *model.EggEnergyBasicSetting | ||||
_, err := e.Db.Where("id > ?", 1).Get(&m) | |||||
_, err := e.Db.Where("id >= ?", 1).Get(&m) | |||||
if err != nil { | if err != nil { | ||||
return nil, zhios_order_relate_logx.Error(err.Error()) | return nil, zhios_order_relate_logx.Error(err.Error()) | ||||
} | } | ||||
@@ -27,16 +27,16 @@ func (e EggEnergyCommunityDividendsDb) EggEnergyCommunityDividendsFindAndCount(p | |||||
var m []*model.EggEnergyCommunityDividends | var m []*model.EggEnergyCommunityDividends | ||||
session := e.Db.Where("") | session := e.Db.Where("") | ||||
if startAt != "" { | if startAt != "" { | ||||
session = session.And("create_at > ?", startAt) | |||||
session = session.And("create_at >= ?", startAt) | |||||
} | } | ||||
if endAt != "" { | if endAt != "" { | ||||
session = session.And("create_at < ?", endAt) | |||||
session = session.And("create_at <= ?", endAt) | |||||
} | } | ||||
if startNums != 0 { | if startNums != 0 { | ||||
session = session.And("nums > ?", startNums) | |||||
session = session.And("nums >= ?", startNums) | |||||
} | } | ||||
if endNums != 0 { | if endNums != 0 { | ||||
session = session.And("nums < ?", endNums) | |||||
session = session.And("nums <= ?", endNums) | |||||
} | } | ||||
total, err := session.Limit(limit, (page-1)*limit).FindAndCount(&m) | total, err := session.Limit(limit, (page-1)*limit).FindAndCount(&m) | ||||
if err != nil { | if err != nil { | ||||
@@ -1,7 +1,9 @@ | |||||
package implement | |||||
package implement | |||||
import ( | import ( | ||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | "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" | "xorm.io/xorm" | ||||
) | ) | ||||
@@ -12,3 +14,22 @@ func NewEggEnergyFundDataDb(engine *xorm.Engine) dao.EggEnergyFundDataDao { | |||||
type EggEnergyFundDataDb struct { | type EggEnergyFundDataDb struct { | ||||
Db *xorm.Engine | 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 | |||||
} |
@@ -1,7 +1,9 @@ | |||||
package implement | |||||
package implement | |||||
import ( | import ( | ||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | "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" | "xorm.io/xorm" | ||||
) | ) | ||||
@@ -12,3 +14,12 @@ func NewEggEnergyFundDataRecordsDb(engine *xorm.Engine) dao.EggEnergyFundDataRec | |||||
type EggEnergyFundDataRecordsDb struct { | type EggEnergyFundDataRecordsDb struct { | ||||
Db *xorm.Engine | 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 | |||||
} |
@@ -1,7 +1,10 @@ | |||||
package implement | |||||
package implement | |||||
import ( | import ( | ||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | "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" | "xorm.io/xorm" | ||||
) | ) | ||||
@@ -12,3 +15,16 @@ func NewEggEnergyPriceDb(engine *xorm.Engine) dao.EggEnergyPriceDao { | |||||
type EggEnergyPriceDb struct { | type EggEnergyPriceDb struct { | ||||
Db *xorm.Engine | 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 | |||||
} |
@@ -1,4 +1,4 @@ | |||||
package implement | |||||
package implement | |||||
import ( | import ( | ||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | ||||
@@ -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) { | 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 | 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 { | if direction != 0 { | ||||
session = session.And("direction = ?", direction) | session = session.And("direction = ?", direction) | ||||
} | } | ||||