diff --git a/.gradle/8.8/executionHistory/executionHistory.lock b/.gradle/8.8/executionHistory/executionHistory.lock index 31b722d..3b99159 100644 Binary files a/.gradle/8.8/executionHistory/executionHistory.lock and b/.gradle/8.8/executionHistory/executionHistory.lock differ diff --git a/.gradle/8.8/fileHashes/fileHashes.lock b/.gradle/8.8/fileHashes/fileHashes.lock index 8da5bff..550b45c 100644 Binary files a/.gradle/8.8/fileHashes/fileHashes.lock and b/.gradle/8.8/fileHashes/fileHashes.lock differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index d92917f..36d1f71 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/src/main/java/likelion/MZConnent/api/club/ClubController.java b/src/main/java/likelion/MZConnent/api/club/ClubController.java index 6f9c8e3..64349cb 100644 --- a/src/main/java/likelion/MZConnent/api/club/ClubController.java +++ b/src/main/java/likelion/MZConnent/api/club/ClubController.java @@ -4,19 +4,18 @@ import likelion.MZConnent.domain.member.Member; import likelion.MZConnent.dto.club.request.CreateClubRequest; import likelion.MZConnent.dto.club.response.CreateClubResponse; +import likelion.MZConnent.dto.club.response.RegionCategoryResponse; import likelion.MZConnent.jwt.principle.UserPrinciple; import likelion.MZConnent.repository.member.MemberRepository; import likelion.MZConnent.service.club.ClubService; +import likelion.MZConnent.service.club.RegionCategoryService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.validation.BindingResult; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; @Slf4j @RestController @@ -24,6 +23,7 @@ public class ClubController { private final ClubService clubService; private final MemberRepository memberRepository; + private final RegionCategoryService regionCategoryService; @PostMapping("/api/clubs") public ResponseEntity createClub(@Valid @RequestBody CreateClubRequest request, @AuthenticationPrincipal UserPrinciple userPrinciple, BindingResult bindingResult) { @@ -39,4 +39,11 @@ public ResponseEntity createClub(@Valid @RequestBody CreateC CreateClubResponse response = clubService.createClub(request, member); return ResponseEntity.ok(response); } + + @GetMapping("/api/categories/region") + public ResponseEntity getAllRegionCategories() { + RegionCategoryResponse all = regionCategoryService.getAllRegionCategories(); + log.info("전체 지역 카테고리: {}", all.getRegionCategories()); + return ResponseEntity.ok(all); + } } diff --git a/src/main/java/likelion/MZConnent/config/SecurityConfig.java b/src/main/java/likelion/MZConnent/config/SecurityConfig.java index 935bcee..d1282d1 100644 --- a/src/main/java/likelion/MZConnent/config/SecurityConfig.java +++ b/src/main/java/likelion/MZConnent/config/SecurityConfig.java @@ -33,7 +33,7 @@ public class SecurityConfig { "/swagger", "/swagger-ui.html", "/swagger-ui/**", "/api-docs", "/api-docs/**", "/v3/api-docs/**", //swagger }; private final String[] anonymousUrl = { - "/api/auth/signup" + "/api/auth/signup", "/api/categories/region" }; diff --git a/src/main/java/likelion/MZConnent/dto/club/RegionCategoryDto.java b/src/main/java/likelion/MZConnent/dto/club/RegionCategoryDto.java new file mode 100644 index 0000000..0c299bf --- /dev/null +++ b/src/main/java/likelion/MZConnent/dto/club/RegionCategoryDto.java @@ -0,0 +1,18 @@ +package likelion.MZConnent.dto.club; + +import likelion.MZConnent.domain.club.RegionCategory; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class RegionCategoryDto { + private Long regionCategoryId; + private String name; + + public RegionCategoryDto(RegionCategory regionCategory) { + this.regionCategoryId = regionCategory.getRegionId(); + this.name = regionCategory.getName(); + } +} diff --git a/src/main/java/likelion/MZConnent/dto/club/response/RegionCategoryResponse.java b/src/main/java/likelion/MZConnent/dto/club/response/RegionCategoryResponse.java new file mode 100644 index 0000000..0509bb6 --- /dev/null +++ b/src/main/java/likelion/MZConnent/dto/club/response/RegionCategoryResponse.java @@ -0,0 +1,24 @@ +package likelion.MZConnent.dto.club.response; + +import likelion.MZConnent.domain.club.RegionCategory; +import likelion.MZConnent.dto.club.RegionCategoryDto; +import likelion.MZConnent.dto.culture.CultureCategoryDto; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +@Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class RegionCategoryResponse { + List regionCategories = new ArrayList<>(); + + public RegionCategoryResponse(List regionCategory) { + this.regionCategories = regionCategory.stream() + .map(RegionCategoryDto::new) + .collect(Collectors.toList()); + } +} diff --git a/src/main/java/likelion/MZConnent/service/club/RegionCategoryService.java b/src/main/java/likelion/MZConnent/service/club/RegionCategoryService.java new file mode 100644 index 0000000..325a936 --- /dev/null +++ b/src/main/java/likelion/MZConnent/service/club/RegionCategoryService.java @@ -0,0 +1,23 @@ +package likelion.MZConnent.service.club; + +import likelion.MZConnent.domain.club.RegionCategory; +import likelion.MZConnent.dto.club.RegionCategoryDto; +import likelion.MZConnent.dto.club.response.RegionCategoryResponse; +import likelion.MZConnent.repository.club.RegionCategoryRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +@Service +@RequiredArgsConstructor +public class RegionCategoryService { + private final RegionCategoryRepository regionCategoryRepository; + + public RegionCategoryResponse getAllRegionCategories() { + List regionCategories = regionCategoryRepository.findAll(); + + return new RegionCategoryResponse(regionCategories); + } +}