-
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.
[FEAT] Application 관련 API 개발 완료 (#69)
- Loading branch information
Showing
17 changed files
with
546 additions
and
7 deletions.
There are no files selected for viewing
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 @@ | ||
== 가입 신청 관리 API | ||
:source-highlighter: highlightjs | ||
|
||
--- | ||
=== 가입 신청 리스트 조회 (GET /applications) | ||
==== | ||
operation::application-controller-test/get-applications[snippets="http-request,query-parameters,http-response,response-fields"] | ||
==== | ||
|
||
=== 가입 신청자 상세 정보 조회 (GET /applications/{applicationId}) | ||
==== | ||
operation::application-controller-test/get-application[snippets="http-request,path-parameters,http-response,response-fields"] | ||
==== | ||
|
||
=== 교수/기업 가입 허가 (PATCH /applications/{applicationId}) | ||
==== | ||
operation::application-controller-test/update-application[snippets="http-request,path-parameters,http-response,response-fields"] | ||
==== | ||
|
||
=== 교수/기업 가입 거절 (DELETE /applications/{applicationId}) | ||
==== | ||
operation::application-controller-test/reject-application[snippets="http-request,path-parameters,http-response"] | ||
==== |
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
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
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
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
63 changes: 63 additions & 0 deletions
63
src/main/java/com/scg/stop/user/controller/ApplicationController.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,63 @@ | ||
package com.scg.stop.user.controller; | ||
|
||
import com.scg.stop.auth.annotation.AuthUser; | ||
import com.scg.stop.user.domain.AccessType; | ||
import com.scg.stop.user.domain.User; | ||
import com.scg.stop.user.dto.response.ApplicationDetailResponse; | ||
import com.scg.stop.user.dto.response.ApplicationListResponse; | ||
import com.scg.stop.user.service.ApplicationService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Page; | ||
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.PatchMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/applications") | ||
public class ApplicationController { | ||
|
||
private final ApplicationService applicationService; | ||
|
||
@GetMapping | ||
public ResponseEntity<Page<ApplicationListResponse>> getApplications( | ||
@PageableDefault(page = 0, size = 10) Pageable pageable, | ||
@AuthUser(accessType = {AccessType.ADMIN}) User user | ||
) { | ||
Page<ApplicationListResponse> applications = applicationService.getApplications(pageable); | ||
return ResponseEntity.ok().body(applications); | ||
} | ||
|
||
@GetMapping("/{applicationId}") | ||
public ResponseEntity<ApplicationDetailResponse> getApplication( | ||
@PathVariable("applicationId") Long applicationId, | ||
@AuthUser(accessType = {AccessType.ADMIN}) User user | ||
) { | ||
ApplicationDetailResponse application = applicationService.getApplication(applicationId); | ||
return ResponseEntity.ok().body(application); | ||
} | ||
|
||
@PatchMapping("/{applicationId}") | ||
public ResponseEntity<ApplicationDetailResponse> approveApplication( | ||
@PathVariable("applicationId") Long applicationId, | ||
@AuthUser(accessType = {AccessType.ADMIN}) User user | ||
) { | ||
ApplicationDetailResponse application = applicationService.approveApplication(applicationId); | ||
return ResponseEntity.ok().body(application); | ||
} | ||
|
||
@DeleteMapping("/{applicationId}") | ||
public ResponseEntity<Void> rejectApplication( | ||
@PathVariable("applicationId") Long applicationId, | ||
@AuthUser(accessType = {AccessType.ADMIN}) User user | ||
) { | ||
applicationService.rejectApplication(applicationId); | ||
return ResponseEntity.noContent().build(); | ||
} | ||
} |
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
8 changes: 8 additions & 0 deletions
8
src/main/java/com/scg/stop/user/domain/ApplicationStatus.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,8 @@ | ||
package com.scg.stop.user.domain; | ||
|
||
public enum ApplicationStatus { | ||
|
||
INACTIVE, // 승인 전 | ||
ACTIVE, // 승인 됨 | ||
REJECTED // 승인 거절 됨 | ||
} |
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
40 changes: 40 additions & 0 deletions
40
src/main/java/com/scg/stop/user/dto/response/ApplicationDetailResponse.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,40 @@ | ||
package com.scg.stop.user.dto.response; | ||
|
||
import static lombok.AccessLevel.PRIVATE; | ||
|
||
import com.scg.stop.user.domain.Application; | ||
import com.scg.stop.user.domain.UserType; | ||
import java.time.LocalDateTime; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = PRIVATE) | ||
@AllArgsConstructor | ||
public class ApplicationDetailResponse { | ||
|
||
private Long id; | ||
private String name; | ||
private String phone; | ||
private String email; | ||
private String division; | ||
private String position; | ||
private UserType userType; | ||
private LocalDateTime createdAt; | ||
private LocalDateTime updatedAt; | ||
|
||
public static ApplicationDetailResponse from(Application application) { | ||
return new ApplicationDetailResponse( | ||
application.getId(), | ||
application.getUser().getName(), | ||
application.getUser().getPhone(), | ||
application.getUser().getEmail(), | ||
application.getDivision(), | ||
application.getPosition(), | ||
application.getUser().getUserType(), | ||
application.getCreatedAt(), | ||
application.getUpdatedAt() | ||
); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/scg/stop/user/dto/response/ApplicationListResponse.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,36 @@ | ||
package com.scg.stop.user.dto.response; | ||
|
||
import static lombok.AccessLevel.PRIVATE; | ||
|
||
import com.scg.stop.user.domain.Application; | ||
import com.scg.stop.user.domain.UserType; | ||
import java.time.LocalDateTime; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = PRIVATE) | ||
@AllArgsConstructor | ||
public class ApplicationListResponse { | ||
|
||
private Long id; | ||
private String name; | ||
private String division; | ||
private String position; | ||
private UserType userType; | ||
private LocalDateTime createdAt; | ||
private LocalDateTime updatedAt; | ||
|
||
public static ApplicationListResponse from(Application application) { | ||
return new ApplicationListResponse( | ||
application.getId(), | ||
application.getUser().getName(), | ||
application.getDivision(), | ||
application.getPosition(), | ||
application.getUser().getUserType(), | ||
application.getCreatedAt(), | ||
application.getUpdatedAt() | ||
); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/scg/stop/user/repository/ApplicationRepository.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 |
---|---|---|
@@ -1,7 +1,16 @@ | ||
package com.scg.stop.user.repository; | ||
|
||
import com.scg.stop.user.domain.Application; | ||
import com.scg.stop.user.domain.ApplicationStatus; | ||
import com.scg.stop.user.domain.UserType; | ||
import java.util.List; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
public interface ApplicationRepository extends JpaRepository<Application, Long> { | ||
|
||
Page<Application> findByStatus(ApplicationStatus status, Pageable pageable); | ||
} |
Oops, something went wrong.