fix_step null false
This commit is contained in:
@@ -34,13 +34,7 @@ func NewGormProductRepository(db *gorm.DB, logger *zap.Logger) repositories.Prod
|
||||
}
|
||||
|
||||
func (r *GormProductRepository) Create(ctx context.Context, entity entities.Product) (entities.Product, error) {
|
||||
// 使用 Select 明确指定所有字段,确保 false 值也能正确保存
|
||||
// 这样可以避免 GORM 的 default:true 标签在字段为 false 时使用数据库默认值
|
||||
err := r.GetDB(ctx).Select(
|
||||
"id", "old_id", "name", "code", "description", "content", "category_id",
|
||||
"price", "cost_price", "remark", "is_enabled", "is_visible", "is_package",
|
||||
"seo_title", "seo_description", "seo_keywords",
|
||||
).Create(&entity).Error
|
||||
err := r.CreateEntity(ctx, &entity)
|
||||
return entity, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user