Repository navigation
feat: 웹사이트 동아리 시트 가져오기 추가 #661
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
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
46 changes: 46 additions & 0 deletions
46
src/main/java/gg/agit/konect/admin/website/controller/AdminWebsiteClubSheetImportApi.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,46 @@ | ||
| package gg.agit.konect.admin.website.controller; | ||
|
|
||
| import org.springframework.http.ResponseEntity; | ||
| 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 gg.agit.konect.admin.website.dto.AdminWebsiteClubSheetImportConfirmRequest; | ||
| import gg.agit.konect.admin.website.dto.AdminWebsiteClubSheetImportPreviewResponse; | ||
| import gg.agit.konect.admin.website.dto.AdminWebsiteClubSheetImportRequest; | ||
| import gg.agit.konect.admin.website.dto.AdminWebsiteClubSheetImportResponse; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||
| import jakarta.validation.Valid; | ||
|
|
||
| @Tag(name = "(Admin) Website Club Sheet Import", description = "konect.space 대학별 동아리 목록 시트 등록 API") | ||
| @RequestMapping("/admin/konect/universities") | ||
| public interface AdminWebsiteClubSheetImportApi { | ||
|
|
||
| @Operation( | ||
| summary = "Google Sheets 동아리 등록 양식을 분석하고 미리보기 JSON을 반환한다.", | ||
| description = """ | ||
| 작성 시트의 동아리 목록을 읽고 Claude Haiku로 KONECT 웹사이트용 동아리 JSON을 생성합니다. | ||
| 이 API는 DB에 저장하지 않고, 사용자가 확인/수정할 수 있는 중간 결과만 반환합니다. | ||
| """ | ||
| ) | ||
| @PostMapping("/{universityId}/clubs/sheet/import/preview") | ||
| ResponseEntity<AdminWebsiteClubSheetImportPreviewResponse> previewClubs( | ||
| @PathVariable(name = "universityId") Integer universityId, | ||
| @Valid @RequestBody AdminWebsiteClubSheetImportRequest request | ||
| ); | ||
|
|
||
| @Operation( | ||
| summary = "미리보기 JSON을 최종 동아리 목록으로 저장한다.", | ||
| description = """ | ||
| preview 응답을 그대로 보내거나 수정한 뒤 보내면 web_club에 저장합니다. | ||
| enabled=false인 항목과 이미 같은 대학에 등록된 같은 이름의 동아리는 저장하지 않습니다. | ||
| """ | ||
| ) | ||
| @PostMapping("/{universityId}/clubs/sheet/import/confirm") | ||
| ResponseEntity<AdminWebsiteClubSheetImportResponse> confirmImport( | ||
| @PathVariable(name = "universityId") Integer universityId, | ||
| @Valid @RequestBody AdminWebsiteClubSheetImportConfirmRequest request | ||
| ); | ||
| } | ||
43 changes: 43 additions & 0 deletions
43
...n/java/gg/agit/konect/admin/website/controller/AdminWebsiteClubSheetImportController.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,43 @@ | ||
| package gg.agit.konect.admin.website.controller; | ||
|
|
||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| import gg.agit.konect.admin.website.dto.AdminWebsiteClubSheetImportConfirmRequest; | ||
| import gg.agit.konect.admin.website.dto.AdminWebsiteClubSheetImportPreviewResponse; | ||
| import gg.agit.konect.admin.website.dto.AdminWebsiteClubSheetImportRequest; | ||
| import gg.agit.konect.admin.website.dto.AdminWebsiteClubSheetImportResponse; | ||
| import gg.agit.konect.admin.website.service.AdminWebsiteClubSheetImportService; | ||
| import gg.agit.konect.domain.user.enums.UserRole; | ||
| import gg.agit.konect.global.auth.annotation.Auth; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @RequestMapping("/admin/konect/universities") | ||
| @Auth(roles = {UserRole.ADMIN}) | ||
| public class AdminWebsiteClubSheetImportController implements AdminWebsiteClubSheetImportApi { | ||
|
|
||
| private final AdminWebsiteClubSheetImportService adminWebsiteClubSheetImportService; | ||
|
|
||
| @Override | ||
| public ResponseEntity<AdminWebsiteClubSheetImportPreviewResponse> previewClubs( | ||
| Integer universityId, | ||
| AdminWebsiteClubSheetImportRequest request | ||
| ) { | ||
| AdminWebsiteClubSheetImportPreviewResponse response = | ||
| adminWebsiteClubSheetImportService.previewClubs(universityId, request.spreadsheetUrl()); | ||
| return ResponseEntity.ok(response); | ||
| } | ||
|
|
||
| @Override | ||
| public ResponseEntity<AdminWebsiteClubSheetImportResponse> confirmImport( | ||
| Integer universityId, | ||
| AdminWebsiteClubSheetImportConfirmRequest request | ||
| ) { | ||
| AdminWebsiteClubSheetImportResponse response = | ||
| adminWebsiteClubSheetImportService.confirmImport(universityId, request.clubs()); | ||
| return ResponseEntity.ok(response); | ||
| } | ||
| } |
46 changes: 46 additions & 0 deletions
46
...main/java/gg/agit/konect/admin/website/dto/AdminWebsiteClubSheetImportConfirmRequest.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,46 @@ | ||
| package gg.agit.konect.admin.website.dto; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import gg.agit.konect.domain.club.enums.ClubCategory; | ||
| import jakarta.validation.Valid; | ||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.NotEmpty; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import jakarta.validation.constraints.Size; | ||
|
|
||
| public record AdminWebsiteClubSheetImportConfirmRequest( | ||
|
|
||
| @NotEmpty | ||
| List<@Valid ConfirmClub> clubs | ||
| ) { | ||
|
|
||
| public record ConfirmClub( | ||
| int rowNumber, | ||
|
|
||
| @NotBlank | ||
| @Size(max = 50) | ||
| String name, | ||
|
|
||
| @NotNull | ||
| ClubCategory clubCategory, | ||
|
|
||
| @NotBlank | ||
| @Size(max = 20) | ||
| String topic, | ||
|
|
||
| @NotBlank | ||
| @Size(max = 30) | ||
| String description, | ||
|
|
||
| @NotBlank | ||
| String introduce, | ||
|
|
||
| @NotBlank | ||
| @Size(max = 255) | ||
| String categoryEmoji, | ||
|
|
||
| boolean enabled | ||
| ) { | ||
| } | ||
| } |
38 changes: 38 additions & 0 deletions
38
...ain/java/gg/agit/konect/admin/website/dto/AdminWebsiteClubSheetImportPreviewResponse.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,38 @@ | ||
| package gg.agit.konect.admin.website.dto; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import gg.agit.konect.domain.club.enums.ClubCategory; | ||
|
|
||
| public record AdminWebsiteClubSheetImportPreviewResponse( | ||
| Integer universityId, | ||
| int previewCount, | ||
| List<PreviewClub> clubs, | ||
| List<String> warnings | ||
| ) { | ||
|
|
||
| public static AdminWebsiteClubSheetImportPreviewResponse of( | ||
| Integer universityId, | ||
| List<PreviewClub> clubs, | ||
| List<String> warnings | ||
| ) { | ||
| return new AdminWebsiteClubSheetImportPreviewResponse( | ||
| universityId, | ||
| clubs.size(), | ||
| clubs, | ||
| warnings == null ? List.of() : warnings | ||
| ); | ||
| } | ||
|
|
||
| public record PreviewClub( | ||
| int rowNumber, | ||
| String name, | ||
| ClubCategory clubCategory, | ||
| String topic, | ||
| String description, | ||
| String introduce, | ||
| String categoryEmoji, | ||
| boolean enabled | ||
| ) { | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/main/java/gg/agit/konect/admin/website/dto/AdminWebsiteClubSheetImportRequest.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,17 @@ | ||
| package gg.agit.konect.admin.website.dto; | ||
|
|
||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.Pattern; | ||
|
|
||
| public record AdminWebsiteClubSheetImportRequest( | ||
|
|
||
| @Schema( | ||
| description = "동아리 등록 양식 Google Sheets URL", | ||
| example = "https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms/edit" | ||
| ) | ||
| @NotBlank | ||
| @Pattern(regexp = "^https://docs\\.google\\.com/spreadsheets/(?:u/\\d+/)?d/[A-Za-z0-9_-]+.*") | ||
| String spreadsheetUrl | ||
| ) { | ||
| } |
22 changes: 22 additions & 0 deletions
22
src/main/java/gg/agit/konect/admin/website/dto/AdminWebsiteClubSheetImportResponse.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,22 @@ | ||
| package gg.agit.konect.admin.website.dto; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public record AdminWebsiteClubSheetImportResponse( | ||
| int importedCount, | ||
| int skippedCount, | ||
| List<String> warnings | ||
| ) { | ||
|
|
||
| public static AdminWebsiteClubSheetImportResponse of( | ||
| int importedCount, | ||
| int skippedCount, | ||
| List<String> warnings | ||
| ) { | ||
| return new AdminWebsiteClubSheetImportResponse( | ||
| importedCount, | ||
| skippedCount, | ||
| warnings == null ? List.of() : warnings | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
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.
정해진 엑셀 양식이 있는데 AI로 파싱을 하는 이유가 있나용
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.
특별한 이유는 없었습니다..
기존에 동아리 인명부 부분에서 구현했던 것을 비슷하게 가져와서 사용하면 될 것이라 생각했는데,
생각해보니 정해진 양식이 있으니 AI 없이도 행렬에 있는 값을 읽어오면 되겠네요
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.
넴 오히려 AI를 사용해서 작업 시간이 더 오래 걸릴 수 있을 것 같아요. 비용 문제도 있고요