logback配置
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -115,3 +115,4 @@ gradle-app.setting
|
|||||||
|
|
||||||
# ---> Gradle
|
# ---> Gradle
|
||||||
.idea
|
.idea
|
||||||
|
logs/
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
"groupId" : "0f7392c3132d4ae698caf0e8ab55756b",
|
"groupId" : "0f7392c3132d4ae698caf0e8ab55756b",
|
||||||
"name" : "登录",
|
"name" : "登录",
|
||||||
"createTime" : 1754119582735,
|
"createTime" : 1754119582735,
|
||||||
"updateTime" : 1754121286889,
|
"updateTime" : 1754193379477,
|
||||||
"lock" : null,
|
"lock" : null,
|
||||||
"createBy" : "admin",
|
"createBy" : "admin",
|
||||||
"updateBy" : "admin",
|
"updateBy" : "admin",
|
||||||
@ -13,7 +13,7 @@
|
|||||||
"method" : "POST",
|
"method" : "POST",
|
||||||
"parameters" : [ ],
|
"parameters" : [ ],
|
||||||
"options" : [ ],
|
"options" : [ ],
|
||||||
"requestBody" : "{\n \"username\": \"admin\",\n \"password\": \"123456\"\n}",
|
"requestBody" : "{\n \"username\": \"admin\",\n \"password\": \"1234567\"\n}",
|
||||||
"headers" : [ ],
|
"headers" : [ ],
|
||||||
"paths" : [ ],
|
"paths" : [ ],
|
||||||
"responseBody" : "{\n \"code\": \"000000\",\n \"message\": \"成功\",\n \"data\": {\n \"access_token\": \"7a01c52f44d54dd6a6517ba36cba122f\",\n \"refresh_token\": \"d8c639f0288a4cdfa96ac56378bdcc23\"\n }\n}",
|
"responseBody" : "{\n \"code\": \"000000\",\n \"message\": \"成功\",\n \"data\": {\n \"access_token\": \"7a01c52f44d54dd6a6517ba36cba122f\",\n \"refresh_token\": \"d8c639f0288a4cdfa96ac56378bdcc23\"\n }\n}",
|
||||||
@ -132,7 +132,7 @@
|
|||||||
================================
|
================================
|
||||||
// 参数校验
|
// 参数校验
|
||||||
if (is_null(body) || is_blank(body.username) || is_blank(body.password)){
|
if (is_null(body) || is_blank(body.username) || is_blank(body.password)){
|
||||||
return biz_failure_fmt(BizConstants.FAILURE, "请求参数无效,用户名或密码不能为空")
|
return biz_failure(BizConstants.AUTH_0301)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 登录
|
// 登录
|
||||||
@ -140,19 +140,13 @@ var userDO = db.select("""
|
|||||||
SELECT * FROM sys_org_user WHERE username = #{body.username}
|
SELECT * FROM sys_org_user WHERE username = #{body.username}
|
||||||
""")
|
""")
|
||||||
if (userDO == null || !bcrypt_match(body.password, userDO.password)){
|
if (userDO == null || !bcrypt_match(body.password, userDO.password)){
|
||||||
return biz_failure_fmt(BizConstants.FAILURE, "用户名或密码错误")
|
return biz_failure(BizConstants.AUTH_0302)
|
||||||
}
|
|
||||||
if (userDO.status == "PENDING") {
|
|
||||||
return biz_failure_fmt(BizConstants.FAILURE, "用户未审核通过")
|
|
||||||
}
|
}
|
||||||
if (userDO.status == "LOCKED") {
|
if (userDO.status == "LOCKED") {
|
||||||
return biz_failure_fmt(BizConstants.FAILURE, "用户以被锁定,请稍后重试")
|
return biz_failure(BizConstants.AUTH_0303)
|
||||||
}
|
}
|
||||||
if (userDO.status == "BANNED") {
|
if (userDO.status == "BANNED") {
|
||||||
return biz_failure_fmt(BizConstants.FAILURE, "用户以被禁用")
|
return biz_failure(BizConstants.AUTH_0304)
|
||||||
}
|
|
||||||
if (userDO.status == "DELETED") {
|
|
||||||
return biz_failure_fmt(BizConstants.FAILURE, "用户不存在")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var access_token = uuid()
|
var access_token = uuid()
|
||||||
|
@ -5,6 +5,8 @@ server:
|
|||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: dolphin-parent
|
name: dolphin-parent
|
||||||
|
profiles:
|
||||||
|
active: dev
|
||||||
datasource:
|
datasource:
|
||||||
name: postgres
|
name: postgres
|
||||||
driver-class-name: org.postgresql.Driver
|
driver-class-name: org.postgresql.Driver
|
||||||
|
47
src/main/resources/logback-spring.xml
Normal file
47
src/main/resources/logback-spring.xml
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration scan="true" scanPeriod="30 seconds">
|
||||||
|
<!-- 定义变量 -->
|
||||||
|
<property name="LOG_PATH" value="logs" />
|
||||||
|
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n" />
|
||||||
|
<springProperty name="APP_NAME" source="spring.application.name" defaultValue="app" />
|
||||||
|
|
||||||
|
<!-- 控制台输出 -->
|
||||||
|
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>${LOG_PATTERN}</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 文件滚动输出 -->
|
||||||
|
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${LOG_PATH}/app-execute.log</file>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||||
|
<fileNamePattern>${LOG_PATH}/app-execute-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||||
|
<maxFileSize>100MB</maxFileSize>
|
||||||
|
<maxHistory>30</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${LOG_PATTERN}</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 异步日志 -->
|
||||||
|
<appender name="ASYNC_FILE" class="ch.qos.logback.classic.AsyncAppender">
|
||||||
|
<appender-ref ref="FILE" />
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 按环境配置 -->
|
||||||
|
<springProfile name="dev">
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="CONSOLE" />
|
||||||
|
<appender-ref ref="ASYNC_FILE" />
|
||||||
|
</root>
|
||||||
|
</springProfile>
|
||||||
|
|
||||||
|
<springProfile name="prod,test">
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="ASYNC_FILE" />
|
||||||
|
</root>
|
||||||
|
<logger name="org.hibernate.SQL" level="DEBUG" />
|
||||||
|
</springProfile>
|
||||||
|
</configuration>
|
Reference in New Issue
Block a user