@@ -4,5 +4,6 @@ import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" | |||||
type EggEnergyCommunityDividendsDao interface { | type EggEnergyCommunityDividendsDao interface { | ||||
//TODO:: You can add specific method definitions here | //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) | EggEnergyCommunityDividendsInsert(EggEnergyCommunityDividends *model.EggEnergyCommunityDividends) (int, error) | ||||
} | } |
@@ -5,4 +5,6 @@ import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" | |||||
type EggEnergyCommunityDividendsWithUserDao interface { | type EggEnergyCommunityDividendsWithUserDao interface { | ||||
//TODO:: You can add specific method definitions here | //TODO:: You can add specific method definitions here | ||||
EggEnergyCommunityDividendsWithUserInsert(EggEnergyCommunityDividendsWithUser *model.EggEnergyCommunityDividendsWithUser) (int, error) | EggEnergyCommunityDividendsWithUserInsert(EggEnergyCommunityDividendsWithUser *model.EggEnergyCommunityDividendsWithUser) (int, error) | ||||
EggEnergyCommunityDividendsWithUserFindAndCount(page, limit int, uid int64) ([]*model.EggEnergyCommunityDividendsWithUser, int64, error) | |||||
EggEnergyCommunityDividendsWithUserExist(uid int64) (bool, error) | |||||
} | } |
@@ -3,6 +3,7 @@ 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" | "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" | ||||
) | ) | ||||
@@ -14,6 +15,28 @@ type EggEnergyCommunityDividendsDb struct { | |||||
Db *xorm.Engine | 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) { | func (e EggEnergyCommunityDividendsDb) EggEnergyCommunityDividendsInsert(EggEnergyCommunityDividends *model.EggEnergyCommunityDividends) (int, error) { | ||||
_, err := e.Db.InsertOne(EggEnergyCommunityDividends) | _, err := e.Db.InsertOne(EggEnergyCommunityDividends) | ||||
if err != nil { | if err != nil { | ||||
@@ -3,6 +3,7 @@ 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" | "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" | ||||
) | ) | ||||
@@ -17,7 +18,29 @@ type EggEnergyCommunityDividendsWithUserDb struct { | |||||
func (e EggEnergyCommunityDividendsWithUserDb) EggEnergyCommunityDividendsWithUserInsert(EggEnergyCommunityDividendsWithUser *model.EggEnergyCommunityDividendsWithUser) (int, error) { | func (e EggEnergyCommunityDividendsWithUserDb) EggEnergyCommunityDividendsWithUserInsert(EggEnergyCommunityDividendsWithUser *model.EggEnergyCommunityDividendsWithUser) (int, error) { | ||||
_, err := e.Db.InsertOne(EggEnergyCommunityDividendsWithUser) | _, err := e.Db.InsertOne(EggEnergyCommunityDividendsWithUser) | ||||
if err != nil { | if err != nil { | ||||
return 0, err | |||||
return 0, zhios_order_relate_logx.Error(err.Error()) | |||||
} | } | ||||
return EggEnergyCommunityDividendsWithUser.Id, nil | 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 | |||||
} |