128 lines
4.5 KiB
Go
128 lines
4.5 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type Skill struct {
|
|
ID uuid.UUID `json:"id" db:"id"`
|
|
Name string `json:"name" db:"name" validate:"required"`
|
|
Category string `json:"category" db:"category" validate:"required"`
|
|
Proficiency int `json:"proficiency" db:"proficiency" validate:"min=1,max=5"`
|
|
Icon string `json:"icon,omitempty" db:"icon"`
|
|
Order int `json:"order" db:"sort_order"`
|
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
|
|
}
|
|
|
|
type Project struct {
|
|
ID uuid.UUID `json:"id" db:"id"`
|
|
Title string `json:"title" db:"title" validate:"required"`
|
|
Description string `json:"description" db:"description" validate:"required"`
|
|
ShortDesc string `json:"short_desc" db:"short_desc"`
|
|
TechStack []string `json:"tech_stack" db:"tech_stack"`
|
|
ImageURL string `json:"image_url,omitempty" db:"image_url"`
|
|
DemoURL string `json:"demo_url,omitempty" db:"demo_url"`
|
|
RepoURL string `json:"repo_url,omitempty" db:"repo_url"`
|
|
Category string `json:"category" db:"category"`
|
|
Featured bool `json:"featured" db:"featured"`
|
|
Order int `json:"order" db:"sort_order"`
|
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
|
|
}
|
|
|
|
type Experience struct {
|
|
ID uuid.UUID `json:"id" db:"id"`
|
|
Company string `json:"company" db:"company" validate:"required"`
|
|
Role string `json:"role" db:"role" validate:"required"`
|
|
Location string `json:"location" db:"location"`
|
|
StartDate time.Time `json:"start_date" db:"start_date" validate:"required"`
|
|
EndDate *time.Time `json:"end_date,omitempty" db:"end_date"`
|
|
Current bool `json:"current" db:"current"`
|
|
Description string `json:"description" db:"description"`
|
|
TechStack []string `json:"tech_stack" db:"tech_stack"`
|
|
Order int `json:"order" db:"sort_order"`
|
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
|
|
}
|
|
|
|
type Service struct {
|
|
ID uuid.UUID `json:"id" db:"id"`
|
|
Title string `json:"title" db:"title" validate:"required"`
|
|
Description string `json:"description" db:"description" validate:"required"`
|
|
Icon string `json:"icon,omitempty" db:"icon"`
|
|
Features []string `json:"features" db:"features"`
|
|
Order int `json:"order" db:"sort_order"`
|
|
Active bool `json:"active" db:"active"`
|
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
|
|
}
|
|
|
|
type ContactForm struct {
|
|
Name string `json:"name" validate:"required,min=2,max=100"`
|
|
Email string `json:"email" validate:"required,email"`
|
|
Subject string `json:"subject" validate:"required,min=5,max=200"`
|
|
Message string `json:"message" validate:"required,min=10,max=5000"`
|
|
}
|
|
|
|
type ContactSubmission struct {
|
|
ID uuid.UUID `json:"id" db:"id"`
|
|
Name string `json:"name" db:"name"`
|
|
Email string `json:"email" db:"email"`
|
|
Subject string `json:"subject" db:"subject"`
|
|
Message string `json:"message" db:"message"`
|
|
Status string `json:"status" db:"status"`
|
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
|
|
}
|
|
|
|
type APIResponse struct {
|
|
Success bool `json:"success"`
|
|
Data interface{} `json:"data,omitempty"`
|
|
Error *APIError `json:"error,omitempty"`
|
|
Meta *Meta `json:"meta,omitempty"`
|
|
}
|
|
|
|
type APIError struct {
|
|
Code string `json:"code"`
|
|
Message string `json:"message"`
|
|
Details string `json:"details,omitempty"`
|
|
}
|
|
|
|
type Meta struct {
|
|
Page int `json:"page,omitempty"`
|
|
PageSize int `json:"page_size,omitempty"`
|
|
Total int `json:"total,omitempty"`
|
|
TotalPages int `json:"total_pages,omitempty"`
|
|
}
|
|
|
|
func SuccessResponse(data interface{}) *APIResponse {
|
|
return &APIResponse{Success: true, Data: data}
|
|
}
|
|
|
|
func ErrorResponse(code, message, details string) *APIResponse {
|
|
return &APIResponse{
|
|
Success: false,
|
|
Error: &APIError{
|
|
Code: code,
|
|
Message: message,
|
|
Details: details,
|
|
},
|
|
}
|
|
}
|
|
|
|
func PaginatedResponse(data interface{}, page, pageSize, total int) *APIResponse {
|
|
totalPages := (total + pageSize - 1) / pageSize
|
|
return &APIResponse{
|
|
Success: true,
|
|
Data: data,
|
|
Meta: &Meta{
|
|
Page: page,
|
|
PageSize: pageSize,
|
|
Total: total,
|
|
TotalPages: totalPages,
|
|
},
|
|
}
|
|
}
|