-
Notifications
You must be signed in to change notification settings - Fork 0
✨ Feat: Admin 도메인 도입 및 Geocoding 기반 체육시설·매칭 관리 기능 확장 #60
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
7 commits
Select commit
Hold shift + click to select a range
c52f786
✨ Feat: Admin 도메인 패키지 생성 및 권한 보안 룰 적용
6bae467
♻️ Refactor: 매칭·시설 생성 API를 Admin 전용 엔드포인트로 이동
ab4fcb8
✨ Feat: 카카오 Geocoding API 연동 및 체육시설 주소 기반 등록 구현
56ca3b0
✨ Feat: 매칭 시작 일시(scheduledAt) 필드 추가
6eb67fe
✨ Feat: 체육시설 목록 조회 응답에 주소(address) 필드 노출
eae2624
✨ Feat: Admin 체육시설 수정·삭제 및 매칭 삭제 API 추가
56d1600
submodule pointer update
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
77 changes: 77 additions & 0 deletions
77
src/main/java/com/be/sportizebe/domain/admin/controller/AdminController.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,77 @@ | ||
| package com.be.sportizebe.domain.admin.controller; | ||
|
|
||
| import com.be.sportizebe.domain.admin.service.AdminService; | ||
| import com.be.sportizebe.domain.facility.dto.request.FacilityCreateRequest; | ||
| import com.be.sportizebe.domain.facility.dto.request.FacilityUpdateRequest; | ||
| import com.be.sportizebe.domain.facility.dto.response.FacilityResponse; | ||
| import com.be.sportizebe.domain.match.dto.request.MatchCreateRequest; | ||
| import com.be.sportizebe.domain.match.dto.response.MatchResponse; | ||
| import com.be.sportizebe.global.cache.dto.UserAuthInfo; | ||
| import com.be.sportizebe.global.response.BaseResponse; | ||
| import io.swagger.v3.oas.annotations.Operation; | ||
| 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/admin") | ||
| @Tag(name = "admin", description = "관리자 전용 API") | ||
| public class AdminController { | ||
|
|
||
| private final AdminService adminService; | ||
|
|
||
| @Operation(summary = "체육시설 등록 (관리자 전용)", description = "새로운 체육시설을 등록합니다.") | ||
| @PostMapping("/facilities") | ||
| public ResponseEntity<BaseResponse<FacilityResponse>> createFacility( | ||
| @RequestBody @Valid FacilityCreateRequest request | ||
| ) { | ||
| FacilityResponse response = adminService.createFacility(request); | ||
| return ResponseEntity.status(HttpStatus.CREATED) | ||
| .body(BaseResponse.success("체육시설 등록 성공", response)); | ||
| } | ||
|
|
||
| @Operation(summary = "체육시설 수정 (관리자 전용)", description = "체육시설 정보를 수정합니다. null 필드는 수정하지 않습니다.") | ||
| @PutMapping("/facilities/{facilityId}") | ||
| public ResponseEntity<BaseResponse<FacilityResponse>> updateFacility( | ||
| @PathVariable Long facilityId, | ||
| @RequestBody @Valid FacilityUpdateRequest request | ||
| ) { | ||
| FacilityResponse response = adminService.updateFacility(facilityId, request); | ||
| return ResponseEntity.ok(BaseResponse.success("체육시설 수정 성공", response)); | ||
| } | ||
|
|
||
| @Operation(summary = "체육시설 삭제 (관리자 전용)", description = "체육시설을 삭제합니다.") | ||
| @DeleteMapping("/facilities/{facilityId}") | ||
| public ResponseEntity<BaseResponse<Void>> deleteFacility( | ||
| @PathVariable Long facilityId | ||
| ) { | ||
| adminService.deleteFacility(facilityId); | ||
| return ResponseEntity.ok(BaseResponse.success("체육시설 삭제 성공", null)); | ||
| } | ||
|
|
||
| @Operation(summary = "매칭 생성 (관리자 전용)", description = "체육시설 기반 매칭을 생성합니다.") | ||
| @PostMapping("/matches") | ||
| public ResponseEntity<BaseResponse<MatchResponse>> createMatch( | ||
| @AuthenticationPrincipal UserAuthInfo userAuthInfo, | ||
| @RequestBody @Valid MatchCreateRequest request | ||
| ) { | ||
| MatchResponse response = adminService.createMatch(userAuthInfo.getId(), request); | ||
| return ResponseEntity.status(HttpStatus.CREATED) | ||
| .body(BaseResponse.success("매칭 생성 성공", response)); | ||
| } | ||
|
|
||
| @Operation(summary = "매칭 삭제 (관리자 전용)", description = "매칭을 강제 삭제합니다.") | ||
| @DeleteMapping("/matches/{matchId}") | ||
| public ResponseEntity<BaseResponse<Void>> deleteMatch( | ||
| @PathVariable Long matchId | ||
| ) { | ||
| adminService.deleteMatch(matchId); | ||
| return ResponseEntity.ok(BaseResponse.success("매칭 삭제 성공", null)); | ||
| } | ||
| } |
Empty file.
Empty file.
16 changes: 16 additions & 0 deletions
16
src/main/java/com/be/sportizebe/domain/admin/exception/AdminErrorCode.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,16 @@ | ||
| package com.be.sportizebe.domain.admin.exception; | ||
|
|
||
| import com.be.sportizebe.global.exception.model.BaseErrorCode; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import org.springframework.http.HttpStatus; | ||
|
|
||
| @Getter | ||
| @AllArgsConstructor | ||
| public enum AdminErrorCode implements BaseErrorCode { | ||
| ADMIN_ACCESS_DENIED("ADMIN_001", "관리자 권한이 없습니다.", HttpStatus.FORBIDDEN); | ||
|
|
||
| private final String code; | ||
| private final String message; | ||
| private final HttpStatus status; | ||
| } |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/be/sportizebe/domain/admin/service/AdminService.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,20 @@ | ||
| package com.be.sportizebe.domain.admin.service; | ||
|
|
||
| import com.be.sportizebe.domain.facility.dto.request.FacilityCreateRequest; | ||
| import com.be.sportizebe.domain.facility.dto.request.FacilityUpdateRequest; | ||
| import com.be.sportizebe.domain.facility.dto.response.FacilityResponse; | ||
| import com.be.sportizebe.domain.match.dto.request.MatchCreateRequest; | ||
| import com.be.sportizebe.domain.match.dto.response.MatchResponse; | ||
|
|
||
| public interface AdminService { | ||
|
|
||
| FacilityResponse createFacility(FacilityCreateRequest request); // 체육시설 등록 | ||
|
|
||
| FacilityResponse updateFacility(Long facilityId, FacilityUpdateRequest request); // 체육시설 수정 | ||
|
|
||
| void deleteFacility(Long facilityId); // 체육시설 삭제 | ||
|
|
||
| MatchResponse createMatch(Long adminId, MatchCreateRequest request); // 매칭 생성 | ||
|
|
||
| void deleteMatch(Long matchId); // 매칭 삭제 | ||
| } |
51 changes: 51 additions & 0 deletions
51
src/main/java/com/be/sportizebe/domain/admin/service/AdminServiceImpl.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,51 @@ | ||
| package com.be.sportizebe.domain.admin.service; | ||
|
|
||
| import com.be.sportizebe.domain.facility.dto.request.FacilityCreateRequest; | ||
| import com.be.sportizebe.domain.facility.dto.request.FacilityUpdateRequest; | ||
| import com.be.sportizebe.domain.facility.dto.response.FacilityResponse; | ||
| import com.be.sportizebe.domain.facility.service.SportsFacilityService; | ||
| import com.be.sportizebe.domain.match.dto.request.MatchCreateRequest; | ||
| import com.be.sportizebe.domain.match.dto.response.MatchResponse; | ||
| import com.be.sportizebe.domain.match.service.MatchService; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| @Transactional(readOnly = true) | ||
| public class AdminServiceImpl implements AdminService { | ||
|
|
||
| private final SportsFacilityService sportsFacilityService; | ||
| private final MatchService matchService; | ||
|
|
||
| @Override | ||
| @Transactional | ||
| public FacilityResponse createFacility(FacilityCreateRequest request) { | ||
| return sportsFacilityService.create(request); | ||
| } | ||
|
|
||
| @Override | ||
| @Transactional | ||
| public FacilityResponse updateFacility(Long facilityId, FacilityUpdateRequest request) { | ||
| return sportsFacilityService.update(facilityId, request); | ||
| } | ||
|
|
||
| @Override | ||
| @Transactional | ||
| public void deleteFacility(Long facilityId) { | ||
| sportsFacilityService.delete(facilityId); | ||
| } | ||
|
|
||
| @Override | ||
| @Transactional | ||
| public MatchResponse createMatch(Long adminId, MatchCreateRequest request) { | ||
| return matchService.createMatch(adminId, request); | ||
| } | ||
|
|
||
| @Override | ||
| @Transactional | ||
| public void deleteMatch(Long matchId) { | ||
| matchService.deleteMatch(matchId); | ||
| } | ||
| } |
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
24 changes: 24 additions & 0 deletions
24
src/main/java/com/be/sportizebe/domain/facility/dto/request/FacilityUpdateRequest.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,24 @@ | ||
| package com.be.sportizebe.domain.facility.dto.request; | ||
|
|
||
| import com.be.sportizebe.domain.facility.entity.FacilityType; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
|
|
||
| @Schema(description = "체육시설 수정 요청 (null 필드는 수정하지 않음)") | ||
| public record FacilityUpdateRequest( | ||
|
|
||
| @Schema(description = "체육시설 이름", example = "OO 풋살장 (리모델링)") | ||
| String facilityName, | ||
|
|
||
| @Schema(description = "도로명 주소 (변경 시 좌표 자동 재계산)", example = "서울특별시 강남구 테헤란로 521") | ||
| String address, | ||
|
|
||
| @Schema(description = "시설 소개", example = "샤워실/주차장 있음") | ||
| String introduce, | ||
|
|
||
| @Schema(description = "썸네일 이미지 URL", example = "https://example.com/facility/thumbnail.jpg") | ||
| String thumbnailUrl, | ||
|
|
||
| @Schema(description = "시설 종목 타입", example = "SOCCER") | ||
| FacilityType facilityType | ||
|
|
||
| ) {} |
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
17 changes: 17 additions & 0 deletions
17
src/main/java/com/be/sportizebe/domain/facility/exception/FacilityErrorCode.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 com.be.sportizebe.domain.facility.exception; | ||
|
|
||
| import com.be.sportizebe.global.exception.model.BaseErrorCode; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import org.springframework.http.HttpStatus; | ||
|
|
||
| @Getter | ||
| @AllArgsConstructor | ||
| public enum FacilityErrorCode implements BaseErrorCode { | ||
| FACILITY_NOT_FOUND("FACILITY_001", "존재하지 않는 체육시설입니다.", HttpStatus.NOT_FOUND), | ||
| ADDRESS_NOT_FOUND("FACILITY_002", "입력한 주소로 좌표를 찾을 수 없습니다. 주소를 확인해주세요.", HttpStatus.BAD_REQUEST); | ||
|
|
||
| private final String code; | ||
| private final String message; | ||
| private final HttpStatus status; | ||
| } |
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
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.
changeAddress에서 null/blank 방어가 없어 DB 무결성 예외로 이어질 수 있습니다.Line 46-48은
address를 그대로 대입해서 엔티티 레벨에서 불변식을 보장하지 못합니다. 최소한 null/blank 검증을 여기서 처리하는 편이 안전합니다.제안 수정안
🤖 Prompt for AI Agents