Parcourir la source

update

master
shenjiachi il y a 1 jour
Parent
révision
20b3391048
2 fichiers modifiés avec 9 ajouts et 4 suppressions
  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 Voir le fichier

@@ -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 Voir le fichier

@@ -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
}


Chargement…
Annuler
Enregistrer