refactor: 优化代码去掉warning
diff --git a/payapi/src/main/kotlin/com/supwisdom/dlpay/mobile/service/impl/MobileUserServiceImpl.kt b/payapi/src/main/kotlin/com/supwisdom/dlpay/mobile/service/impl/MobileUserServiceImpl.kt
index 197da10..2878eb3 100644
--- a/payapi/src/main/kotlin/com/supwisdom/dlpay/mobile/service/impl/MobileUserServiceImpl.kt
+++ b/payapi/src/main/kotlin/com/supwisdom/dlpay/mobile/service/impl/MobileUserServiceImpl.kt
@@ -4,7 +4,7 @@
 import com.supwisdom.dlpay.mobile.domain.TBMobileUser
 import com.supwisdom.dlpay.mobile.exception.UserLoginFailException
 import com.supwisdom.dlpay.mobile.service.MobileUserService
-import org.slf4j.LoggerFactory
+import mu.KotlinLogging
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.security.core.GrantedAuthority
 import org.springframework.security.core.authority.AuthorityUtils
@@ -14,42 +14,44 @@
 
 @Service
 class MobileUserServiceImpl : MobileUserService {
-    var logger = LoggerFactory.getLogger(MobileUserServiceImpl::class.java)
+    companion object {
+        const val TIME_INTERVAL = 1000 * 6 * 30
+    }
+
+    val logger = KotlinLogging.logger { }
 
     @Autowired
     lateinit var mobileUserDao: MobileUserDao
 
     override fun loadUserByUsername(username: String?): UserDetails {
-        logger.error("username:"+username)
-        if(username.isNullOrEmpty()){
+        logger.error("username:$username")
+        if (username.isNullOrEmpty()) {
             throw UsernameNotFoundException("用户不存在")
         }
-        var temp = mobileUserDao.findByPhone(username!!)
-        if(temp!=null) {
-            if(temp.loginpwd.isNullOrEmpty()){
+        val temp = mobileUserDao.findByPhone(username)
+        if (temp != null) {
+            if (temp.loginpwd.isEmpty()) {
                 throw UserLoginFailException("用户注册后未设置登录密码,请找回密码或重新注册")
             }
-            if (temp.loginpwderror != null && temp.loginpwderror!! >= 5 && (System.currentTimeMillis() - temp.loginpwderrortime!!) < 1000 * 60 * 30) {
+            if (temp.loginpwderror >= 5 && (System.currentTimeMillis() - temp.loginpwderrortime!!) < TIME_INTERVAL) {
                 throw UserLoginFailException("密码错误次数过多,请30分钟后再试")
-            } else if (temp.loginpwderror != null && temp.loginpwderror!! >= 5 && (System.currentTimeMillis() - temp.loginpwderrortime!!) > 1000 * 60 * 30) {
+            } else if (temp.loginpwderror >= 5 && (System.currentTimeMillis() - temp.loginpwderrortime!!) > TIME_INTERVAL) {
                 //更新时间
                 temp.loginpwderror = 0
                 temp.loginpwderrortime = null
                 mobileUserDao.save(temp)
             }
-            var authorities: Collection<GrantedAuthority> = AuthorityUtils.createAuthorityList("ROLE_USER")
+            val authorities: Collection<GrantedAuthority> = AuthorityUtils.createAuthorityList("ROLE_USER")
             temp.auths = authorities
-        }else{
+        } else {
             throw UsernameNotFoundException("用户不存在")
         }
         return temp
     }
 
     override fun getByUid(uid: String): TBMobileUser? {
-        var t = mobileUserDao.findById(uid)
-        if(t.isPresent){
-            return t.get()
+        return mobileUserDao.findById(uid).let {
+            if (it.isPresent) it.get() else null
         }
-        return null
     }
 }
\ No newline at end of file