-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[#58] 기타 카테고리 미조회 에러 해결
- Loading branch information
Showing
5 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/main/java/com/hobak/happinessql/domain/activity/application/CategoryCreateService.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,21 @@ | ||
package com.hobak.happinessql.domain.activity.application; | ||
|
||
import com.hobak.happinessql.domain.activity.converter.CategoryConverter; | ||
import com.hobak.happinessql.domain.activity.domain.Category; | ||
import com.hobak.happinessql.domain.activity.dto.CategoryResponseDto; | ||
import com.hobak.happinessql.domain.activity.repository.CategoryRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class CategoryCreateService { | ||
private final CategoryRepository categoryRepository; | ||
public CategoryResponseDto createCategory(Long userId){ | ||
Category category = CategoryConverter.toCategory(userId); | ||
categoryRepository.save(category); | ||
return CategoryConverter.toCategoryResponseDto(category.getCategoryId()); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/hobak/happinessql/domain/activity/converter/CategoryConverter.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,18 @@ | ||
package com.hobak.happinessql.domain.activity.converter; | ||
|
||
import com.hobak.happinessql.domain.activity.domain.Category; | ||
import com.hobak.happinessql.domain.activity.dto.CategoryResponseDto; | ||
|
||
public class CategoryConverter { | ||
public static Category toCategory(Long userId) { | ||
return Category.builder() | ||
.name("기타") | ||
.userId(userId) | ||
.build(); | ||
} | ||
public static CategoryResponseDto toCategoryResponseDto(Long categoryId){ | ||
return CategoryResponseDto.builder() | ||
.categoryId(categoryId) | ||
.build(); | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
src/main/java/com/hobak/happinessql/domain/activity/dto/CategoryResponseDto.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,16 @@ | ||
package com.hobak.happinessql.domain.activity.dto; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class CategoryResponseDto { | ||
private Long categoryId; | ||
@Builder | ||
CategoryResponseDto(Long categoryId){ | ||
this.categoryId = categoryId; | ||
} | ||
} |
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