Update config file

This commit is contained in:
2023-10-05 21:04:08 +08:00
parent 5e555569c2
commit ca4fa26187
5 changed files with 34 additions and 21 deletions

View File

@@ -5,6 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication import org.springframework.boot.runApplication
import org.springframework.transaction.annotation.EnableTransactionManagement import org.springframework.transaction.annotation.EnableTransactionManagement
import java.io.File import java.io.File
import java.util.*
@SpringBootApplication @SpringBootApplication
@EnableTransactionManagement @EnableTransactionManagement
@@ -17,7 +18,14 @@ fun main(args: Array<String>) {
runApplication<FatWebApiApplication>(*args) runApplication<FatWebApiApplication>(*args)
} else { } else {
logger.warn("File application.yml cannot be found in the running path. The configuration file template 'application.example.yml' has been created. Please change the configuration file content and rename it to 'application.yml', and then restart the server.") logger.warn("File application.yml cannot be found in the running path. The configuration file template 'application.example.yml' has been created. Please change the configuration file content and rename it to 'application.yml', and then restart the server.")
FatWebApiApplication::class.java.getResource("/application-config-template.yml")?.readText() FatWebApiApplication::class.java.getResource("/application-config-template.yml")?.readText()
?.let { File("application-config.example.yml").writeText(it) } ?.let {
File("application-config.example.yml").writeText(
it.replace(
"\$uuid\$",
UUID.randomUUID().toString()
)
)
}
} }
} }

View File

@@ -1,8 +1,7 @@
package top.fatweb.api.constants package top.fatweb.api.constant
import org.springframework.boot.context.properties.ConfigurationProperties import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.stereotype.Component import org.springframework.stereotype.Component
import java.security.MessageDigest
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
@Component @Component
@@ -16,14 +15,7 @@ object SecurityConstants {
var jwtTtlUnit = TimeUnit.HOURS var jwtTtlUnit = TimeUnit.HOURS
lateinit var jwtKey: String var jwtKey = "FatWeb"
private fun ByteArray.hex(): String { var jwtIssuer = "FatWeb"
return joinToString("") { "%02X".format(it) }
}
private fun String.md5(): String {
val bytes = MessageDigest.getInstance("MD5").digest(this.toByteArray())
return bytes.hex()
}
} }

View File

@@ -1,4 +1,4 @@
package top.fatweb.api.constants package top.fatweb.api.constant
import org.springframework.boot.context.properties.ConfigurationProperties import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.stereotype.Component import org.springframework.stereotype.Component
@@ -13,5 +13,6 @@ object ServerConstants {
lateinit var buildTime: String lateinit var buildTime: String
fun buildZoneDateTime(zoneId: ZoneId = ZoneId.systemDefault()): ZonedDateTime = LocalDateTime.parse(buildTime).atZone(ZoneId.of("UTC")).withZoneSameInstant(zoneId) fun buildZoneDateTime(zoneId: ZoneId = ZoneId.systemDefault()): ZonedDateTime =
LocalDateTime.parse(buildTime).atZone(ZoneId.of("UTC")).withZoneSameInstant(zoneId)
} }

View File

@@ -1,3 +1,12 @@
app:
security:
# header-string: "Authorization" # The key of head to get token
# token-prefix: "Bearer " # Token prefix
# jwt-ttl: 2 # The life of token
# jwt-ttl-unit: hours # Unit of life of token
jwt-key: $uuid$ # Key to generate token
# jwt-issuer: FatWeb # Token issuer
server: server:
# port: 8080 # Server port # port: 8080 # Server port

View File

@@ -1,15 +1,18 @@
app: app:
version: @project.version@ version: @project.version@
build-time: @build.timestamp@ build-time: @build.timestamp@
security:
header-string: "Authorization"
token-prefix: "Bearer "
jwt-ttl: 2
jwt-ttl-unit: hours
spring: spring:
profiles: profiles:
active: config active: config
datasource: datasource:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
mybatis-plus:
global-config:
db-config:
logic-delete-field: deleted
logic-not-delete-value: 0
logic-delete-value: id
id-type: assign_id
type-aliases-package: top.fatweb.api.entity