-
Notifications
You must be signed in to change notification settings - Fork 8
feat: 어드민에서 파견 대학을 관리하도록 #633
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
Changes from 13 commits
5a11bc4
ff30af8
1adeb67
5897bf3
c38ae47
9d20694
e81b2a2
1bedd3d
743791e
df5ab29
5033c98
9c4ad74
e327a08
4b112c4
227925a
138b3a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| package com.example.solidconnection.admin.university.controller; | ||
|
|
||
| import com.example.solidconnection.admin.university.dto.AdminHostUniversityCreateRequest; | ||
| import com.example.solidconnection.admin.university.dto.AdminHostUniversityDetailResponse; | ||
| import com.example.solidconnection.admin.university.dto.AdminHostUniversityListResponse; | ||
| import com.example.solidconnection.admin.university.dto.AdminHostUniversitySearchCondition; | ||
| import com.example.solidconnection.admin.university.dto.AdminHostUniversityUpdateRequest; | ||
| import com.example.solidconnection.admin.university.service.AdminHostUniversityService; | ||
| import jakarta.validation.Valid; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.data.web.PageableDefault; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.DeleteMapping; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.PutMapping; | ||
| import org.springframework.web.bind.annotation.RequestBody; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| @RequiredArgsConstructor | ||
| @RequestMapping("/admin/host-universities") | ||
| @RestController | ||
| public class AdminHostUniversityController { | ||
|
|
||
| private final AdminHostUniversityService adminHostUniversityService; | ||
|
|
||
| @GetMapping | ||
| public ResponseEntity<AdminHostUniversityListResponse> getHostUniversities( | ||
| AdminHostUniversitySearchCondition condition, | ||
| @PageableDefault(size = 20) Pageable pageable | ||
| ) { | ||
| AdminHostUniversityListResponse response = adminHostUniversityService.getHostUniversities(condition, pageable); | ||
| return ResponseEntity.ok(response); | ||
| } | ||
|
|
||
| @GetMapping("/{id}") | ||
|
||
| public ResponseEntity<AdminHostUniversityDetailResponse> getHostUniversity( | ||
| @PathVariable Long id | ||
| ) { | ||
| AdminHostUniversityDetailResponse response = adminHostUniversityService.getHostUniversity(id); | ||
| return ResponseEntity.ok(response); | ||
| } | ||
|
|
||
| @PostMapping | ||
| public ResponseEntity<AdminHostUniversityDetailResponse> createHostUniversity( | ||
| @Valid @RequestBody AdminHostUniversityCreateRequest request | ||
| ) { | ||
| AdminHostUniversityDetailResponse response = adminHostUniversityService.createHostUniversity(request); | ||
| return ResponseEntity.ok(response); | ||
| } | ||
|
|
||
| @PutMapping("/{id}") | ||
| public ResponseEntity<AdminHostUniversityDetailResponse> updateHostUniversity( | ||
| @PathVariable Long id, | ||
| @Valid @RequestBody AdminHostUniversityUpdateRequest request | ||
| ) { | ||
| AdminHostUniversityDetailResponse response = adminHostUniversityService.updateHostUniversity(id, request); | ||
| return ResponseEntity.ok(response); | ||
| } | ||
|
|
||
| @DeleteMapping("/{id}") | ||
| public ResponseEntity<Void> deleteHostUniversity( | ||
| @PathVariable Long id | ||
| ) { | ||
| adminHostUniversityService.deleteHostUniversity(id); | ||
| return ResponseEntity.ok().build(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package com.example.solidconnection.admin.university.dto; | ||
|
|
||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.Size; | ||
|
|
||
| public record AdminHostUniversityCreateRequest( | ||
| @NotBlank(message = "한글 대학명은 필수입니다") | ||
| @Size(max = 100, message = "한글 대학명은 100자 이하여야 합니다") | ||
| String koreanName, | ||
|
|
||
| @NotBlank(message = "영문 대학명은 필수입니다") | ||
| @Size(max = 100, message = "영문 대학명은 100자 이하여야 합니다") | ||
| String englishName, | ||
|
|
||
| @NotBlank(message = "표시 대학명은 필수입니다") | ||
| @Size(max = 100, message = "표시 대학명은 100자 이하여야 합니다") | ||
| String formatName, | ||
|
|
||
| @Size(max = 500, message = "홈페이지 URL은 500자 이하여야 합니다") | ||
| String homepageUrl, | ||
|
|
||
| @Size(max = 500, message = "영어 강좌 URL은 500자 이하여야 합니다") | ||
| String englishCourseUrl, | ||
|
|
||
| @Size(max = 500, message = "숙소 URL은 500자 이하여야 합니다") | ||
| String accommodationUrl, | ||
|
|
||
| @NotBlank(message = "로고 이미지 URL은 필수입니다") | ||
| @Size(max = 500, message = "로고 이미지 URL은 500자 이하여야 합니다") | ||
| String logoImageUrl, | ||
|
|
||
| @NotBlank(message = "배경 이미지 URL은 필수입니다") | ||
| @Size(max = 500, message = "배경 이미지 URL은 500자 이하여야 합니다") | ||
| String backgroundImageUrl, | ||
|
|
||
| @Size(max = 1000, message = "상세 정보는 1000자 이하여야 합니다") | ||
| String detailsForLocal, | ||
|
|
||
| @NotBlank(message = "국가 코드는 필수입니다") | ||
| String countryCode, | ||
|
|
||
| @NotBlank(message = "지역 코드는 필수입니다") | ||
| String regionCode | ||
| ) { | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| package com.example.solidconnection.admin.university.dto; | ||
|
|
||
| import com.example.solidconnection.university.domain.HostUniversity; | ||
|
|
||
| public record AdminHostUniversityDetailResponse( | ||
| Long id, | ||
| String koreanName, | ||
| String englishName, | ||
| String formatName, | ||
| String homepageUrl, | ||
| String englishCourseUrl, | ||
| String accommodationUrl, | ||
| String logoImageUrl, | ||
| String backgroundImageUrl, | ||
| String detailsForLocal, | ||
| String countryCode, | ||
| String countryKoreanName, | ||
| String regionCode, | ||
| String regionKoreanName | ||
| ) { | ||
|
|
||
| public static AdminHostUniversityDetailResponse from(HostUniversity hostUniversity) { | ||
| return new AdminHostUniversityDetailResponse( | ||
| hostUniversity.getId(), | ||
| hostUniversity.getKoreanName(), | ||
| hostUniversity.getEnglishName(), | ||
| hostUniversity.getFormatName(), | ||
| hostUniversity.getHomepageUrl(), | ||
| hostUniversity.getEnglishCourseUrl(), | ||
| hostUniversity.getAccommodationUrl(), | ||
| hostUniversity.getLogoImageUrl(), | ||
| hostUniversity.getBackgroundImageUrl(), | ||
| hostUniversity.getDetailsForLocal(), | ||
| hostUniversity.getCountry() != null ? hostUniversity.getCountry().getCode() : null, | ||
| hostUniversity.getCountry() != null ? hostUniversity.getCountry().getKoreanName() : null, | ||
| hostUniversity.getRegion() != null ? hostUniversity.getRegion().getCode() : null, | ||
| hostUniversity.getRegion() != null ? hostUniversity.getRegion().getKoreanName() : null | ||
| ); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package com.example.solidconnection.admin.university.dto; | ||
|
|
||
| import com.example.solidconnection.university.domain.HostUniversity; | ||
| import java.util.List; | ||
| import org.springframework.data.domain.Page; | ||
|
|
||
| public record AdminHostUniversityListResponse( | ||
| List<AdminHostUniversityResponse> hostUniversities, | ||
| int page, | ||
| int size, | ||
| long totalElements, | ||
| int totalPages, | ||
| boolean hasNext, | ||
| boolean hasPrevious | ||
| ) { | ||
|
|
||
| public static AdminHostUniversityListResponse from(Page<HostUniversity> hostUniversityPage) { | ||
| List<AdminHostUniversityResponse> hostUniversities = hostUniversityPage.getContent() | ||
| .stream() | ||
| .map(AdminHostUniversityResponse::from) | ||
| .toList(); | ||
|
|
||
| return new AdminHostUniversityListResponse( | ||
| hostUniversities, | ||
| hostUniversityPage.getNumber(), | ||
| hostUniversityPage.getSize(), | ||
| hostUniversityPage.getTotalElements(), | ||
| hostUniversityPage.getTotalPages(), | ||
| hostUniversityPage.hasNext(), | ||
| hostUniversityPage.hasPrevious() | ||
| ); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package com.example.solidconnection.admin.university.dto; | ||
|
|
||
| import com.example.solidconnection.university.domain.HostUniversity; | ||
|
|
||
| public record AdminHostUniversityResponse( | ||
| Long id, | ||
| String koreanName, | ||
| String englishName, | ||
| String formatName, | ||
| String logoImageUrl, | ||
| String countryCode, | ||
| String countryKoreanName, | ||
| String regionCode, | ||
| String regionKoreanName | ||
| ) { | ||
|
|
||
| public static AdminHostUniversityResponse from(HostUniversity hostUniversity) { | ||
| return new AdminHostUniversityResponse( | ||
| hostUniversity.getId(), | ||
| hostUniversity.getKoreanName(), | ||
| hostUniversity.getEnglishName(), | ||
| hostUniversity.getFormatName(), | ||
| hostUniversity.getLogoImageUrl(), | ||
| hostUniversity.getCountry() != null ? hostUniversity.getCountry().getCode() : null, | ||
| hostUniversity.getCountry() != null ? hostUniversity.getCountry().getKoreanName() : null, | ||
| hostUniversity.getRegion() != null ? hostUniversity.getRegion().getCode() : null, | ||
| hostUniversity.getRegion() != null ? hostUniversity.getRegion().getKoreanName() : null | ||
| ); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.example.solidconnection.admin.university.dto; | ||
|
|
||
| public record AdminHostUniversitySearchCondition( | ||
| String keyword, | ||
| String countryCode, | ||
| String regionCode | ||
| ) { | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package com.example.solidconnection.admin.university.dto; | ||
|
|
||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.Size; | ||
|
|
||
| public record AdminHostUniversityUpdateRequest( | ||
| @NotBlank(message = "한글 대학명은 필수입니다") | ||
| @Size(max = 100, message = "한글 대학명은 100자 이하여야 합니다") | ||
| String koreanName, | ||
|
|
||
| @NotBlank(message = "영문 대학명은 필수입니다") | ||
| @Size(max = 100, message = "영문 대학명은 100자 이하여야 합니다") | ||
| String englishName, | ||
|
|
||
| @NotBlank(message = "표시 대학명은 필수입니다") | ||
| @Size(max = 100, message = "표시 대학명은 100자 이하여야 합니다") | ||
| String formatName, | ||
|
|
||
| @Size(max = 500, message = "홈페이지 URL은 500자 이하여야 합니다") | ||
| String homepageUrl, | ||
|
|
||
| @Size(max = 500, message = "영어 강좌 URL은 500자 이하여야 합니다") | ||
| String englishCourseUrl, | ||
|
|
||
| @Size(max = 500, message = "숙소 URL은 500자 이하여야 합니다") | ||
| String accommodationUrl, | ||
|
|
||
| @NotBlank(message = "로고 이미지 URL은 필수입니다") | ||
| @Size(max = 500, message = "로고 이미지 URL은 500자 이하여야 합니다") | ||
| String logoImageUrl, | ||
|
|
||
| @NotBlank(message = "배경 이미지 URL은 필수입니다") | ||
| @Size(max = 500, message = "배경 이미지 URL은 500자 이하여야 합니다") | ||
| String backgroundImageUrl, | ||
|
|
||
| @Size(max = 1000, message = "상세 정보는 1000자 이하여야 합니다") | ||
| String detailsForLocal, | ||
|
|
||
| @NotBlank(message = "국가 코드는 필수입니다") | ||
| String countryCode, | ||
|
|
||
| @NotBlank(message = "지역 코드는 필수입니다") | ||
| String regionCode | ||
| ) { | ||
|
|
||
| } |
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.
PageResponse 라는 공통객체가 있는데 혹시 사용안하신 이유가 있을까요? response객체보니 따로
boolean hasNext,
boolean hasPrevious
를 정의하신 거 같아서요!
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.
이 부분도 수정했습니다 !
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.
227925a