-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChallengeController.java
More file actions
79 lines (64 loc) · 2.95 KB
/
ChallengeController.java
File metadata and controls
79 lines (64 loc) · 2.95 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package com.writon.admin.domain.controller;
import com.writon.admin.domain.dto.request.challenge.ChallengeInfoRequestDto;
import com.writon.admin.domain.dto.request.challenge.CreateChallengeRequestDto;
import com.writon.admin.domain.dto.request.challenge.QuestionsRequestDto;
import com.writon.admin.domain.dto.response.challenge.ChallengeInfoResponseDto;
import com.writon.admin.domain.dto.response.challenge.CreateChallengeResponseDto;
import com.writon.admin.domain.dto.response.challenge.QuestionsResponseDto;
import com.writon.admin.domain.dto.lcoal.UserStatus;
import com.writon.admin.domain.service.ChallengeService;
import com.writon.admin.global.response.SuccessDto;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/challenge")
@RequiredArgsConstructor
public class ChallengeController {
private final ChallengeService challengeService;
@PostMapping
public SuccessDto<CreateChallengeResponseDto> createChallenge(
@RequestBody CreateChallengeRequestDto createChallengeRequestDto
) {
CreateChallengeResponseDto responseDto = challengeService.createChallenge(
createChallengeRequestDto);
return new SuccessDto<>(responseDto);
}
@GetMapping("/dashboard")
public SuccessDto<List<UserStatus>> getDashboard(@RequestParam Long challengeId) {
List<UserStatus> userStatusList = challengeService.getDashboard(challengeId);
return new SuccessDto<>(userStatusList);
}
@GetMapping("/questions")
public SuccessDto<QuestionsResponseDto> getQuestions(@RequestParam Long challengeId) {
QuestionsResponseDto responseDto = challengeService.getQuestions(challengeId);
return new SuccessDto<>(responseDto);
}
@GetMapping("/info")
public SuccessDto<ChallengeInfoResponseDto> getInfo(@RequestParam Long challengeId) {
ChallengeInfoResponseDto responseDto = challengeService.getInfo(challengeId);
return new SuccessDto<>(responseDto);
}
@PutMapping("/questions")
public SuccessDto<QuestionsResponseDto> putQuestions(
@RequestParam Long challengeId,
@RequestBody QuestionsRequestDto requestDto
) {
QuestionsResponseDto responseDto = challengeService.putQuestions(challengeId, requestDto);
return new SuccessDto<>(responseDto);
}
@PutMapping("/info")
public SuccessDto<ChallengeInfoResponseDto> putInfo(
@RequestParam Long challengeId,
@RequestBody ChallengeInfoRequestDto requestDto
) {
ChallengeInfoResponseDto responseDto = challengeService.putInfo(challengeId, requestDto);
return new SuccessDto<>(responseDto);
}
}