Skip to content

Commit

Permalink
feat: 문화 저장 시 region도 저장하게 변경
Browse files Browse the repository at this point in the history
문화 저장 시 region도 저장하게 변경함
  • Loading branch information
chaeyoungeee committed Jul 27, 2024
1 parent 09873f5 commit 2e2ca3d
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package likelion.MZConnent.api.culture;

import likelion.MZConnent.domain.club.RegionCategory;
import likelion.MZConnent.domain.culture.Culture;
import likelion.MZConnent.domain.culture.CultureCategory;
import likelion.MZConnent.dto.culture.request.CreateCultureRequest;
import likelion.MZConnent.repository.club.RegionCategoryRepository;
import likelion.MZConnent.repository.culture.CultureCategoryRepository;
import likelion.MZConnent.repository.culture.CultureRepository;
import lombok.RequiredArgsConstructor;
Expand All @@ -22,6 +24,7 @@
public class CreateCultureController {
private final CultureRepository cultureRepository;
private final CultureCategoryRepository cultureCategoryRepository;
private final RegionCategoryRepository regionCategoryRepository;

@PostMapping("/api/cultures")
public ResponseEntity<Culture> createCulture(@RequestBody CreateCultureRequest request) {
Expand All @@ -30,6 +33,8 @@ public ResponseEntity<Culture> createCulture(@RequestBody CreateCultureRequest r

CultureCategory cultureCategory = cultureCategoryRepository.findById(request.getCultureCategoryId()).orElseThrow(()-> new IllegalArgumentException("해당하는 카테고리가 존재하지 않습니다."));

RegionCategory regionCategory = regionCategoryRepository.findById(request.getRegionId()).orElseThrow(()-> new IllegalArgumentException("해당하는 지역이 존재하지 않습니다."));

Culture newCulture = Culture.builder()
.name(request.getName())
.summary(request.getSummary())
Expand All @@ -38,6 +43,7 @@ public ResponseEntity<Culture> createCulture(@RequestBody CreateCultureRequest r
.getCultureImageUrl())
.recommendedMember(request.getRecommendedMember())
.cultureCategory(cultureCategory)
.region(regionCategory)
.build();

Culture savedCulture = cultureRepository.save(newCulture);
Expand Down

0 comments on commit 2e2ca3d

Please sign in to comment.