From 5b07032c1c6bd042078d62c9fc3024d0e600bb05 Mon Sep 17 00:00:00 2001 From: oosedus Date: Thu, 25 Jul 2024 16:53:02 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=A7=80=EC=97=AD=20=EC=B9=B4=ED=85=8C?= =?UTF-8?q?=EA=B3=A0=EB=A6=AC=20=EC=A1=B0=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../executionHistory/executionHistory.lock | Bin 17 -> 17 bytes .gradle/8.8/fileHashes/fileHashes.lock | Bin 17 -> 17 bytes .../buildOutputCleanup.lock | Bin 17 -> 17 bytes .../MZConnent/api/club/ClubController.java | 15 ++++++++--- .../MZConnent/config/SecurityConfig.java | 2 +- .../MZConnent/dto/club/RegionCategoryDto.java | 18 +++++++++++++ .../club/response/RegionCategoryResponse.java | 24 ++++++++++++++++++ .../service/club/RegionCategoryService.java | 23 +++++++++++++++++ 8 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 src/main/java/likelion/MZConnent/dto/club/RegionCategoryDto.java create mode 100644 src/main/java/likelion/MZConnent/dto/club/response/RegionCategoryResponse.java create mode 100644 src/main/java/likelion/MZConnent/service/club/RegionCategoryService.java diff --git a/.gradle/8.8/executionHistory/executionHistory.lock b/.gradle/8.8/executionHistory/executionHistory.lock index 31b722dffd4a9ca748d20a887f6fb79be1d6975e..3b99159ff484703d9046cca068eff312942672ca 100644 GIT binary patch literal 17 TcmZSHP-fmz;vOKx00H~}C^7>P literal 17 ScmZSHP-fmz;vOKx00jUjBLe~e diff --git a/.gradle/8.8/fileHashes/fileHashes.lock b/.gradle/8.8/fileHashes/fileHashes.lock index 8da5bff25ba2e20fd80035c51d7cb6de96abf567..550b45cf6c2d27edbb2bbf804423d34453c83836 100644 GIT binary patch literal 17 VcmZRcGGUkcmR8wd1~6dc1^_Tz1HJ$N literal 17 TcmZRcGGUkcmR8wd1}FdkFi!)r diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index d92917fdcaaaca349730c9c2db67b7b827e37a05..36d1f7121f25e50a039564941a32f75b2faa31c7 100644 GIT binary patch literal 17 UcmZSnsC8m)WKdT(0|eLt05<6afdBvi literal 17 UcmZSnsC8m)WKdT(0|YPv05+`zMF0Q* 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); + } +}