32 lines
775 B
Go
32 lines
775 B
Go
package services
|
|
|
|
import (
|
|
"netina/commands"
|
|
models "netina/models"
|
|
cm "netina/models/commands"
|
|
plan_repository "netina/repositories/plan"
|
|
)
|
|
|
|
|
|
|
|
type PlanService struct {
|
|
CommandRepo plan_repository.PlanCommandRepository
|
|
QueryRepo plan_repository.PlanQueryRepository
|
|
}
|
|
|
|
|
|
func(s *PlanService) Createplan(cmd cm.CreatePlanCommand) error {
|
|
handler := commands.CreatePlanHandler{Repository: s.CommandRepo}
|
|
return handler.Handle(cmd)
|
|
}
|
|
|
|
|
|
func(s *PlanService) Updateplan(id uint,cmd cm.UpdatePlanCommand)(*models.Plan ,error) {
|
|
handler := commands.UpdatePlanHandler{Repository: s.CommandRepo}
|
|
return handler.Handle(id,cmd)
|
|
}
|
|
|
|
func(s *PlanService) Removeplan(id uint) error {
|
|
handler := commands.RemovePlanHandler{Repository: s.CommandRepo}
|
|
return handler.Handle(id)
|
|
} |