From 877e423f73e0574b8b45ea9b4d28f6621a5fa144 Mon Sep 17 00:00:00 2001
From: hyxklee <ewgt1234@naver.com>
Date: Sun, 21 Jul 2024 15:23:58 +0900
Subject: [PATCH] =?UTF-8?q?feat:=20/admin=20=EA=B6=8C=ED=95=9C=EC=9D=B4=20?=
 =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20=EC=9A=94=EC=B2=AD=EC=9D=84=20?=
 =?UTF-8?q?=EC=88=98=ED=96=89=ED=95=98=EA=B8=B0=20=EC=9C=84=ED=95=9C=20adm?=
 =?UTF-8?q?inController=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../admin/controller/AdminController.java     | 101 ++++++++++++++++++
 1 file changed, 101 insertions(+)
 create mode 100644 src/main/java/leets/weeth/domain/admin/controller/AdminController.java

diff --git a/src/main/java/leets/weeth/domain/admin/controller/AdminController.java b/src/main/java/leets/weeth/domain/admin/controller/AdminController.java
new file mode 100644
index 00000000..35841ed3
--- /dev/null
+++ b/src/main/java/leets/weeth/domain/admin/controller/AdminController.java
@@ -0,0 +1,101 @@
+package leets.weeth.domain.admin.controller;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.validation.Valid;
+import leets.weeth.domain.event.attendanceEvent.dto.RequestAttendanceEvent;
+import leets.weeth.domain.event.attendanceEvent.service.AttendanceEventService;
+import leets.weeth.domain.event.dto.RequestEvent;
+import leets.weeth.domain.event.service.EventService;
+import leets.weeth.domain.notice.dto.RequestNotice;
+import leets.weeth.domain.notice.service.NoticeService;
+import leets.weeth.global.auth.annotation.CurrentUser;
+import leets.weeth.global.common.error.exception.custom.BusinessLogicException;
+import leets.weeth.global.common.response.CommonResponse;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+
+import static leets.weeth.domain.event.attendanceEvent.enums.ResponseMessage.ATTENDANCE_EVENT_CREATED_SUCCESS;
+import static leets.weeth.domain.event.entity.enums.ResponseMessage.*;
+import static leets.weeth.domain.notice.enums.ResponseMessage.*;
+
+@Tag(name = "AdminController", description = "어드민 전용 API입니다.")
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("/admin")
+public class AdminController {
+    private final EventService eventService;
+    private final NoticeService noticeService;
+    private final AttendanceEventService attendanceEventService;
+
+    /*
+        Event 관련 admin api
+     */
+    @Operation(summary = "일정 생성", description = "관리자가 일정을 등록합니다.")
+    @PostMapping("/event/create")
+    public CommonResponse<String> createEvent(@RequestBody @Valid RequestEvent requestEvent,
+                                              @Parameter(hidden = true) @CurrentUser Long userId) throws BusinessLogicException {
+        eventService.createEvent(requestEvent, userId);
+        return CommonResponse.createSuccess(EVENT_CREATED_SUCCESS.getMessage());
+    }
+
+    @Operation(summary = "일정 수정", description = "관리자가 일정을 수정합니다.")
+    @PatchMapping("/event/{eventId}")
+    public CommonResponse<String> updateEvent(@PathVariable Long eventId, @RequestBody RequestEvent requestEvent,
+                                              @Parameter(hidden = true) @CurrentUser Long userId) throws BusinessLogicException {
+        eventService.updateEvent(eventId, requestEvent, userId);
+        return CommonResponse.createSuccess(EVENT_UPDATED_SUCCESS.getMessage());
+    }
+
+    @Operation(summary = "일정 삭제", description = "관리자가 일정을 삭제합니다.")
+    @DeleteMapping("/event/{eventId}")
+    public CommonResponse<String> deleteEvent(@PathVariable Long eventId,
+                                              @Parameter(hidden = true) @CurrentUser Long userId) throws BusinessLogicException {
+        eventService.deleteEvent(eventId, userId);
+        return CommonResponse.createSuccess(EVENT_DELETED_SUCCESS.getMessage());
+    }
+
+    /*
+        Notice 관련 admin api
+     */
+    @Operation(summary = "공지 생성", description = "관리자가 공지사항을 등록합니다.")
+    @PostMapping("/notice/create")
+    public CommonResponse<String> createNotice(@RequestPart(value = "requestNotice") @Valid RequestNotice requestNotice,
+                                               @RequestPart(value = "files", required = false) List<MultipartFile> files,
+                                               @Parameter(hidden = true) @CurrentUser Long userId) throws BusinessLogicException {
+        noticeService.createNotice(requestNotice, files, userId);
+        return CommonResponse.createSuccess(NOTICE_CREATED_SUCCESS.getMessage());
+    }
+
+    @Operation(summary = "공지사항 수정", description = "관리자가 공지사항을 수정합니다.")
+    @PatchMapping("/notice/{noticeId}")
+    public CommonResponse<String> updateNotice(@RequestPart(value = "requestNotice") @Valid RequestNotice requestNotice,
+                                               @RequestPart(value = "files", required = false) List<MultipartFile> files,
+                                               @Parameter(hidden = true) @CurrentUser Long userId,
+                                               @PathVariable Long noticeId) throws BusinessLogicException {
+        noticeService.updateNotice(noticeId, requestNotice, files, userId);
+        return CommonResponse.createSuccess(NOTICE_UPDATED_SUCCESS.getMessage());
+    }
+
+    @Operation(summary = "공지사항 삭제", description = "관리자가 공지사항을 삭제합니다.")
+    @DeleteMapping("/notice/{noticeId}")
+    public CommonResponse<String> deleteNotice(@PathVariable Long noticeId, @Parameter(hidden = true) @CurrentUser Long userId) throws BusinessLogicException {
+        noticeService.deleteNotice(noticeId, userId);
+        return CommonResponse.createSuccess(NOTICE_DELETED_SUCCESS.getMessage());
+    }
+
+    /*
+        AttendanceEvent 관련 admin api
+     */
+    @Operation(summary = "출석 일정 생성", description = "관리자가 출석일정을 등록합니다.")
+    @PostMapping("/attendanceEvent/create")
+    public CommonResponse<String> createAttendanceEvent(@RequestBody @Valid RequestAttendanceEvent requestAttendanceEvent,
+                                                        @Parameter(hidden = true) @CurrentUser Long userId) {
+        attendanceEventService.createAttendanceEvent(requestAttendanceEvent, userId);
+        return CommonResponse.createSuccess(ATTENDANCE_EVENT_CREATED_SUCCESS.getMessage());
+    }
+}