package db import ( "context" "youngee_b_api/model/gorm_model" "youngee_b_api/model/http_model" ) func CreateProduct(ctx context.Context, newProduct http_model.CreateProductRequest) (*http_model.CreateProductData, error) { db := GetReadDB(ctx) Product := gorm_model.YounggeeProduct{ ProductName: newProduct.ProductName, ProductType: newProduct.ProductType, ShopAddress: newProduct.ShopAddress, ProductPrice: newProduct.ProductPrice, ProductUrl: newProduct.ProductUrl, EnterpriseID: newProduct.EnterpriseID, BrandName: newProduct.BrandName, } err := db.Create(&Product).Error if err != nil { return nil, err } data := &http_model.CreateProductData{ ProductID: Product.ProductID, } return data, nil }