build: 添加代码格式化配置
This commit is contained in:
parent
29f5e1b75f
commit
db9be40c16
2
.gitignore
vendored
2
.gitignore
vendored
@ -7,6 +7,8 @@ build/
|
||||
!**/src/test/**/build/
|
||||
/logs
|
||||
/config
|
||||
/gradlew
|
||||
/gradlew.bat
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
plugins {
|
||||
kotlin("jvm") version "1.9.25"
|
||||
kotlin("plugin.spring") version "1.9.25"
|
||||
id("com.diffplug.spotless") version "6.25.0"
|
||||
id("org.springframework.boot") version "3.4.4"
|
||||
id("io.spring.dependency-management") version "1.1.7"
|
||||
id("com.google.devtools.ksp") version "1.9.25-1.0.20"
|
||||
@ -29,6 +30,21 @@ kotlin {
|
||||
}
|
||||
}
|
||||
|
||||
spotless {
|
||||
kotlin {
|
||||
ktlint()
|
||||
.editorConfigOverride(
|
||||
mapOf(
|
||||
"ktlint_standard_no-wildcard-imports" to "disabled",
|
||||
"ktlint_standard_trailing-comma-on-call-site" to "disabled",
|
||||
"ktlint_standard_trailing-comma-on-declaration-site" to "disabled",
|
||||
"indent_size" to "2"
|
||||
)
|
||||
)
|
||||
target("src/**/*.kt")
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<Test> {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package com.app.config.exception
|
||||
|
||||
|
||||
import com.app.data.RespBean
|
||||
import jakarta.servlet.http.HttpServletRequest
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package com.app.config.satoken
|
||||
|
||||
|
||||
import cn.dev33.satoken.context.SaHolder
|
||||
import cn.dev33.satoken.filter.SaServletFilter
|
||||
import cn.dev33.satoken.interceptor.SaInterceptor
|
||||
|
||||
@ -26,6 +26,7 @@ class SwaggerConfig {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
fun customOpenAPI(): OpenAPI {
|
||||
return OpenAPI()
|
||||
@ -57,5 +58,4 @@ class SwaggerConfig {
|
||||
// .packagesToScan("com.csrs.web.controller.ai")
|
||||
// .build()
|
||||
// }
|
||||
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package com.app.controller;
|
||||
package com.app.controller
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil
|
||||
import com.app.data.dto.SignInRequest
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package com.app.controller
|
||||
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
|
||||
@ -56,8 +56,11 @@ class RequestLogFilter(
|
||||
fun logRequestEnd(wrapper: ContentCachingResponseWrapper, startTime: Long) {
|
||||
val time = System.currentTimeMillis() - startTime
|
||||
val status = wrapper.status
|
||||
val content = if (status != 200) "$status 错误"
|
||||
else String(wrapper.contentAsByteArray)
|
||||
val content = if (status != 200) {
|
||||
"$status 错误"
|
||||
} else {
|
||||
String(wrapper.contentAsByteArray)
|
||||
}
|
||||
|
||||
log.info("\n>>>>>请求处理耗时:[{}ms] 响应结果:{}", time, content)
|
||||
}
|
||||
@ -79,25 +82,29 @@ class RequestLogFilter(
|
||||
|
||||
if (StpUtil.isLogin()) {
|
||||
val id = StpUtil.getLoginId()
|
||||
log.info("""
|
||||
log.info(
|
||||
"""
|
||||
|
||||
>>>>>请求ID:[${reqId}]
|
||||
>>>>>请求ID:[$reqId]
|
||||
>>>>>请求URL:["${request.servletPath}"](${request.method})
|
||||
>>>>>远程IP:[${request.remoteAddr}]
|
||||
>>>>>用户名:[username]
|
||||
>>>>>用户ID:$id
|
||||
>>>>>角色:${StpUtil.getRoleList()}
|
||||
>>>>>请求参数列表: [$params]
|
||||
""".trimIndent())
|
||||
""".trimIndent()
|
||||
)
|
||||
} else {
|
||||
log.info("""
|
||||
log.info(
|
||||
"""
|
||||
|
||||
>>>>>请求ID:[${reqId}]
|
||||
>>>>>请求ID:[$reqId]
|
||||
>>>>>请求URL:["${request.servletPath}"](${request.method})
|
||||
>>>>>远程IP地址:[${request.remoteAddr}]
|
||||
>>>>>身份:未验证
|
||||
>>>>>请求参数列表: [$params]
|
||||
""".trimIndent())
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -8,7 +8,6 @@ import org.babyfish.jimmer.spring.repository.KRepository
|
||||
import org.babyfish.jimmer.sql.kt.ast.expression.eq
|
||||
import org.babyfish.jimmer.sql.kt.ast.expression.`eq?`
|
||||
|
||||
|
||||
interface UserRepository : KRepository<User, Long> {
|
||||
fun findUser(
|
||||
pageIndex: Int = 0,
|
||||
|
||||
@ -14,9 +14,6 @@ class UserServiceImpl(
|
||||
private val userRepository: UserRepository
|
||||
) : UserService {
|
||||
override fun signIn(username: String, password: String): String {
|
||||
// withContext(Dispatchers.IO) {
|
||||
//
|
||||
// }
|
||||
val user = userRepository.findByUserName(username) ?: throw Exception("User not found")
|
||||
if (user.password != SecureUtil.sha1(password)) {
|
||||
throw Exception("Invalid password")
|
||||
@ -25,7 +22,7 @@ class UserServiceImpl(
|
||||
.setExtraData(mapOf("deptId" to user.deptId))
|
||||
StpUtil.login(user.userId.toString(), parameter)
|
||||
val token = StpUtil.getTokenInfo()
|
||||
return token.tokenValue;
|
||||
return token.tokenValue
|
||||
}
|
||||
|
||||
override fun list(
|
||||
|
||||
@ -9,5 +9,4 @@ class ApplicationTests {
|
||||
@Test
|
||||
fun contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user