Skip to content

Commit

Permalink
header 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
JeaSungLEE committed Jan 26, 2020
1 parent c033131 commit 4519543
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -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?
)
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -16,9 +17,7 @@ class HomeController(val homeService : HomeService){
@ApiOperation(value = "홈화면 정보 가져오기", notes = "지정한 연도의 감정기록과 각 달의 메인감정을 가져옵니다.")
@GetMapping()
fun getHomeList (@RequestParam year :Int, request: HttpServletRequest): ResponseEntity<ResultRes> {
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))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Unit> {
return ResponseEntity.status(HttpStatus.OK).body(pushService.getToken())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -16,36 +17,28 @@ class RemindController() {
@ApiOperation(value = "회고 목록 가져오기", notes = "회고 목록 가져오기")
@GetMapping()
fun getRemindList(request: HttpServletRequest): ResponseEntity<SpecificRemindListDto> {
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<RemindDto> {
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<RemindDto> {
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)
}
}

0 comments on commit 4519543

Please sign in to comment.