Skip to content

Commit

Permalink
✨ 크리에이터 등록 초기 화면 불러오기 (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jindongleee authored Nov 13, 2024
1 parent b943515 commit 5a2afa3
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class CreatorController implements CreatorControllerApi {
private final WorkService workService;
private final BucketService bucketService;

// 크리에이터 등록
@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public SuccessResponse<?> createCreator(
Authentication authentication,
Expand Down Expand Up @@ -78,4 +79,13 @@ public SuccessResponse<?> getCreator(@PathVariable String nickname) {
return SuccessResponse.of(getCreatorRes);
}

// 크리에이터 등록 초기화면 불러오기
@GetMapping
public SuccessResponse<?> getCreatorInfo(Authentication authentication) {

GetCreatorRes getCreatorRes = creatorService.getCreatorInfo(authentication);

return SuccessResponse.of(getCreatorRes);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,23 @@ SuccessResponse<?> createCreator(
})
@GetMapping
SuccessResponse<?> getCreator(@PathVariable String nickname);

@Operation(summary = "크리에이터 등록 초기 화면 불러 오기")
@ApiResponses(value = {
@ApiResponse(responseCode = "200",
description = "크리에이터 등록 초기화면 불러오기 즉 크리에이터 등록을 클릭 시"
+" 기존에 저장 되어 있던 크리에이터 정보 불러 온다.",
content = @Content(mediaType = "application/json",
examples = @ExampleObject(value = "{\n"
+ " \"timestamp\": \"2024-11-03T05:07:47.704694\",\n"
+ " \"isSuccess\": true,\n"
+ " \"code\": \"200\",\n"
+ " \"message\": \"호출에 성공하였습니다.\",\n"
+ " \"data\": \"null"
+ "}"),
schema = @Schema(implementation = SuccessResponse.class)))
})
@GetMapping
SuccessResponse<?> getCreatorInfo(Authentication authentication);

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.example.gather_back_end.creator.service;

import org.example.gather_back_end.creator.dto.GetCreatorRes;
import org.springframework.security.core.Authentication;

public interface CreatorService {

Expand All @@ -14,4 +15,6 @@ void createCreator(
);

GetCreatorRes getCreator(String nickname);

GetCreatorRes getCreatorInfo(Authentication authentication);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import org.example.gather_back_end.repository.PortfolioRepository;
import org.example.gather_back_end.repository.UserRepository;
import org.example.gather_back_end.repository.WorkRepository;
import org.example.gather_back_end.util.jwt.dto.CustomOAuth2User;
import org.example.gather_back_end.work.dto.GetWorkRes;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Service;
import java.util.List;

Expand Down Expand Up @@ -60,4 +62,31 @@ public GetCreatorRes getCreator(String nickname){

}

// 크리에이터 등록 초기 화면
@Override
public GetCreatorRes getCreatorInfo(Authentication authentication){

CustomOAuth2User customOAuth2User = (CustomOAuth2User) authentication.getPrincipal();

User user = userRepository.getByUsername(customOAuth2User.getUsername());

List<GetPortfolioRes> getPortfolioResList = portfolioRepository.getAllByUser(user);
List<GetWorkRes> getWorkResList = workRepository.findAllByUser(user);

// GetCreatorRes에 하나하나 다 담아야함
GetCreatorRes res = new GetCreatorRes(
user.getNickname(),
user.getProfileImgUrl(),
user.getIntroductionTitle(),
user.getIntroductionContent(),
getPortfolioResList,
getWorkResList,
user.getContactKakaoId(),
user.getContactEmail()
);

return res;

}

}

0 comments on commit 5a2afa3

Please sign in to comment.