fix
This commit is contained in:
parent
b77695305a
commit
2668c232b1
|
@ -2,6 +2,7 @@ package gmodel
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"fusenapi/utils/handlers"
|
||||
"reflect"
|
||||
|
||||
|
@ -58,8 +59,14 @@ func (m *FsUserMaterialModel) RowSelectBuilder(selectData []string) *gorm.DB {
|
|||
|
||||
// 获取最新记录
|
||||
func (m *FsUserMaterialModel) FindLatestOne(ctx context.Context, userId int64, guestId int64) (resp FsUserMaterial, err error) {
|
||||
var cond string
|
||||
if userId != 0 {
|
||||
cond = fmt.Sprintf("user_id = %d", userId)
|
||||
} else {
|
||||
cond = fmt.Sprintf("guest_id = %d", guestId)
|
||||
}
|
||||
db := m.db.WithContext(ctx).Model(&FsUserMaterial{}).
|
||||
Where("`user_id` = ? and `guest_id` = ?", userId, guestId).
|
||||
Where(cond).
|
||||
Order("id DESC")
|
||||
err = db.Take(&resp).Error
|
||||
return resp, err
|
||||
|
@ -70,7 +77,13 @@ func (m *FsUserMaterialModel) FindOneById(ctx context.Context, id int64) (resp *
|
|||
return resp, err
|
||||
}
|
||||
func (m *FsUserMaterialModel) GetListByUser(ctx context.Context, userId, guestId int64, limit int) (resp *FsUserMaterial, err error) {
|
||||
var cond string
|
||||
if userId != 0 {
|
||||
cond = fmt.Sprintf("user_id = %d", userId)
|
||||
} else {
|
||||
cond = fmt.Sprintf("guest_id = %d", guestId)
|
||||
}
|
||||
err = m.db.WithContext(ctx).Model(&FsUserMaterial{}).
|
||||
Where("`user_id` = ? and `guest_id` = ?", userId, guestId).Order("id DESC").Limit(limit).Find(&resp).Error
|
||||
Where(cond).Order("id DESC").Limit(limit).Find(&resp).Error
|
||||
return resp, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user