Skip to content

Commit

Permalink
✨Feat: 테스트용 API 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
jiinkyung committed Feb 17, 2024
1 parent b2b648b commit 09a431c
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

import com.trendithon.timetris.domain.mainpage.dto.MainPageDTO;
import com.trendithon.timetris.domain.mainpage.service.MainPageService;
import com.trendithon.timetris.global.auth.jwt.TokenProvider;
import com.trendithon.timetris.global.exception.ApiResponse;
import com.trendithon.timetris.global.exception.CustomException;
import com.trendithon.timetris.global.exception.enums.ErrorStatus;
import com.trendithon.timetris.global.exception.enums.SuccessStatus;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -19,13 +23,25 @@
public class MainPageController {

private final MainPageService mainPageService;
private final TokenProvider tokenProvider;

@GetMapping("/{userId}")
public ApiResponse<MainPageDTO> getMainPage(Authentication authentication,
@PathVariable long userId)
{
@PathVariable long userId) {
MainPageDTO mainPageDTO = mainPageService.getMainPage(userId);
return ApiResponse.success(SuccessStatus.OK, mainPageDTO);
}


@GetMapping
public ApiResponse<String> MainForTest(HttpServletRequest request) {
String userName = (String) request.getSession().getAttribute("name");

if (userName == null) {
return ApiResponse.of("LOGIN", "로그인 하세요");
} else {
return ApiResponse.success(SuccessStatus.OK, userName);
}

}
}

0 comments on commit 09a431c

Please sign in to comment.