Add initial project structure with core functionality for book and stationery uploads

- Created main application entry point in `main.go`.
- Added configuration management in `config/config.go` and tests in `config/config_test.go`.
- Implemented handlers for book and stationery uploads in `handlers/book.go` and `handlers/stationery.go`, including validation logic.
- Established database connection and services in `services/database.go` and `services/book_service.go`.
- Defined models for books and stationery in `models/book.go` and `models/stationery.go`.
- Set up Firebase integration for image uploads in `services/firebase.go`.
- Created migration scripts for database schema in `migrations/001_create_tables.sql` and subsequent updates.
- Added CORS and error handling middleware.
- Included comprehensive tests for handlers, services, and utilities.
- Documented API endpoints and usage in `README.md` and migration instructions in `migrations/README.md`.
- Introduced `.gitignore` to exclude unnecessary files and directories.
- Added Go module support with `go.mod` and `go.sum` files.
- Implemented utility functions for slug generation and validation in `utils/slug.go` and `utils/validation.go`.
This commit is contained in:
ianshaloom
2025-11-21 08:50:27 +03:00
commit ebeae34e01
39 changed files with 4044 additions and 0 deletions

33
models/book.go Normal file
View File

@@ -0,0 +1,33 @@
package models
import "time"
// Book represents a book product in the database
type Book struct {
BookCode string `json:"book_code" db:"book_code"`
BookName string `json:"book_name" db:"book_name"`
Cost float64 `json:"cost" db:"cost"`
Price float64 `json:"price" db:"price"`
Discount float64 `json:"discount" db:"discount"`
Quantity int `json:"quantity" db:"quantity"`
PublisherAuthor string `json:"publisher_author" db:"publisher_author"`
Category string `json:"category" db:"category"`
Description string `json:"description" db:"description"`
ImageURL string `json:"image_url" db:"image_url"`
Slug string `json:"slug" db:"slug"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
// BookCreateRequest represents the data needed to create a new book
type BookCreateRequest struct {
BookName string `json:"book_name"`
Cost float64 `json:"cost"`
Price float64 `json:"price"`
Discount float64 `json:"discount"`
Quantity int `json:"quantity"`
PublisherAuthor string `json:"publisher_author"`
Category string `json:"category"`
Description string `json:"description"`
ImageURL string `json:"image_url"`
}

37
models/stationery.go Normal file
View File

@@ -0,0 +1,37 @@
package models
import "time"
// Stationery represents a stationery product in the database
type Stationery struct {
StationeryCode string `json:"stationery_code" db:"stationery_code"`
StationeryName string `json:"stationery_name" db:"stationery_name"`
Cost float64 `json:"cost" db:"cost"`
Price float64 `json:"price" db:"price"`
Discount float64 `json:"discount" db:"discount"`
Quantity int `json:"quantity" db:"quantity"`
Color string `json:"color" db:"color"`
Material string `json:"material" db:"material"`
Dimensions string `json:"dimensions" db:"dimensions"`
Category string `json:"category" db:"category"`
Description string `json:"description" db:"description"`
ImageURL string `json:"image_url" db:"image_url"`
Slug string `json:"slug" db:"slug"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}
// StationeryCreateRequest represents the data needed to create a new stationery item
type StationeryCreateRequest struct {
StationeryName string `json:"stationery_name"`
Cost float64 `json:"cost"`
Price float64 `json:"price"`
Discount float64 `json:"discount"`
Quantity int `json:"quantity"`
Color string `json:"color"`
Material string `json:"material"`
Dimensions string `json:"dimensions"`
Category string `json:"category"`
Description string `json:"description"`
ImageURL string `json:"image_url"`
}