991771ee19
- Introduced a new company category management feature, including CRUD operations for categories in both admin and public API endpoints. - Implemented category entity, service, repository, and handler layers following clean architecture principles. - Added new API routes for searching, retrieving, updating, deleting, and toggling publish status of categories, enhancing the overall functionality of the system. - Updated Swagger and YAML documentation to include detailed descriptions and examples for the new category endpoints, ensuring clarity for API consumers. - Enhanced error handling for duplicate categories and validation, improving the robustness of the category management process. - Updated existing routes to integrate category handling, ensuring a seamless user experience across the application.
47 lines
1.3 KiB
Go
47 lines
1.3 KiB
Go
package company_category
|
|
|
|
import (
|
|
"tm/pkg/mongo"
|
|
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
)
|
|
|
|
type Category struct {
|
|
mongo.Model `bson:",inline"`
|
|
Name string `bson:"name" json:"name"`
|
|
Description *string `bson:"description" json:"description"`
|
|
Thumbnail *string `bson:"thumbnail" json:"thumbnail"`
|
|
Published bool `bson:"published" json:"published"`
|
|
PublishedAt *int64 `bson:"published_at" json:"published_at"`
|
|
}
|
|
|
|
// SetID sets the category ID (implements IDSetter interface)
|
|
func (c *Category) SetID(id string) {
|
|
c.ID, _ = primitive.ObjectIDFromHex(id)
|
|
}
|
|
|
|
// GetID returns the category ID (implements IDGetter interface)
|
|
func (c *Category) GetID() string {
|
|
return c.ID.Hex()
|
|
}
|
|
|
|
// SetCreatedAt sets the created timestamp (implements Timestamp interface)
|
|
func (c *Category) SetCreatedAt(timestamp int64) {
|
|
c.CreatedAt = timestamp
|
|
}
|
|
|
|
// SetUpdatedAt sets the updated timestamp (implements Timestamp interface)
|
|
func (c *Category) SetUpdatedAt(timestamp int64) {
|
|
c.UpdatedAt = timestamp
|
|
}
|
|
|
|
// GetCreatedAt returns the created timestamp (implements Timestamp interface)
|
|
func (c *Category) GetCreatedAt() int64 {
|
|
return c.CreatedAt
|
|
}
|
|
|
|
// GetUpdatedAt returns the updated timestamp (implements Timestamp interface)
|
|
func (c *Category) GetUpdatedAt() int64 {
|
|
return c.UpdatedAt
|
|
}
|