68 lines
1.4 KiB
Go
68 lines
1.4 KiB
Go
package commands
|
|
|
|
import (
|
|
"netina/models"
|
|
s "netina/repositories/store"
|
|
"time"
|
|
)
|
|
|
|
|
|
type CreateStoreHandler struct {
|
|
Repository s.StoreCommandRepository
|
|
}
|
|
|
|
|
|
func (r *CreateStoreHandler) Handle (command models.CreateStoreCommand)error {
|
|
store := &models.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 models.UpdateStoreCommand)(*models.Store , error) {
|
|
store := &models.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)
|
|
} |