package commands import ( m "netina/models" c "netina/models/commands" l "netina/repositories/license" "netina/validation" "time" ) type CreateLicenseHandler struct { Repository l.LicenseCommandRepository } func(r *CreateLicenseHandler) Handle (command c.CreateLicenseCommand) error { if err := validation.ValidateStruct(command); err != nil { return err } license := &m.License{ Plan_id: command.Plan_id, Period: command.Period, Created_at: time.Now(), Modified_by: command.Modified_by, } return r.Repository.CreateLicense(license) } type UpdateLicenseHandler struct { Repository l.LicenseCommandRepository } func (r *UpdateLicenseHandler) Handle (id uint , command c.UpdateLicenseCommand) (*m.License , error) { if err := validation.ValidateStruct(command); err != nil { return nil , err } license := &m.License{ Plan_id: command.Plan_id, Period: command.Period, Modified_by: command.Modified_by, } return r.Repository.UpdateLicense(id , license) } type RemoveLicenseHandler struct { Repository l.LicenseCommandRepository } func ( r *RemoveLicenseHandler) Handle (id uint) error { return r.Repository.RemoveLicense(id) }