add initial application structure with configuration, logging, and health check endpoints

This commit is contained in:
kever
2026-01-15 21:39:15 +08:00
parent fed727e593
commit ed8c3d55b8
103 changed files with 39974 additions and 80 deletions

View 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
}