-
Notifications
You must be signed in to change notification settings - Fork 0
✨ Feat: 동호회 관련 기능 구현 및 채팅 구조 최적화 #33
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
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8574e39
:sparkles:Feat: 동호회 생성 기능 구현
imjuyongp 9f42107
:recycel:Refactor: Club엔티티 참조에 따른 ChatRoom 필드 최소화
imjuyongp 5e17619
:recycle:Refactor: 동호회 생성과 채팅방 생성 같은 요청 안에서 로직 처리
imjuyongp 702717d
:sparkles:Feat: 동호회 정보 수정기능 구현
imjuyongp cd6f533
:recycle:Refactor: 동호회 생성, 수정 시 동호회 관련 종목 태그 선택 가능하도록 수정
imjuyongp 4fba4ae
:sparkles:Feat: 게시글 목록 조회 기능 구현
imjuyongp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
3 changes: 3 additions & 0 deletions
3
src/main/java/com/be/sportizebe/domain/auth/dto/request/LoginRequest.java
This file contains hidden or 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,14 +1,17 @@ | ||
| package com.be.sportizebe.domain.auth.dto.request; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.Email; | ||
| import jakarta.validation.constraints.NotBlank; | ||
|
|
||
| public record LoginRequest( | ||
| @NotBlank(message = "아이디를 입력해주세요.") | ||
| @Email(message = "아이디는 이메일 형식만 지원합니다.") | ||
| @Schema(description = "사용자 아이디(이메일 형식)", example = "user@example.com") | ||
| String username, | ||
|
|
||
| @NotBlank(message = "비밀번호를 입력해주세요.") | ||
| @Schema(description = "비밀번호", example = "password123") | ||
| String password | ||
| ) { | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
47 changes: 47 additions & 0 deletions
47
src/main/java/com/be/sportizebe/domain/club/controller/ClubController.java
This file contains hidden or 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,47 @@ | ||
| package com.be.sportizebe.domain.club.controller; | ||
|
|
||
| import com.be.sportizebe.domain.club.dto.request.ClubCreateRequest; | ||
| import com.be.sportizebe.domain.club.dto.request.ClubUpdateRequest; | ||
| import com.be.sportizebe.domain.club.dto.response.ClubResponse; | ||
| import com.be.sportizebe.domain.club.service.ClubServiceImpl; | ||
| import com.be.sportizebe.domain.user.entity.SportType; | ||
| import com.be.sportizebe.domain.user.entity.User; | ||
| import com.be.sportizebe.global.response.BaseResponse; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.Parameter; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import jakarta.validation.Valid; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @RequestMapping("/api/clubs") | ||
| @Tag(name = "club", description = "동호회 관련 API") | ||
| public class ClubController { | ||
|
|
||
| private final ClubServiceImpl clubService; | ||
|
|
||
| @PostMapping("") | ||
| @Operation(summary = "동호회 생성", description = "종목별 동호회를 생성합니다. 생성한 사용자가 동호회장이 됩니다.") | ||
| public ResponseEntity<BaseResponse<ClubResponse>> createClub( | ||
| @RequestBody @Valid ClubCreateRequest request, | ||
| @AuthenticationPrincipal User user) { | ||
| ClubResponse response = clubService.createClub(request, user); | ||
| return ResponseEntity.status(HttpStatus.CREATED) | ||
| .body(BaseResponse.success("동호회 생성 성공", response)); | ||
| } | ||
|
|
||
| @PutMapping("/{clubId}") | ||
| @Operation(summary = "동호회 수정", description = "동호회 정보를 수정합니다. 동호회장만 수정할 수 있습니다.") | ||
| public ResponseEntity<BaseResponse<ClubResponse>> updateClub( | ||
| @PathVariable Long clubId, | ||
| @RequestBody @Valid ClubUpdateRequest request, | ||
| @AuthenticationPrincipal User user) { | ||
| ClubResponse response = clubService.updateClub(clubId, request, user); | ||
| return ResponseEntity.ok(BaseResponse.success("동호회 수정 성공", response)); | ||
| } | ||
| } | ||
27 changes: 27 additions & 0 deletions
27
src/main/java/com/be/sportizebe/domain/club/dto/request/ClubCreateRequest.java
This file contains hidden or 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,27 @@ | ||
| package com.be.sportizebe.domain.club.dto.request; | ||
|
|
||
| import com.be.sportizebe.domain.club.entity.Club; | ||
| import com.be.sportizebe.domain.user.entity.SportType; | ||
| import com.be.sportizebe.domain.user.entity.User; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.NotBlank; | ||
|
|
||
| public record ClubCreateRequest( | ||
| @NotBlank(message = "동호회 이름은 필수 입니다.") | ||
| @Schema(description = "동호회 이름", example = "축구 동호회") String name, | ||
| @Schema(description = "동호회 소개", example = "매주 토요일 축구합니다") String introduce, | ||
| @Schema(description = "동호회 관련 종목", example = "SOCCER") SportType clubType, | ||
| @Schema(description = "최대 정원", example = "20") Integer maxMembers) { | ||
| // 관련 종목은 파라미터로 받음 | ||
| // TODO : S3 세팅 후 imgUrl은 multipartform으로 변경 | ||
|
|
||
| public Club toEntity(User user) { | ||
| return Club.builder() | ||
| .name(name) | ||
| .introduce(introduce) | ||
| .clubType(clubType) | ||
| .maxMembers(maxMembers) | ||
| .leader(user) | ||
| .build(); | ||
|
Comment on lines
+9
to
+25
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. maxMembers 검증이 누락되어 있습니다. Line 13에서 maxMembers가 null/음수여도 통과할 수 있어 저장 시 제약 위반 또는 런타임 오류가 날 수 있습니다. 최소한 null/양수 검증을 추가해 주세요. 🔧 제안 수정-import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Positive;
public record ClubCreateRequest(
`@NotBlank`(message = "동호회 이름은 필수 입니다.")
`@Schema`(description = "동호회 이름", example = "축구 동호회") String name,
`@Schema`(description = "동호회 소개", example = "매주 토요일 축구합니다") String introduce,
- `@Schema`(description = "최대 정원", example = "20") Integer maxMembers) {
+ `@NotNull`(message = "최대 정원은 필수 입니다.")
+ `@Positive`(message = "최대 정원은 양수여야 합니다.")
+ `@Schema`(description = "최대 정원", example = "20") Integer maxMembers) {🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
13 changes: 13 additions & 0 deletions
13
src/main/java/com/be/sportizebe/domain/club/dto/request/ClubUpdateRequest.java
This file contains hidden or 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,13 @@ | ||
| package com.be.sportizebe.domain.club.dto.request; | ||
|
|
||
| import com.be.sportizebe.domain.user.entity.SportType; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.NotBlank; | ||
|
|
||
| public record ClubUpdateRequest( | ||
| @NotBlank(message = "동호회 이름은 필수 입니다.") | ||
| @Schema(description = "동호회 이름", example = "축구 동호회") String name, | ||
| @Schema(description = "동호회 소개", example = "매주 토요일 축구합니다") String introduce, | ||
| @Schema(description = "동호회 관련 종목", example = "SOCCER") SportType clubType, | ||
| @Schema(description = "최대 정원", example = "20") Integer maxMembers) { | ||
| } |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/be/sportizebe/domain/club/dto/response/ClubResponse.java
This file contains hidden or 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,28 @@ | ||
| package com.be.sportizebe.domain.club.dto.response; | ||
|
|
||
| import com.be.sportizebe.domain.club.entity.Club; | ||
| import com.be.sportizebe.domain.user.entity.SportType; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import lombok.Builder; | ||
|
|
||
| @Builder | ||
| @Schema(title = "ClubResponse DTO", description = "동호회 관련 응답") | ||
| public record ClubResponse( | ||
| @Schema(description = "동호회 ID", example = "1") Long clubId, | ||
| @Schema(description = "동호회 이름", example = "축구 동호회") String name, | ||
| @Schema(description = "동호회 소개", example = "매주 토요일 축구합니다") String introduce, | ||
| @Schema(description = "동호회 관련 종목", example = "SOCCER") SportType clubType, | ||
| @Schema(description = "최대 정원", example = "20") Integer maxMembers, | ||
| @Schema(description = "동호회장 닉네임", example = "닉네임") String leaderNickname) { | ||
|
|
||
| public static ClubResponse from(Club club) { | ||
| return ClubResponse.builder() | ||
| .clubId(club.getId()) | ||
| .name(club.getName()) | ||
| .introduce(club.getIntroduce()) | ||
| .clubType(club.getClubType()) | ||
| .maxMembers(club.getMaxMembers()) | ||
| .leaderNickname(club.getLeader().getNickname()) | ||
| .build(); | ||
| } | ||
| } |
57 changes: 57 additions & 0 deletions
57
src/main/java/com/be/sportizebe/domain/club/entity/Club.java
This file contains hidden or 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,57 @@ | ||
| package com.be.sportizebe.domain.club.entity; | ||
|
|
||
| import com.be.sportizebe.domain.chat.entity.ChatRoom; | ||
| import com.be.sportizebe.domain.user.entity.SportType; | ||
| import com.be.sportizebe.domain.user.entity.User; | ||
| import com.be.sportizebe.global.common.BaseTimeEntity; | ||
| import jakarta.persistence.*; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| @Entity | ||
| @Getter | ||
| @Builder | ||
| @AllArgsConstructor | ||
| @NoArgsConstructor | ||
| @Table(name = "clubs") | ||
| public class Club extends BaseTimeEntity { | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @Column(nullable = false, unique = true) | ||
| private String name; // 동호회 이름 == 단테 채팅방 이름 | ||
|
|
||
| @Column(columnDefinition = "TEXT") | ||
| private String introduce; // 동호회 소개글 | ||
|
|
||
| @Column(nullable = false) | ||
| @Enumerated(EnumType.STRING) | ||
| private SportType clubType; // 동호회 관련 종목 (동호회 생성 시 선택) | ||
|
|
||
| @Column(nullable = false) | ||
| private Integer maxMembers; // 최대 정원 | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "leader_id", nullable = false) | ||
| private User leader; // 동호회장 | ||
|
|
||
| @OneToOne(mappedBy = "club", fetch = FetchType.LAZY) | ||
| private ChatRoom chatRoom; // 동호회 채팅방 | ||
|
|
||
| @OneToMany(mappedBy = "club", cascade = CascadeType.ALL, orphanRemoval = true) | ||
| @Builder.Default | ||
| private List<ClubMember> members = new ArrayList<>(); | ||
|
|
||
| public void update(String name, String introduce, Integer maxMembers, SportType clubType) { | ||
| this.name = name; | ||
| this.introduce = introduce; | ||
| this.maxMembers = maxMembers; | ||
| this.clubType = clubType; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🧩 Analysis chain
🏁 Script executed:
Repository: Sportize/be
Length of output: 127
🏁 Script executed:
Repository: Sportize/be
Length of output: 2962
🏁 Script executed:
Repository: Sportize/be
Length of output: 265
🏁 Script executed:
Repository: Sportize/be
Length of output: 1570
@AuthenticationPrincipal주입 타입 변경 필요CustomUserDetails는UserDetails인터페이스를 구현하며User를 상속하지 않습니다.@AuthenticationPrincipal의 기본 동작은Authentication.getPrincipal()에서CustomUserDetails인스턴스를 반환하므로, 현재@AuthenticationPrincipal User user로 직접User엔티티를 주입받을 수 없습니다.다음 중 하나로 변경하세요:
@AuthenticationPrincipal(expression = "principal.user") User user사용@AuthenticationPrincipal CustomUserDetails customUserDetails로 변경하고customUserDetails.getUser()로 User 엔티티 접근🤖 Prompt for AI Agents