diff --git a/src/dao/virtual_coin_dao.go b/src/dao/virtual_coin_dao.go index bc7301c..0d8a94c 100644 --- a/src/dao/virtual_coin_dao.go +++ b/src/dao/virtual_coin_dao.go @@ -6,4 +6,7 @@ type VirtualCoinDao interface { //TODO:: You can add specific method definitions here VirtualCoinFindAll() ([]model.VirtualCoin, error) VirtualCoinGetOneByParams(params map[string]interface{}) (*model.VirtualCoin, error) + VirtualCoinBatchAdd(virtualCoin []model.VirtualCoin) (int64, error) + VirtualCoinUpdate(virtualCoin *model.VirtualCoin, forceColumns ...string) (int64, error) + VirtualCoinDelete(id interface{}) (int64, error) } diff --git a/src/implement/egg_energy_fund_data_implement.go b/src/implement/egg_energy_fund_data_implement.go index 1ace4e2..9ab21a7 100644 --- a/src/implement/egg_energy_fund_data_implement.go +++ b/src/implement/egg_energy_fund_data_implement.go @@ -23,10 +23,10 @@ func (e EggEnergyFundDataDb) EggEnergyFundDataFindAndCount(page, limit, kind int session = session.Where("kind = ?", kind) } if startAt != "" { - session = session.Where("start_at >= ?", startAt) + session = session.Where("create_at >= ?", startAt) } if endAt != "" { - session = session.Where("end_at <= ?", endAt) + session = session.Where("create_at <= ?", endAt) } total, err := session.Limit(limit, (page-1)*limit).FindAndCount(&m) if err != nil { diff --git a/src/implement/virtual_coin_implement.go b/src/implement/virtual_coin_implement.go index ed65061..53a10ee 100644 --- a/src/implement/virtual_coin_implement.go +++ b/src/implement/virtual_coin_implement.go @@ -33,3 +33,35 @@ func (v VirtualCoinDb) VirtualCoinGetOneByParams(params map[string]interface{}) } return &m, nil } + +func (v VirtualCoinDb) VirtualCoinBatchAdd(virtualCoin []model.VirtualCoin) (int64, error) { + affected, err := v.Db.Insert(virtualCoin) + if err != nil { + return 0, zhios_order_relate_logx.Error(err.Error()) + } + return affected, nil +} + +func (v VirtualCoinDb) VirtualCoinUpdate(virtualCoin *model.VirtualCoin, forceColumns ...string) (int64, error) { + var ( + affected int64 + err error + ) + if forceColumns != nil { + affected, err = v.Db.Where("id=?", virtualCoin.Id).MustCols(forceColumns...).Update(virtualCoin) + } else { + affected, err = v.Db.Where("id=?", virtualCoin.Id).Update(virtualCoin) + } + if err != nil { + return 0, zhios_order_relate_logx.Error(err.Error()) + } + return affected, nil +} + +func (v VirtualCoinDb) VirtualCoinDelete(id interface{}) (int64, error) { + affected, err := v.Db.Where("id = ?", id).Delete(&model.VirtualCoin{}) + if err != nil { + return 0, err + } + return affected, nil +}