style: форматирование кода - убраны лишние пустые строки и исправлены импорты
This commit is contained in:
@@ -34,7 +34,7 @@ func NewLocationService(locationRepo repository.LocationRepository) LocationServ
|
||||
|
||||
func (s *locationService) CreateLocation(ctx context.Context, orgID uuid.UUID, req *models.CreateLocationRequest) (*models.StorageLocation, error) {
|
||||
s.logger.Info("Creating location for organization: ", orgID)
|
||||
|
||||
|
||||
location := &models.StorageLocation{
|
||||
ID: uuid.New(),
|
||||
OrganizationID: orgID,
|
||||
@@ -45,86 +45,86 @@ func (s *locationService) CreateLocation(ctx context.Context, orgID uuid.UUID, r
|
||||
Coordinates: req.Coordinates,
|
||||
CreatedAt: time.Now(),
|
||||
}
|
||||
|
||||
|
||||
if err := s.locationRepo.Create(ctx, location); err != nil {
|
||||
s.logger.Error("Failed to create location: ", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
s.logger.Info("Location created successfully: ", location.ID)
|
||||
return location, nil
|
||||
}
|
||||
|
||||
func (s *locationService) GetLocation(ctx context.Context, id uuid.UUID, orgID uuid.UUID) (*models.StorageLocation, error) {
|
||||
s.logger.Info("Getting location: ", id, " for organization: ", orgID)
|
||||
|
||||
|
||||
location, err := s.locationRepo.GetByID(ctx, id, orgID)
|
||||
if err != nil {
|
||||
s.logger.Error("Failed to get location: ", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
return location, nil
|
||||
}
|
||||
|
||||
func (s *locationService) GetLocations(ctx context.Context, orgID uuid.UUID) ([]*models.StorageLocation, error) {
|
||||
s.logger.Info("Getting all locations for organization: ", orgID)
|
||||
|
||||
|
||||
locations, err := s.locationRepo.GetByOrganization(ctx, orgID)
|
||||
if err != nil {
|
||||
s.logger.Error("Failed to get locations: ", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
return locations, nil
|
||||
}
|
||||
|
||||
func (s *locationService) UpdateLocation(ctx context.Context, id uuid.UUID, orgID uuid.UUID, req *models.CreateLocationRequest) (*models.StorageLocation, error) {
|
||||
s.logger.Info("Updating location: ", id, " for organization: ", orgID)
|
||||
|
||||
|
||||
// Сначала получаем существующую локацию
|
||||
location, err := s.locationRepo.GetByID(ctx, id, orgID)
|
||||
if err != nil {
|
||||
s.logger.Error("Failed to get location for update: ", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
// Обновляем поля
|
||||
location.ParentID = req.ParentID
|
||||
location.Name = req.Name
|
||||
location.Address = req.Address
|
||||
location.Type = req.Type
|
||||
location.Coordinates = req.Coordinates
|
||||
|
||||
|
||||
if err := s.locationRepo.Update(ctx, location); err != nil {
|
||||
s.logger.Error("Failed to update location: ", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
s.logger.Info("Location updated successfully: ", location.ID)
|
||||
return location, nil
|
||||
}
|
||||
|
||||
func (s *locationService) DeleteLocation(ctx context.Context, id uuid.UUID, orgID uuid.UUID) error {
|
||||
s.logger.Info("Deleting location: ", id, " for organization: ", orgID)
|
||||
|
||||
|
||||
if err := s.locationRepo.Delete(ctx, id, orgID); err != nil {
|
||||
s.logger.Error("Failed to delete location: ", err)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
s.logger.Info("Location deleted successfully: ", id)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *locationService) GetChildren(ctx context.Context, parentID uuid.UUID, orgID uuid.UUID) ([]*models.StorageLocation, error) {
|
||||
s.logger.Info("Getting children for location: ", parentID, " in organization: ", orgID)
|
||||
|
||||
|
||||
children, err := s.locationRepo.GetChildren(ctx, parentID, orgID)
|
||||
if err != nil {
|
||||
s.logger.Error("Failed to get children: ", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
return children, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user