-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndexController.java
More file actions
47 lines (39 loc) · 2.13 KB
/
Copy pathIndexController.java
File metadata and controls
47 lines (39 loc) · 2.13 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
package com.knoc.global.controller;
import com.knoc.senior.SeniorProfileService;
import com.knoc.senior.dto.SeniorSearchCondition;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import java.util.List;
@Tag(name="Index-Controller",description = "메인페이지 및 시니어 조회 관련 API")
@Controller
@RequiredArgsConstructor
public class IndexController {
private static final List<String> POPULAR_SKILLS =
List.of("Java", "Spring", "React", "TypeScript", "Next.js", "Python", "AWS", "Kotlin");
private final SeniorProfileService seniorProfileService;
@Value("${toss.payments.client-key:}")
private String tossClientKey;
@Operation(summary = "메인 페이지 조회",description = "메인 페이지에 접속하여 검색 조건에 따른 시니어 목록 조회합니다.")
@GetMapping("/")
public String index(@ModelAttribute SeniorSearchCondition condition, Model model) {
model.addAttribute("seniors", seniorProfileService.searchProfiles(condition));
model.addAttribute("condition", condition);
model.addAttribute("popularSkills", POPULAR_SKILLS);
model.addAttribute("tossClientKey", tossClientKey);
return "index";
}
@Operation(summary = "시니어 목록 fragment 조회", description = "검색 조건에 따른 시니어 목록을 HTML fragment으로 반환 / AJAX 필터링에 사용한다.")
@GetMapping("/seniors/fragment")
public String searchFragment(@ModelAttribute SeniorSearchCondition condition, Model model) {
model.addAttribute("seniors", seniorProfileService.searchProfiles(condition));
model.addAttribute("condition", condition);
model.addAttribute("popularSkills", POPULAR_SKILLS);
return "index :: seniorSection"; // 시니어 섹션 fragment만 반환
}
}