Skip to content

Commit

Permalink
Merge pull request #58 from Team-UMC/fix/#57/modify-github-authentica…
Browse files Browse the repository at this point in the history
…tion

[FIX] 깃허브 연동하기 임시 수정 및 테스트 코드 에러 해결
  • Loading branch information
junseokkim authored Feb 5, 2024
2 parents aeaba99 + 276cf5f commit af66b42
Show file tree
Hide file tree
Showing 40 changed files with 79 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import com.umc.networkingService.domain.board.entity.HostType;
import com.umc.networkingService.global.common.enums.Part;
import com.umc.networkingService.global.common.enums.Semester;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import com.umc.networkingService.domain.board.entity.BoardType;
import com.umc.networkingService.domain.board.entity.HostType;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

@Getter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.umc.networkingService.domain.board.dto.response.notice;

import com.umc.networkingService.domain.board.entity.HostType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.UUID;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.umc.networkingService.domain.board.dto.response.notice;

import com.umc.networkingService.domain.board.dto.response.notice.BoardNoticePageResponse;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import com.umc.networkingService.domain.branch.entity.Branch;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.Optional;
import java.util.UUID;

public interface BranchRepository extends JpaRepository<Branch, UUID> {
boolean existsByName(String name);
Optional<Branch> findByName(String name);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.security.core.parameters.P;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.UUID;

@Tag(name = "친구 API", description = "친구 관련 API")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.umc.networkingService.domain.friend.service;

import com.umc.networkingService.domain.friend.repository.FriendRepository;
import com.umc.networkingService.domain.member.dto.response.MemberInquiryProfileResponse;
import com.umc.networkingService.domain.member.entity.Member;
import com.umc.networkingService.domain.member.entity.MemberRelation;
import com.umc.networkingService.domain.member.mapper.MemberMapper;
import com.umc.networkingService.domain.member.repository.MemberRepository;
import com.umc.networkingService.domain.member.service.MemberService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ public BaseResponse<MemberInquiryInfoWithPointResponse> inquiryHomeInfo(@Current
})
@PostMapping("/github")
public BaseResponse<MemberAuthenticateGithubResponse> authenticationGithub(@CurrentMember Member member,
@RequestParam String code) {
return BaseResponse.onSuccess(memberService.authenticateGithub(member, code));
@RequestParam String nickname) {
return BaseResponse.onSuccess(memberService.authenticateGithub(member, nickname));
}

@Operation(summary = "깃허브 데이터 조회 API", description = "깃허브 잔디 이미지를 조회하는 API입니다.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@
import org.hibernate.annotations.SQLRestriction;
import org.hibernate.annotations.UuidGenerator;

import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.UUID;

@Getter
@Entity
Expand Down Expand Up @@ -111,13 +107,6 @@ public void updateSemesterParts(List<SemesterPart> semesterParts) {
this.semesterParts = semesterParts;
}

// 가장 마지막 기수 파트를 반환하는 함수
public SemesterPart getLatestSemesterPart() {
return semesterParts.stream()
.max(Comparator.comparing(SemesterPart::getSemester))
.orElseThrow(() -> new RestApiException(ErrorCode.NO_SEMESTER_PARTS));
}

// 깃허브 닉네임 업데이트 함수
public void authenticateGithub(String gitNickname) {
this.gitNickname = gitNickname;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ public interface MemberRepository extends JpaRepository<Member, UUID> {
Optional<Member> findByClientIdAndSocialType(String clientId, SocialType socialType);
List<Member> findAllByUniversityOrderByContributionPointDesc(University university);
List<Member> findAllByNicknameAndName(String nickname, String name);
boolean existsByGitNickname(String gitNickname);
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ public MemberIdResponse signUp(Member member, MemberSignUpRequest request) {
semesterPartService.saveSemesterPartInfos(loginMember, request.getSemesterParts());

// 이외의 기본 정보 저장
member.setMemberInfo(request.getName(), request.getNickname(), university,
loginMember.setMemberInfo(request.getName(), request.getNickname(), university,
// 대학교와 멤버의 마지막 기수를 통해 지부 정보 조회
branchUniversityService.findBranchByUniversityAndSemester(university, member.getLatestSemesterPart().getSemester())
branchUniversityService.findBranchByUniversityAndSemester(university, loginMember.getRecentSemester())
);

return new MemberIdResponse(memberService.saveEntity(loginMember).getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public interface MemberService extends EntityLoader<Member, UUID> {
MemberIdResponse updateMyProfile(Member member, MultipartFile profileImage, MemberUpdateMyProfileRequest request);
MemberIdResponse updateProfile(Member member, UUID memberId, MemberUpdateProfileRequest request);
MemberAuthenticateGithubResponse authenticateGithub(Member member, String code);
MemberAuthenticateGithubResponse authenticateGithub(Member member, String nickname);
MemberInquiryInfoWithPointResponse inquiryInfoWithPoint(Member member);
MemberInquiryGithubResponse inquiryGithubImage(Member member);
MemberInquiryPointsResponse inquiryMemberPoints(Member member);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@

import com.umc.networkingService.domain.branch.entity.Branch;
import com.umc.networkingService.domain.branch.service.BranchUniversityService;
import com.umc.networkingService.domain.friend.service.FriendService;
import com.umc.networkingService.domain.member.client.GithubMemberClient;
import com.umc.networkingService.domain.member.dto.request.MemberUpdateMyProfileRequest;
import com.umc.networkingService.domain.member.dto.request.MemberUpdateProfileRequest;
import com.umc.networkingService.domain.member.dto.response.*;
import com.umc.networkingService.domain.member.entity.*;
import com.umc.networkingService.domain.member.entity.Member;
import com.umc.networkingService.domain.member.entity.MemberPoint;
import com.umc.networkingService.domain.member.entity.MemberPosition;
import com.umc.networkingService.domain.member.entity.PositionType;
import com.umc.networkingService.domain.member.mapper.MemberMapper;
import com.umc.networkingService.domain.member.repository.MemberPointRepository;
import com.umc.networkingService.domain.member.repository.MemberRepository;
Expand Down Expand Up @@ -94,16 +96,18 @@ public MemberInquiryInfoWithPointResponse inquiryInfoWithPoint(Member member) {
// 깃허브 인증 함수
@Override
@Transactional
public MemberAuthenticateGithubResponse authenticateGithub(Member member, String code) {
public MemberAuthenticateGithubResponse authenticateGithub(Member member, String nickname) {

Member loginMember = loadEntity(member.getId());

String gitNickname = githubMemberClient.getGithubNickname(code);
//// String gitNickname = githubMemberClient.getGithubNickname(code);
//
// if (gitNickname == null || gitNickname.isBlank())
// throw new RestApiException(ErrorCode.FAILED_GITHUB_AUTHENTICATION);

if (gitNickname == null || gitNickname.isBlank())
throw new RestApiException(ErrorCode.FAILED_GITHUB_AUTHENTICATION);

loginMember.authenticateGithub(gitNickname);
if (memberRepository.existsByGitNickname(nickname))
throw new RestApiException(ErrorCode.DUPLICATED_GIT_NICKNAME);
loginMember.authenticateGithub(nickname);

return new MemberAuthenticateGithubResponse(loginMember.getGitNickname());
}
Expand Down Expand Up @@ -183,7 +187,7 @@ private void updatePositionAndSemesterPart(Member updateMember, MemberUpdateProf

// 기수 변경에 의해 소속 지부 변경
Branch newBranch = branchUniversityService.findBranchByUniversityAndSemester(
updateMember.getUniversity(), updateMember.getLatestSemesterPart().getSemester());
updateMember.getUniversity(), updateMember.getRecentSemester());
updateMember.updateBranch(newBranch);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.umc.networkingService.domain.project.entity;

import com.umc.networkingService.domain.member.entity.Member;
import com.umc.networkingService.global.common.base.BaseEntity;
import com.umc.networkingService.global.common.enums.Semester;
import jakarta.persistence.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,24 @@

import com.umc.networkingService.config.security.auth.CurrentMember;
import com.umc.networkingService.domain.member.entity.Member;
import com.umc.networkingService.domain.todayILearned.dto.requeest.TodayILearnedRequest;
import com.umc.networkingService.domain.todayILearned.dto.requeest.TodayILearnedRequest.TodayILearnedCreate;
import com.umc.networkingService.domain.todayILearned.dto.requeest.TodayILearnedRequest.TodayILearnedUpdate;
import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedId;
import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedInfo;
import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedInfos;
import com.umc.networkingService.domain.todayILearned.service.TodayILearnedService;
import com.umc.networkingService.global.common.base.BaseResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import java.util.UUID;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
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.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.UUID;

@Tag(name = "Today I Learned API", description = "Today I Learned 관련 API")
@RestController
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.umc.networkingService.domain.todayILearned.dto.requeest;

import com.umc.networkingService.global.common.enums.Part;
import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.umc.networkingService.domain.todayILearned.dto.response;

import com.umc.networkingService.global.common.enums.Part;
import java.util.List;
import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.UUID;

public class TodayILearnedResponse {

@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
import com.umc.networkingService.global.common.base.BaseEntity;
import com.umc.networkingService.global.common.enums.Part;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.*;
import org.hibernate.annotations.SQLRestriction;
import org.hibernate.annotations.UuidGenerator;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

import com.umc.networkingService.domain.member.entity.Member;
import com.umc.networkingService.domain.todayILearned.dto.requeest.TodayILearnedRequest.TodayILearnedCreate;
import com.umc.networkingService.domain.todayILearned.dto.requeest.TodayILearnedRequest.TodayILearnedUpdate;
import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedId;
import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedInfo;
import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedInfos;
import com.umc.networkingService.domain.todayILearned.entity.TodayILearned;
import com.umc.networkingService.domain.todayILearned.entity.TodayILearnedFile;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.UUID;
import org.springframework.stereotype.Component;

@Component
public class TodayILearnedMapper {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.umc.networkingService.domain.todayILearned.repository;

import com.umc.networkingService.domain.todayILearned.entity.TodayILearnedFile;
import java.util.UUID;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.UUID;

public interface TodayILearnedFileRepository extends JpaRepository<TodayILearnedFile, UUID> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import com.umc.networkingService.domain.member.entity.Member;
import com.umc.networkingService.domain.todayILearned.entity.TodayILearned;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface TodayILearnedRepository extends JpaRepository<TodayILearned, UUID> {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.umc.networkingService.domain.todayILearned.service;

import com.umc.networkingService.domain.todayILearned.entity.TodayILearned;
import java.util.List;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

public interface TodayILearnedFileService {
void uploadTodayILearnedFiles(TodayILearned todayILearned, List<MultipartFile> files);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import com.umc.networkingService.domain.todayILearned.entity.TodayILearned;
import com.umc.networkingService.domain.todayILearned.mapper.TodayILearnedFileMapper;
import com.umc.networkingService.domain.todayILearned.repository.TodayILearnedFileRepository;
import com.umc.networkingService.domain.todayILearned.repository.TodayILearnedRepository;
import com.umc.networkingService.global.utils.S3FileComponent;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import com.umc.networkingService.domain.todayILearned.dto.requeest.TodayILearnedRequest.TodayILearnedCreate;
import com.umc.networkingService.domain.todayILearned.dto.requeest.TodayILearnedRequest.TodayILearnedUpdate;
import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedId;
import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedInfo;
import com.umc.networkingService.domain.todayILearned.dto.response.TodayILearnedResponse.TodayILearnedInfos;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.UUID;
import org.springframework.web.multipart.MultipartFile;

public interface TodayILearnedService {
TodayILearnedId createTodayILearned(Member member, List<MultipartFile> files, TodayILearnedCreate request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
import com.umc.networkingService.domain.todayILearned.repository.TodayILearnedRepository;
import com.umc.networkingService.global.common.exception.ErrorCode;
import com.umc.networkingService.global.common.exception.RestApiException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import java.time.LocalDate;
import java.util.List;
import java.util.UUID;

@Service
@RequiredArgsConstructor
public class TodayILearnedServiceImpl implements TodayILearnedService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.List;

@Getter
@RequiredArgsConstructor
public enum Role {
Expand Down
Loading

0 comments on commit af66b42

Please sign in to comment.