ultisuite-backend/internal/api/admin/sort.go
R3D347HR4Y 621b0099d6
Some checks are pending
CI / Go tests (push) Waiting to run
CI / Integration tests (push) Waiting to run
CI / DB migrations (push) Waiting to run
feat(deploy): enhance Nginx configuration and API integration for UltiAI
- Updated .env.example to include new configuration options for the UltiAI branding and API endpoints.
- Enhanced Nginx configuration to support new API routes for the MCP and WebSocket connections.
- Introduced sub-filters for branding adjustments in Nginx responses.
- Added new JavaScript patch for API endpoint adjustments.
- Implemented tests for new API functionalities and improved error handling in the AI gateway.
2026-06-15 00:22:23 +02:00

36 lines
738 B
Go

package admin
import "strings"
func parseSortField(sort string) (field string, desc bool) {
sort = strings.TrimSpace(sort)
if sort == "" {
return "", false
}
if strings.HasPrefix(sort, "-") {
return strings.TrimPrefix(sort, "-"), true
}
return sort, false
}
func buildUserOrderBy(sort string) string {
field, desc := parseSortField(sort)
allowed := map[string]string{
"created_at": "created_at",
"updated_at": "updated_at",
"email": "LOWER(email)",
"name": "LOWER(name)",
"status": "status",
"external_id": "LOWER(external_id)",
}
col, ok := allowed[field]
if !ok {
return "ORDER BY created_at DESC"
}
dir := "ASC"
if desc {
dir = "DESC"
}
return "ORDER BY " + col + " " + dir
}