-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature/48] 카테고리 validation 검증 로직 및 비기능 개발 #52
Changes from all commits
b5bf788
6ad668d
4c544ad
d18121e
9924bb8
f8bdc9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.example.namo2.domain.category.dao.repository; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.data.repository.query.Param; | ||
|
||
import com.example.namo2.domain.category.domain.Category; | ||
import com.example.namo2.domain.category.domain.CategoryKind; | ||
|
||
import com.example.namo2.domain.user.domain.User; | ||
|
||
public interface CategoryRepositoryCustom { | ||
List<Category> findMoimCategoriesByUsers(@Param("users") List<User> users, @Param("kind") CategoryKind kind); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.example.namo2.domain.category.dao.repository; | ||
|
||
import static com.example.namo2.domain.category.domain.QCategory.*; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.persistence.EntityManager; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
|
||
import com.example.namo2.domain.category.domain.Category; | ||
import com.example.namo2.domain.category.domain.CategoryKind; | ||
|
||
import com.example.namo2.domain.user.domain.User; | ||
|
||
public class CategoryRepositoryImpl implements CategoryRepositoryCustom { | ||
private final JPAQueryFactory queryFactory; | ||
|
||
public CategoryRepositoryImpl(EntityManager em) { | ||
queryFactory = new JPAQueryFactory(em); | ||
} | ||
|
||
@Override | ||
public List<Category> findMoimCategoriesByUsers(List<User> users, CategoryKind kind) { | ||
return queryFactory | ||
.selectFrom(category) | ||
.join(category.user).fetchJoin() | ||
.where(category.user.in(users), | ||
category.kind.eq(kind)) | ||
.fetch(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,13 +46,17 @@ public class Category extends BaseTimeEntity { | |
@Enumerated(EnumType.STRING) | ||
private CategoryStatus status; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private CategoryKind kind; | ||
|
||
@Builder | ||
public Category(Palette palette, User user, String name, Boolean share) { | ||
public Category(Palette palette, User user, String name, Boolean share, CategoryKind kind) { | ||
this.palette = palette; | ||
this.user = user; | ||
this.name = name; | ||
this.share = share; | ||
this.status = CategoryStatus.ACTIVE; | ||
this.kind = kind; | ||
} | ||
|
||
public void update(String name, Boolean share, Palette palette) { | ||
|
@@ -64,4 +68,15 @@ public void update(String name, Boolean share, Palette palette) { | |
public void delete() { | ||
this.status = CategoryStatus.DELETE; | ||
} | ||
|
||
public boolean isNotCreatedByUser(Long userId) { | ||
return this.user.getId() != userId; | ||
} | ||
|
||
public boolean isBaseCategory() { | ||
if (kind == CategoryKind.SCHEDULE || kind == CategoryKind.MOIM) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❗ method 명은 |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.example.namo2.domain.category.domain; | ||
|
||
public enum CategoryKind { | ||
/* | ||
SCHEDULE: 기본 | ||
MOIM: MOIM 기본 | ||
CUSTOM: 유저가 생성한 카테고리 | ||
*/ | ||
SCHEDULE("일정"), MOIM("모임"), CUSTOM("커스텀"); | ||
|
||
private String categoryName; | ||
|
||
CategoryKind(String categoryName) { | ||
this.categoryName = categoryName; | ||
} | ||
|
||
public String getCategoryName() { | ||
return categoryName; | ||
} | ||
} |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,7 @@ | |
import com.example.namo2.domain.category.application.impl.CategoryService; | ||
import com.example.namo2.domain.category.application.impl.PaletteService; | ||
import com.example.namo2.domain.category.domain.Category; | ||
import com.example.namo2.domain.category.domain.CategoryKind; | ||
|
||
import com.example.namo2.domain.memo.application.impl.MoimMemoLocationService; | ||
|
||
|
@@ -285,16 +286,18 @@ private User saveOrNot(User user) { | |
|
||
private void makeBaseCategory(User save) { | ||
Category baseCategory = CategoryConverter.toCategory( | ||
"일정", | ||
CategoryKind.SCHEDULE.getCategoryName(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 Enum을 통해서 관리해 주니까 더 보기 좋네요! |
||
paletteService.getReferenceById(1L), | ||
Boolean.TRUE, | ||
save | ||
save, | ||
CategoryKind.SCHEDULE | ||
); | ||
Category groupCategory = CategoryConverter.toCategory( | ||
"모임", | ||
CategoryKind.MOIM.getCategoryName(), | ||
paletteService.getReferenceById(4L), | ||
Boolean.TRUE, | ||
save | ||
save, | ||
CategoryKind.MOIM | ||
); | ||
|
||
categoryService.create(baseCategory); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ 해당 데이터 DB 스키마에도 적용이 되어있나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
만약 안되어있다면 merge 하기 전에 스키마 수정 부탁드릴게요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
혹시 스키마에 적용해달라고 하시는게 그 저희 운영 서버에 적용해야하는 건가요?