package Ġru . work log . services Ċ Ċ import Ġorg . springframework . security . crypto . password . Password Encoder Ċ import Ġorg . springframework . stereotype . Component Ċ import Ġorg . springframework . transaction . annotation . Transactional Ċ import Ġru . work log . domain . Domain User Ċ import Ġru . work log . repositories . Domain UserRepository Ċ import Ġjava . util .* Ċ Ċ @ Component Ċ @ Transactional Ċ class ĠUserService ( private Ġval Ġuser Repository : ĠDomain UserRepository , Ġprivate Ġval Ġpassword Encoder : ĠPassword Encoder ) Ġ{ ĊĊĠĠĠ Ġ@ Transactional ( readOnly Ġ= Ġtrue ) ĊĠĠĠ Ġfun ĠgetUser By Login ( userName : ĠString ): ĠOptional < Domain User > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġuser Repository . findBy UserName ( userName ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġsave New User ( userName : ĠString , Ġpassword : ĠString ): ĠLong Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġuser Repository . save ( Domain User ( userName , Ġpassword Encoder . encode ( password ))). id ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġis User Present ( userName : ĠString ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġuser Repository . exists By UserName ( userName ) ĊĠĠĠ Ġ} Ċ Ċ }