-
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.
<body> - code formatting - 자동 수정 기능을 이용하여 수정 진행 <footer> - 관련: #28
- Loading branch information
Showing
118 changed files
with
3,755 additions
and
3,455 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# namo | ||
|
||
### ERD Cloud | ||
|
||
https://www.erdcloud.com/d/kdtBpLtftuRiBXdvc |
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
44 changes: 22 additions & 22 deletions
44
...va/com/example/namo2/domain/category/application/converter/CategoryResponseConverter.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 |
---|---|---|
@@ -1,33 +1,33 @@ | ||
package com.example.namo2.domain.category.application.converter; | ||
|
||
import com.example.namo2.domain.category.domain.Category; | ||
import com.example.namo2.domain.category.ui.dto.CategoryResponse; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import com.example.namo2.domain.category.domain.Category; | ||
import com.example.namo2.domain.category.ui.dto.CategoryResponse; | ||
|
||
public class CategoryResponseConverter { | ||
|
||
private CategoryResponseConverter() { | ||
throw new IllegalStateException("Utility class"); | ||
} | ||
private CategoryResponseConverter() { | ||
throw new IllegalStateException("Utility class"); | ||
} | ||
|
||
public static CategoryResponse.CategoryIdDto toCategoryIdDto(Category category) { | ||
return new CategoryResponse.CategoryIdDto(category.getId()); | ||
} | ||
public static CategoryResponse.CategoryIdDto toCategoryIdDto(Category category) { | ||
return new CategoryResponse.CategoryIdDto(category.getId()); | ||
} | ||
|
||
public static List<CategoryResponse.CategoryDto> toCategoryDtoList(List<Category> categories) { | ||
return categories.stream() | ||
.map(CategoryResponseConverter::toCategoryDto) | ||
.collect(Collectors.toList()); | ||
} | ||
public static List<CategoryResponse.CategoryDto> toCategoryDtoList(List<Category> categories) { | ||
return categories.stream() | ||
.map(CategoryResponseConverter::toCategoryDto) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
public static CategoryResponse.CategoryDto toCategoryDto(Category category) { | ||
return new CategoryResponse.CategoryDto( | ||
category.getId(), | ||
category.getName(), | ||
category.getPalette().getId(), | ||
category.getShare() | ||
); | ||
} | ||
public static CategoryResponse.CategoryDto toCategoryDto(Category category) { | ||
return new CategoryResponse.CategoryDto( | ||
category.getId(), | ||
category.getName(), | ||
category.getPalette().getId(), | ||
category.getShare() | ||
); | ||
} | ||
} |
73 changes: 38 additions & 35 deletions
73
src/main/java/com/example/namo2/domain/category/application/impl/CategoryService.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 |
---|---|---|
@@ -1,50 +1,53 @@ | ||
package com.example.namo2.domain.category.application.impl; | ||
|
||
import static com.example.namo2.global.common.response.BaseResponseStatus.*; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
import com.example.namo2.domain.category.dao.repository.CategoryRepository; | ||
import com.example.namo2.domain.category.domain.Category; | ||
import com.example.namo2.domain.category.domain.CategoryStatus; | ||
import com.example.namo2.domain.category.domain.Palette; | ||
import com.example.namo2.domain.category.ui.dto.CategoryRequest; | ||
|
||
import com.example.namo2.domain.user.domain.User; | ||
import com.example.namo2.global.common.exception.BaseException; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
import com.example.namo2.global.common.exception.BaseException; | ||
|
||
import static com.example.namo2.global.common.response.BaseResponseStatus.NOT_FOUND_CATEGORY_FAILURE; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class CategoryService { | ||
private final CategoryRepository categoryRepository; | ||
|
||
public Category create(Category category) { | ||
return categoryRepository.save(category); | ||
} | ||
|
||
public List<Category> getCategories(Long userId) { | ||
return categoryRepository.findCategoriesByUserIdAndStatusEquals(userId, CategoryStatus.ACTIVE); | ||
} | ||
|
||
public void delete(Long categoryId) { | ||
Category category = getCategory(categoryId); | ||
category.delete(); | ||
} | ||
|
||
|
||
public Category getCategory(Long categoryId) { | ||
return categoryRepository.findById(categoryId) | ||
.orElseThrow(() -> new BaseException(NOT_FOUND_CATEGORY_FAILURE)); | ||
} | ||
|
||
public Category modifyCategory(Long categoryId, CategoryRequest.PostCategoryDto dto, Palette palette) { | ||
Category category = getCategory(categoryId); | ||
category.update(dto.getName(), dto.isShare(), palette); | ||
return category; | ||
} | ||
|
||
public List<Category> getMoimUsersCategories(List<User> users) { | ||
return categoryRepository.findMoimCategoriesByUsers(users); | ||
} | ||
private final CategoryRepository categoryRepository; | ||
|
||
public Category create(Category category) { | ||
return categoryRepository.save(category); | ||
} | ||
|
||
public List<Category> getCategories(Long userId) { | ||
return categoryRepository.findCategoriesByUserIdAndStatusEquals(userId, CategoryStatus.ACTIVE); | ||
} | ||
|
||
public void delete(Long categoryId) { | ||
Category category = getCategory(categoryId); | ||
category.delete(); | ||
} | ||
|
||
public Category getCategory(Long categoryId) { | ||
return categoryRepository.findById(categoryId) | ||
.orElseThrow(() -> new BaseException(NOT_FOUND_CATEGORY_FAILURE)); | ||
} | ||
|
||
public Category modifyCategory(Long categoryId, CategoryRequest.PostCategoryDto dto, Palette palette) { | ||
Category category = getCategory(categoryId); | ||
category.update(dto.getName(), dto.isShare(), palette); | ||
return category; | ||
} | ||
|
||
public List<Category> getMoimUsersCategories(List<User> users) { | ||
return categoryRepository.findMoimCategoriesByUsers(users); | ||
} | ||
} |
25 changes: 14 additions & 11 deletions
25
src/main/java/com/example/namo2/domain/category/application/impl/PaletteService.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 |
---|---|---|
@@ -1,25 +1,28 @@ | ||
package com.example.namo2.domain.category.application.impl; | ||
|
||
import static com.example.namo2.global.common.response.BaseResponseStatus.*; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
import com.example.namo2.domain.category.dao.repository.PaletteRepository; | ||
import com.example.namo2.domain.category.domain.Palette; | ||
|
||
import com.example.namo2.global.common.exception.BaseException; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import static com.example.namo2.global.common.response.BaseResponseStatus.NOT_FOUND_PALETTE_FAILURE; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class PaletteService { | ||
|
||
private final PaletteRepository paletteRepository; | ||
private final PaletteRepository paletteRepository; | ||
|
||
public Palette getPalette(Long paletteId) { | ||
return paletteRepository.findById(paletteId) | ||
.orElseThrow(() -> new BaseException(NOT_FOUND_PALETTE_FAILURE)); | ||
} | ||
public Palette getPalette(Long paletteId) { | ||
return paletteRepository.findById(paletteId) | ||
.orElseThrow(() -> new BaseException(NOT_FOUND_PALETTE_FAILURE)); | ||
} | ||
|
||
public Palette getReferenceById(Long id){ | ||
return paletteRepository.getReferenceById(id); | ||
} | ||
public Palette getReferenceById(Long id) { | ||
return paletteRepository.getReferenceById(id); | ||
} | ||
} |
23 changes: 12 additions & 11 deletions
23
src/main/java/com/example/namo2/domain/category/dao/repository/CategoryRepository.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 |
---|---|---|
@@ -1,21 +1,22 @@ | ||
package com.example.namo2.domain.category.dao.repository; | ||
|
||
import com.example.namo2.domain.category.ui.dto.MoimCategoryDto; | ||
import com.example.namo2.domain.category.domain.Category; | ||
import com.example.namo2.domain.category.domain.CategoryStatus; | ||
import com.example.namo2.domain.user.domain.User; | ||
import java.util.List; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
import java.util.List; | ||
import com.example.namo2.domain.category.domain.Category; | ||
import com.example.namo2.domain.category.domain.CategoryStatus; | ||
|
||
import com.example.namo2.domain.user.domain.User; | ||
|
||
public interface CategoryRepository extends JpaRepository<Category, Long> { | ||
public List<Category> findCategoriesByUserIdAndStatusEquals(Long userId, CategoryStatus status); | ||
public List<Category> findCategoriesByUserIdAndStatusEquals(Long userId, CategoryStatus status); | ||
|
||
@Query(value = "select c" + | ||
" from Category c" + | ||
" join fetch c.user" + | ||
" where c.user in :users and c.name = '모임'") | ||
List<Category> findMoimCategoriesByUsers(@Param("users") List<User> users); | ||
@Query(value = "select c" | ||
+ " from Category c" | ||
+ " join fetch c.user" | ||
+ " where c.user in :users and c.name = '모임'") | ||
List<Category> findMoimCategoriesByUsers(@Param("users") List<User> users); | ||
} |
Oops, something went wrong.