12345678910111213141516171819202122232425 |
- package db
- import (
- "context"
- "youngee_b_api/model/gorm_model"
- "youngee_b_api/model/http_model"
- )
- func CreateProductPhoto(ctx context.Context, productID int, newProductPhotos []http_model.CreateProductPhoto) error {
- db := GetReadDB(ctx)
- productPhotos := []gorm_model.YounggeeProductPhoto{}
- for _, newPhoto := range newProductPhotos {
- productPhoto := gorm_model.YounggeeProductPhoto{
- PhotoUrl: newPhoto.PhotoUrl,
- Symbol: newPhoto.Symbol,
- ProductID: productID,
- }
- productPhotos = append(productPhotos, productPhoto)
- }
- err := db.Create(&productPhotos).Error
- if err != nil {
- return err
- }
- return nil
- }
|