浏览代码

update

master
shenjiachi 3 天前
父节点
当前提交
3abab34746
共有 2 个文件被更改,包括 30 次插入0 次删除
  1. +1
    -0
      src/dao/user_wallet_flow_dao.go
  2. +29
    -0
      src/implement/user_wallet_flow_implement.go

+ 1
- 0
src/dao/user_wallet_flow_dao.go 查看文件

@@ -8,4 +8,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)
UserWalletFlowFindByCoinAndUser(page, pageSize int, uid int64, startAt string, endAt string, direction int, isAsc bool, kind int, state int) ([]model.UserWalletFlow, int64, error)
}

+ 29
- 0
src/implement/user_wallet_flow_implement.go 查看文件

@@ -48,3 +48,32 @@ func (u UserWalletFlowDb) UserWalletFlowFindByParams(params map[string]interface
}
return &m, total, nil
}

func (u UserWalletFlowDb) UserWalletFlowFindByCoinAndUser(page, pageSize int, uid int64, startAt string, endAt string, direction int, isAsc bool, kind int, state int) ([]model.UserWalletFlow, int64, error) {
var m []model.UserWalletFlow
session := u.Db.Where("uid = ?", uid)
if startAt != "" && endAt != "" {
session = session.And("create_at >= ?", startAt).And("create_at <= ?", endAt)
}
if direction != 0 {
session = session.And("direction = ?", direction)
}
if kind != 0 {
session = session.And("kind = ?", kind)
}
if state != 0 {
session = session.And("state = ?", state)
}
session = session.Limit(pageSize, (page-1)*pageSize)
if isAsc {
session = session.Asc("create_at")
} else {
session = session.Desc("create_at")
}
total, err := session.FindAndCount(&m)
if err != nil {
return nil, 0, err
}

return m, total, nil
}

正在加载...
取消
保存