Skip to content

Commit f2e09de

Browse files
Feat: 그룹 검색시 그룹명 포함하도록 수정
Feat: 그룹 검색시 그룹명 포함하도록 수정
2 parents eceb98f + e812056 commit f2e09de

6 files changed

Lines changed: 32 additions & 19 deletions

File tree

src/main/java/flipnote/group/adapter/out/persistence/GroupRepositoryAdapter.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,18 @@ public void delete(Long groupId) {
4646
}
4747

4848
@Override
49-
public List<GroupInfo> findAllByCursor(Long cursorId, Category category, int size) {
50-
return groupRepository.findAllByCursor(cursorId, category, size);
49+
public List<GroupInfo> findAllByCursor(Long cursorId, Category category, int size, String groupName) {
50+
return groupRepository.findAllByCursor(cursorId, category, size, groupName);
5151
}
5252

5353
@Override
54-
public List<GroupInfo> findAllByCursorAndUserId(Long cursorId, Category category, int size, Long userId) {
55-
return groupRepository.findAllByCursorAndUserId(cursorId, category, size, userId);
54+
public List<GroupInfo> findAllByCursorAndUserId(Long cursorId, Category category, int size, Long userId, String groupName) {
55+
return groupRepository.findAllByCursorAndUserId(cursorId, category, size, userId, groupName);
5656
}
5757

5858
@Override
59-
public List<GroupInfo> findAllByCursorAndCreatedUserId(Long cursorId, Category category, int size, Long userId) {
60-
return groupRepository.findAllByCursorAndCreatedUserId(cursorId, category, size, userId);
59+
public List<GroupInfo> findAllByCursorAndCreatedUserId(Long cursorId, Category category, int size, Long userId, String groupName) {
60+
return groupRepository.findAllByCursorAndCreatedUserId(cursorId, category, size, userId, groupName);
6161
}
6262

6363
@Override

src/main/java/flipnote/group/api/dto/request/GroupListRequestDto.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
public class GroupListRequestDto extends CursorPagingRequest {
1313

1414
private Category category;
15+
private String groupName;
1516

1617
@Override
1718
public PageRequest getPageRequest() {

src/main/java/flipnote/group/application/port/out/GroupRepositoryPort.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ public interface GroupRepositoryPort {
1414

1515
void delete(Long id);
1616

17-
List<GroupInfo> findAllByCursor(Long cursorId, Category category, int size);
17+
List<GroupInfo> findAllByCursor(Long cursorId, Category category, int size, String groupName);
1818

19-
List<GroupInfo> findAllByCursorAndUserId(Long cursorId, Category category, int size, Long userId);
19+
List<GroupInfo> findAllByCursorAndUserId(Long cursorId, Category category, int size, Long userId, String groupName);
2020

21-
List<GroupInfo> findAllByCursorAndCreatedUserId(Long cursorId, Category category, int size, Long userId);
21+
List<GroupInfo> findAllByCursorAndCreatedUserId(Long cursorId, Category category, int size, Long userId, String groupName);
2222

2323
boolean checkJoinable(Long groupId);
2424

src/main/java/flipnote/group/application/service/FindGroupService.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ public CursorPagingResponseDto<GroupInfo> findAllGroup(Long userId, GroupListReq
9797
List<GroupInfo> groups = groupRepository.findAllByCursor(
9898
req.getCursorId(),
9999
req.getCategory(),
100-
req.getSize());
100+
req.getSize(),
101+
req.getGroupName());
101102

102103
enrichGroupsWithImageUrl(groups);
103104

@@ -116,7 +117,8 @@ public CursorPagingResponseDto<GroupInfo> findMyGroup(Long userId, GroupListRequ
116117
req.getCursorId(),
117118
req.getCategory(),
118119
req.getSize(),
119-
userId);
120+
userId,
121+
req.getGroupName());
120122

121123
enrichGroupsWithImageUrl(groups);
122124

@@ -135,7 +137,8 @@ public CursorPagingResponseDto<GroupInfo> findCreatedGroup(Long userId, GroupLis
135137
req.getCursorId(),
136138
req.getCategory(),
137139
req.getSize(),
138-
userId);
140+
userId,
141+
req.getGroupName());
139142

140143
enrichGroupsWithImageUrl(groups);
141144

src/main/java/flipnote/group/infrastructure/persistence/querydsl/GroupRepositoryCustom.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
import flipnote.group.domain.model.group.GroupInfo;
77

88
public interface GroupRepositoryCustom {
9-
List<GroupInfo> findAllByCursor(Long lastId, Category category, int pageSize);
9+
List<GroupInfo> findAllByCursor(Long lastId, Category category, int pageSize, String groupName);
1010

11-
List<GroupInfo> findAllByCursorAndUserId(Long lastId, Category category, int pageSize, Long userId);
11+
List<GroupInfo> findAllByCursorAndUserId(Long lastId, Category category, int pageSize, Long userId, String groupName);
1212

13-
List<GroupInfo> findAllByCursorAndCreatedUserId(Long cursorId, Category category, int size, Long id);
13+
List<GroupInfo> findAllByCursorAndCreatedUserId(Long cursorId, Category category, int size, Long id, String groupName);
1414
}

src/main/java/flipnote/group/infrastructure/persistence/querydsl/GroupRepositoryImpl.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class GroupRepositoryImpl implements GroupRepositoryCustom {
3333
* @return
3434
*/
3535
@Override
36-
public List<GroupInfo> findAllByCursor(Long lastId, Category category, int pageSize) {
36+
public List<GroupInfo> findAllByCursor(Long lastId, Category category, int pageSize, String groupName) {
3737
//삭제되지 않은
3838
BooleanBuilder where = new BooleanBuilder()
3939
.and(group.deletedAt.isNull());
@@ -43,6 +43,10 @@ public List<GroupInfo> findAllByCursor(Long lastId, Category category, int pageS
4343
where.and(group.id.lt(lastId));
4444
}
4545

46+
if (groupName != null && !groupName.isBlank()) {
47+
where.and(group.name.contains(groupName));
48+
}
49+
4650
//카테고리 제한
4751
if (category != null) {
4852
where.and(group.category.eq(category));
@@ -73,7 +77,7 @@ public List<GroupInfo> findAllByCursor(Long lastId, Category category, int pageS
7377
* @return
7478
*/
7579
@Override
76-
public List<GroupInfo> findAllByCursorAndUserId(Long lastId, Category category, int pageSize, Long userId) {
80+
public List<GroupInfo> findAllByCursorAndUserId(Long lastId, Category category, int pageSize, Long userId, String groupName) {
7781

7882
BooleanBuilder where = new BooleanBuilder()
7983
.and(group.deletedAt.isNull())
@@ -83,6 +87,10 @@ public List<GroupInfo> findAllByCursorAndUserId(Long lastId, Category category,
8387
where.and(group.id.lt(lastId));
8488
}
8589

90+
if (groupName != null && !groupName.isBlank()) {
91+
where.and(group.name.contains(groupName));
92+
}
93+
8694
if (category != null) {
8795
where.and(group.category.eq(category));
8896
}
@@ -114,7 +122,7 @@ public List<GroupInfo> findAllByCursorAndUserId(Long lastId, Category category,
114122
* @return
115123
*/
116124
@Override
117-
public List<GroupInfo> findAllByCursorAndCreatedUserId(Long lastId, Category category, int pageSize, Long userId) {
125+
public List<GroupInfo> findAllByCursorAndCreatedUserId(Long lastId, Category category, int pageSize, Long userId, String groupName) {
118126

119127
return queryFactory
120128
.select(Projections.constructor(
@@ -134,7 +142,8 @@ public List<GroupInfo> findAllByCursorAndCreatedUserId(Long lastId, Category cat
134142
groupMember.userId.eq(userId),
135143
groupMember.role.role.eq(GroupMemberRole.OWNER),
136144
lastId != null ? group.id.lt(lastId) : null,
137-
category != null ? group.category.eq(category) : null
145+
category != null ? group.category.eq(category) : null,
146+
groupName != null && !groupName.isBlank() ? group.name.contains(groupName) : null
138147
)
139148
.orderBy(group.id.desc())
140149
.limit(pageSize + 1)

0 commit comments

Comments
 (0)