diff --git a/src/main/kotlin/kr/co/mashup/spacedeploy/spacedeploy/Header/HeaderController.kt b/src/main/kotlin/kr/co/mashup/spacedeploy/spacedeploy/Header/HeaderController.kt new file mode 100644 index 0000000..4ea9326 --- /dev/null +++ b/src/main/kotlin/kr/co/mashup/spacedeploy/spacedeploy/Header/HeaderController.kt @@ -0,0 +1,21 @@ +package kr.co.mashup.spacedeploy.spacedeploy.Header + +import kr.co.mashup.spacedeploy.spacedeploy.oauth.getUID +import javax.servlet.http.HttpServletRequest + + +fun getHeader(request: HttpServletRequest): HeaderDTO { + val token = request.getHeader("Authorization") + val provider = request.getHeader("Provider") + val uid = getUID(token, provider) + val timeZone = request.getHeader("TimeZone") + val header = HeaderDTO(uid, timeZone, token) + + return header +} + +data class HeaderDTO( + val uid: String?, + val timeZone: String, + val token: String? +) \ No newline at end of file diff --git a/src/main/kotlin/kr/co/mashup/spacedeploy/spacedeploy/SwaggerConfig.kt b/src/main/kotlin/kr/co/mashup/spacedeploy/spacedeploy/SwaggerConfig.kt index c7e2ea5..cc17ce1 100644 --- a/src/main/kotlin/kr/co/mashup/spacedeploy/spacedeploy/SwaggerConfig.kt +++ b/src/main/kotlin/kr/co/mashup/spacedeploy/spacedeploy/SwaggerConfig.kt @@ -51,6 +51,16 @@ TimeZone: ex) Asia/Seoul yyyy-MM-dd'T'HH:mm:ss.SSS +### Emotion Enum +각 기분에 해당되는 Int값을 사용합니다. +- 기쁨: pleasure - 0 +- 행복: Happiness - 1 +- 평온: tranquility - 2 +- 만족: Satisfaction - 3 +- 화남: aggro - 4 +- 우울: depressed - 5 +- 피곤: tired - 6 +- 슬픔 : sadness - 7 """) .version("1.0.0") .build() diff --git a/src/main/kotlin/kr/co/mashup/spacedeploy/spacedeploy/home/HomeController.kt b/src/main/kotlin/kr/co/mashup/spacedeploy/spacedeploy/home/HomeController.kt index d9bfbf7..2fe2212 100644 --- a/src/main/kotlin/kr/co/mashup/spacedeploy/spacedeploy/home/HomeController.kt +++ b/src/main/kotlin/kr/co/mashup/spacedeploy/spacedeploy/home/HomeController.kt @@ -2,6 +2,7 @@ package kr.co.mashup.spacedeploy.spacedeploy.home import io.swagger.annotations.Api import io.swagger.annotations.ApiOperation +import kr.co.mashup.spacedeploy.spacedeploy.Header.getHeader import kr.co.mashup.spacedeploy.spacedeploy.oauth.getUID import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity @@ -16,9 +17,7 @@ class HomeController(val homeService : HomeService){ @ApiOperation(value = "홈화면 정보 가져오기", notes = "지정한 연도의 감정기록과 각 달의 메인감정을 가져옵니다.") @GetMapping() fun getHomeList (@RequestParam year :Int, request: HttpServletRequest): ResponseEntity { - val token = request.getHeader("Authorization") - val provider = request.getHeader("Provider") - val userInfoJson = getUID(token, provider) + val header = getHeader(request) return ResponseEntity.status(HttpStatus.OK).body(homeService.getHome(year)) } diff --git a/src/main/kotlin/kr/co/mashup/spacedeploy/spacedeploy/login/LoginController.kt b/src/main/kotlin/kr/co/mashup/spacedeploy/spacedeploy/login/LoginController.kt index 1e0ab0f..d3d17fe 100644 --- a/src/main/kotlin/kr/co/mashup/spacedeploy/spacedeploy/login/LoginController.kt +++ b/src/main/kotlin/kr/co/mashup/spacedeploy/spacedeploy/login/LoginController.kt @@ -2,6 +2,7 @@ package kr.co.mashup.spacedeploy.spacedeploy.login import io.swagger.annotations.Api import io.swagger.annotations.ApiOperation +import kr.co.mashup.spacedeploy.spacedeploy.Header.getHeader import kr.co.mashup.spacedeploy.spacedeploy.oauth.getUID import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity @@ -14,10 +15,8 @@ class LoginController(val loginService: LoginService) { @ApiOperation(value = "로그인", notes = "로그인") @PostMapping("/login") fun login(@RequestBody pushToken: String, request: HttpServletRequest) { - val token = request.getHeader("Authorization") - val provider = request.getHeader("Provider") - val uid = getUID(token, provider) - val loginDto = LoginDto(uid, token, pushToken) + val header = getHeader(request) + val loginDto = LoginDto(header.uid, header.token, pushToken) ResponseEntity.status(HttpStatus.OK).body(loginService.login(loginDto)) } } \ No newline at end of file diff --git a/src/main/kotlin/kr/co/mashup/spacedeploy/spacedeploy/push/PushController.kt b/src/main/kotlin/kr/co/mashup/spacedeploy/spacedeploy/push/PushController.kt index 7a6beff..0eb5b3a 100644 --- a/src/main/kotlin/kr/co/mashup/spacedeploy/spacedeploy/push/PushController.kt +++ b/src/main/kotlin/kr/co/mashup/spacedeploy/spacedeploy/push/PushController.kt @@ -13,6 +13,7 @@ class PushController(val pushService : PushService){ @ApiOperation(value = "푸쉬발송", notes = "내용의 푸쉬를 발송합니다") @GetMapping() - fun postPush () = - ResponseEntity.status(HttpStatus.OK).body(pushService.getToken()) + fun postPush (): ResponseEntity { + return ResponseEntity.status(HttpStatus.OK).body(pushService.getToken()) + } } diff --git a/src/main/kotlin/kr/co/mashup/spacedeploy/spacedeploy/remind/RemindController.kt b/src/main/kotlin/kr/co/mashup/spacedeploy/spacedeploy/remind/RemindController.kt index 298bf00..0896cc7 100644 --- a/src/main/kotlin/kr/co/mashup/spacedeploy/spacedeploy/remind/RemindController.kt +++ b/src/main/kotlin/kr/co/mashup/spacedeploy/spacedeploy/remind/RemindController.kt @@ -2,6 +2,7 @@ package kr.co.mashup.spacedeploy.spacedeploy.remind import io.swagger.annotations.Api import io.swagger.annotations.ApiOperation +import kr.co.mashup.spacedeploy.spacedeploy.Header.getHeader import kr.co.mashup.spacedeploy.spacedeploy.oauth.getUID import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity @@ -16,36 +17,28 @@ class RemindController() { @ApiOperation(value = "회고 목록 가져오기", notes = "회고 목록 가져오기") @GetMapping() fun getRemindList(request: HttpServletRequest): ResponseEntity { - val token = request.getHeader("Authorization") - val provider = request.getHeader("Provider") - val userInfoJson = getUID(token, provider) + val header = getHeader(request) return ResponseEntity.status(HttpStatus.OK).body(SpecificRemindListDto(LocalDateTime.now(), null)) } @ApiOperation(value = "회고 작성", notes = "회고 작성") @PostMapping() fun writeRemind(postRemindDto: PostRemindDto, request: HttpServletRequest): ResponseEntity { - val token = request.getHeader("Authorization") - val provider = request.getHeader("Provider") - val userInfoJson = getUID(token, provider) + val header = getHeader(request) return ResponseEntity.status(HttpStatus.OK).body(RemindDto(0, null, LocalDateTime.now(), LocalDateTime.now(), null, null)) } @ApiOperation(value = "회고 수정", notes = "회고 수정") @PutMapping() fun editRemind(editRemindDto: EditRemindDto, request: HttpServletRequest): ResponseEntity { - val token = request.getHeader("Authorization") - val provider = request.getHeader("Provider") - val userInfoJson = getUID(token, provider) + val header = getHeader(request) return ResponseEntity.status(HttpStatus.OK).body(RemindDto(0, null, LocalDateTime.now(), LocalDateTime.now(), null, null)) } @ApiOperation(value = "회고 삭제", notes = "회고 삭제") @DeleteMapping() fun deleteRemind(editRemindDto: EditRemindDto, request: HttpServletRequest) { - val token = request.getHeader("Authorization") - val provider = request.getHeader("Provider") - val userInfoJson = getUID(token, provider) + val header = getHeader(request) ResponseEntity.status(HttpStatus.OK) } } \ No newline at end of file