-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from LIKELION-TEAM4-HACKATHON/feature/login
전체 문화 조회 기능 추가함 + DB 테이블명 단수 변경
- Loading branch information
Showing
15 changed files
with
90 additions
and
13 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/main/java/likelion/MZConnent/api/culture/CultureController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package likelion.MZConnent.api.culture; | ||
|
||
import likelion.MZConnent.dto.culture.CultureCategoryResponse; | ||
import likelion.MZConnent.service.culture.CultureCategoryService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class CultureController { | ||
private final CultureCategoryService cultureCategoryService; | ||
|
||
// 전체 문화 카테고리 조회 | ||
@GetMapping("/api/categories/culture") | ||
public CultureCategoryResponse getAllCultureCategories() { | ||
CultureCategoryResponse all = cultureCategoryService.getAllCultureCategories(); | ||
log.info("전체 문화 카테고리: {}", all.getCultureCategories()); | ||
return all; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ | |
import java.util.List; | ||
|
||
@Entity | ||
@Table(name="clubs") | ||
@Getter | ||
@NoArgsConstructor | ||
public class Club { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/likelion/MZConnent/dto/culture/CultureCategoryResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package likelion.MZConnent.dto.culture; | ||
|
||
import likelion.MZConnent.domain.culture.CultureCategory; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
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 CultureCategoryResponse { | ||
List<CultureCategoryDto> cultureCategories = new ArrayList<>(); | ||
|
||
public CultureCategoryResponse(List<CultureCategory> cultureCategory) { | ||
this.cultureCategories = cultureCategory.stream() | ||
.map(CultureCategoryDto::new) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
@Getter | ||
private static class CultureCategoryDto { | ||
private Long cultureCategoryId; | ||
private String name; | ||
|
||
public CultureCategoryDto(CultureCategory cultureCategory) { | ||
this.cultureCategoryId = cultureCategory.getId(); | ||
this.name = getName(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/java/likelion/MZConnent/service/culture/CultureCategoryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package likelion.MZConnent.service.culture; | ||
|
||
|
||
import likelion.MZConnent.domain.culture.CultureCategory; | ||
import likelion.MZConnent.dto.culture.CultureCategoryResponse; | ||
import likelion.MZConnent.repository.culture.CultureCategoryRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class CultureCategoryService { | ||
private final CultureCategoryRepository cultureCategoryRepository; | ||
|
||
public CultureCategoryResponse getAllCultureCategories() { | ||
List<CultureCategory> cultureCategories = cultureCategoryRepository.findAll(); | ||
log.info("cultureCategories: {}", cultureCategories); | ||
return new CultureCategoryResponse(cultureCategories); | ||
} | ||
} |