优化结构
This commit is contained in:
@@ -40,9 +40,18 @@ func (r *auditQueryRepo) ListLogins(ctx context.Context, page, size int, q *syst
|
||||
if q.Username != "" {
|
||||
db = db.Where("username LIKE ?", "%"+q.Username+"%")
|
||||
}
|
||||
if q.IP != "" {
|
||||
db = db.Where("ip LIKE ?", "%"+q.IP+"%")
|
||||
}
|
||||
if q.Status != nil {
|
||||
db = db.Where("status = ?", *q.Status)
|
||||
}
|
||||
if q.StartCreatedAt != nil {
|
||||
db = db.Where("created_at >= ?", *q.StartCreatedAt)
|
||||
}
|
||||
if q.EndCreatedAt != nil {
|
||||
db = db.Where("created_at <= ?", *q.EndCreatedAt)
|
||||
}
|
||||
}
|
||||
var total int64
|
||||
if err := db.Count(&total).Error; err != nil {
|
||||
|
||||
Reference in New Issue
Block a user