Compare commits
2 Commits
7bf95f136f
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 7e83e5a7e3 | |||
| 590fed23ca |
@ -78,16 +78,16 @@ func (r *sqliteCourseRepository) List(
|
|||||||
direction = "DESC"
|
direction = "DESC"
|
||||||
}
|
}
|
||||||
|
|
||||||
allowedOrderBy := map[string]bool{
|
allowedOrderBy := map[string]struct{}{
|
||||||
"id": true,
|
"id": {},
|
||||||
"name": true,
|
"name": {},
|
||||||
"created_at": true,
|
"created_at": {},
|
||||||
"updated_at": true,
|
"updated_at": {},
|
||||||
"full_price": true,
|
"full_price": {},
|
||||||
"discount": true,
|
"discount": {},
|
||||||
"duration": true,
|
"duration": {},
|
||||||
}
|
}
|
||||||
if !allowedOrderBy[params.OrderBy] {
|
if _, ok := allowedOrderBy[params.OrderBy]; !ok {
|
||||||
return result, fmt.Errorf("invalid order by field: %s", params.OrderBy)
|
return result, fmt.Errorf("invalid order by field: %s", params.OrderBy)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user