5d721705b7
- Updated the MongoDB driver from v1.17.4 to v2.3.0, ensuring compatibility with the latest features and improvements. - Refactored company-related entity and repository files to utilize the new driver, replacing `primitive.ObjectID` with `bson.ObjectID` for ID handling. - Adjusted the configuration in `.drone.yml` to include the `main` branch in the trigger settings, enhancing CI/CD pipeline flexibility.
47 lines
1.3 KiB
Go
47 lines
1.3 KiB
Go
package company_category
|
|
|
|
import (
|
|
"tm/pkg/mongo"
|
|
|
|
"go.mongodb.org/mongo-driver/v2/bson"
|
|
)
|
|
|
|
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, _ = bson.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
|
|
}
|