2025-03-10 10:28:23 +08:00

28 lines
526 B
Go

package adssvc
import (
"fmt"
adsdomain "legalgo-BE-go/internal/domain/ads"
"strings"
"github.com/google/uuid"
)
func (i *impl) Create(spec adsdomain.AdsReq) error {
if !(strings.HasPrefix(spec.Image, "http")) {
return fmt.Errorf("image url is not started with http")
}
if !(strings.HasPrefix(spec.URL, "http")) {
return fmt.Errorf("url is not started with http")
}
newSpec := adsdomain.Ads{
ID: uuid.NewString(),
ImageUrl: spec.Image,
Url: spec.URL,
}
return i.adsRepo.Create(newSpec)
}