
This commit adds a complete Go implementation of the Todo application. The application uses Gin framework for the web server, GORM for database access, and SQLite for storage. Key features: - Todo CRUD operations with the same API endpoints - Health check endpoint - Database migrations - Tests for models, services, and API handlers - Documentation for the API - Configurable settings
20 lines
553 B
Go
20 lines
553 B
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// Todo represents a todo item in the database
|
|
type Todo struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
Title string `gorm:"index" json:"title"`
|
|
Description string `gorm:"default:null" json:"description"`
|
|
Completed bool `gorm:"default:false" json:"completed"`
|
|
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
|
}
|
|
|
|
// TableName overrides the table name
|
|
func (Todo) TableName() string {
|
|
return "todos"
|
|
} |