diff --git a/src/main/kotlin/top/fatweb/oxygen/api/config/DateFormatConfig.kt b/src/main/kotlin/top/fatweb/oxygen/api/config/DateFormatConfig.kt index 9eb49c8..2e908a8 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/config/DateFormatConfig.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/config/DateFormatConfig.kt @@ -6,7 +6,6 @@ import org.springframework.beans.factory.annotation.Value import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer import org.springframework.boot.jackson.JsonComponent import org.springframework.context.annotation.Bean -import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder import java.text.DateFormat import java.text.SimpleDateFormat import java.time.LocalDateTime @@ -41,18 +40,18 @@ class DateFormatConfig { lateinit var timeZone: TimeZone @Bean - fun jackson2ObjectMapperBuilder() = Jackson2ObjectMapperBuilderCustomizer { builder: Jackson2ObjectMapperBuilder -> + fun jackson2ObjectMapperBuilder() = Jackson2ObjectMapperBuilderCustomizer { val tz = timeZone val df: DateFormat = SimpleDateFormat(dateFormat) df.timeZone = tz - builder.failOnEmptyBeans(false).failOnUnknownProperties(false) + it.failOnEmptyBeans(false).failOnUnknownProperties(false) .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).dateFormat(df) } @Bean fun jackson2ObjectMapperBuilderCustomizer() = - Jackson2ObjectMapperBuilderCustomizer { builder: Jackson2ObjectMapperBuilder -> - builder.serializerByType( + Jackson2ObjectMapperBuilderCustomizer { + it.serializerByType( LocalDateTime::class.java, LocalDateTimeSerializer(DateTimeFormatter.ofPattern(dateFormat)) ) } diff --git a/src/main/kotlin/top/fatweb/oxygen/api/config/SecurityConfig.kt b/src/main/kotlin/top/fatweb/oxygen/api/config/SecurityConfig.kt index c4b8679..d42d5af 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/config/SecurityConfig.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/config/SecurityConfig.kt @@ -6,7 +6,6 @@ import org.springframework.security.authentication.AuthenticationManager import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity import org.springframework.security.config.annotation.web.builders.HttpSecurity -import org.springframework.security.config.annotation.web.configurers.* import org.springframework.security.config.http.SessionCreationPolicy import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder import org.springframework.security.web.SecurityFilterChain @@ -56,15 +55,17 @@ class SecurityConfig( @Bean fun securityFilterChain(httpSecurity: HttpSecurity): SecurityFilterChain = httpSecurity // Disable CSRF - .csrf { csrfConfigurer: CsrfConfigurer -> csrfConfigurer.disable() } + .csrf { + it.disable() + } // Do not get SecurityContent by Session - .sessionManagement { sessionManagementConfigurer: SessionManagementConfigurer -> - sessionManagementConfigurer.sessionCreationPolicy( + .sessionManagement { + it.sessionCreationPolicy( SessionCreationPolicy.STATELESS ) } - .authorizeHttpRequests { authorizeHttpRequests: AuthorizeHttpRequestsConfigurer.AuthorizationManagerRequestMatcherRegistry -> - authorizeHttpRequests + .authorizeHttpRequests { + it // Allow anonymous access .requestMatchers( "/error/thrown", @@ -84,19 +85,21 @@ class SecurityConfig( .anyRequest().authenticated() } - .logout { logoutConfigurer: LogoutConfigurer -> logoutConfigurer.disable() } + .logout { + it.disable() + } - .exceptionHandling { exceptionHandlingConfigurer: ExceptionHandlingConfigurer -> - exceptionHandlingConfigurer.authenticationEntryPoint( + .exceptionHandling { + it.authenticationEntryPoint( authenticationEntryPointHandler ) - exceptionHandlingConfigurer.accessDeniedHandler( + it.accessDeniedHandler( accessDeniedHandler ) } - .cors { cors: CorsConfigurer -> - cors.configurationSource( + .cors { + it.configurationSource( corsConfigurationSource() ) } diff --git a/src/main/kotlin/top/fatweb/oxygen/api/converter/permission/GroupConverter.kt b/src/main/kotlin/top/fatweb/oxygen/api/converter/permission/GroupConverter.kt index 8f3db91..28cbbd6 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/converter/permission/GroupConverter.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/converter/permission/GroupConverter.kt @@ -51,7 +51,7 @@ object GroupConverter { enable = group.enable == 1, createTime = group.createTime, updateTime = group.updateTime, - roles = group.roles?.map { RoleConverter.roleToRoleVo(it) } + roles = group.roles?.map(RoleConverter::roleToRoleVo) ) /** @@ -71,9 +71,7 @@ object GroupConverter { pages = groupPage.pages, size = groupPage.size, current = groupPage.current, - records = groupPage.records.map { - groupToGroupWithRoleVo(it) - } + records = groupPage.records.map(::groupToGroupWithRoleVo) ) /** diff --git a/src/main/kotlin/top/fatweb/oxygen/api/converter/permission/PowerConverter.kt b/src/main/kotlin/top/fatweb/oxygen/api/converter/permission/PowerConverter.kt index 80a21c0..5fea079 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/converter/permission/PowerConverter.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/converter/permission/PowerConverter.kt @@ -21,9 +21,9 @@ object PowerConverter { * @see PowerSetVo */ fun powerSetToPowerSetVo(powerSet: PowerSet) = PowerSetVo( - moduleList = powerSet.moduleList?.map { ModuleConverter.moduleToModuleVo(it) }, - menuList = powerSet.menuList?.map { MenuConverter.menuToMenuVo(it) }, - funcList = powerSet.funcList?.map { FuncConverter.funcToFuncVo(it) }, - operationList = powerSet.operationList?.map { OperationConverter.operationToOperationVo(it) } + moduleList = powerSet.moduleList?.map(ModuleConverter::moduleToModuleVo), + menuList = powerSet.menuList?.map(MenuConverter::menuToMenuVo), + funcList = powerSet.funcList?.map(FuncConverter::funcToFuncVo), + operationList = powerSet.operationList?.map(OperationConverter::operationToOperationVo) ) } \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/converter/permission/RoleConverter.kt b/src/main/kotlin/top/fatweb/oxygen/api/converter/permission/RoleConverter.kt index 13a9005..98f7375 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/converter/permission/RoleConverter.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/converter/permission/RoleConverter.kt @@ -51,10 +51,10 @@ object RoleConverter { enable = role.enable == 1, createTime = role.createTime, updateTime = role.updateTime, - modules = role.modules?.map { ModuleConverter.moduleToModuleVo(it) }, - menus = role.menus?.map { MenuConverter.menuToMenuVo(it) }, - funcs = role.funcs?.map { FuncConverter.funcToFuncVo(it) }, - operations = role.operations?.map { OperationConverter.operationToOperationVo(it) } + modules = role.modules?.map(ModuleConverter::moduleToModuleVo), + menus = role.menus?.map(MenuConverter::menuToMenuVo), + funcs = role.funcs?.map(FuncConverter::funcToFuncVo), + operations = role.operations?.map(OperationConverter::operationToOperationVo) ) /** @@ -74,9 +74,7 @@ object RoleConverter { pages = rolePage.pages, size = rolePage.size, current = rolePage.current, - records = rolePage.records.map { - roleToRoleWithPowerVo(it) - } + records = rolePage.records.map(::roleToRoleWithPowerVo) ) /** diff --git a/src/main/kotlin/top/fatweb/oxygen/api/converter/permission/UserConverter.kt b/src/main/kotlin/top/fatweb/oxygen/api/converter/permission/UserConverter.kt index b75bc68..9f299b7 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/converter/permission/UserConverter.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/converter/permission/UserConverter.kt @@ -45,21 +45,11 @@ object UserConverter { lastLoginIp = user.lastLoginIp, createTime = user.createTime, updateTime = user.updateTime, - userInfo = user.userInfo?.let { - UserInfoConverter.userInfoToUserInfoVo(it) - }, - modules = user.modules?.map { - ModuleConverter.moduleToModuleVo(it) - }, - menus = user.menus?.map { - MenuConverter.menuToMenuVo(it) - }, - funcs = user.funcs?.map { - FuncConverter.funcToFuncVo(it) - }, - operations = user.operations?.map { - OperationConverter.operationToOperationVo(it) - } + userInfo = user.userInfo?.let(UserInfoConverter::userInfoToUserInfoVo), + modules = user.modules?.map(ModuleConverter::moduleToModuleVo), + menus = user.menus?.map(MenuConverter::menuToMenuVo), + funcs = user.funcs?.map(FuncConverter::funcToFuncVo), + operations = user.operations?.map(OperationConverter::operationToOperationVo) ) /** @@ -86,15 +76,9 @@ object UserConverter { lastLoginIp = user.lastLoginIp, createTime = user.createTime, updateTime = user.updateTime, - userInfo = user.userInfo?.let { - UserInfoConverter.userInfoToUserInfoVo(it) - }, - roles = user.roles?.map { - RoleConverter.roleToRoleVo(it) - }, - groups = user.groups?.map { - GroupConverter.groupToGroupVo(it) - } + userInfo = user.userInfo?.let(UserInfoConverter::userInfoToUserInfoVo), + roles = user.roles?.map(RoleConverter::roleToRoleVo), + groups = user.groups?.map(GroupConverter::groupToGroupVo) ) /** @@ -121,9 +105,7 @@ object UserConverter { lastLoginIp = user.lastLoginIp, createTime = user.createTime, updateTime = user.updateTime, - userInfo = user.userInfo?.let { - UserInfoConverter.userInfoToUserInfoVo(it) - } + userInfo = user.userInfo?.let(UserInfoConverter::userInfoToUserInfoVo) ) /** @@ -151,15 +133,9 @@ object UserConverter { lastLoginIp = user.lastLoginIp, createTime = user.createTime, updateTime = user.updateTime, - userInfo = user.userInfo?.let { - UserInfoConverter.userInfoToUserInfoVo(it) - }, - roles = user.roles?.map { - RoleConverter.roleToRoleVo(it) - }, - groups = user.groups?.map { - GroupConverter.groupToGroupVo(it) - } + userInfo = user.userInfo?.let(UserInfoConverter::userInfoToUserInfoVo), + roles = user.roles?.map(RoleConverter::roleToRoleVo), + groups = user.groups?.map(GroupConverter::groupToGroupVo) ) /** @@ -232,8 +208,6 @@ object UserConverter { pages = userPage.pages, size = userPage.size, current = userPage.current, - records = userPage.records.map { - userToUserWithRoleInfoVo(it) - } + records = userPage.records.map(::userToUserWithRoleInfoVo) ) } \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolConverter.kt b/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolConverter.kt index b5b378d..b07c8bc 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolConverter.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/converter/tool/ToolConverter.kt @@ -60,6 +60,6 @@ object ToolConverter { pages = toolPage.pages, size = toolPage.size, current = toolPage.current, - records = toolPage.records.map(this::toolToToolVo) + records = toolPage.records.map(::toolToToolVo) ) } \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/filter/JwtAuthenticationTokenFilter.kt b/src/main/kotlin/top/fatweb/oxygen/api/filter/JwtAuthenticationTokenFilter.kt index 0c61eb5..a3ab155 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/filter/JwtAuthenticationTokenFilter.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/filter/JwtAuthenticationTokenFilter.kt @@ -45,7 +45,7 @@ class JwtAuthenticationTokenFilter(private val redisUtil: RedisUtil) : OncePerRe } val loginUser = redisUtil.getObject(redisKeys.first()) - loginUser ?: let { throw TokenHasExpiredException() } + loginUser ?: throw TokenHasExpiredException() redisUtil.setExpire(redisKeys.first(), SecurityProperties.redisTtl, SecurityProperties.redisTtlUnit) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/api/v1/impl/AvatarServiceImpl.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/api/v1/impl/AvatarServiceImpl.kt index 9fc383d..630d46b 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/api/v1/impl/AvatarServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/api/v1/impl/AvatarServiceImpl.kt @@ -59,12 +59,12 @@ class AvatarServiceImpl : IAvatarService { if (avatarBaseParam == null || avatarBaseParam.colors.isNullOrEmpty()) TriangleAvatar.newAvatarBuilder() else TriangleAvatar.newAvatarBuilder( - *avatarBaseParam.colors!!.map(this::decodeColor).toTypedArray() + *avatarBaseParam.colors!!.map(::decodeColor).toTypedArray() ) ).apply { - avatarBaseParam?.size?.let(this::size) - avatarBaseParam?.margin?.let(this::margin) - avatarBaseParam?.padding?.let(this::padding) + avatarBaseParam?.size?.let(::size) + avatarBaseParam?.margin?.let(::margin) + avatarBaseParam?.padding?.let(::padding) avatarBaseParam?.background?.let { layers(ColorPaintBackgroundLayer(decodeColor(it))) } }.build() @@ -79,12 +79,12 @@ class AvatarServiceImpl : IAvatarService { if (avatarBaseParam == null || avatarBaseParam.colors.isNullOrEmpty()) SquareAvatar.newAvatarBuilder() else SquareAvatar.newAvatarBuilder( - *avatarBaseParam.colors!!.map(this::decodeColor).toTypedArray() + *avatarBaseParam.colors!!.map(::decodeColor).toTypedArray() ) ).apply { - avatarBaseParam?.size?.let(this::size) - avatarBaseParam?.margin?.let(this::margin) - avatarBaseParam?.padding?.let(this::padding) + avatarBaseParam?.size?.let(::size) + avatarBaseParam?.margin?.let(::margin) + avatarBaseParam?.padding?.let(::padding) avatarBaseParam?.background?.let { layers(ColorPaintBackgroundLayer(decodeColor(it))) } }.build() @@ -96,9 +96,9 @@ class AvatarServiceImpl : IAvatarService { override fun identicon(avatarBaseParam: AvatarBaseParam?): ByteArray { val avatar = IdenticonAvatar.newAvatarBuilder().apply { - avatarBaseParam?.size?.let(this::size) - avatarBaseParam?.margin?.let(this::margin) - avatarBaseParam?.padding?.let(this::padding) + avatarBaseParam?.size?.let(::size) + avatarBaseParam?.margin?.let(::margin) + avatarBaseParam?.padding?.let(::padding) if (avatarBaseParam != null && !avatarBaseParam.colors.isNullOrEmpty()) { color(decodeColor(avatarBaseParam.colors!!.random())) } @@ -114,9 +114,9 @@ class AvatarServiceImpl : IAvatarService { override fun github(avatarGitHubParam: AvatarGitHubParam?): ByteArray { val avatar = (avatarGitHubParam?.let { GitHubAvatar.newAvatarBuilder(it.elementSize, it.precision) } ?: let { GitHubAvatar.newAvatarBuilder(400, 5) }).apply { - avatarGitHubParam?.size?.let(this::size) - avatarGitHubParam?.margin?.let(this::margin) - avatarGitHubParam?.padding?.let(this::padding) + avatarGitHubParam?.size?.let(::size) + avatarGitHubParam?.margin?.let(::margin) + avatarGitHubParam?.padding?.let(::padding) if (avatarGitHubParam != null && !avatarGitHubParam.colors.isNullOrEmpty()) { color(decodeColor(avatarGitHubParam.colors!!.random())) } diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/AuthenticationServiceImpl.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/AuthenticationServiceImpl.kt index b83dbe5..5b360aa 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/AuthenticationServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/AuthenticationServiceImpl.kt @@ -152,7 +152,7 @@ class AuthenticationServiceImpl( verifyCaptcha(forgetParam.captchaCode!!) val user = userService.getUserWithPowerByAccount(forgetParam.email!!) - user ?: let { throw UserNotFoundException() } + user ?: throw UserNotFoundException() user.forget?.let { if (LocalDateTime.ofInstant(Instant.ofEpochMilli(it.split("-").first().toLong()), ZoneOffset.UTC) @@ -210,21 +210,19 @@ class AuthenticationServiceImpl( @EventLogRecord(EventLog.Event.LOGOUT) override fun logout(token: String): Boolean { - val loginUser = WebUtil.getLoginUser() ?: let { throw TokenHasExpiredException() } + val loginUser = WebUtil.getLoginUser() ?: throw TokenHasExpiredException() return redisUtil.delObject("${SecurityProperties.jwtIssuer}_login_${loginUser.user.id}:" + token) } override fun renewToken(token: String): TokenVo { - val loginUser = WebUtil.getLoginUser() ?: let { throw TokenHasExpiredException() } + val loginUser = WebUtil.getLoginUser() ?: throw TokenHasExpiredException() val oldRedisKey = "${SecurityProperties.jwtIssuer}_login_${loginUser.user.id}:" + token redisUtil.delObject(oldRedisKey) val jwt = JwtUtil.createJwt(WebUtil.getLoginUserId().toString()) - jwt ?: let { - throw RuntimeException("Login failed") - } + jwt ?: throw RuntimeException("Login failed") val redisKey = "${SecurityProperties.jwtIssuer}_login_${loginUser.user.id}:" + jwt redisUtil.setObject( @@ -308,9 +306,7 @@ class AuthenticationServiceImpl( val usernamePasswordAuthenticationToken = UsernamePasswordAuthenticationToken(account, password) val authentication = authenticationManager.authenticate(usernamePasswordAuthenticationToken) - authentication ?: let { - throw RuntimeException("Login failed") - } + authentication ?: throw RuntimeException("Login failed") val loginUser = authentication.principal as LoginUser loginUser.user.password = "" @@ -326,9 +322,7 @@ class AuthenticationServiceImpl( val userId = loginUser.user.id.toString() val jwt = JwtUtil.createJwt(userId) - jwt ?: let { - throw RuntimeException("Login failed") - } + jwt ?: throw RuntimeException("Login failed") val redisKey = "${SecurityProperties.jwtIssuer}_login_${userId}:" + jwt redisUtil.setObject(redisKey, loginUser, SecurityProperties.redisTtl, SecurityProperties.redisTtlUnit) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/RoleServiceImpl.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/RoleServiceImpl.kt index 49859c3..4fb6636 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/RoleServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/RoleServiceImpl.kt @@ -68,7 +68,7 @@ class RoleServiceImpl( @Transactional override fun add(roleAddParam: RoleAddParam): RoleVo { - val fullPowerIds = roleAddParam.powerIds?.let(this::getFullPowerIds) + val fullPowerIds = roleAddParam.powerIds?.let(::getFullPowerIds) val role = RoleConverter.roleAddParamToRole(roleAddParam) if (baseMapper.insert(role) != 1) { @@ -90,7 +90,7 @@ class RoleServiceImpl( @Transactional override fun update(roleUpdateParam: RoleUpdateParam): RoleVo { - val fullPowerIds = roleUpdateParam.powerIds?.let(this::getFullPowerIds) + val fullPowerIds = roleUpdateParam.powerIds?.let(::getFullPowerIds) val role = RoleConverter.roleUpdateParamToRole(roleUpdateParam) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/UserDetailsServiceImpl.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/UserDetailsServiceImpl.kt index 9aa4351..5b3bad7 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/UserDetailsServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/UserDetailsServiceImpl.kt @@ -18,7 +18,7 @@ import top.fatweb.oxygen.api.service.permission.IUserService class UserDetailsServiceImpl(val userService: IUserService) : UserDetailsService { override fun loadUserByUsername(account: String): UserDetails { val user = userService.getUserWithPowerByAccount(account) - user ?: let { throw Exception("Username not found") } + user ?: throw Exception("Username not found") return LoginUser(user) } diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/UserServiceImpl.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/UserServiceImpl.kt index 912413a..c3ad55f 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/UserServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/permission/impl/UserServiceImpl.kt @@ -68,7 +68,7 @@ class UserServiceImpl( ) : ServiceImpl(), IUserService { override fun getUserWithPowerByAccount(account: String): User? { val user = baseMapper.selectOneWithPowerInfoByAccount(account) - user ?: let { return null } + user ?: return null if (user.id == 0L) { user.modules = moduleService.list() @@ -81,7 +81,7 @@ class UserServiceImpl( } override fun getInfo(): UserWithPowerInfoVo = - WebUtil.getLoginUsername()?.let(this::getUserWithPowerByAccount)?.let(UserConverter::userToUserWithPowerInfoVo) + WebUtil.getLoginUsername()?.let(::getUserWithPowerByAccount)?.let(UserConverter::userToUserWithPowerInfoVo) ?: throw UserNotFoundException() override fun getOne(id: Long): UserWithRoleInfoVo = @@ -260,9 +260,7 @@ class UserServiceImpl( } userUpdatePasswordParam.id?.let { WebUtil.offlineUser(redisUtil, it) } - } ?: let { - throw NoRecordFoundException() - } + } ?: throw NoRecordFoundException() } @Transactional diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/system/impl/SensitiveWordServiceImpl.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/system/impl/SensitiveWordServiceImpl.kt index e279160..e973d23 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/system/impl/SensitiveWordServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/system/impl/SensitiveWordServiceImpl.kt @@ -49,7 +49,7 @@ class SensitiveWordServiceImpl : ServiceImpl @Transactional(propagation = Propagation.REQUIRES_NEW) override fun checkSensitiveWord(str: String) { this.list(KtQueryWrapper(SensitiveWord()).eq(SensitiveWord::enable, 1)).map(SensitiveWord::word).forEach { - it ?: let { return@forEach } + it ?: return@forEach try { if (Regex(it, RegexOption.IGNORE_CASE).matches(str)) { diff --git a/src/main/kotlin/top/fatweb/oxygen/api/util/ApiResponseMappingHandlerMapping.kt b/src/main/kotlin/top/fatweb/oxygen/api/util/ApiResponseMappingHandlerMapping.kt index 03f2bda..7d10d7e 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/util/ApiResponseMappingHandlerMapping.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/util/ApiResponseMappingHandlerMapping.kt @@ -15,7 +15,7 @@ class ApiResponseMappingHandlerMapping : RequestMappingHandlerMapping() { private fun createCondition(clazz: Class<*>): RequestCondition? { val apiController = clazz.getAnnotation(ApiController::class.java) - apiController ?: let { return null } + apiController ?: return null return ApiVersionCondition(apiController.version) } diff --git a/src/main/kotlin/top/fatweb/oxygen/api/util/StrUtil.kt b/src/main/kotlin/top/fatweb/oxygen/api/util/StrUtil.kt index bb356ad..c237ee0 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/util/StrUtil.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/util/StrUtil.kt @@ -19,7 +19,7 @@ object StrUtil { * @since 1.0.0 */ fun upperToUnderLetter(str: String?): String { - str ?: let { return "" } + str ?: return "" return Regex("[A-Z]").replace(str) { matchResult -> "_${matchResult.value.lowercase()}" } } @@ -33,7 +33,7 @@ object StrUtil { * @since 1.0.0 */ fun underToUpperLetter(str: String?): String { - str ?: let { return "" } + str ?: return "" return Regex("_[a-z]").replace(str) { matchResult -> matchResult.value.removePrefix("_").uppercase() } }