Skip to content

Commit

Permalink
refactor: change package structure for city/region/country
Browse files Browse the repository at this point in the history
  • Loading branch information
ShulV committed Oct 29, 2023
1 parent 8afc5c4 commit 0c44436
Show file tree
Hide file tree
Showing 18 changed files with 54 additions and 46 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.shulpov.spots_app.controllers;
package com.shulpov.spots_app.location.controllers;

import com.shulpov.spots_app.dto.CityDto;
import com.shulpov.spots_app.models.City;
import com.shulpov.spots_app.services.CityService;
import com.shulpov.spots_app.location.dto.CityDto;
import com.shulpov.spots_app.location.models.City;
import com.shulpov.spots_app.location.services.CityService;
import com.shulpov.spots_app.utils.DtoConverter;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
Expand All @@ -22,6 +22,7 @@
@RequestMapping(value ="/api/cities", produces = "application/json")
@Tag(name="Контроллер городов (справочник)", description="Выдает города")
public class CityController {
private static final String ERROR_MESSAGE_KEY = "errorMessage";
private final CityService cityService;

private final DtoConverter dtoConverter;
Expand All @@ -46,7 +47,7 @@ public ResponseEntity<?> getAll() {
} catch (NotFoundException e) {
return ResponseEntity
.status(HttpStatus.NOT_FOUND)
.body(Map.of("errorMessage", "There is no data in the table"));
.body(Map.of(ERROR_MESSAGE_KEY, "There is no data in the table"));
}
}

Expand All @@ -64,7 +65,7 @@ public ResponseEntity<?> getByRegionId(@PathVariable("id") Integer id){
} catch (NotFoundException e) {
return ResponseEntity
.status(HttpStatus.NOT_FOUND)
.body(Map.of("errorMessage", "Region with id=" + id + " not found"));
.body(Map.of(ERROR_MESSAGE_KEY, "Region with id=" + id + " not found"));
}
}

Expand All @@ -82,7 +83,7 @@ public ResponseEntity<?> getByCountryId(@PathVariable("id") Integer id) {
} catch (NotFoundException e) {
return ResponseEntity
.status(HttpStatus.NOT_FOUND)
.body(Map.of("errorMessage", "Country with id=" + id + " not found"));
.body(Map.of(ERROR_MESSAGE_KEY, "Country with id=" + id + " not found"));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.shulpov.spots_app.controllers;
package com.shulpov.spots_app.location.controllers;

import com.shulpov.spots_app.dto.CountryDto;
import com.shulpov.spots_app.services.CountryService;
import com.shulpov.spots_app.location.dto.CountryDto;
import com.shulpov.spots_app.location.services.CountryService;
import com.shulpov.spots_app.utils.DtoConverter;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.shulpov.spots_app.controllers;
package com.shulpov.spots_app.location.controllers;

import com.shulpov.spots_app.dto.RegionDto;
import com.shulpov.spots_app.models.Region;
import com.shulpov.spots_app.services.RegionService;
import com.shulpov.spots_app.location.dto.RegionDto;
import com.shulpov.spots_app.location.models.Region;
import com.shulpov.spots_app.location.services.RegionService;
import com.shulpov.spots_app.utils.DtoConverter;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.shulpov.spots_app.dto;
package com.shulpov.spots_app.location.dto;

import lombok.Getter;
import lombok.Setter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.shulpov.spots_app.dto;
package com.shulpov.spots_app.location.dto;

import lombok.Getter;
import lombok.Setter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.shulpov.spots_app.dto;
package com.shulpov.spots_app.location.dto;

import lombok.Getter;
import lombok.Setter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.shulpov.spots_app.models;
package com.shulpov.spots_app.location.models;

import com.shulpov.spots_app.models.Spot;
import com.shulpov.spots_app.user.User;
import jakarta.persistence.*;
import lombok.Builder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.shulpov.spots_app.models;
package com.shulpov.spots_app.location.models;

import jakarta.persistence.*;
import lombok.Builder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.shulpov.spots_app.models;
package com.shulpov.spots_app.location.models;

import jakarta.persistence.*;
import lombok.Builder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.shulpov.spots_app.repo;
package com.shulpov.spots_app.location.repo;

import com.shulpov.spots_app.models.City;
import com.shulpov.spots_app.models.Country;
import com.shulpov.spots_app.models.Region;
import com.shulpov.spots_app.location.models.City;
import com.shulpov.spots_app.location.models.Country;
import com.shulpov.spots_app.location.models.Region;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.shulpov.spots_app.repo;
package com.shulpov.spots_app.location.repo;

import com.shulpov.spots_app.models.Country;
import com.shulpov.spots_app.location.models.Country;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.shulpov.spots_app.repo;
package com.shulpov.spots_app.location.repo;

import com.shulpov.spots_app.models.Country;
import com.shulpov.spots_app.models.Region;
import com.shulpov.spots_app.location.models.Country;
import com.shulpov.spots_app.location.models.Region;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.shulpov.spots_app.services;
package com.shulpov.spots_app.location.services;

import com.shulpov.spots_app.models.City;
import com.shulpov.spots_app.models.Country;
import com.shulpov.spots_app.models.Region;
import com.shulpov.spots_app.repo.CityRepo;
import com.shulpov.spots_app.location.models.City;
import com.shulpov.spots_app.location.models.Country;
import com.shulpov.spots_app.location.models.Region;
import com.shulpov.spots_app.location.repo.CityRepo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.shulpov.spots_app.services;
package com.shulpov.spots_app.location.services;

import com.shulpov.spots_app.models.Country;
import com.shulpov.spots_app.repo.CountryRepo;
import com.shulpov.spots_app.location.models.Country;
import com.shulpov.spots_app.location.repo.CountryRepo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.shulpov.spots_app.services;
package com.shulpov.spots_app.location.services;

import com.shulpov.spots_app.models.Country;
import com.shulpov.spots_app.models.Region;
import com.shulpov.spots_app.repo.RegionRepo;
import com.shulpov.spots_app.location.models.Country;
import com.shulpov.spots_app.location.models.Region;
import com.shulpov.spots_app.location.repo.RegionRepo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Scope;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/shulpov/spots_app/models/Spot.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.shulpov.spots_app.models;

import com.shulpov.spots_app.location.models.City;
import com.shulpov.spots_app.user.User;
import jakarta.persistence.*;

Expand Down
9 changes: 4 additions & 5 deletions src/main/java/com/shulpov/spots_app/user/User.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.shulpov.spots_app.user;

import com.shulpov.spots_app.auth.token.Token;
import com.shulpov.spots_app.location.models.City;
import com.shulpov.spots_app.models.*;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.*;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

Expand All @@ -16,7 +14,8 @@


@Entity
@Data
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/shulpov/spots_app/utils/DtoConverter.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package com.shulpov.spots_app.utils;

import com.shulpov.spots_app.dto.*;
import com.shulpov.spots_app.location.dto.CityDto;
import com.shulpov.spots_app.location.dto.CountryDto;
import com.shulpov.spots_app.location.dto.RegionDto;
import com.shulpov.spots_app.location.models.City;
import com.shulpov.spots_app.location.models.Country;
import com.shulpov.spots_app.location.models.Region;
import com.shulpov.spots_app.models.*;
import com.shulpov.spots_app.services.*;
import com.shulpov.spots_app.user.Role;
Expand Down

0 comments on commit 0c44436

Please sign in to comment.