fix
This commit is contained in:
parent
b77695305a
commit
2668c232b1
|
@ -2,6 +2,7 @@ package gmodel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"fusenapi/utils/handlers"
|
"fusenapi/utils/handlers"
|
||||||
"reflect"
|
"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) {
|
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{}).
|
db := m.db.WithContext(ctx).Model(&FsUserMaterial{}).
|
||||||
Where("`user_id` = ? and `guest_id` = ?", userId, guestId).
|
Where(cond).
|
||||||
Order("id DESC")
|
Order("id DESC")
|
||||||
err = db.Take(&resp).Error
|
err = db.Take(&resp).Error
|
||||||
return resp, err
|
return resp, err
|
||||||
|
@ -70,7 +77,13 @@ func (m *FsUserMaterialModel) FindOneById(ctx context.Context, id int64) (resp *
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
func (m *FsUserMaterialModel) GetListByUser(ctx context.Context, userId, guestId int64, limit int) (resp *FsUserMaterial, err error) {
|
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{}).
|
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
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user