Skip to content

Commit

Permalink
Merge pull request #16 from molohala/Feature/information
Browse files Browse the repository at this point in the history
user info check
  • Loading branch information
dongchandev authored Apr 17, 2024
2 parents 42b4dd8 + 4fe8985 commit e8a5268
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@ class InfoController(

@GetMapping("/solvedac")
fun solvedAcInfo(@RequestParam("name") name: String)
= ResponseData.ok("솔브드 프로필 조회 완료", infoService.getSolvedAcInfo(name))
= ResponseData.ok("솔브드 프로필 조회 완료", infoService.getSolvedAcInfo(name))

@GetMapping("/me")
fun getMyUserInfo()
= ResponseData.ok("내 정보 조회 완료", infoService.getMyInfo())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.molohala.infinitycore.info.application.dto.res

import java.time.LocalDateTime

data class MyInfoRes(
val id: Long,
val email: String,
val name: String,
val createdAt: LocalDateTime,
)
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.molohala.infinitycore.info.application.service

import com.molohala.infinitycore.info.application.dto.GithubUserInfo
import com.molohala.infinitycore.info.application.dto.res.MyInfoRes
import com.molohala.infinitycore.info.application.dto.res.SolvedAcInfoRes

interface InfoService {
fun getGithubInfo(name: String): GithubUserInfo
fun getSolvedAcInfo(name: String): SolvedAcInfoRes
fun getMyInfo(): MyInfoRes
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ import com.molohala.infinitycore.info.GithubInfoClient
import com.molohala.infinitycore.info.SolvedAcInfoClient
import com.molohala.infinitycore.info.application.dto.GithubUserInfo
import com.molohala.infinitycore.info.application.dto.SolvedAcSolves
import com.molohala.infinitycore.info.application.dto.res.MyInfoRes
import com.molohala.infinitycore.info.application.dto.res.SolvedAcInfoRes
import com.molohala.infinitycore.info.exception.InfoExceptionCode
import com.molohala.infinitycore.member.application.MemberSessionHolder
import org.springframework.stereotype.Service
import java.time.LocalDate

@Service
class InfoServiceImpl(
private val githubInfoClient: GithubInfoClient,
private val solvedAcInfoClient: SolvedAcInfoClient,
private val memberSessionHolder: MemberSessionHolder
) : InfoService {
override fun getGithubInfo(name: String): GithubUserInfo {
return githubInfoClient.getInfo(name) ?: throw CustomException(InfoExceptionCode.USER_NOT_FOUND)
Expand All @@ -40,4 +43,14 @@ class InfoServiceImpl(
grass.find { it.date == today } ?: SolvedAcSolves(today)
)
}

override fun getMyInfo(): MyInfoRes {
val cur = memberSessionHolder.current()
return MyInfoRes(
cur.id!!, // id won't be null
cur.email,
cur.name,
cur.createdAt,
)
}
}

0 comments on commit e8a5268

Please sign in to comment.