package db import ( "context" "youngee_b_api/model/gorm_model" ) func CreateProductPhoto(ctx context.Context, productPhotos []gorm_model.YounggeeProductPhoto) error { db := GetReadDB(ctx) err := db.Create(&productPhotos).Error if err != nil { return err } return nil } func GetProductPhotoByProductID(ctx context.Context, productID int64) ([]gorm_model.YounggeeProductPhoto, error) { db := GetReadDB(ctx) productPhotos := []gorm_model.YounggeeProductPhoto{} err := db.Where("product_id = ?", productID).Find(&productPhotos).Error if err != nil { return nil, err } return productPhotos, nil } func DeleteProductPhotoByProductID(ctx context.Context, productID int64) error { db := GetReadDB(ctx) err := db.Where("product_id = ?", productID).Delete(&gorm_model.YounggeeProductPhoto{}).Error if err != nil { return err } return nil } // GetStorePhotoByStoreID 根据门店ID查找门店图片信息 func GetStorePhotoByStoreID(ctx context.Context, storeId int) ([]gorm_model.YounggeeProductPhoto, error) { db := GetReadDB(ctx) productPhotos := []gorm_model.YounggeeProductPhoto{} err := db.Where("store_id = ?", storeId).Find(&productPhotos).Error if err != nil { return nil, err } return productPhotos, nil } // GetTeamPhotoByStoreID 根据团购ID查找团购图片信息 func GetTeamPhotoByStoreID(ctx context.Context, teamId int) ([]gorm_model.YounggeeProductPhoto, error) { db := GetReadDB(ctx) productPhotos := []gorm_model.YounggeeProductPhoto{} err := db.Where("team_buying_id = ?", teamId).Find(&productPhotos).Error if err != nil { return nil, err } return productPhotos, nil }