diff --git a/src/dao/egg_energy_community_dividends_dao.go b/src/dao/egg_energy_community_dividends_dao.go index 4a9e62e..02d6d71 100644 --- a/src/dao/egg_energy_community_dividends_dao.go +++ b/src/dao/egg_energy_community_dividends_dao.go @@ -4,5 +4,6 @@ import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" type EggEnergyCommunityDividendsDao interface { //TODO:: You can add specific method definitions here + EggEnergyCommunityDividendsFindAndCount(page, limit int, startAt, endAt string, startNums, endNums int64) ([]*model.EggEnergyCommunityDividends, int64, error) EggEnergyCommunityDividendsInsert(EggEnergyCommunityDividends *model.EggEnergyCommunityDividends) (int, error) } diff --git a/src/dao/egg_energy_community_dividends_with_user_dao.go b/src/dao/egg_energy_community_dividends_with_user_dao.go index ed9a424..bdfa775 100644 --- a/src/dao/egg_energy_community_dividends_with_user_dao.go +++ b/src/dao/egg_energy_community_dividends_with_user_dao.go @@ -5,4 +5,6 @@ import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" type EggEnergyCommunityDividendsWithUserDao interface { //TODO:: You can add specific method definitions here EggEnergyCommunityDividendsWithUserInsert(EggEnergyCommunityDividendsWithUser *model.EggEnergyCommunityDividendsWithUser) (int, error) + EggEnergyCommunityDividendsWithUserFindAndCount(page, limit int, uid int64) ([]*model.EggEnergyCommunityDividendsWithUser, int64, error) + EggEnergyCommunityDividendsWithUserExist(uid int64) (bool, error) } diff --git a/src/implement/egg_energy_community_dividends_implement.go b/src/implement/egg_energy_community_dividends_implement.go index 96a254e..16be221 100644 --- a/src/implement/egg_energy_community_dividends_implement.go +++ b/src/implement/egg_energy_community_dividends_implement.go @@ -3,6 +3,7 @@ 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" "xorm.io/xorm" ) @@ -14,6 +15,28 @@ type EggEnergyCommunityDividendsDb struct { Db *xorm.Engine } +func (e EggEnergyCommunityDividendsDb) EggEnergyCommunityDividendsFindAndCount(page, limit int, startAt, endAt string, startNums, endNums int64) ([]*model.EggEnergyCommunityDividends, int64, error) { + var m []*model.EggEnergyCommunityDividends + session := e.Db.Where("") + if startAt != "" { + session = session.And("create_at > ?", startAt) + } + if endAt != "" { + session = session.And("create_at < ?", endAt) + } + if startNums != 0 { + session = session.And("nums > ?", startNums) + } + if endNums != 0 { + session = session.And("nums < ?", endNums) + } + 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 +} + func (e EggEnergyCommunityDividendsDb) EggEnergyCommunityDividendsInsert(EggEnergyCommunityDividends *model.EggEnergyCommunityDividends) (int, error) { _, err := e.Db.InsertOne(EggEnergyCommunityDividends) if err != nil { diff --git a/src/implement/egg_energy_community_dividends_with_user_implement.go b/src/implement/egg_energy_community_dividends_with_user_implement.go index be878c8..4a4510c 100644 --- a/src/implement/egg_energy_community_dividends_with_user_implement.go +++ b/src/implement/egg_energy_community_dividends_with_user_implement.go @@ -3,6 +3,7 @@ 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" "xorm.io/xorm" ) @@ -17,7 +18,29 @@ type EggEnergyCommunityDividendsWithUserDb struct { func (e EggEnergyCommunityDividendsWithUserDb) EggEnergyCommunityDividendsWithUserInsert(EggEnergyCommunityDividendsWithUser *model.EggEnergyCommunityDividendsWithUser) (int, error) { _, err := e.Db.InsertOne(EggEnergyCommunityDividendsWithUser) if err != nil { - return 0, err + return 0, zhios_order_relate_logx.Error(err.Error()) } return EggEnergyCommunityDividendsWithUser.Id, nil } + +func (e EggEnergyCommunityDividendsWithUserDb) EggEnergyCommunityDividendsWithUserFindAndCount(page, limit int, uid int64) ([]*model.EggEnergyCommunityDividendsWithUser, int64, error) { + var m []*model.EggEnergyCommunityDividendsWithUser + session := e.Db.Where("") + if uid > 0 { + session = session.And("uid=?", uid) + } + 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 +} + +func (e EggEnergyCommunityDividendsWithUserDb) EggEnergyCommunityDividendsWithUserExist(uid int64) (bool, error) { + var m model.EggEnergyCommunityDividendsWithUser + has, err := e.Db.Where("uid=?", uid).Exist(&m) + if err != nil { + return false, zhios_order_relate_logx.Error(err.Error()) + } + return has, nil +}