Move project files from uzdb/ subdirectory to root directory for cleaner project structure.
Changes:
- Move frontend/ to root
- Move internal/ to root
- Move build/ to root
- Move all config files (go.mod, wails.json, etc.) to root
- Remove redundant uzdb/ subdirectory nesting
Project structure is now:
├── frontend/ # React application
├── internal/ # Go backend
├── build/ # Wails build assets
├── doc/ # Design documentation
├── main.go # Entry point
└── ...
🤖 Generated with Qoder
129 lines
4.0 KiB
Go
129 lines
4.0 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// APIResponse represents a standard API response
|
|
type APIResponse struct {
|
|
Success bool `json:"success"`
|
|
Message string `json:"message,omitempty"`
|
|
Data interface{} `json:"data,omitempty"`
|
|
Error string `json:"error,omitempty"`
|
|
}
|
|
|
|
// QueryResult represents the result of a SQL query execution
|
|
type QueryResult struct {
|
|
Columns []string `json:"columns"`
|
|
Rows [][]interface{} `json:"rows"`
|
|
RowCount int64 `json:"row_count"`
|
|
AffectedRows int64 `json:"affected_rows"`
|
|
Duration int64 `json:"duration_ms"`
|
|
Success bool `json:"success"`
|
|
Error string `json:"error,omitempty"`
|
|
}
|
|
|
|
// Table represents a database table
|
|
type Table struct {
|
|
Name string `json:"name"`
|
|
Schema string `json:"schema,omitempty"`
|
|
Type string `json:"type"` // table, view, etc.
|
|
RowCount int64 `json:"row_count,omitempty"`
|
|
Description string `json:"description,omitempty"`
|
|
}
|
|
|
|
// TableStructure represents the structure of a database table
|
|
type TableStructure struct {
|
|
TableName string `json:"table_name"`
|
|
Schema string `json:"schema,omitempty"`
|
|
Columns []TableColumn `json:"columns"`
|
|
Indexes []TableIndex `json:"indexes,omitempty"`
|
|
ForeignKeys []ForeignKey `json:"foreign_keys,omitempty"`
|
|
}
|
|
|
|
// TableColumn represents a column in a database table
|
|
type TableColumn struct {
|
|
Name string `json:"name"`
|
|
DataType string `json:"data_type"`
|
|
Nullable bool `json:"nullable"`
|
|
Default string `json:"default,omitempty"`
|
|
IsPrimary bool `json:"is_primary"`
|
|
IsUnique bool `json:"is_unique"`
|
|
AutoIncrement bool `json:"auto_increment"`
|
|
Length int `json:"length,omitempty"`
|
|
Scale int `json:"scale,omitempty"`
|
|
Comment string `json:"comment,omitempty"`
|
|
}
|
|
|
|
// TableIndex represents an index on a database table
|
|
type TableIndex struct {
|
|
Name string `json:"name"`
|
|
Columns []string `json:"columns"`
|
|
IsUnique bool `json:"is_unique"`
|
|
IsPrimary bool `json:"is_primary"`
|
|
Type string `json:"type,omitempty"`
|
|
}
|
|
|
|
// ForeignKey represents a foreign key constraint
|
|
type ForeignKey struct {
|
|
Name string `json:"name"`
|
|
Columns []string `json:"columns"`
|
|
ReferencedTable string `json:"referenced_table"`
|
|
ReferencedColumns []string `json:"referenced_columns"`
|
|
OnDelete string `json:"on_delete,omitempty"`
|
|
OnUpdate string `json:"on_update,omitempty"`
|
|
}
|
|
|
|
// ConnectionTestResult represents the result of a connection test
|
|
type ConnectionTestResult struct {
|
|
Success bool `json:"success"`
|
|
Message string `json:"message"`
|
|
Duration int64 `json:"duration_ms"`
|
|
Metadata *DBMetadata `json:"metadata,omitempty"`
|
|
}
|
|
|
|
// DBMetadata represents database metadata
|
|
type DBMetadata struct {
|
|
Version string `json:"version"`
|
|
Database string `json:"database"`
|
|
User string `json:"user"`
|
|
Host string `json:"host"`
|
|
Port int `json:"port"`
|
|
ServerTime string `json:"server_time"`
|
|
}
|
|
|
|
// ErrorResponse represents an error response
|
|
type ErrorResponse struct {
|
|
Error string `json:"error"`
|
|
Message string `json:"message"`
|
|
Code string `json:"code,omitempty"`
|
|
Details map[string]interface{} `json:"details,omitempty"`
|
|
Timestamp time.Time `json:"timestamp"`
|
|
Path string `json:"path,omitempty"`
|
|
}
|
|
|
|
// PaginatedResponse represents a paginated response
|
|
type PaginatedResponse struct {
|
|
Data interface{} `json:"data"`
|
|
Total int64 `json:"total"`
|
|
Page int `json:"page"`
|
|
PageSize int `json:"page_size"`
|
|
TotalPages int `json:"total_pages"`
|
|
}
|
|
|
|
// NewAPIResponse creates a new API response
|
|
func NewAPIResponse(data interface{}) *APIResponse {
|
|
return &APIResponse{
|
|
Success: true,
|
|
Data: data,
|
|
}
|
|
}
|
|
|
|
// NewErrorResponse creates a new error response
|
|
func NewErrorResponse(message string) *APIResponse {
|
|
return &APIResponse{
|
|
Success: false,
|
|
Error: message,
|
|
}
|
|
}
|