package commands import ( m "netina/models" c "netina/models/commands" p "netina/repositories/plan" "netina/validation" "time" ) type CreatePlanHandler struct { Repository p.PlanCommandRepository } func (r *CreatePlanHandler) Handle(command c.CreatePlanCommand , modified_by string) error { if err := validation.ValidateStruct(command); err != nil { return err } plan := &m.Plan{ Price: command.Price, Period: command.Period, Partnership: *command.Partnership, PercentageOfOwner: command.PercentageOfOwner, Created_at: time.Now(), Modified_by: modified_by, } return r.Repository.CreatePlan(plan) } type UpdatePlanHandler struct { Repository p.PlanCommandRepository } func (r *UpdatePlanHandler) Handle (id uint , command c.UpdatePlanCommand , modified_by string)(*m.Plan , error) { if err := validation.ValidateStruct(command); err != nil { return nil , err } plan := &m.Plan{ Price: command.Price, Period: command.Period, Partnership: *command.Partnership, PercentageOfOwner: command.PercentageOfOwner, Modified_by: modified_by, Modified_at: time.Now(), } return r.Repository.UpdatePlan(id , plan) } type RemovePlanHandler struct { Repository p.PlanCommandRepository } func (r *RemovePlanHandler) Handle (id uint )error { return r.Repository.RemovePlan(id) }