-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: club entity 생성 * feat: 동아리 생성 api 구현 * feat: 동아리 조회 api 구현 * feat: 동아리 수정 api 구현 * feat: 동아리 삭제 api 구현 * feat: 동아리 더미 데이터 추가 * feat: test code * refactor: test 에러 주석처리 * refactor: 더미 데이터 수정 * refactor: createClub 메소드 이름 수정 * refactor: db 디렉터리 삭제 * refactor: 코멘트 반영
- Loading branch information
Showing
30 changed files
with
817 additions
and
506 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
aics-admin/src/main/java/kgu/developers/admin/club/application/ClubAdminFacade.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package kgu.developers.admin.club.application; | ||
|
||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import kgu.developers.admin.club.presentation.request.ClubRequest; | ||
import kgu.developers.admin.club.presentation.response.ClubPersistResponse; | ||
import kgu.developers.domain.club.application.command.ClubCommandService; | ||
import kgu.developers.domain.club.application.query.ClubQueryService; | ||
import kgu.developers.domain.club.domain.Club; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Component | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class ClubAdminFacade { | ||
private final ClubCommandService clubCommandService; | ||
private final ClubQueryService clubQueryService; | ||
|
||
public ClubPersistResponse createClub(ClubRequest request) { | ||
Long id = clubCommandService.createClub(request.name(), request.description(), request.site()); | ||
return ClubPersistResponse.of(id); | ||
} | ||
|
||
public void updateClub(Long id, ClubRequest request) { | ||
Club club = clubQueryService.getById(id); | ||
clubCommandService.updateClub(club, request.name(), request.description(), request.site()); | ||
} | ||
|
||
public void deleteClub(Long id) { | ||
clubCommandService.deleteClubById(id); | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
aics-admin/src/main/java/kgu/developers/admin/club/presentation/ClubAdminController.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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package kgu.developers.admin.club.presentation; | ||
|
||
import static org.springframework.http.HttpStatus.CREATED; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.PatchMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.validation.Valid; | ||
import jakarta.validation.constraints.Positive; | ||
import kgu.developers.admin.club.application.ClubAdminFacade; | ||
import kgu.developers.admin.club.presentation.request.ClubRequest; | ||
import kgu.developers.admin.club.presentation.response.ClubPersistResponse; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/v1/clubs") | ||
@Tag(name = "Club", description = "동아리 관리자 API") | ||
public class ClubAdminController { | ||
private final ClubAdminFacade clubAdminFacade; | ||
|
||
@Operation(summary = "동아리 생성 API", description = """ | ||
- Description : 이 API는 동아리를 생성합니다. | ||
- Assignee : 박민준 | ||
""") | ||
@ApiResponse(responseCode = "201", content = @Content(schema = @Schema(implementation = ClubPersistResponse.class))) | ||
@PostMapping | ||
public ResponseEntity<ClubPersistResponse> createClub( | ||
@Valid @RequestBody ClubRequest request | ||
) { | ||
ClubPersistResponse response = clubAdminFacade.createClub(request); | ||
return ResponseEntity.status(CREATED).body(response); | ||
} | ||
|
||
@Operation(summary = "동아리 수정 API", description = """ | ||
- Description : 이 API는 동아리 정보를 수정합니다. | ||
- Assignee : 박민준 | ||
""") | ||
@ApiResponse(responseCode = "204") | ||
@PatchMapping("/{id}") | ||
public ResponseEntity<Void> updateClub( | ||
@Parameter(description = "수정할 동아리 id", example = "1", required = true) @PathVariable @Positive Long id, | ||
@Valid @RequestBody ClubRequest request | ||
) { | ||
clubAdminFacade.updateClub(id, request); | ||
return ResponseEntity.noContent().build(); | ||
} | ||
|
||
@Operation(summary = "동아리 삭제 API", description = """ | ||
- Description : 이 API는 해당 동아리를 삭제합니다. | ||
- Assignee : 박민준 | ||
""") | ||
@ApiResponse(responseCode = "204") | ||
@DeleteMapping("/{id}") | ||
public ResponseEntity<Void> deleteClub( | ||
@Parameter(description = "삭제할 동아리의 id", example = "1", required = true) @PathVariable @Positive Long id | ||
) { | ||
clubAdminFacade.deleteClub(id); | ||
return ResponseEntity.noContent().build(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
aics-admin/src/main/java/kgu/developers/admin/club/presentation/request/ClubRequest.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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package kgu.developers.admin.club.presentation.request; | ||
|
||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.NOT_REQUIRED; | ||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.Pattern; | ||
import jakarta.validation.constraints.Size; | ||
|
||
public record ClubRequest( | ||
@Schema(description = "동아리 이름", example = "C-Lab", requiredMode = REQUIRED) | ||
@NotBlank | ||
@Size(max = 15) | ||
String name, | ||
|
||
@Schema(description = "동아리 설명", example = "경기대학교 AI컴퓨터공학부 개발동아리입니다.", requiredMode = REQUIRED) | ||
@NotBlank | ||
@Size(max = 50) | ||
String description, | ||
|
||
@Schema(description = "동아리 홈페이지", example = "https://www.clab.page/", requiredMode = NOT_REQUIRED) | ||
@Pattern(regexp = "^(http|https)://.*$", message = "URL은 http:// 또는 https://으로 시작해야 합니다.") | ||
String site | ||
) { | ||
} |
18 changes: 18 additions & 0 deletions
18
...in/src/main/java/kgu/developers/admin/club/presentation/response/ClubPersistResponse.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package kgu.developers.admin.club.presentation.response; | ||
|
||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record ClubPersistResponse( | ||
@Schema(description = "동아리 id", example = "1", requiredMode = REQUIRED) | ||
Long id | ||
) { | ||
public static ClubPersistResponse of(Long id) { | ||
return ClubPersistResponse.builder() | ||
.id(id) | ||
.build(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
aics-api/src/main/java/kgu/developers/api/club/application/ClubFacade.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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package kgu.developers.api.club.application; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import kgu.developers.api.club.presentation.response.ClubListResponse; | ||
import kgu.developers.domain.club.application.query.ClubQueryService; | ||
import kgu.developers.domain.club.domain.Club; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class ClubFacade { | ||
private final ClubQueryService clubQueryService; | ||
|
||
public ClubListResponse getClubs() { | ||
List<Club> clubs = clubQueryService.getClubs(); | ||
return ClubListResponse.from(clubs); | ||
} | ||
} |
Oops, something went wrong.