From 9e05dce2edc43ab7f243c57d1a5ca5fa8b50e72e Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Thu, 21 Nov 2024 13:47:44 +0800 Subject: [PATCH] update --- src/dao/user_virtual_coin_flow_dao.go | 2 +- src/dao/virtual_coin_dao.go | 1 + src/implement/user_virtual_coin_flow_implement.go | 5 ++++- src/implement/virtual_coin_implement.go | 10 ++++++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/dao/user_virtual_coin_flow_dao.go b/src/dao/user_virtual_coin_flow_dao.go index e0b8570..748b25e 100644 --- a/src/dao/user_virtual_coin_flow_dao.go +++ b/src/dao/user_virtual_coin_flow_dao.go @@ -7,5 +7,5 @@ import ( type UserVirtualCoinFlowDao interface { UserVirtualCoinFlowInsertBySession(session *xorm.Session, UserVirtualCoinFlow *model.UserVirtualCoinFlow) (int64, error) - UserVirtualCoinFlowFindByCoinAndUser(page, pageSize int, coinID int, uid int64, startAt string, endAt string, direction int, isAsc bool) ([]model.UserVirtualCoinFlow, int64, error) + UserVirtualCoinFlowFindByCoinAndUser(page, pageSize int, coinID int, uid int64, startAt string, endAt string, direction int, isAsc bool, transferType int) ([]model.UserVirtualCoinFlow, int64, error) } diff --git a/src/dao/virtual_coin_dao.go b/src/dao/virtual_coin_dao.go index 1ac66b6..bc7301c 100644 --- a/src/dao/virtual_coin_dao.go +++ b/src/dao/virtual_coin_dao.go @@ -5,4 +5,5 @@ import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" type VirtualCoinDao interface { //TODO:: You can add specific method definitions here VirtualCoinFindAll() ([]model.VirtualCoin, error) + VirtualCoinGetOneByParams(params map[string]interface{}) (*model.VirtualCoin, error) } diff --git a/src/implement/user_virtual_coin_flow_implement.go b/src/implement/user_virtual_coin_flow_implement.go index 8687677..7eaff09 100644 --- a/src/implement/user_virtual_coin_flow_implement.go +++ b/src/implement/user_virtual_coin_flow_implement.go @@ -22,7 +22,7 @@ func (u UserVirtualCoinFlowDb) UserVirtualCoinFlowInsertBySession(session *xorm. return UserVirtualCoinFlow.Id, nil } -func (u UserVirtualCoinFlowDb) UserVirtualCoinFlowFindByCoinAndUser(page, pageSize int, coinID int, uid int64, startAt string, endAt string, direction int, isAsc bool) ([]model.UserVirtualCoinFlow, int64, error) { +func (u UserVirtualCoinFlowDb) UserVirtualCoinFlowFindByCoinAndUser(page, pageSize int, coinID int, uid int64, startAt string, endAt string, direction int, isAsc bool, transferType int) ([]model.UserVirtualCoinFlow, int64, error) { var m []model.UserVirtualCoinFlow session := u.Db.Where("uid = ?", uid).And("coin_id = ?", coinID) if startAt != "" && endAt != "" { @@ -31,6 +31,9 @@ func (u UserVirtualCoinFlowDb) UserVirtualCoinFlowFindByCoinAndUser(page, pageSi if direction != 0 { session = session.And("direction = ?", direction) } + if transferType != 0{ + session = session.And("type = ?", type) + } session = session.Limit(pageSize, (page-1)*pageSize) if isAsc { session = session.Asc("create_at") diff --git a/src/implement/virtual_coin_implement.go b/src/implement/virtual_coin_implement.go index 6241927..ed65061 100644 --- a/src/implement/virtual_coin_implement.go +++ b/src/implement/virtual_coin_implement.go @@ -4,6 +4,7 @@ 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" + "fmt" "xorm.io/xorm" ) @@ -23,3 +24,12 @@ func (v VirtualCoinDb) VirtualCoinFindAll() ([]model.VirtualCoin, error) { } return m, nil } + +func (v VirtualCoinDb) VirtualCoinGetOneByParams(params map[string]interface{}) (*model.VirtualCoin, error) { + var m model.VirtualCoin + var query = fmt.Sprintf("%s = ?", params["key"]) + if has, err := v.Db.Where(query, params["value"]).Get(&m); err != nil || has == false { + return nil, zhios_order_relate_logx.Error(err) + } + return &m, nil +}