feat: 实现分类管理功能,包括数据模型、仓库层、服务层和数据库初始化脚本

This commit is contained in:
2026-01-28 09:55:29 +08:00
parent 1b6feae015
commit 4d024eba8e
6 changed files with 447 additions and 30 deletions

View File

@@ -26,6 +26,11 @@ func NewCategoryRepository(db *gorm.DB) *CategoryRepository {
return &CategoryRepository{db: db}
}
// GetDB returns the underlying database connection
func (r *CategoryRepository) GetDB() *gorm.DB {
return r.db
}
// Create creates a new category in the database
func (r *CategoryRepository) Create(category *models.Category) error {
if err := r.db.Create(category).Error; err != nil {