package commands import ( m "netina/models" c "netina/models/commands" s "netina/repositories/store" "netina/validation" "time" ) type CreateStoreHandler struct { Repository s.StoreCommandRepository } func (r *CreateStoreHandler) Handle (command c.CreateStoreCommand)error { if err := validation.ValidateStruct(command); err != nil { return err } store := &m.Store{ Owner_id: command.Owner_id, Name: command.Name, Address: command.Address, PhoneNumber: command.PhoneNumber, WebAddress: command.WebAddress, ApiAddress: command.ApiAddress, AdminPanelAddress: command.AdminPanelAddress, StorageAddress: command.StorageAddress, License_id: command.License_id, Modified_by: command.Modified_by, Created_at: time.Now(), } return r.Repository.CreateStore(store) } type UpdateStoreHandler struct { Repository s.StoreCommandRepository } func (r *UpdateStoreHandler) Handle (id uint ,command c.UpdateStoreCommand)(*m.Store , error) { if err := validation.ValidateStruct(command); err != nil { return nil,err } store := &m.Store{ Owner_id: command.Owner_id, Name: command.Name, Address: command.Address, PhoneNumber: command.PhoneNumber, WebAddress: command.WebAddress, ApiAddress: command.ApiAddress, AdminPanelAddress: command.AdminPanelAddress, StorageAddress: command.StorageAddress, License_id: command.License_id, Modified_by: command.Modified_by, } return r.Repository.UpdateStore(id ,store ) } type RemoveStoreHandler struct { Repository s.StoreCommandRepository } func (r *RemoveStoreHandler) Handle (id uint) error { return r.Repository.RemoveStore(id) }