<aside> π‘ μμ½
<aside> π‘ μμΈ κ·μΉ
<aside> π‘ Entity, DTO, Vo μ²λΌ λ°μ΄ν°λ₯Ό λνλ΄λ κ°μ²΄ μλ λ°λμ λλ±μ± λΉκ΅, λ¬Έμμ΄ μΆλ ₯, ν΄μ¬ λ±μ μ¬μ μ ν©λλ€.
</aside>
<aside> π‘ Layerκ° λ°μ΄ν° κ΅ν μλ ex: Controller β Service β Repository λ°λμ DTOλ₯Ό μ μνμ¬ μ¬μ©νλ©° DTOλ μμ±νν λΆλ³μ μ μ§ ν©λλ€.
data class SomeDTO(
val data1: String,
val data2: Int,
)
// λ°μ΄ν° κ΅ν κ°μ²΄ μμ±ν DTO, Voμ λ΄λΆκ°μ λΆλ³μ μ μ§ ν΄μΌ ν©λλ€.
</aside>
<aside>
π‘ κ°μ Layer λΌλ¦¬ λ°μ΄ν° κ΅νμ DTOλ₯Ό μ μ νμ§ μμ΅λλ€.
μ λ§ νμνλ€λ©΄ Voλ₯Ό μ μν΄μ μ¬μ©ν©λλ€.
ex): Service β Service
[**π]** fun sum(a:Int, b:Int, c:Int): Int {}
[**π]** fun sum(sumVo: SumVo): Int {} -> λ°μ΄ν° κ²μ¦μ©μΌλ‘ Voμμ±ν μ¬μ©
</aside>
<aside> π‘ λ©μλ, ν¨μλ₯Ό νΈμΆν λλ λ°λμ Named Parameter λ₯Ό μ¬μ©ν©λλ€.
@PostMapping(...)
fun updateUser(userData: UserUpdateForm){
this.service(
user = userData.user,
info = userData.information
)
}
</aside>
<aside> π‘ 컨νΈλ‘€λ¬μμ try-catchλ¬Έμ μ°μ§ μμ΅λλ€.
[ Global Exception Handlerμμ μ²λ¦¬ ] ****
[**π]** @GetMapping("/api")
fun getValue(): BaseResponseForm {
return BaseResponseForm(
statusCode = ErrorCode.SUCCESS,
result = "value"
)
}
[**π₯]** @GetMapping("/api")
fun getValue(): BaseResponseForm {
return try {
BaseResponseForm(
statusCode = ErrorCode.SUCCESS,
result = "value"
)
} catch (e: BaseCustomException){
BaseResponseForm(
statusCode = e.message,
result = ErrorCode.EMPTY_RESULT
)
}
}
</aside>
<aside> π‘ ν΄λμ€ λ° ν¨μ ν€λ μλ λ°λμ λΌμΈμΌλ‘ κ΅¬λ³ ν©λλ€.
class SomeClass
def __init__(
data: int,
info: str
):
[**π] sample: SomeClass = SomeClass(
data = 1,
info = "info"
)**
[**π₯] sample: SomeClass = SomeClass( data = 1, info = "info")**
</aside>