본문 바로가기

Back-End/kotlin

(3)
SecurityExpressionRoot를 상속하여 새로운 보안 표현식을 정의하자 사용자 정의 Security Expression Root 클래스 생성lass CustomSecurityExpressionRoot( private val authentication: Authentication, private val roleHierarchy: RoleHierarchy? = null, private val invocation: MethodInvocation? = null,) : SecurityExpressionRoot(authentication), MethodSecurityExpressionOperations { private var filterObject: Any? = null private var returnObject: Any? = null private..
[kotlin] groupBy Story 환불 시스템은 금액별로 사용자를 처리하게끔 되어있다. 환불 시스템에 맞춰서 데이터를 가공해야한다. 가공을 완료 되었다면 환불 시스템을 통해 사용자들에게 환불 처리한다. Process 사용자들의 환불 정보 이다. val users = listOf( mapOf("userId" to 1, "cashback" to 5000), mapOf("userId" to 2, "cashback" to 5000), mapOf("userId" to 3, "cashback" to 500), mapOf("userId" to 4, "cashback" to 500), mapOf("userId" to 5, "cashback" to 3000), mapOf("userId" to 6, "cashback" to 2000), ) 가정..
apply, with, let, also, run 고차 함수 사용법 함수형 프로그래밍은 kotlin의 표준 라이브러리에있는 다양한 함수뿐만 아니라 Kotlin의 구문에 의해 많은지지를 받고 지원됩니다. ● 5가지의 고차함수는 기본적으로 매우 유사한 작업을 수행한다. ▷ 수신자 인수와 코드 블록을 취한 다음 제공된 수신자에서 코드 블록을 실행하는 범위 지정 함수이다. ○ 작동 확인 (with) inline fun with (receiver : T, block : T. ()-> R) : R { return receiver.block () } 이를 사용하면 코드를 더 간결하게 만들 수 있다. ○ with 함수를 사용하지 않은 코드 class User { var id : Long? = null var passwd : String? = null } val user : User =..