35 lines
938 B
Go
35 lines
938 B
Go
|
|
package service
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"web-qudo-be/app/module/hero_section_image/repository"
|
||
|
|
)
|
||
|
|
|
||
|
|
type HeroSectionImageService struct {
|
||
|
|
Repo *repository.HeroSectionImageRepository
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewHeroSectionImageService(repo *repository.HeroSectionImageRepository) *HeroSectionImageService {
|
||
|
|
return &HeroSectionImageService{Repo: repo}
|
||
|
|
}
|
||
|
|
|
||
|
|
// GET by hero_id
|
||
|
|
func (s *HeroSectionImageService) GetByHeroID(ctx context.Context, heroId int) (interface{}, error) {
|
||
|
|
return s.Repo.FindByHeroID(ctx, heroId)
|
||
|
|
}
|
||
|
|
|
||
|
|
// CREATE (UPLOAD)
|
||
|
|
func (s *HeroSectionImageService) Upload(ctx context.Context, heroId int, path, url string) error {
|
||
|
|
return s.Repo.Create(ctx, heroId, path, url)
|
||
|
|
}
|
||
|
|
|
||
|
|
// UPDATE
|
||
|
|
func (s *HeroSectionImageService) Update(ctx context.Context, id int, path, url string) error {
|
||
|
|
return s.Repo.Update(ctx, id, path, url)
|
||
|
|
}
|
||
|
|
|
||
|
|
// DELETE
|
||
|
|
func (s *HeroSectionImageService) Delete(ctx context.Context, id int) error {
|
||
|
|
return s.Repo.Delete(ctx, id)
|
||
|
|
}
|