Browse Source

update

master
shenjiachi 1 month ago
parent
commit
20b3391048
2 changed files with 9 additions and 4 deletions
  1. +1
    -1
      src/dao/user_virtual_coin_flow_dao.go
  2. +8
    -3
      src/implement/user_virtual_coin_flow_implement.go

+ 1
- 1
src/dao/user_virtual_coin_flow_dao.go View File

@@ -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) ([]model.UserVirtualCoinFlow, int64, error)
UserVirtualCoinFlowFindByCoinAndUser(page, pageSize int, coinID int, uid int64, startAt string, endAt string, direction int, isAsc bool) ([]model.UserVirtualCoinFlow, int64, error)
}

+ 8
- 3
src/implement/user_virtual_coin_flow_implement.go View File

@@ -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) ([]model.UserVirtualCoinFlow, int64, error) {
func (u UserVirtualCoinFlowDb) UserVirtualCoinFlowFindByCoinAndUser(page, pageSize int, coinID int, uid int64, startAt string, endAt string, direction int, isAsc bool) ([]model.UserVirtualCoinFlow, int64, error) {
var m []model.UserVirtualCoinFlow
session := u.Db.Where("uid = ?", uid).And("coin_id = ?", coinID)
if startAt != "" && endAt != "" {
@@ -31,8 +31,13 @@ func (u UserVirtualCoinFlowDb) UserVirtualCoinFlowFindByCoinAndUser(page, pageSi
if direction != 0 {
session = session.And("direction = ?", direction)
}

total, err := session.Limit(pageSize, (page-1)*pageSize).Desc("create_at").FindAndCount(&m)
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
}


Loading…
Cancel
Save