1. 增加新类型中继设备
2. 优化代码
This commit is contained in:
@@ -20,6 +20,9 @@ type OperationHistoryRepo interface {
|
||||
|
||||
// List 获取操作历史记录列表(分页)
|
||||
List(offset, limit int) ([]*model.OperationHistory, error)
|
||||
|
||||
// ListByUserID 根据用户ID获取操作历史记录列表(分页)
|
||||
ListByUserID(userID uint, offset, limit int) ([]*model.OperationHistory, error)
|
||||
}
|
||||
|
||||
// operationHistoryRepo 操作历史仓库实现
|
||||
@@ -69,3 +72,13 @@ func (r *operationHistoryRepo) List(offset, limit int) ([]*model.OperationHistor
|
||||
}
|
||||
return histories, nil
|
||||
}
|
||||
|
||||
// ListByUserID 根据用户ID获取操作历史记录列表(分页)
|
||||
func (r *operationHistoryRepo) ListByUserID(userID uint, offset, limit int) ([]*model.OperationHistory, error) {
|
||||
var histories []*model.OperationHistory
|
||||
result := r.db.Where("user_id = ?", userID).Offset(offset).Limit(limit).Order("created_at DESC").Find(&histories)
|
||||
if result.Error != nil {
|
||||
return nil, result.Error
|
||||
}
|
||||
return histories, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user