修复聊天消息不显示最新数据:所有列表查询排序从 created_at DESC 改为 id DESC,记录创建函数显式设置 CreatedAt,后端 v1.2.1 / 前端 v0.3.1
This commit is contained in:
@@ -1,13 +1,18 @@
|
||||
package store
|
||||
|
||||
import "time"
|
||||
|
||||
func (s *Store) InsertLoginLog(log LoginLogRecord) error {
|
||||
if log.CreatedAt.IsZero() {
|
||||
log.CreatedAt = time.Now()
|
||||
}
|
||||
return s.db.Create(&log).Error
|
||||
}
|
||||
|
||||
func (s *Store) ListLoginLogs(opts ListOptions) ([]LoginLogRecord, error) {
|
||||
opts = NormalizeListOptions(opts)
|
||||
var rows []LoginLogRecord
|
||||
q := s.db.Order("created_at DESC").Order("id DESC").Limit(opts.Limit).Offset(opts.Offset)
|
||||
q := s.db.Order("id DESC").Limit(opts.Limit).Offset(opts.Offset)
|
||||
if opts.Since != nil {
|
||||
q = q.Where("created_at >= ?", *opts.Since)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user