Skip to content

Commit

Permalink
v2.2.0 (#686)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlmondBreez3 authored Aug 25, 2024
2 parents 0dec94d + 2ee4399 commit 52c4a44
Show file tree
Hide file tree
Showing 103 changed files with 3,430 additions and 230 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.gdschongik.gdsc.domain.member.api;

import com.gdschongik.gdsc.domain.member.application.CommonMemberService;
import com.gdschongik.gdsc.domain.member.dto.response.MemberAccountInfoResponse;
import com.gdschongik.gdsc.domain.member.dto.response.MemberDepartmentResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
Expand Down Expand Up @@ -34,4 +35,11 @@ public ResponseEntity<List<MemberDepartmentResponse>> searchDepartments(
List<MemberDepartmentResponse> response = commonMemberService.searchDepartments(departmentName);
return ResponseEntity.ok().body(response);
}

@Operation(summary = "내 계정 정보 조회", description = "내 계정 정보를 조회합니다.")
@GetMapping("/me/account-info")
public ResponseEntity<MemberAccountInfoResponse> getAccountInfo() {
MemberAccountInfoResponse response = commonMemberService.getAccountInfo();
return ResponseEntity.ok().body(response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import com.gdschongik.gdsc.domain.member.dao.MemberRepository;
import com.gdschongik.gdsc.domain.member.domain.Department;
import com.gdschongik.gdsc.domain.member.domain.Member;
import com.gdschongik.gdsc.domain.member.dto.response.MemberAccountInfoResponse;
import com.gdschongik.gdsc.domain.member.dto.response.MemberDepartmentResponse;
import com.gdschongik.gdsc.domain.membership.dao.MembershipRepository;
import com.gdschongik.gdsc.domain.membership.domain.Membership;
import com.gdschongik.gdsc.global.exception.CustomException;
import com.gdschongik.gdsc.global.util.MemberUtil;
import com.gdschongik.gdsc.infra.github.client.GithubClient;
import java.util.Arrays;
import java.util.List;
import lombok.RequiredArgsConstructor;
Expand All @@ -23,6 +26,8 @@ public class CommonMemberService {

private final MembershipRepository membershipRepository;
private final MemberRepository memberRepository;
private final MemberUtil memberUtil;
private final GithubClient githubClient;

@Transactional(readOnly = true)
public List<MemberDepartmentResponse> getDepartments() {
Expand Down Expand Up @@ -81,4 +86,11 @@ public void demoteMemberToAssociateByMembership(Long membershipId) {

log.info("[CommonMemberService] 준회원 강등 완료: memberId={}", member.getId());
}

@Transactional(readOnly = true)
public MemberAccountInfoResponse getAccountInfo() {
Member currentMember = memberUtil.getCurrentMember();
String githubHandle = githubClient.getGithubHandle(currentMember.getOauthId());
return MemberAccountInfoResponse.of(currentMember, githubHandle);
}
}
12 changes: 12 additions & 0 deletions src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -345,4 +345,16 @@ public boolean isAssociate() {
public boolean isRegular() {
return role.equals(REGULAR);
}

public boolean isAdmin() {
return manageRole.equals(ADMIN);
}

public boolean isMentor() {
return studyRole.equals(MENTOR);
}

public boolean isStudent() {
return studyRole.equals(STUDENT);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.gdschongik.gdsc.domain.member.dto.response;

import com.gdschongik.gdsc.domain.member.domain.Member;

public record MemberAccountInfoResponse(String name, String githubHandle) {
public static MemberAccountInfoResponse of(Member member, String githubHandle) {
return new MemberAccountInfoResponse(member.getName(), githubHandle);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

import com.gdschongik.gdsc.domain.study.application.AdminStudyService;
import com.gdschongik.gdsc.domain.study.dto.request.StudyCreateRequest;
import com.gdschongik.gdsc.domain.study.dto.response.StudyResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -26,4 +29,11 @@ public ResponseEntity<Void> createStudy(@Valid @RequestBody StudyCreateRequest r
adminStudyService.createStudyAndStudyDetail(request);
return ResponseEntity.ok().build();
}

@Operation(summary = "전체 스터디 조회", description = "모든 스터디를 조회합니다. 코어멤버만 접근 가능합니다.")
@GetMapping
public ResponseEntity<List<StudyResponse>> getStudies() {
List<StudyResponse> response = adminStudyService.getAllStudies();
return ResponseEntity.ok(response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.gdschongik.gdsc.domain.study.api;

import com.gdschongik.gdsc.domain.study.application.CommonStudyService;
import com.gdschongik.gdsc.domain.study.dto.response.CommonStudyResponse;
import com.gdschongik.gdsc.domain.study.dto.response.StudyAnnouncementResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "Common Study", description = "공통 스터디 API입니다.")
@RestController
@RequestMapping("/common/studies")
@RequiredArgsConstructor
public class CommonStudyController {

private final CommonStudyService commonStudyService;

@Operation(summary = "스터디 기본 정보 조회", description = "스터디 기본 정보를 조회합니다.")
@GetMapping("/{studyId}")
public ResponseEntity<CommonStudyResponse> getStudyInformation(@PathVariable Long studyId) {
CommonStudyResponse response = commonStudyService.getStudyInformation(studyId);
return ResponseEntity.ok(response);
}

@Operation(summary = "스터디 공지 목록 조회", description = "스터디 공지 목록을 조회합니다.")
@GetMapping("/{studyId}/announcements")
public ResponseEntity<List<StudyAnnouncementResponse>> getStudyAnnouncements(@PathVariable Long studyId) {
List<StudyAnnouncementResponse> response = commonStudyService.getStudyAnnouncements(studyId);
return ResponseEntity.ok(response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.gdschongik.gdsc.domain.study.api;

import com.gdschongik.gdsc.domain.study.application.MentorStudyService;
import com.gdschongik.gdsc.domain.study.dto.request.StudyAnnouncementCreateUpdateRequest;
import com.gdschongik.gdsc.domain.study.dto.request.StudyUpdateRequest;
import com.gdschongik.gdsc.domain.study.dto.response.MentorStudyResponse;
import com.gdschongik.gdsc.domain.study.dto.response.StudyStudentResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@Tag(name = "Mentor Study", description = "멘토 스터디 API입니다.")
@RestController
@RequestMapping("/mentor/studies")
@RequiredArgsConstructor
public class MentorStudyController {

private final MentorStudyService mentorStudyService;

@Operation(summary = "스터디 정보 작성", description = "스터디 기본 정보와 상세 정보를 작성합니다.")
@PatchMapping("/{studyId}")
public ResponseEntity<Void> updateStudy(@PathVariable Long studyId, @RequestBody StudyUpdateRequest request) {
mentorStudyService.updateStudy(studyId, request);
return ResponseEntity.ok().build();
}

@Operation(summary = "내 스터디 조회", description = "내가 멘토로 있는 스터디를 조회합니다.")
@GetMapping("/me")
public ResponseEntity<List<MentorStudyResponse>> getStudiesInCharge() {
List<MentorStudyResponse> response = mentorStudyService.getStudiesInCharge();
return ResponseEntity.ok(response);
}

@Operation(summary = "스터디 수강생 명단 조회", description = "해당 스터디의 수강생 명단을 조회합니다")
@GetMapping("/{studyId}/students")
public ResponseEntity<List<StudyStudentResponse>> getStudyStudents(@PathVariable Long studyId) {
List<StudyStudentResponse> response = mentorStudyService.getStudyStudents(studyId);
return ResponseEntity.ok(response);
}

@Operation(summary = "스터디 공지 생성", description = "스터디의 공지사항을 생성합니다.")
@PostMapping("/{studyId}/announcements")
public ResponseEntity<Void> createStudyAnnouncement(
@PathVariable Long studyId, @Valid @RequestBody StudyAnnouncementCreateUpdateRequest request) {
mentorStudyService.createStudyAnnouncement(studyId, request);
return ResponseEntity.ok().build();
}

@Operation(summary = "스터디 공지 수정", description = "스터디의 공지사항을 수정합니다.")
@PutMapping("/announcements/{studyAnnouncementId}")
public ResponseEntity<Void> updateStudyAnnouncement(
@PathVariable Long studyAnnouncementId, @Valid @RequestBody StudyAnnouncementCreateUpdateRequest request) {
mentorStudyService.updateStudyAnnouncement(studyAnnouncementId, request);
return ResponseEntity.ok().build();
}

@Operation(summary = "스터디 공지 삭제", description = "스터디의 공지사항을 삭제합니다.")
@DeleteMapping("/announcements/{studyAnnouncementId}")
public ResponseEntity<Void> deleteStudyAnnouncement(@PathVariable Long studyAnnouncementId) {
mentorStudyService.deleteStudyAnnouncement(studyAnnouncementId);
return ResponseEntity.ok().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.gdschongik.gdsc.domain.study.application.MentorStudyDetailService;
import com.gdschongik.gdsc.domain.study.dto.request.AssignmentCreateUpdateRequest;
import com.gdschongik.gdsc.domain.study.dto.response.AssignmentResponse;
import com.gdschongik.gdsc.domain.study.dto.response.StudySessionResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
Expand Down Expand Up @@ -62,4 +63,12 @@ public ResponseEntity<Void> cancelStudyAssignment(@PathVariable Long studyDetail
mentorStudyDetailService.cancelStudyAssignment(studyDetailId);
return ResponseEntity.noContent().build();
}

// TODO 스터디 세션 워딩을 커리큘럼으로 변경해야함
@Operation(summary = "스터디 주차별 커리큘럼 목록 조회", description = "멘토가 자신의 스터디 커리큘럼 목록을 조회합니다")
@GetMapping("/sessions")
public ResponseEntity<List<StudySessionResponse>> getStudySessions(@RequestParam(name = "study") Long studyId) {
List<StudySessionResponse> response = mentorStudyDetailService.getSessions(studyId);
return ResponseEntity.ok(response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.gdschongik.gdsc.domain.study.api;

import com.gdschongik.gdsc.domain.study.application.StudentStudyService;
import com.gdschongik.gdsc.domain.study.dto.request.StudyAttendCreateRequest;
import com.gdschongik.gdsc.domain.study.dto.response.StudentMyCurrentStudyResponse;
import com.gdschongik.gdsc.domain.study.dto.response.StudyApplicableResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
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;

@Tag(name = "Student Study", description = "사용자 스터디 API입니다.")
@RestController
@RequestMapping("/studies")
@RequiredArgsConstructor
public class StudentStudyController {

private final StudentStudyService studentStudyService;

@Operation(summary = "신청 가능한 스터디 조회", description = "모집 기간 중에 있는 스터디를 조회합니다.")
@GetMapping("/apply")
public ResponseEntity<StudyApplicableResponse> getAllApplicableStudies() {
StudyApplicableResponse response = studentStudyService.getAllApplicableStudies();
return ResponseEntity.ok().body(response);
}

@Operation(summary = "스터디 수강신청", description = "스터디에 수강신청 합니다. 모집 기간 중이어야 하고, 이미 수강 중인 스터디가 없어야 합니다.")
@PostMapping("/apply/{studyId}")
public ResponseEntity<Void> applyStudy(@PathVariable Long studyId) {
studentStudyService.applyStudy(studyId);
return ResponseEntity.ok().build();
}

@Operation(summary = "스터디 수강신청 취소", description = "수강신청을 취소합니다. 스터디 수강신청 기간 중에만 취소할 수 있습니다.")
@DeleteMapping("/apply/{studyId}")
public ResponseEntity<Void> cancelStudyApply(@PathVariable Long studyId) {
studentStudyService.cancelStudyApply(studyId);
return ResponseEntity.noContent().build();
}

@Operation(summary = "스터디 출석체크", description = "스터디에 출석체크합니다. 현재 진행중인 스터디 회차에 출석체크해야 하며, 중복출석체크할 수 없습니다.")
@PostMapping("/study-details/{studyDetailId}/attend")
public ResponseEntity<Void> attend(
@PathVariable Long studyDetailId, @Valid @RequestBody StudyAttendCreateRequest request) {
studentStudyService.attend(studyDetailId, request);
return ResponseEntity.ok().build();
}

@Operation(summary = "내 수강중인 스터디 조회", description = "나의 수강 중인 스터디를 조회합니다.")
@GetMapping("/me/ongoing")
public ResponseEntity<StudentMyCurrentStudyResponse> getMyCurrentStudy() {
StudentMyCurrentStudyResponse response = studentStudyService.getMyCurrentStudy();
return ResponseEntity.ok(response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.gdschongik.gdsc.domain.study.api;

import com.gdschongik.gdsc.domain.study.application.StudentStudyDetailService;
import com.gdschongik.gdsc.domain.study.dto.response.AssignmentDashboardResponse;
import com.gdschongik.gdsc.domain.study.dto.response.AssignmentHistoryStatusResponse;
import com.gdschongik.gdsc.domain.study.dto.response.StudyStudentSessionResponse;
import com.gdschongik.gdsc.domain.study.dto.response.StudyTodoResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "Student Study Detail", description = "수강자 스터디 상세 API입니다.")
@RestController
@RequestMapping("/study-details")
@RequiredArgsConstructor
public class StudentStudyDetailController {

private final StudentStudyDetailService studentStudyDetailService;

@Operation(summary = "내 제출 가능한 과제 조회", description = "나의 제출 가능한 과제를 조회합니다.")
@GetMapping("/assignments/dashboard")
public ResponseEntity<AssignmentDashboardResponse> getSubmittableAssignments(
@RequestParam(name = "studyId") Long studyId) {
AssignmentDashboardResponse response = studentStudyDetailService.getSubmittableAssignments(studyId);
return ResponseEntity.ok(response);
}

@Operation(summary = "내 할일 리스트 조회", description = "해당 스터디의 내 할일 리스트를 조회합니다")
@GetMapping("/todo")
public ResponseEntity<List<StudyTodoResponse>> getStudyTodoList(@RequestParam(name = "studyId") Long studyId) {
List<StudyTodoResponse> response = studentStudyDetailService.getStudyTodoList(studyId);
return ResponseEntity.ok(response);
}

// TODO 스터디 세션 워딩을 커리큘럼으로 변경해야함
@Operation(summary = "스터디 커리큘럼 조회", description = "해당 스터디의 커리큘럼들을 조회합니다.")
@GetMapping("/sessions")
public ResponseEntity<List<StudyStudentSessionResponse>> getStudySessions(
@RequestParam(name = "studyId") Long studyId) {
List<StudyStudentSessionResponse> response = studentStudyDetailService.getStudySessions(studyId);
return ResponseEntity.ok(response);
}

@Operation(summary = "이번주 제출해야 할 과제 조회", description = "마감 기한이 이번주까지인 과제를 조회합니다.")
@GetMapping("/assignments/upcoming")
public ResponseEntity<List<AssignmentHistoryStatusResponse>> getUpcomingAssignments(
@RequestParam(name = "studyId") Long studyId) {
List<AssignmentHistoryStatusResponse> response = studentStudyDetailService.getUpcomingAssignments(studyId);
return ResponseEntity.ok(response);
}
}
Loading

0 comments on commit 52c4a44

Please sign in to comment.