1010import dgu .sw .domain .admin .dto .AdminDTO .AdminResponse .AdminUserResponse ;
1111import dgu .sw .domain .admin .dto .AdminDTO .AdminResponse .AdminVocaResponse ;
1212import dgu .sw .domain .admin .service .AdminService ;
13+ import dgu .sw .global .ApiResponse ;
1314import io .swagger .v3 .oas .annotations .tags .Tag ;
1415import lombok .RequiredArgsConstructor ;
1516import org .springframework .security .core .Authentication ;
@@ -27,66 +28,94 @@ public class AdminController {
2728
2829 // 관리자 로그인
2930 @ PostMapping ("/login" )
30- public AdminLoginResponse login (@ RequestBody AdminLoginRequest request ) {
31- return adminService .login (request );
31+ public ApiResponse < AdminLoginResponse > login (@ RequestBody AdminLoginRequest request ) {
32+ return ApiResponse . onSuccess ( adminService .login (request ) );
3233 }
34+
3335 // 사용자 전체 조회
3436 @ GetMapping ("/users" )
35- public List <AdminUserResponse > getAllUsers (Authentication authentication ) {
36- return adminService .getAllUsers (authentication .getName ());
37+ public ApiResponse < List <AdminUserResponse > > getAllUsers (Authentication authentication ) {
38+ return ApiResponse . onSuccess ( adminService .getAllUsers (authentication .getName () ));
3739 }
3840
3941 // 매너 전체 조회
4042 @ GetMapping ("/manners" )
41- public List <AdminMannerResponse > getAllManners (Authentication authentication ) {
42- return adminService .getAllManners (authentication .getName ());
43+ public ApiResponse < List <AdminMannerResponse > > getAllManners (Authentication authentication ) {
44+ return ApiResponse . onSuccess ( adminService .getAllManners (authentication .getName () ));
4345 }
4446
4547 // 매너 등록
4648 @ PostMapping ("/manners" )
47- public void saveManner (@ RequestBody AdminMannerRequest request , Authentication authentication ) {
49+ public ApiResponse < String > saveManner (@ RequestBody AdminMannerRequest request , Authentication authentication ) {
4850 adminService .saveManner (request , authentication .getName ());
51+ return ApiResponse .onSuccess ("매너가 등록되었습니다." );
52+ }
53+
54+ // 매너 수정
55+ @ PatchMapping ("/manners/{mannerId}" )
56+ public ApiResponse <String > updateManner (@ PathVariable Long mannerId , @ RequestBody AdminMannerRequest request , Authentication authentication ) {
57+ adminService .updateManner (mannerId , request , authentication .getName ());
58+ return ApiResponse .onSuccess ("매너가 수정되었습니다." );
4959 }
5060
5161 // 매너 삭제
5262 @ DeleteMapping ("/manners/{mannerId}" )
53- public void deleteManner (@ PathVariable Long mannerId , Authentication authentication ) {
63+ public ApiResponse < String > deleteManner (@ PathVariable Long mannerId , Authentication authentication ) {
5464 adminService .deleteManner (mannerId , authentication .getName ());
65+ return ApiResponse .onSuccess ("매너가 삭제되었습니다." );
5566 }
5667
5768 // 퀴즈 전체 조회
5869 @ GetMapping ("/quizzes" )
59- public List <AdminQuizResponse > getAllQuizzes (Authentication authentication ) {
60- return adminService .getAllQuizzes (authentication .getName ());
70+ public ApiResponse < List <AdminQuizResponse > > getAllQuizzes (Authentication authentication ) {
71+ return ApiResponse . onSuccess ( adminService .getAllQuizzes (authentication .getName () ));
6172 }
6273
6374 // 퀴즈 등록
6475 @ PostMapping ("/quizzes" )
65- public void saveQuiz (@ RequestBody AdminQuizRequest request , Authentication authentication ) {
76+ public ApiResponse < String > saveQuiz (@ RequestBody AdminQuizRequest request , Authentication authentication ) {
6677 adminService .saveQuiz (request , authentication .getName ());
78+ return ApiResponse .onSuccess ("퀴즈가 등록되었습니다." );
79+ }
80+
81+ // 퀴즈 수정
82+ @ PatchMapping ("/quizzes/{quizId}" )
83+ public ApiResponse <String > updateQuiz (@ PathVariable Long quizId , @ RequestBody AdminQuizRequest request , Authentication authentication ) {
84+ adminService .updateQuiz (quizId , request , authentication .getName ());
85+ return ApiResponse .onSuccess ("퀴즈가 수정되었습니다." );
6786 }
6887
6988 // 퀴즈 삭제
7089 @ DeleteMapping ("/quizzes/{quizId}" )
71- public void deleteQuiz (@ PathVariable Long quizId , Authentication authentication ) {
90+ public ApiResponse < String > deleteQuiz (@ PathVariable Long quizId , Authentication authentication ) {
7291 adminService .deleteQuiz (quizId , authentication .getName ());
92+ return ApiResponse .onSuccess ("퀴즈가 삭제되었습니다." );
7393 }
7494
7595 // 단어 전체 조회
7696 @ GetMapping ("/vocas" )
77- public List <AdminVocaResponse > getAllVocas (Authentication authentication ) {
78- return adminService .getAllVocas (authentication .getName ());
97+ public ApiResponse < List <AdminVocaResponse > > getAllVocas (Authentication authentication ) {
98+ return ApiResponse . onSuccess ( adminService .getAllVocas (authentication .getName () ));
7999 }
80100
81101 // 단어 등록
82102 @ PostMapping ("/vocas" )
83- public void saveVoca (@ RequestBody AdminVocaRequest request , Authentication authentication ) {
103+ public ApiResponse < String > saveVoca (@ RequestBody AdminVocaRequest request , Authentication authentication ) {
84104 adminService .saveVoca (request , authentication .getName ());
105+ return ApiResponse .onSuccess ("단어가 등록되었습니다." );
106+ }
107+
108+ // 단어 수정
109+ @ PatchMapping ("/vocas/{vocaId}" )
110+ public ApiResponse <String > updateVoca (@ PathVariable Long vocaId , @ RequestBody AdminVocaRequest request , Authentication authentication ) {
111+ adminService .updateVoca (vocaId , request , authentication .getName ());
112+ return ApiResponse .onSuccess ("단어가 수정되었습니다." );
85113 }
86114
87115 // 단어 삭제
88116 @ DeleteMapping ("/vocas/{vocaId}" )
89- public void deleteVoca (@ PathVariable Long vocaId , Authentication authentication ) {
117+ public ApiResponse < String > deleteVoca (@ PathVariable Long vocaId , Authentication authentication ) {
90118 adminService .deleteVoca (vocaId , authentication .getName ());
119+ return ApiResponse .onSuccess ("단어가 삭제되었습니다." );
91120 }
92121}
0 commit comments