forked from solid-connection/solid-connect-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdminMentorApplicationController.java
More file actions
65 lines (58 loc) · 2.86 KB
/
AdminMentorApplicationController.java
File metadata and controls
65 lines (58 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package com.example.solidconnection.admin.controller;
import com.example.solidconnection.admin.dto.MentorApplicationCountResponse;
import com.example.solidconnection.admin.dto.MentorApplicationRejectRequest;
import com.example.solidconnection.admin.dto.MentorApplicationSearchCondition;
import com.example.solidconnection.admin.dto.MentorApplicationSearchResponse;
import com.example.solidconnection.admin.service.AdminMentorApplicationService;
import com.example.solidconnection.common.response.PageResponse;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
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;
@RequiredArgsConstructor
@RequestMapping("/admin/mentor-applications")
@RestController
@Slf4j
public class AdminMentorApplicationController {
private final AdminMentorApplicationService adminMentorApplicationService;
@GetMapping
public ResponseEntity<PageResponse<MentorApplicationSearchResponse>> searchMentorApplications(
@Valid @ModelAttribute MentorApplicationSearchCondition mentorApplicationSearchCondition,
Pageable pageable
) {
Page<MentorApplicationSearchResponse> page = adminMentorApplicationService.searchMentorApplications(
mentorApplicationSearchCondition,
pageable
);
return ResponseEntity.ok(PageResponse.of(page));
}
@PostMapping("/{mentorApplicationId}/approve")
public ResponseEntity<Void> approveMentorApplication(
@PathVariable("mentorApplicationId") Long mentorApplicationId
) {
adminMentorApplicationService.approveMentorApplication(mentorApplicationId);
return ResponseEntity.ok().build();
}
@PostMapping("/{mentorApplicationId}/reject")
public ResponseEntity<Void> rejectMentorApplication(
@PathVariable("mentorApplicationId") Long mentorApplicationId,
@Valid @RequestBody MentorApplicationRejectRequest request
) {
adminMentorApplicationService.rejectMentorApplication(mentorApplicationId, request);
return ResponseEntity.ok().build();
}
@GetMapping("/count")
public ResponseEntity<MentorApplicationCountResponse> getMentorApplicationCount() {
MentorApplicationCountResponse response = adminMentorApplicationService.getMentorApplicationCount();
return ResponseEntity.ok(response);
}
}