Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,15 @@ public ResponseEntity<CursorPagingResponse<GroupInfo>> findMyGroup(

return ResponseEntity.ok(res);
}

//내가 생성한 그룹 전체 조회
@GetMapping("/created")
public ResponseEntity<CursorPagingResponse<GroupInfo>> findCreatedGroup(
@AuthenticationPrincipal AuthPrinciple authPrinciple,
@Valid @ModelAttribute GroupListRequest req
) {
CursorPagingResponse<GroupInfo> res = groupService.findCreatedGroup(authPrinciple, req);

return ResponseEntity.ok(res);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ public interface GroupRepositoryCustom {
List<GroupInfo> findAllByCursor(Long lastId, Category category, int pageSize);

List<GroupInfo> findAllByCursorAndUserId(Long lastId, Category category, int pageSize, Long userId);

List<GroupInfo> findAllByCursorAndCreatedUserId(Long cursorId, Category category, int size, Long id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import lombok.RequiredArgsConstructor;
import project.flipnote.group.entity.Category;
import project.flipnote.group.entity.GroupMemberRole;
import project.flipnote.group.entity.QGroup;
import project.flipnote.group.entity.QGroupMember;
import project.flipnote.group.model.GroupInfo;
Expand Down Expand Up @@ -90,4 +91,41 @@ public List<GroupInfo> findAllByCursorAndUserId(Long lastId, Category category,
.fetch();
}

/**
* 그룹 테이블에 생성한 유저 추가?
* @param lastId
* @param category
* @param pageSize
* @param userId
* @return
*/
Comment on lines +94 to +101
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Javadoc을 명확하게 작성하세요.

Javadoc 주석이 불명확합니다. "그룹 테이블에 생성한 유저 추가?"라는 질문 형태의 설명은 메서드의 목적을 명확히 전달하지 못합니다.

다음과 같이 수정하는 것을 권장합니다:

 /**
- * 그룹 테이블에 생성한 유저 추가?
+ * 특정 사용자가 생성한(OWNER 역할) 그룹 목록을 커서 기반 페이징으로 조회합니다.
+ * 
  * @param lastId 마지막으로 조회된 그룹 ID (커서)
  * @param category 필터링할 카테고리 (선택사항)
  * @param pageSize 페이지 크기
- * @param userId
- * @return
+ * @param userId 그룹을 생성한 사용자 ID
+ * @return 조회된 그룹 정보 리스트
  */
🤖 Prompt for AI Agents
In src/main/java/project/flipnote/group/repository/GroupRepositoryImpl.java
around lines 94 to 101, replace the ambiguous question-style Javadoc with a
clear method description and parameter/return details: state the method’s
purpose in one sentence (e.g., what it retrieves or modifies in the group
table), document each parameter (lastId, category, pageSize, userId) with
types/semantics and any nullable/optional behavior, describe the return value
and its contents (e.g., list of groups, paging token), and note any thrown
exceptions or side effects; keep it concise, use imperative form, and localize
language consistently (Korean or English) to match project conventions.

@Override
public List<GroupInfo> findAllByCursorAndCreatedUserId(Long lastId, Category category, int pageSize, Long userId) {
return queryFactory
.select(Projections.constructor(
GroupInfo.class,
group.id,
group.name,
group.description,
group.category,
group.imageUrl,
imageRef.id
))
.from(group)
.join(groupMember).on(groupMember.group.eq(group))
.where(
group.deletedAt.isNull(),
groupMember.user.id.eq(userId),
groupMember.role.eq(GroupMemberRole.OWNER),
lastId != null ? group.id.lt(lastId) : null,
category != null ? group.category.eq(category) : null
)
.leftJoin(imageRef)
.on(imageRef.referenceType.eq(ReferenceType.GROUP)
.and(imageRef.referenceId.eq(group.id)))
.orderBy(group.id.desc())
.limit(pageSize + 1)
.fetch();
}

}
15 changes: 15 additions & 0 deletions src/main/java/project/flipnote/group/service/GroupService.java
Original file line number Diff line number Diff line change
Expand Up @@ -461,4 +461,19 @@ private CursorPagingResponse<GroupInfo> createGroupInfoCursorPagingResponse(Grou

return CursorPagingResponse.of(groups, hasNext, nextCursor);
}

//리팩토링
public CursorPagingResponse<GroupInfo> findCreatedGroup(AuthPrinciple authPrinciple, GroupListRequest req) {
//1. 유저 가져오기
UserProfile user = getUser(authPrinciple);

//2. 카테고리 변환
Category category = convertCategory(req.getCategory());

List<GroupInfo> groups = groupRepository.findAllByCursorAndCreatedUserId(req.getCursorId(), category, req.getSize(),
user.getId());


return createGroupInfoCursorPagingResponse(req, groups);
}
}
Loading