Explorar el Código

add user management

master
shenjiachi hace 3 días
padre
commit
56176dca63
Se han modificado 3 ficheros con 32 adiciones y 1 borrados
  1. +1
    -0
      src/dao/user_wallet_flow_dao.go
  2. +4
    -1
      src/implement/user_virtual_coin_flow_implement.go
  3. +27
    -0
      src/implement/user_wallet_flow_implement.go

+ 1
- 0
src/dao/user_wallet_flow_dao.go Ver fichero

@@ -7,4 +7,5 @@ import (

type UserWalletFlowDao interface {
UserWalletFlowInsertBySession(session *xorm.Session, userWalletFlow *model.UserWalletFlow) (int64, error)
UserWalletFlowFindByParams(params map[string]interface{}, page, limit int) (*[]model.UserWalletFlow, int64, error)
}

+ 4
- 1
src/implement/user_virtual_coin_flow_implement.go Ver fichero

@@ -24,7 +24,10 @@ func (u UserVirtualCoinFlowDb) UserVirtualCoinFlowInsertBySession(session *xorm.

func (u UserVirtualCoinFlowDb) UserVirtualCoinFlowFindByCoinAndUser(page, pageSize int, coinID int, uid int64, startAt string, endAt string, direction int) ([]model.UserVirtualCoinFlow, int64, error) {
var m []model.UserVirtualCoinFlow
session := u.Db.Where("uid = ?", uid).And("coin_id = ?", coinID).And("create_at >= ?", startAt).And("create_at <= ?", endAt)
session := u.Db.Where("uid = ?", uid).And("coin_id = ?", coinID)
if startAt != "" && endAt != "" {
session = session.And("create_at >= ?", startAt).And("create_at <= ?", endAt)
}
if direction != 0 {
session = session.And("direction = ?", direction)
}


+ 27
- 0
src/implement/user_wallet_flow_implement.go Ver fichero

@@ -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"
)

@@ -21,3 +25,26 @@ func (u UserWalletFlowDb) UserWalletFlowInsertBySession(session *xorm.Session, u
}
return userWalletFlow.Id, nil
}

func (u UserWalletFlowDb) UserWalletFlowFindByParams(params map[string]interface{}, page, limit int) (*[]model.UserWalletFlow, int64, error) {
var m []model.UserWalletFlow
if page == 0 || limit == 0 {
page = 1
limit = 10
}
var total int64
var err error
if reflect.TypeOf(params["value"]).Kind() == reflect.Slice {
//指定In查询
if total, err = u.Db.In(zhios_order_relate_utils.AnyToString(params["key"]), params["value"]).Limit(limit, (page-1)*limit).FindAndCount(&m); err != nil {
return nil, 0, zhios_order_relate_logx.Warn(err)
}
} else {
var query = fmt.Sprintf("%s =?", params["key"])
total, err = u.Db.Where(query, params["value"]).Limit(limit, (page-1)*limit).FindAndCount(&m)
if err != nil {
return nil, 0, zhios_order_relate_logx.Error(err)
}
}
return &m, total, nil
}

Cargando…
Cancelar
Guardar