add initial application structure with configuration, logging, and health check endpoints
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"epic-ent/internal/domain/vo"
|
||||
"epic-ent/internal/repository"
|
||||
)
|
||||
|
||||
type HealthService struct {
|
||||
repo *repository.HealthRepository
|
||||
}
|
||||
|
||||
func NewHealthService(repo *repository.HealthRepository) *HealthService {
|
||||
return &HealthService{repo: repo}
|
||||
}
|
||||
|
||||
func (s *HealthService) Check() vo.HealthStatus {
|
||||
return s.repo.Check()
|
||||
}
|
||||
49
internal/service/hero_service.go
Normal file
49
internal/service/hero_service.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"epic-ent/internal/domain/dto"
|
||||
"epic-ent/internal/domain/vo"
|
||||
"epic-ent/internal/repository"
|
||||
)
|
||||
|
||||
type HeroService struct {
|
||||
repo *repository.HeroRepository
|
||||
}
|
||||
|
||||
func NewHeroService(repo *repository.HeroRepository) *HeroService {
|
||||
return &HeroService{repo: repo}
|
||||
}
|
||||
|
||||
func (s *HeroService) Create(ctx context.Context, req dto.HeroCreateRequest) (vo.Hero, error) {
|
||||
now := time.Now()
|
||||
if req.CreateTime == nil {
|
||||
req.CreateTime = &now
|
||||
}
|
||||
if req.UpdateTime == nil {
|
||||
req.UpdateTime = &now
|
||||
}
|
||||
if req.Deleted == nil {
|
||||
req.Deleted = boolPtr(false)
|
||||
}
|
||||
|
||||
return s.repo.Create(ctx, req)
|
||||
}
|
||||
|
||||
func (s *HeroService) GetByID(ctx context.Context, id int64) (vo.Hero, error) {
|
||||
return s.repo.GetByID(ctx, id)
|
||||
}
|
||||
|
||||
func (s *HeroService) Update(ctx context.Context, id int64, req dto.HeroUpdateRequest) (vo.Hero, error) {
|
||||
return s.repo.Update(ctx, id, req)
|
||||
}
|
||||
|
||||
func (s *HeroService) Delete(ctx context.Context, id int64) error {
|
||||
return s.repo.Delete(ctx, id)
|
||||
}
|
||||
|
||||
func boolPtr(v bool) *bool {
|
||||
return &v
|
||||
}
|
||||
@@ -4,6 +4,6 @@ import "go.uber.org/fx"
|
||||
|
||||
var Module = fx.Options(
|
||||
fx.Provide(
|
||||
NewHealthService,
|
||||
NewHeroService,
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user