|
@@ -14,13 +14,14 @@ type product struct {
|
|
|
|
|
|
func (*product) Create(ctx context.Context, newProduct http_model.CreateProductRequest, enterpriseID int64) (*http_model.CreateProductData, error) {
|
|
|
product := gorm_model.YounggeeProduct{
|
|
|
- ProductName: newProduct.ProductName,
|
|
|
- ProductType: newProduct.ProductType,
|
|
|
- ShopAddress: newProduct.ShopAddress,
|
|
|
- ProductPrice: newProduct.ProductPrice,
|
|
|
- ProductUrl: newProduct.ProductUrl,
|
|
|
- EnterpriseID: enterpriseID,
|
|
|
- BrandName: newProduct.BrandName,
|
|
|
+ ProductName: newProduct.ProductName,
|
|
|
+ ProductType: newProduct.ProductType,
|
|
|
+ ShopAddress: newProduct.ShopAddress,
|
|
|
+ ProductPrice: newProduct.ProductPrice,
|
|
|
+ ProductDetail: newProduct.ProductDetail,
|
|
|
+ ProductUrl: newProduct.ProductUrl,
|
|
|
+ EnterpriseID: enterpriseID,
|
|
|
+ BrandName: newProduct.BrandName,
|
|
|
}
|
|
|
productID, err := db.CreateProduct(ctx, product)
|
|
|
if err != nil {
|
|
@@ -48,14 +49,15 @@ func (*product) Create(ctx context.Context, newProduct http_model.CreateProductR
|
|
|
|
|
|
func (*product) Update(ctx context.Context, newProduct http_model.CreateProductRequest, enterpriseID int64) (*http_model.CreateProductData, error) {
|
|
|
product := gorm_model.YounggeeProduct{
|
|
|
- ProductID: newProduct.ProductId,
|
|
|
- ProductName: newProduct.ProductName,
|
|
|
- ProductType: newProduct.ProductType,
|
|
|
- ShopAddress: newProduct.ShopAddress,
|
|
|
- ProductPrice: newProduct.ProductPrice,
|
|
|
- ProductUrl: newProduct.ProductUrl,
|
|
|
- EnterpriseID: enterpriseID,
|
|
|
- BrandName: newProduct.BrandName,
|
|
|
+ ProductID: newProduct.ProductId,
|
|
|
+ ProductName: newProduct.ProductName,
|
|
|
+ ProductType: newProduct.ProductType,
|
|
|
+ ShopAddress: newProduct.ShopAddress,
|
|
|
+ ProductPrice: newProduct.ProductPrice,
|
|
|
+ ProductDetail: newProduct.ProductDetail,
|
|
|
+ ProductUrl: newProduct.ProductUrl,
|
|
|
+ EnterpriseID: enterpriseID,
|
|
|
+ BrandName: newProduct.BrandName,
|
|
|
}
|
|
|
productID, err := db.UpdateProduct(ctx, product)
|
|
|
if err != nil {
|
|
@@ -114,14 +116,15 @@ func (*product) FindByID(ctx context.Context, productID int64) (*http_model.Find
|
|
|
return nil, err
|
|
|
}
|
|
|
findProductData := http_model.FindProductData{
|
|
|
- ProductID: product.ProductID,
|
|
|
- ProductName: product.ProductName,
|
|
|
- ProductType: product.ProductType,
|
|
|
- ShopAddress: product.ShopAddress,
|
|
|
- ProductPrice: product.ProductPrice,
|
|
|
- ProductUrl: product.ProductUrl,
|
|
|
- EnterpriseID: product.EnterpriseID,
|
|
|
- BrandName: product.BrandName,
|
|
|
+ ProductID: product.ProductID,
|
|
|
+ ProductName: product.ProductName,
|
|
|
+ ProductType: product.ProductType,
|
|
|
+ ShopAddress: product.ShopAddress,
|
|
|
+ ProductPrice: product.ProductPrice,
|
|
|
+ ProductDetail: product.ProductDetail,
|
|
|
+ ProductUrl: product.ProductUrl,
|
|
|
+ EnterpriseID: product.EnterpriseID,
|
|
|
+ BrandName: product.BrandName,
|
|
|
}
|
|
|
for _, photo := range productPhotos {
|
|
|
productPhoto := http_model.ProductPhoto{
|