3e4831c2e7
- Updated README.md to include comprehensive Swagger documentation details, highlighting new features and endpoint categories. - Introduced a new router structure to streamline route registration for admin and public endpoints, enhancing maintainability. - Updated health check endpoint documentation to reflect comprehensive server status information. - Enhanced customer and company management routes with improved descriptions and examples in Swagger. - Refactored customer and user handlers to remove obsolete route registrations, aligning with the new router structure. - Improved response handling in customer and user services to utilize string IDs consistently. - Updated validation rules and forms for customer management to support multiple company assignments. - Enhanced logging practices across services to ensure better traceability and error handling.
69 lines
1.7 KiB
Go
69 lines
1.7 KiB
Go
package mongo
|
|
|
|
import (
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
)
|
|
|
|
// Logger defines the interface for logging operations
|
|
type Logger interface {
|
|
Info(message string, fields map[string]interface{})
|
|
Error(message string, fields map[string]interface{})
|
|
Debug(message string, fields map[string]interface{})
|
|
Warn(message string, fields map[string]interface{})
|
|
}
|
|
|
|
// Timestampable interface for models that support timestamps
|
|
type Timestampable interface {
|
|
SetCreatedAt(timestamp int64)
|
|
SetUpdatedAt(timestamp int64)
|
|
GetCreatedAt() int64
|
|
GetUpdatedAt() int64
|
|
}
|
|
|
|
// IDGetter interface for models that can provide their ID
|
|
type IDGetter interface {
|
|
GetID() string
|
|
}
|
|
|
|
// IDSetter interface for models that can set their ID
|
|
type IDSetter interface {
|
|
SetID(id string)
|
|
}
|
|
|
|
// Model provides a common base for MongoDB documents
|
|
type Model struct {
|
|
ID primitive.ObjectID `bson:"_id,omitempty" json:"id,omitempty"`
|
|
CreatedAt int64 `bson:"created_at" json:"created_at"`
|
|
UpdatedAt int64 `bson:"updated_at" json:"updated_at"`
|
|
}
|
|
|
|
// GetID returns the document ID
|
|
func (b *Model) GetID() string {
|
|
return b.ID.Hex()
|
|
}
|
|
|
|
// SetID sets the document ID
|
|
func (b *Model) SetID(id string) {
|
|
b.ID, _ = primitive.ObjectIDFromHex(id)
|
|
}
|
|
|
|
// SetCreatedAt sets the creation timestamp
|
|
func (b *Model) SetCreatedAt(timestamp int64) {
|
|
b.CreatedAt = timestamp
|
|
}
|
|
|
|
// SetUpdatedAt sets the update timestamp
|
|
func (b *Model) SetUpdatedAt(timestamp int64) {
|
|
b.UpdatedAt = timestamp
|
|
}
|
|
|
|
// GetCreatedAt returns the creation timestamp
|
|
func (b *Model) GetCreatedAt() int64 {
|
|
return b.CreatedAt
|
|
}
|
|
|
|
// GetUpdatedAt returns the update timestamp
|
|
func (b *Model) GetUpdatedAt() int64 {
|
|
return b.UpdatedAt
|
|
}
|