Skip to content

Commit

Permalink
Merge pull request #138 from mash-up-kr/junhyoung/fix-earncoinapi
Browse files Browse the repository at this point in the history
fix: remove earncoinapi & validadmin policy
  • Loading branch information
toychip authored Sep 21, 2024
2 parents a6d3d0f + f75adb8 commit c4bdda4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 23 deletions.
17 changes: 0 additions & 17 deletions api/src/main/kotlin/com/mashup/dojo/CoinController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,6 @@ class CoinController(
)
}

@PostMapping
@Operation(
summary = "(투표 완료를 통한) 잼 보상을 합니다(+ 보상 제공용 임시 API)",
description = "투표 완료를 통한 잼 제공 API",
responses = [
ApiResponse(responseCode = "200", description = "투표 완료 보상 제공 성공")
]
)
fun provideCoinByCompletePick(
@RequestParam(defaultValue = DEFAULT_COMPLETE_PICK_OFFER_AMOUNT.toString()) amount: Long,
): DojoApiResponse<CoinUseDetailId> {
val memberId = MemberPrincipalContextHolder.current().id
// todo : 현재 운영중인 QSet 에 대한 pick 개수가 모두 있는가 validation?
return coinUseCase.earnCoin(CoinUseCase.EarnCoinCommand(memberId, amount))
.let { DojoApiResponse.success(it) }
}

@GetMapping("/current/question-set/solved-picks")
@Operation(
summary = "현재 운영중인 QuestionSheet에서 지급된 코인을 반환합니다.",
Expand Down
4 changes: 4 additions & 0 deletions api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ dojo:
size: 3
coin:
solvedPick: 20
adminKey1: ENC(6vmD1X1w6fIO+6hM92EYo9IF6hQIvuN2d6NSY38sjTR+SWGMdSQzueGJ/Wtkw1bd)
adminKey2: ENC(pwjY18V7A5eWi0NAG05+aBF/VtAtMfP9v0wyuu/94ReQ6nNbuSlWQ8JgBZwCVGo2)
adminKey3: ENC(y5CzhWOriopg+6katqbz4HtwJPPoMQfYR3Uh42LLIi8Q+ovIXXeTqonYro0JiVSq)
adminKey4: ENC(nLz//A9qbEFOXcrcyh/Gp2PfHjcojlJxVPjXY1TBG9WKFehW6La/OWO/sVWWyHIP)
profile:
male: ENC(y7SDgKPyWwAg4dJMql9v7uWrAdJRQoMCHyPLxvma89kwZgpCKhva2Qi9Yfn7XBEyP6Z1hPVdfAJ4cuvcjoglQ1Obp3HtOc6+4+IXG7jttKCIA+sWpf9D3FagSvybbjN7BxgXrWIkloQ=)
female: ENC(G6ycXZSiw82d4TkZ8q5TOGbV/PnPW5TMvBPx6a0hojXGIm3c3Ho/K5FqNBhuKl/m2pSIPzK5ammRqCCKpFw6+S8YvjrmWumC/ky6ciXrIKAbriS45RwKNuprrpnT+zyVcdf0M8VXBnI=)
Expand Down
19 changes: 13 additions & 6 deletions service/src/main/kotlin/com/mashup/dojo/usecase/CoinUseCase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.mashup.dojo.service.MemberService
import com.mashup.dojo.service.PickService
import com.mashup.dojo.service.QuestionService
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.stereotype.Component
import org.springframework.transaction.annotation.Transactional

Expand Down Expand Up @@ -43,6 +44,7 @@ class DefaultCoinUseCase(
private val pickService: PickService,
@Value("\${dojo.coin.solvedPick}")
private val provideCoinByCompletePick: Int,
private val properties: AdminProperties,
) : CoinUseCase {
override fun getCurrentCoin(command: CoinUseCase.GetCurrentCoinCommand): Coin {
return coinService.getCoin(command.memberId) ?: throw DojoException.of(DojoExceptionType.NOT_EXIST, "유저의 코인정보가 없습니다")
Expand Down Expand Up @@ -79,13 +81,9 @@ class DefaultCoinUseCase(

// todo 추후 Role을 넣어서 Security에서 관리하도록하면 좋을듯합니다.
private fun validAdmin(currentMemberId: MemberId) {
val currentMember =
membersService.findMemberById(currentMemberId)
?: throw DojoException.of(DojoExceptionType.MEMBER_NOT_FOUND)
val adminKeys = listOf(properties.adminKey1, properties.adminKey2, properties.adminKey3, properties.adminKey4)

val dojo = listOf("한정민", "오예원", "박세원", "임준형", "이현재", "황태규", "최민석", "낭은영", "오시연")

if (currentMember.fullName !in dojo) {
if (currentMemberId.value !in adminKeys) {
throw DojoException.of(DojoExceptionType.AUTHENTICATION_FAILURE, "You Are Not Dojo")
}
}
Expand All @@ -102,3 +100,12 @@ class DefaultCoinUseCase(
}
}
}

@Component
@ConfigurationProperties(prefix = "dojo.coin")
class AdminProperties {
lateinit var adminKey1: String
lateinit var adminKey2: String
lateinit var adminKey3: String
lateinit var adminKey4: String
}

0 comments on commit c4bdda4

Please sign in to comment.