From fbbf8cb1fe98f00777d66f49309a21e796e25f05 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Mon, 18 Nov 2024 18:17:25 +0800 Subject: [PATCH] update table user --- src/dao/user_wallet_dao.go | 1 + src/implement/user_wallet_implement.go | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/dao/user_wallet_dao.go b/src/dao/user_wallet_dao.go index ae16577..f6877ee 100644 --- a/src/dao/user_wallet_dao.go +++ b/src/dao/user_wallet_dao.go @@ -4,4 +4,5 @@ import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" type UserWalletDao interface { GetUserVirtualWallet(uid int64) (*model.UserWallet, error) + FindUserWalletByParams(params map[string]interface{}) (*[]model.UserWallet, error) } diff --git a/src/implement/user_wallet_implement.go b/src/implement/user_wallet_implement.go index 764e1b4..891ccc8 100644 --- a/src/implement/user_wallet_implement.go +++ b/src/implement/user_wallet_implement.go @@ -3,6 +3,10 @@ import ( "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + zhios_order_relate_utils "code.fnuoos.com/EggPlanet/egg_models.git/utils" + zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" + "fmt" + "reflect" "xorm.io/xorm" ) @@ -32,3 +36,20 @@ func (u UserWalletDb) GetUserVirtualWallet(uid int64) (*model.UserWallet, error) return &userWallet, nil } } + +func (u UserWalletDb) FindUserWalletByParams(params map[string]interface{}) (*[]model.UserWallet, error) { + var m []model.UserWallet + if reflect.TypeOf(params["value"]).Kind() == reflect.Slice { + //指定In查询 + if err := u.Db.In(zhios_order_relate_utils.AnyToString(params["key"]), params["value"]).Find(&m); err != nil { + return nil, zhios_order_relate_logx.Warn(err) + } + } else { + var query = fmt.Sprintf("%s =?", params["key"]) + err := u.Db.Where(query, params["value"]).Find(&m) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + } + return &m, nil +}