Compare commits
2
Commits
5.4.3
...
16da482de7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16da482de7
|
||
|
|
aa83f575b1
|
+185
-160
@@ -16,24 +16,49 @@
|
|||||||
* ProjectName mingli-utils
|
* ProjectName mingli-utils
|
||||||
* ModuleName mingli-utils
|
* ModuleName mingli-utils
|
||||||
* CurrentFile build.gradle.kts
|
* CurrentFile build.gradle.kts
|
||||||
* LastUpdate 2026-10-28 21:50:32
|
* LastUpdate 2026-11-17 10:19:02
|
||||||
* UpdateUser MingLiPro
|
* UpdateUser MingLiPro
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
|
import kotlin.math.sign
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2026 mingliqiye
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
* ProjectName mingli-utils
|
||||||
|
* ModuleName mingli-utils
|
||||||
|
* CurrentFile build.gradle.kts
|
||||||
|
* LastUpdate 2026-11-17 10:18:28
|
||||||
|
* UpdateUser MingLiPro
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
idea
|
idea
|
||||||
java
|
java
|
||||||
signing
|
signing
|
||||||
`java-library`
|
`java-library`
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
kotlin("jvm") version "2.2.20"
|
kotlin("jvm") version "2.2.20"
|
||||||
kotlin("kapt") version "2.2.20"
|
kotlin("kapt") version "2.2.20"
|
||||||
id("org.jetbrains.dokka") version "2.1.0"
|
id("org.jetbrains.dokka") version "2.1.0"
|
||||||
id("org.jetbrains.dokka-javadoc") version "2.1.0"
|
id("org.jetbrains.dokka-javadoc") version "2.1.0"
|
||||||
kotlin("plugin.spring") version "2.1.0"
|
kotlin("plugin.spring") version "2.1.0"
|
||||||
}
|
}
|
||||||
val GROUPSID = project.properties["GROUPSID"] as String
|
val GROUPSID = project.properties["GROUPSID"] as String
|
||||||
val VERSIONS = project.properties["VERSIONS"] as String
|
val VERSIONS = project.properties["VERSIONS"] as String
|
||||||
@@ -45,205 +70,205 @@ group = GROUPSID
|
|||||||
version = VERSIONS
|
version = VERSIONS
|
||||||
|
|
||||||
base {
|
base {
|
||||||
archivesName.set(ARTIFACTID)
|
archivesName.set(ARTIFACTID)
|
||||||
}
|
}
|
||||||
|
|
||||||
val buildDir: java.nio.file.Path = File("build").toPath()
|
val buildDir: java.nio.file.Path = File("build").toPath()
|
||||||
|
|
||||||
java {
|
java {
|
||||||
toolchain.languageVersion.set(JavaLanguageVersion.of(JDKVERSIONS))
|
toolchain.languageVersion.set(JavaLanguageVersion.of(JDKVERSIONS))
|
||||||
withSourcesJar()
|
withSourcesJar()
|
||||||
}
|
}
|
||||||
kotlin {
|
kotlin {
|
||||||
jvmToolchain(JDKVERSIONS)
|
jvmToolchain(JDKVERSIONS)
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
maven {
|
maven {
|
||||||
url = uri("https://maven.mingliqiye.com/")
|
name = "mingliqiye-public"
|
||||||
}
|
url = uri("https://repository.mingliqiye.com/repository/maven-public/")
|
||||||
mavenCentral()
|
}
|
||||||
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("org.slf4j:slf4j-api:2.0.17")
|
implementation("org.slf4j:slf4j-api:2.0.17")
|
||||||
implementation(kotlin("reflect"))
|
implementation(kotlin("reflect"))
|
||||||
api("com.mingliqiye.utils.aliasfor:alias-for:1.0.1")
|
api("com.mingliqiye.utils.aliasfor:alias-for:1.0.1")
|
||||||
compileOnly("org.mindrot:jbcrypt:0.4")
|
compileOnly("org.mindrot:jbcrypt:0.4")
|
||||||
compileOnly("com.squareup.okhttp3:okhttp:5.3.2")
|
compileOnly("com.squareup.okhttp3:okhttp:5.3.2")
|
||||||
compileOnly("com.fasterxml.jackson.core:jackson-databind:2.21.0")
|
compileOnly("com.fasterxml.jackson.core:jackson-databind:2.21.0")
|
||||||
compileOnly("com.fasterxml.jackson.module:jackson-module-kotlin:2.21.0")
|
compileOnly("com.fasterxml.jackson.module:jackson-module-kotlin:2.21.0")
|
||||||
compileOnly("org.springframework:spring-context:5.3.0")
|
compileOnly("org.springframework:spring-context:5.3.0")
|
||||||
compileOnly("org.springframework.boot:spring-boot-autoconfigure:2.7.16")
|
compileOnly("org.springframework.boot:spring-boot-autoconfigure:2.7.16")
|
||||||
compileOnly("tools.jackson.core:jackson-databind:3.1.0")
|
compileOnly("tools.jackson.core:jackson-databind:3.1.0")
|
||||||
compileOnly(fileTree("libs"))
|
compileOnly(fileTree("libs"))
|
||||||
compileOnly("com.google.code.gson:gson:2.13.2")
|
compileOnly("com.google.code.gson:gson:2.13.2")
|
||||||
compileOnly("org.mybatis:mybatis:3.5.19")
|
compileOnly("org.mybatis:mybatis:3.5.19")
|
||||||
compileOnly("io.netty:netty-all:4.2.15.Final")
|
compileOnly("io.netty:netty-all:4.2.15.Final")
|
||||||
compileOnly("com.baomidou:mybatis-plus-core:3.5.15")
|
compileOnly("com.baomidou:mybatis-plus-core:3.5.15")
|
||||||
compileOnly("net.java.dev.jna:jna:5.17.0")
|
compileOnly("net.java.dev.jna:jna:5.17.0")
|
||||||
compileOnly("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.8")
|
compileOnly("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.8")
|
||||||
compileOnly("com.baomidou:mybatis-plus-extension:3.5.15")
|
compileOnly("com.baomidou:mybatis-plus-extension:3.5.15")
|
||||||
compileOnly("com.baomidou:mybatis-plus-jsqlparser:3.5.15")
|
compileOnly("com.baomidou:mybatis-plus-jsqlparser:3.5.15")
|
||||||
compileOnly("com.baomidou:mybatis-plus-spring:3.5.9")
|
compileOnly("com.baomidou:mybatis-plus-spring:3.5.9")
|
||||||
testImplementation("org.junit.jupiter:junit-jupiter:5.7.1")
|
testImplementation("org.junit.jupiter:junit-jupiter:5.7.1")
|
||||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||||
testImplementation("com.mingliqiye.logger:logger-log4j2:1.0.9")
|
testImplementation("com.mingliqiye.logger:logger-log4j2:1.0.9")
|
||||||
testImplementation("com.google.code.gson:gson:2.13.2")
|
testImplementation("com.google.code.gson:gson:2.13.2")
|
||||||
|
|
||||||
testImplementation("com.fasterxml.jackson.core:jackson-databind:2.21.0")
|
testImplementation("com.fasterxml.jackson.core:jackson-databind:2.21.0")
|
||||||
testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.21.0")
|
testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.21.0")
|
||||||
|
|
||||||
testImplementation("tools.jackson.module:jackson-module-kotlin:3.1.0")
|
testImplementation("tools.jackson.module:jackson-module-kotlin:3.1.0")
|
||||||
testImplementation("tools.jackson.core:jackson-databind:3.1.0")
|
testImplementation("tools.jackson.core:jackson-databind:3.1.0")
|
||||||
testImplementation(kotlin("test"))
|
testImplementation(kotlin("test"))
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
tasks.withType<JavaCompile>().configureEach {
|
tasks.withType<JavaCompile>().configureEach {
|
||||||
options.encoding = "UTF-8"
|
options.encoding = "UTF-8"
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named<Test>("test") {
|
tasks.named<Test>("test") {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
tasks.withType<JavaExec> {
|
tasks.withType<JavaExec> {
|
||||||
jvmArgs(
|
jvmArgs(
|
||||||
"-Dfile.encoding=UTF-8", "-Dsun.stdout.encoding=UTF-8", "-Dsun.stderr.encoding=UTF-8"
|
"-Dfile.encoding=UTF-8", "-Dsun.stdout.encoding=UTF-8", "-Dsun.stderr.encoding=UTF-8"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
kapt {
|
kapt {
|
||||||
arguments {
|
arguments {
|
||||||
arg(
|
arg(
|
||||||
"kapt.kotlin.generated",
|
"kapt.kotlin.generated",
|
||||||
project.layout.buildDirectory.dir("generated/source/kapt/main").get().asFile.absolutePath
|
project.layout.buildDirectory.dir("generated/source/kapt/main").get().asFile.absolutePath
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<org.gradle.jvm.tasks.Jar> {
|
tasks.withType<org.gradle.jvm.tasks.Jar> {
|
||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
from("LICENSE") { into("META-INF") }
|
from("LICENSE") { into("META-INF") }
|
||||||
from("NOTICE") { into("META-INF") }
|
from("NOTICE") { into("META-INF") }
|
||||||
manifest {
|
manifest {
|
||||||
attributes(
|
attributes(
|
||||||
mapOf(
|
mapOf(
|
||||||
"Main-Class" to "com.mingliqiye.utils.main.Main",
|
"Main-Class" to "com.mingliqiye.utils.main.Main",
|
||||||
"Specification-Title" to ARTIFACTID,
|
"Specification-Title" to ARTIFACTID,
|
||||||
"Specification-Version" to VERSIONS,
|
"Specification-Version" to VERSIONS,
|
||||||
"Specification-Vendor" to "minglipro",
|
"Specification-Vendor" to "minglipro",
|
||||||
"Specification-Build-Time" to LocalDateTime.now()
|
"Specification-Build-Time" to LocalDateTime.now()
|
||||||
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSS")),
|
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSS")),
|
||||||
"Specification-Package" to GROUPSID,
|
"Specification-Package" to GROUPSID,
|
||||||
"Specification-Build-Number" to "1",
|
"Specification-Build-Number" to "1",
|
||||||
"Specification-Build-OS" to System.getProperty("os.name"),
|
"Specification-Build-OS" to System.getProperty("os.name"),
|
||||||
"Specification-Build-Java" to System.getProperty("java.version"),
|
"Specification-Build-Java" to System.getProperty("java.version"),
|
||||||
"Specification-Build-Java-Vendor" to System.getProperty("java.vendor"),
|
"Specification-Build-Java-Vendor" to System.getProperty("java.vendor"),
|
||||||
"Specification-Build-Java-Vendor-URL" to System.getProperty("java.vendor.url"),
|
"Specification-Build-Java-Vendor-URL" to System.getProperty("java.vendor.url"),
|
||||||
"Implementation-Title" to ARTIFACTID,
|
"Implementation-Title" to ARTIFACTID,
|
||||||
"Implementation-Version" to VERSIONS,
|
"Implementation-Version" to VERSIONS,
|
||||||
"Implementation-Package" to GROUPSID,
|
"Implementation-Package" to GROUPSID,
|
||||||
"Implementation-Vendor" to "minglipro",
|
"Implementation-Vendor" to "minglipro",
|
||||||
"Implementation-Build-Time" to LocalDateTime.now()
|
"Implementation-Build-Time" to LocalDateTime.now()
|
||||||
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSS"))
|
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSS"))
|
||||||
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val isJdk8Build = project.findProperty("buildForJdk8") == "true"
|
val isJdk8Build = project.findProperty("buildForJdk8") == "true"
|
||||||
|
|
||||||
tasks.register<Jar>("javaDocJar") {
|
|
||||||
group = "build"
|
dokka {
|
||||||
archiveClassifier.set("javadoc-dec")
|
pluginsConfiguration.html {
|
||||||
dependsOn("dokkaGeneratePublicationJavadoc")
|
customAssets.from("logo.png")
|
||||||
from(buildDir.resolve("dokka/javadoc"))
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.register<Jar>("javaDocJar") {
|
||||||
|
group = "build"
|
||||||
|
archiveClassifier.set("javadoc")
|
||||||
|
dependsOn("dokkaGenerateJavadoc")
|
||||||
|
from(buildDir.resolve("dokka/javadoc"))
|
||||||
|
}
|
||||||
|
|
||||||
tasks.register<Jar>("kotlinDocJar") {
|
tasks.register<Jar>("kotlinDocJar") {
|
||||||
group = "build"
|
group = "build"
|
||||||
archiveClassifier.set("javadoc")
|
archiveClassifier.set("kotlindoc")
|
||||||
dependsOn("dokkaGeneratePublicationHtml")
|
dependsOn("dokkaGeneratePublicationHtml")
|
||||||
from(buildDir.resolve("dokka/html"))
|
from(buildDir.resolve("dokka/html"))
|
||||||
}
|
}
|
||||||
publishing {
|
publishing {
|
||||||
repositories {
|
publications {
|
||||||
maven {
|
create<MavenPublication>("mavenJava") {
|
||||||
name = "mingliqiye"
|
from(components["java"])
|
||||||
url = uri("https://repository.mingliqiye.com/repository/maven")
|
artifact(tasks.named("javaDocJar"))
|
||||||
credentials {
|
artifact(tasks.named("kotlinDocJar"))
|
||||||
username = System.getenv("mingliqiye.username")
|
artifactId = ARTIFACTID
|
||||||
password = System.getenv("mingliqiye.password")
|
pom {
|
||||||
}
|
name = "mingli-utils"
|
||||||
}
|
url = "https://mingli-utils.mingliqiye.com"
|
||||||
}
|
description = "A Java/kotlin Utils"
|
||||||
publications {
|
licenses {
|
||||||
create<MavenPublication>("mavenJava") {
|
license {
|
||||||
from(components["java"])
|
name = "The Apache License, Version 2.0"
|
||||||
artifact(tasks.named("kotlinDocJar"))
|
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
|
||||||
artifactId = ARTIFACTID
|
}
|
||||||
pom {
|
}
|
||||||
name = "mingli-utils"
|
developers {
|
||||||
url = "https://mingli-utils.mingliqiye.com"
|
developer {
|
||||||
description = "A Java/kotlin Utils"
|
id = "minglipro"
|
||||||
licenses {
|
name = "mingli"
|
||||||
license {
|
email = "minglipro@163.com"
|
||||||
name = "The Apache License, Version 2.0"
|
}
|
||||||
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
|
}
|
||||||
}
|
scm {
|
||||||
}
|
connection = "scm:git:https://git.mingliqiye.com/minglipro/mingli-utils.git"
|
||||||
developers {
|
developerConnection = "scm:git:https://git.mingliqiye.com:minglipro/mingli-utils.git"
|
||||||
developer {
|
url = "https://git.mingliqiye.com/minglipro/mingli-utils"
|
||||||
id = "minglipro"
|
}
|
||||||
name = "mingli"
|
}
|
||||||
email = "minglipro@163.com"
|
}
|
||||||
}
|
}
|
||||||
}
|
signing {
|
||||||
scm {
|
sign(publishing.publications)
|
||||||
connection = "scm:git:https://git.mingliqiye.com/minglipro/mingli-utils.git"
|
}
|
||||||
developerConnection = "scm:git:https://git.mingliqiye.com:minglipro/mingli-utils.git"
|
|
||||||
url = "https://git.mingliqiye.com/minglipro/mingli-utils"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
signing {
|
|
||||||
sign(publishing.publications)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.build {
|
tasks.build {
|
||||||
dependsOn("javaDocJar", "kotlinDocJar")
|
dependsOn("javaDocJar", "kotlinDocJar")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
tasks.processResources {
|
tasks.processResources {
|
||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
outputs.upToDateWhen { false }
|
outputs.upToDateWhen { false }
|
||||||
filesMatching(listOf("META-INF/meta-data", "fabric.mod.json")) {
|
filesMatching(listOf("META-INF/meta-data", "fabric.mod.json")) {
|
||||||
expand(
|
expand(
|
||||||
project.properties + mapOf(
|
project.properties + mapOf(
|
||||||
"buildTime" to LocalDateTime.now().format(
|
"buildTime" to LocalDateTime.now().format(
|
||||||
DateTimeFormatter.ofPattern(
|
DateTimeFormatter.ofPattern(
|
||||||
"yyyy-MM-dd HH:mm:ss.SSSSSSS"
|
"yyyy-MM-dd HH:mm:ss.SSSSSSS"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
signing {
|
signing {
|
||||||
val secretKeyRingFile = System.getenv("SIGNING_SECRET_KEY_RING_FILE")
|
val secretKeyRingFile = System.getenv("SIGNING_SECRET_KEY_RING_FILE")
|
||||||
val keyId = System.getenv("SIGNING_KEY_ID")
|
val keyId = System.getenv("SIGNING_KEY_ID")
|
||||||
useGpgCmd()
|
useGpgCmd()
|
||||||
project.ext.set("signing.secretKeyRingFile", secretKeyRingFile)
|
project.ext.set("signing.secretKeyRingFile", secretKeyRingFile)
|
||||||
project.ext.set("signing.keyId", keyId)
|
project.ext.set("signing.keyId", keyId)
|
||||||
project.ext.set("signing.password", "")
|
project.ext.set("signing.password", "")
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -16,10 +16,10 @@
|
|||||||
# ProjectName mingli-utils
|
# ProjectName mingli-utils
|
||||||
# ModuleName mingli-utils
|
# ModuleName mingli-utils
|
||||||
# CurrentFile gradle.properties
|
# CurrentFile gradle.properties
|
||||||
# LastUpdate 2026-11-09 19:49:52
|
# LastUpdate 2026-11-17 09:07:20
|
||||||
# UpdateUser MingLiPro
|
# UpdateUser MingLiPro
|
||||||
#
|
#
|
||||||
JDKVERSIONS=17
|
JDKVERSIONS=17
|
||||||
GROUPSID=com.mingliqiye.utils
|
GROUPSID=com.mingliqiye.utils
|
||||||
ARTIFACTID=mingli-utils
|
ARTIFACTID=mingli-utils
|
||||||
VERSIONS=5.4.3
|
VERSIONS=5.4.4
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2026 mingliqiye
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
* ProjectName mingli-utils
|
||||||
|
* ModuleName mingli-utils.main
|
||||||
|
* CurrentFile Base64NoPaddingCodec.kt
|
||||||
|
* LastUpdate 2026-11-16 14:24:59
|
||||||
|
* UpdateUser MingLiPro
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.mingliqiye.utils.base
|
||||||
|
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
internal class Base64NoPaddingCodec : BaseCodec {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Base64编码器实例
|
||||||
|
* 用于执行字节数组到Base64字符串的编码操作
|
||||||
|
*/
|
||||||
|
val encoder: Base64.Encoder = Base64.getUrlEncoder().withoutPadding()
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Base64解码器实例
|
||||||
|
* 用于执行Base64字符串到字节数组的解码操作
|
||||||
|
*/
|
||||||
|
val decoder: Base64.Decoder = Base64.getUrlDecoder()
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 将字节数组编码为Base64字符串
|
||||||
|
*
|
||||||
|
* @param bytes 待编码的字节数组
|
||||||
|
* @return 编码后的Base64字符串
|
||||||
|
*/
|
||||||
|
override fun encode(bytes: ByteArray): String {
|
||||||
|
return encoder.encodeToString(bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 将Base64字符串解码为字节数组
|
||||||
|
*
|
||||||
|
* @param string 待解码的Base64字符串
|
||||||
|
* @return 解码后的字节数组
|
||||||
|
*/
|
||||||
|
override fun decode(string: String): ByteArray {
|
||||||
|
return decoder.decode(string)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
* ProjectName mingli-utils
|
* ProjectName mingli-utils
|
||||||
* ModuleName mingli-utils.main
|
* ModuleName mingli-utils.main
|
||||||
* CurrentFile Base64UrlCodec.kt
|
* CurrentFile Base64UrlCodec.kt
|
||||||
* LastUpdate 2026-03-12 10:34:36
|
* LastUpdate 2026-11-16 14:24:59
|
||||||
* UpdateUser MingLiPro
|
* UpdateUser MingLiPro
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -16,23 +16,36 @@
|
|||||||
* ProjectName mingli-utils
|
* ProjectName mingli-utils
|
||||||
* ModuleName mingli-utils.main
|
* ModuleName mingli-utils.main
|
||||||
* CurrentFile BaseType.kt
|
* CurrentFile BaseType.kt
|
||||||
* LastUpdate 2026-03-12 10:08:42
|
* LastUpdate 2026-11-16 14:21:51
|
||||||
* UpdateUser MingLiPro
|
* UpdateUser MingLiPro
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.mingliqiye.utils.base
|
package com.mingliqiye.utils.base
|
||||||
|
|
||||||
enum class BaseType(val baseCodec: BaseCodec) : BaseCodec {
|
import com.mingliqiye.utils.base.code.BASE10 as CODE_BASE10
|
||||||
|
import com.mingliqiye.utils.base.code.BASE16 as CODE_BASE16
|
||||||
|
import com.mingliqiye.utils.base.code.BASE2 as CODE_BASE2
|
||||||
|
import com.mingliqiye.utils.base.code.BASE256 as CODE_BASE256
|
||||||
|
import com.mingliqiye.utils.base.code.BASE64 as CODE_BASE64
|
||||||
|
import com.mingliqiye.utils.base.code.BASE64_NO_PADDING as CODE_BASE64_NO_PADDING
|
||||||
|
import com.mingliqiye.utils.base.code.BASE64_URL as CODE_BASE64_URL
|
||||||
|
import com.mingliqiye.utils.base.code.BASE91 as CODE_BASE91
|
||||||
|
|
||||||
BASE2(com.mingliqiye.utils.base.code.BASE2),
|
enum class BaseType(private val baseCodec: () -> BaseCodec) : BaseCodec {
|
||||||
BASE10(com.mingliqiye.utils.base.code.BASE10),
|
|
||||||
BASE16(com.mingliqiye.utils.base.code.BASE16),
|
|
||||||
BASE64(com.mingliqiye.utils.base.code.BASE64),
|
|
||||||
BASE64URL(com.mingliqiye.utils.base.code.BASE64URL),
|
|
||||||
BASE91(com.mingliqiye.utils.base.code.BASE91),
|
|
||||||
BASE256(com.mingliqiye.utils.base.code.BASE256);
|
|
||||||
|
|
||||||
override fun encode(bytes: ByteArray) = baseCodec.encode(bytes)
|
BASE2(::CODE_BASE2),
|
||||||
override fun decode(string: String) = baseCodec.decode(string)
|
BASE10(::CODE_BASE10),
|
||||||
|
BASE16(::CODE_BASE16),
|
||||||
|
BASE64(::CODE_BASE64),
|
||||||
|
BASE64_URL(::CODE_BASE64_URL),
|
||||||
|
BASE64_NO_PADDING(::CODE_BASE64_NO_PADDING),
|
||||||
|
BASE91(::CODE_BASE91),
|
||||||
|
BASE256(::CODE_BASE256);
|
||||||
|
|
||||||
|
val codec
|
||||||
|
get() = baseCodec()
|
||||||
|
|
||||||
|
override fun encode(bytes: ByteArray) = codec.encode(bytes)
|
||||||
|
override fun decode(string: String) = codec.decode(string)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
* ProjectName mingli-utils
|
* ProjectName mingli-utils
|
||||||
* ModuleName mingli-utils.main
|
* ModuleName mingli-utils.main
|
||||||
* CurrentFile BaseCodes.kt
|
* CurrentFile BaseCodes.kt
|
||||||
* LastUpdate 2026-03-12 10:03:32
|
* LastUpdate 2026-11-16 14:10:57
|
||||||
* UpdateUser MingLiPro
|
* UpdateUser MingLiPro
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -63,10 +63,16 @@ val BASE64: BaseCodec by lazy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@get:JvmName("base64Url")
|
@get:JvmName("base64Url")
|
||||||
val BASE64URL: BaseCodec by lazy {
|
val BASE64_URL: BaseCodec by lazy {
|
||||||
Base64UrlCodec()
|
Base64UrlCodec()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@get:JvmName("base64NoPadding")
|
||||||
|
val BASE64_NO_PADDING: BaseCodec by lazy {
|
||||||
|
Base64NoPaddingCodec()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提供Base91编码器的懒加载实例。
|
* 提供Base91编码器的懒加载实例。
|
||||||
* 该编码器用于将数据编码为Base91格式,具有较高的压缩效率。
|
* 该编码器用于将数据编码为Base91格式,具有较高的压缩效率。
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
* ProjectName mingli-utils
|
* ProjectName mingli-utils
|
||||||
* ModuleName mingli-utils.main
|
* ModuleName mingli-utils.main
|
||||||
* CurrentFile ByteFlags.kt
|
* CurrentFile ByteFlags.kt
|
||||||
* LastUpdate 2026-06-21 10:40:58
|
* LastUpdate 2026-11-16 21:35:04
|
||||||
* UpdateUser MingLiPro
|
* UpdateUser MingLiPro
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ data class ByteFlags(
|
|||||||
*
|
*
|
||||||
* @param byte 要解析的字节
|
* @param byte 要解析的字节
|
||||||
*/
|
*/
|
||||||
fun fromByte(byte: Byte) {
|
fun fromByte(byte: Byte): ByteFlags {
|
||||||
val value = byte.toInt() and 0xFF
|
val value = byte.toInt() and 0xFF
|
||||||
b0 = (value and 0x01) != 0
|
b0 = (value and 0x01) != 0
|
||||||
b1 = (value and 0x02) != 0
|
b1 = (value and 0x02) != 0
|
||||||
@@ -74,6 +74,7 @@ data class ByteFlags(
|
|||||||
b5 = (value and 0x20) != 0
|
b5 = (value and 0x20) != 0
|
||||||
b6 = (value and 0x40) != 0
|
b6 = (value and 0x40) != 0
|
||||||
b7 = (value and 0x80) != 0
|
b7 = (value and 0x80) != 0
|
||||||
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -122,7 +123,7 @@ data class ByteFlags(
|
|||||||
* @param value 要设置的布尔值
|
* @param value 要设置的布尔值
|
||||||
* @throws IndexOutOfBoundsException 如果索引不在 0~7 范围内
|
* @throws IndexOutOfBoundsException 如果索引不在 0~7 范围内
|
||||||
*/
|
*/
|
||||||
operator fun set(index: Int, value: Boolean) {
|
operator fun set(index: Int, value: Boolean): ByteFlags {
|
||||||
when (index) {
|
when (index) {
|
||||||
0 -> b0 = value
|
0 -> b0 = value
|
||||||
1 -> b1 = value
|
1 -> b1 = value
|
||||||
@@ -134,12 +135,13 @@ data class ByteFlags(
|
|||||||
7 -> b7 = value
|
7 -> b7 = value
|
||||||
else -> throw IndexOutOfBoundsException("索引必须在0-7之间")
|
else -> throw IndexOutOfBoundsException("索引必须在0-7之间")
|
||||||
}
|
}
|
||||||
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将所有 8 个位设置为 `true`。
|
* 将所有 8 个位设置为 `true`。
|
||||||
*/
|
*/
|
||||||
fun setAll() {
|
fun setAll(): ByteFlags {
|
||||||
b0 = true
|
b0 = true
|
||||||
b1 = true
|
b1 = true
|
||||||
b2 = true
|
b2 = true
|
||||||
@@ -148,12 +150,14 @@ data class ByteFlags(
|
|||||||
b5 = true
|
b5 = true
|
||||||
b6 = true
|
b6 = true
|
||||||
b7 = true
|
b7 = true
|
||||||
|
|
||||||
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将所有 8 个位设置为 `false`。
|
* 将所有 8 个位设置为 `false`。
|
||||||
*/
|
*/
|
||||||
fun clearAll() {
|
fun clearAll(): ByteFlags {
|
||||||
b0 = false
|
b0 = false
|
||||||
b1 = false
|
b1 = false
|
||||||
b2 = false
|
b2 = false
|
||||||
@@ -162,12 +166,14 @@ data class ByteFlags(
|
|||||||
b5 = false
|
b5 = false
|
||||||
b6 = false
|
b6 = false
|
||||||
b7 = false
|
b7 = false
|
||||||
|
|
||||||
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对所有位执行逻辑取反(true ↔ false)。
|
* 对所有位执行逻辑取反(true ↔ false)。
|
||||||
*/
|
*/
|
||||||
fun toggleAll() {
|
fun toggleAll(): ByteFlags {
|
||||||
b0 = !b0
|
b0 = !b0
|
||||||
b1 = !b1
|
b1 = !b1
|
||||||
b2 = !b2
|
b2 = !b2
|
||||||
@@ -176,6 +182,8 @@ data class ByteFlags(
|
|||||||
b5 = !b5
|
b5 = !b5
|
||||||
b6 = !b6
|
b6 = !b6
|
||||||
b7 = !b7
|
b7 = !b7
|
||||||
|
|
||||||
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -184,8 +192,9 @@ data class ByteFlags(
|
|||||||
* @param index 要切换的位索引(0~7)
|
* @param index 要切换的位索引(0~7)
|
||||||
* @throws IndexOutOfBoundsException 如果索引无效
|
* @throws IndexOutOfBoundsException 如果索引无效
|
||||||
*/
|
*/
|
||||||
fun toggle(index: Int) {
|
fun toggle(index: Int): ByteFlags {
|
||||||
this[index] = !this[index]
|
this[index] = !this[index]
|
||||||
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -304,7 +313,7 @@ data class ByteFlags(
|
|||||||
* @param array 布尔数组(长度至少为 8)
|
* @param array 布尔数组(长度至少为 8)
|
||||||
* @throws IllegalArgumentException 如果数组长度不足 8
|
* @throws IllegalArgumentException 如果数组长度不足 8
|
||||||
*/
|
*/
|
||||||
fun fromBooleanArray(array: BooleanArray) {
|
fun fromBooleanArray(array: BooleanArray): ByteFlags {
|
||||||
require(array.size >= 8) { "数组长度至少为8" }
|
require(array.size >= 8) { "数组长度至少为8" }
|
||||||
b0 = array[0]
|
b0 = array[0]
|
||||||
b1 = array[1]
|
b1 = array[1]
|
||||||
@@ -314,6 +323,7 @@ data class ByteFlags(
|
|||||||
b5 = array[5]
|
b5 = array[5]
|
||||||
b6 = array[6]
|
b6 = array[6]
|
||||||
b7 = array[7]
|
b7 = array[7]
|
||||||
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -434,7 +444,6 @@ data class ByteFlags(
|
|||||||
fun fromBinaryString(binary: String): ByteFlags {
|
fun fromBinaryString(binary: String): ByteFlags {
|
||||||
require(binary.length == 8) { "二进制字符串长度必须为8" }
|
require(binary.length == 8) { "二进制字符串长度必须为8" }
|
||||||
require(binary.all { it == '0' || it == '1' }) { "二进制字符串只能包含0和1" }
|
require(binary.all { it == '0' || it == '1' }) { "二进制字符串只能包含0和1" }
|
||||||
|
|
||||||
return ByteFlags(
|
return ByteFlags(
|
||||||
binary[7] == '1', // b0 是最低位(对应字符串最后一位)
|
binary[7] == '1', // b0 是最低位(对应字符串最后一位)
|
||||||
binary[6] == '1',
|
binary[6] == '1',
|
||||||
@@ -447,6 +456,10 @@ data class ByteFlags(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun fromBooleanArray(booleanArray: BooleanArray): ByteFlags {
|
||||||
|
return ByteFlags().fromBooleanArray(booleanArray)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从整数创建 [ByteFlags] 实例(仅使用低 8 位)。
|
* 从整数创建 [ByteFlags] 实例(仅使用低 8 位)。
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
* ProjectName mingli-utils
|
* ProjectName mingli-utils
|
||||||
* ModuleName mingli-utils.main
|
* ModuleName mingli-utils.main
|
||||||
* CurrentFile MingLiLogger.kt
|
* CurrentFile MingLiLogger.kt
|
||||||
* LastUpdate 2026-02-06 08:27:44
|
* LastUpdate 2026-11-16 11:35:40
|
||||||
* UpdateUser MingLiPro
|
* UpdateUser MingLiPro
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -24,6 +24,7 @@ package com.mingliqiye.utils.logger
|
|||||||
|
|
||||||
import org.slf4j.Logger
|
import org.slf4j.Logger
|
||||||
import org.slf4j.Marker
|
import org.slf4j.Marker
|
||||||
|
import org.slf4j.helpers.MessageFormatter
|
||||||
|
|
||||||
class MingLiLogger(private val name: String) : Logger {
|
class MingLiLogger(private val name: String) : Logger {
|
||||||
override fun getName(): String {
|
override fun getName(): String {
|
||||||
@@ -40,14 +41,14 @@ class MingLiLogger(private val name: String) : Logger {
|
|||||||
|
|
||||||
override fun trace(format: String?, arg: Any?) {
|
override fun trace(format: String?, arg: Any?) {
|
||||||
format?.let {
|
format?.let {
|
||||||
val message = format1(it, arg)
|
val message = format(it, arg)
|
||||||
toPrintln(message, MingLiLoggerLevel.TRACE)
|
toPrintln(message, MingLiLoggerLevel.TRACE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun trace(format: String?, arg1: Any?, arg2: Any?) {
|
override fun trace(format: String?, arg1: Any?, arg2: Any?) {
|
||||||
format?.let {
|
format?.let {
|
||||||
val message = format2(it, arg1, arg2)
|
val message = format(it, arg1, arg2)
|
||||||
toPrintln(message, MingLiLoggerLevel.TRACE)
|
toPrintln(message, MingLiLoggerLevel.TRACE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,14 +101,14 @@ class MingLiLogger(private val name: String) : Logger {
|
|||||||
|
|
||||||
override fun debug(format: String?, arg: Any?) {
|
override fun debug(format: String?, arg: Any?) {
|
||||||
format?.let {
|
format?.let {
|
||||||
val message = format1(it, arg)
|
val message = format(it, arg)
|
||||||
toPrintln(message, MingLiLoggerLevel.DEBUG)
|
toPrintln(message, MingLiLoggerLevel.DEBUG)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun debug(format: String?, arg1: Any?, arg2: Any?) {
|
override fun debug(format: String?, arg1: Any?, arg2: Any?) {
|
||||||
format?.let {
|
format?.let {
|
||||||
val message = format2(it, arg1, arg2)
|
val message = format(it, arg1, arg2)
|
||||||
toPrintln(message, MingLiLoggerLevel.DEBUG)
|
toPrintln(message, MingLiLoggerLevel.DEBUG)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,14 +161,14 @@ class MingLiLogger(private val name: String) : Logger {
|
|||||||
|
|
||||||
override fun info(format: String?, arg: Any?) {
|
override fun info(format: String?, arg: Any?) {
|
||||||
format?.let {
|
format?.let {
|
||||||
val message = format1(it, arg)
|
val message = format(it, arg)
|
||||||
toPrintln(message, MingLiLoggerLevel.INFO)
|
toPrintln(message, MingLiLoggerLevel.INFO)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun info(format: String?, arg1: Any?, arg2: Any?) {
|
override fun info(format: String?, arg1: Any?, arg2: Any?) {
|
||||||
format?.let {
|
format?.let {
|
||||||
val message = format2(it, arg1, arg2)
|
val message = format(it, arg1, arg2)
|
||||||
toPrintln(message, MingLiLoggerLevel.INFO)
|
toPrintln(message, MingLiLoggerLevel.INFO)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,7 +221,7 @@ class MingLiLogger(private val name: String) : Logger {
|
|||||||
|
|
||||||
override fun warn(format: String?, arg: Any?) {
|
override fun warn(format: String?, arg: Any?) {
|
||||||
format?.let {
|
format?.let {
|
||||||
val message = format1(it, arg)
|
val message = format(it, arg)
|
||||||
toPrintln(message, MingLiLoggerLevel.WARN)
|
toPrintln(message, MingLiLoggerLevel.WARN)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -234,7 +235,7 @@ class MingLiLogger(private val name: String) : Logger {
|
|||||||
|
|
||||||
override fun warn(format: String?, arg1: Any?, arg2: Any?) {
|
override fun warn(format: String?, arg1: Any?, arg2: Any?) {
|
||||||
format?.let {
|
format?.let {
|
||||||
val message = format2(it, arg1, arg2)
|
val message = format(it, arg1, arg2)
|
||||||
toPrintln(message, MingLiLoggerLevel.WARN)
|
toPrintln(message, MingLiLoggerLevel.WARN)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -280,14 +281,14 @@ class MingLiLogger(private val name: String) : Logger {
|
|||||||
|
|
||||||
override fun error(format: String?, arg: Any?) {
|
override fun error(format: String?, arg: Any?) {
|
||||||
format?.let {
|
format?.let {
|
||||||
val message = format1(it, arg)
|
val message = format(it, arg)
|
||||||
toPrintln(message, MingLiLoggerLevel.ERROR)
|
toPrintln(message, MingLiLoggerLevel.ERROR)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun error(format: String?, arg1: Any?, arg2: Any?) {
|
override fun error(format: String?, arg1: Any?, arg2: Any?) {
|
||||||
format?.let {
|
format?.let {
|
||||||
val message = format2(it, arg1, arg2)
|
val message = format(it, arg1, arg2)
|
||||||
toPrintln(message, MingLiLoggerLevel.ERROR)
|
toPrintln(message, MingLiLoggerLevel.ERROR)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -343,24 +344,14 @@ class MingLiLogger(private val name: String) : Logger {
|
|||||||
System.out.write(string.toByteArray())
|
System.out.write(string.toByteArray())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun format1(format: String, arg: Any?): String {
|
private fun format(format: String, vararg args: Any?): String {
|
||||||
return if (format.contains("{}")) {
|
return formatArray(format, args)
|
||||||
format.replaceFirst("{}", arg?.toString() ?: "null")
|
|
||||||
} else {
|
|
||||||
"$format $arg"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun format2(format: String, arg1: Any?, arg2: Any?): String {
|
|
||||||
return format.replaceFirst("{}", arg1?.toString() ?: "null")
|
|
||||||
.replaceFirst("{}", arg2?.toString() ?: "null")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun formatArray(format: String, arguments: Array<out Any?>): String {
|
private fun formatArray(format: String, arguments: Array<out Any?>): String {
|
||||||
var result = format
|
return MessageFormatter.arrayFormat(
|
||||||
for (arg in arguments) {
|
format,
|
||||||
result = result.replaceFirst("{}", arg?.toString() ?: "null")
|
arguments
|
||||||
}
|
).message
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-4
@@ -16,7 +16,7 @@
|
|||||||
* ProjectName mingli-utils
|
* ProjectName mingli-utils
|
||||||
* ModuleName mingli-utils.main
|
* ModuleName mingli-utils.main
|
||||||
* CurrentFile JSONAAutoConfiguration.kt
|
* CurrentFile JSONAAutoConfiguration.kt
|
||||||
* LastUpdate 2026-11-09 14:59:49
|
* LastUpdate 2026-11-16 11:28:52
|
||||||
* UpdateUser MingLiPro
|
* UpdateUser MingLiPro
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -41,9 +41,7 @@ open class JSONAAutoConfiguration(
|
|||||||
init {
|
init {
|
||||||
JSONA.setJsonApi(jsonApi)
|
JSONA.setJsonApi(jsonApi)
|
||||||
log.info(
|
log.info(
|
||||||
"JSONA use ${
|
"JSONA use {}", jsonApi.javaClass
|
||||||
jsonApi.javaClass
|
|
||||||
}"
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -16,7 +16,7 @@
|
|||||||
* ProjectName mingli-utils
|
* ProjectName mingli-utils
|
||||||
* ModuleName mingli-utils.main
|
* ModuleName mingli-utils.main
|
||||||
* CurrentFile Jackson3AutoConfiguration.kt
|
* CurrentFile Jackson3AutoConfiguration.kt
|
||||||
* LastUpdate 2026-11-09 14:18:45
|
* LastUpdate 2026-11-17 10:16:38
|
||||||
* UpdateUser MingLiPro
|
* UpdateUser MingLiPro
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -39,8 +39,8 @@ open class Jackson3AutoConfiguration {
|
|||||||
|
|
||||||
private val log = MingLiLoggerFactory.getLogger<Jackson3AutoConfiguration>()
|
private val log = MingLiLoggerFactory.getLogger<Jackson3AutoConfiguration>()
|
||||||
|
|
||||||
@Bean("UUIDJsonConverterJsonMapperCustomizer")
|
@Bean("jackson3MapperBuilderCustomizer")
|
||||||
@ConditionalOnMissingBean(name = ["UUIDJsonConverterJsonMapperCustomizer"])
|
@ConditionalOnMissingBean(name = ["jackson3MapperBuilderCustomizer"])
|
||||||
fun jsonMapperBuilderCustomizer(builders: ObjectProvider<JacksonBuilder>): JsonMapperBuilderCustomizer {
|
fun jsonMapperBuilderCustomizer(builders: ObjectProvider<JacksonBuilder>): JsonMapperBuilderCustomizer {
|
||||||
val builderList = builders.orderedStream().toList()
|
val builderList = builders.orderedStream().toList()
|
||||||
var jacksonJsonBuilderImpl = JacksonJsonBuilderImpl()
|
var jacksonJsonBuilderImpl = JacksonJsonBuilderImpl()
|
||||||
@@ -52,7 +52,7 @@ open class Jackson3AutoConfiguration {
|
|||||||
it.addModules(
|
it.addModules(
|
||||||
*jacksonJsonBuilderImpl.getData().map { converter ->
|
*jacksonJsonBuilderImpl.getData().map { converter ->
|
||||||
converter.getJackson3Module().also { module ->
|
converter.getJackson3Module().also { module ->
|
||||||
log.info("Jackson3 Module Install ${module.moduleName}")
|
log.debug("Jackson3 Module Install {}", module.moduleName)
|
||||||
}
|
}
|
||||||
}.toTypedArray()
|
}.toTypedArray()
|
||||||
)
|
)
|
||||||
|
|||||||
+5
-3
@@ -16,7 +16,7 @@
|
|||||||
* ProjectName mingli-utils
|
* ProjectName mingli-utils
|
||||||
* ModuleName mingli-utils.main
|
* ModuleName mingli-utils.main
|
||||||
* CurrentFile JacksonJsonAutoConfiguration.kt
|
* CurrentFile JacksonJsonAutoConfiguration.kt
|
||||||
* LastUpdate 2026-11-09 14:19:05
|
* LastUpdate 2026-11-16 23:32:09
|
||||||
* UpdateUser MingLiPro
|
* UpdateUser MingLiPro
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -29,6 +29,7 @@ import com.mingliqiye.utils.springboot.autoconfigure.builder.JacksonJsonBuilderI
|
|||||||
import org.springframework.beans.factory.ObjectProvider
|
import org.springframework.beans.factory.ObjectProvider
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter
|
import org.springframework.boot.autoconfigure.AutoConfigureAfter
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
|
||||||
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer
|
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer
|
||||||
import org.springframework.context.annotation.Bean
|
import org.springframework.context.annotation.Bean
|
||||||
|
|
||||||
@@ -67,7 +68,8 @@ open class JacksonJsonAutoConfiguration {
|
|||||||
private val log = MingLiLoggerFactory.getLogger<JacksonJsonAutoConfiguration>()
|
private val log = MingLiLoggerFactory.getLogger<JacksonJsonAutoConfiguration>()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean("mingliUtilsJacksonObjectMapperBuilderCustomizer")
|
@Bean("jacksonMapperBuilderCustomizer")
|
||||||
|
@ConditionalOnMissingBean(name = ["jacksonMapperBuilderCustomizer"])
|
||||||
fun jackson2ObjectMapperBuilderCustomizer(builders: ObjectProvider<JacksonBuilder>): Jackson2ObjectMapperBuilderCustomizer {
|
fun jackson2ObjectMapperBuilderCustomizer(builders: ObjectProvider<JacksonBuilder>): Jackson2ObjectMapperBuilderCustomizer {
|
||||||
val builderList = builders.orderedStream().toList()
|
val builderList = builders.orderedStream().toList()
|
||||||
var jacksonJsonBuilderImpl = JacksonJsonBuilderImpl()
|
var jacksonJsonBuilderImpl = JacksonJsonBuilderImpl()
|
||||||
@@ -78,7 +80,7 @@ open class JacksonJsonAutoConfiguration {
|
|||||||
builder.modulesToInstall(
|
builder.modulesToInstall(
|
||||||
*jacksonJsonBuilderImpl.getData().map { converter ->
|
*jacksonJsonBuilderImpl.getData().map { converter ->
|
||||||
converter.getJacksonModule().also { module ->
|
converter.getJacksonModule().also { module ->
|
||||||
log.info("Jackson Module Install ${module.moduleName}")
|
log.debug("Jackson Module Install {}", module.moduleName)
|
||||||
}
|
}
|
||||||
}.toTypedArray()
|
}.toTypedArray()
|
||||||
)
|
)
|
||||||
|
|||||||
+3
-3
@@ -13,10 +13,10 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
*
|
||||||
* ProjectName FastBaseMapper.kt
|
* ProjectName mingli-utils
|
||||||
* ModuleName mingli-utils.main
|
* ModuleName mingli-utils.main
|
||||||
* CurrentFile Okhttp3AutoConfiguration.kt
|
* CurrentFile Okhttp3AutoConfiguration.kt
|
||||||
* LastUpdate 2026-10-26 23:22:18
|
* LastUpdate 2026-11-16 11:29:35
|
||||||
* UpdateUser MingLiPro
|
* UpdateUser MingLiPro
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ open class Okhttp3AutoConfiguration {
|
|||||||
b.build()
|
b.build()
|
||||||
}.also {
|
}.also {
|
||||||
okhttp = it
|
okhttp = it
|
||||||
log.info("load $connt OkhttpBuilder initialized OkHttpClient successfully")
|
log.info("load {} OkhttpBuilder initialized OkHttpClient successfully", connt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-27
@@ -16,38 +16,12 @@
|
|||||||
* ProjectName mingli-utils
|
* ProjectName mingli-utils
|
||||||
* ModuleName mingli-utils.main
|
* ModuleName mingli-utils.main
|
||||||
* CurrentFile JacksonBuilder.kt
|
* CurrentFile JacksonBuilder.kt
|
||||||
* LastUpdate 2026-11-09 14:39:28
|
* LastUpdate 2026-11-16 11:36:46
|
||||||
* UpdateUser MingLiPro
|
* UpdateUser MingLiPro
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.mingliqiye.utils.springboot.autoconfigure.builder
|
package com.mingliqiye.utils.springboot.autoconfigure.builder
|
||||||
|
|
||||||
import com.mingliqiye.utils.json.converters.base.JsonConverter
|
|
||||||
|
|
||||||
sealed class JacksonJsonBuilder {
|
|
||||||
abstract fun addJsonConverter(jsonConverter: JsonConverter<*, *>): JacksonJsonBuilder
|
|
||||||
abstract fun addJsonConverters(vararg jsonConverters: JsonConverter<*, *>): JacksonJsonBuilder
|
|
||||||
}
|
|
||||||
|
|
||||||
open class JacksonJsonBuilderImpl : JacksonJsonBuilder() {
|
|
||||||
override fun addJsonConverter(jsonConverter: JsonConverter<*, *>): JacksonJsonBuilderImpl {
|
|
||||||
data.add(jsonConverter)
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun addJsonConverters(vararg jsonConverters: JsonConverter<*, *>): JacksonJsonBuilder {
|
|
||||||
data.addAll(jsonConverters)
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
private val data = mutableListOf<JsonConverter<*, *>>()
|
|
||||||
|
|
||||||
fun getData(): List<JsonConverter<*, *>> {
|
|
||||||
return data.toList()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
fun interface JacksonBuilder {
|
fun interface JacksonBuilder {
|
||||||
fun customize(builder: JacksonJsonBuilder): JacksonJsonBuilder
|
fun customize(builder: JacksonJsonBuilder): JacksonJsonBuilder
|
||||||
|
|||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2026 mingliqiye
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
* ProjectName mingli-utils
|
||||||
|
* ModuleName mingli-utils.main
|
||||||
|
* CurrentFile JacksonJsonBuilder.kt
|
||||||
|
* LastUpdate 2026-11-16 11:36:46
|
||||||
|
* UpdateUser MingLiPro
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.mingliqiye.utils.springboot.autoconfigure.builder
|
||||||
|
|
||||||
|
import com.mingliqiye.utils.json.converters.base.JsonConverter
|
||||||
|
|
||||||
|
sealed class JacksonJsonBuilder {
|
||||||
|
abstract fun addJsonConverter(jsonConverter: JsonConverter<*, *>): JacksonJsonBuilder
|
||||||
|
abstract fun addJsonConverters(vararg jsonConverters: JsonConverter<*, *>): JacksonJsonBuilder
|
||||||
|
}
|
||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2026 mingliqiye
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
* ProjectName mingli-utils
|
||||||
|
* ModuleName mingli-utils.main
|
||||||
|
* CurrentFile JacksonJsonBuilderImpl.kt
|
||||||
|
* LastUpdate 2026-11-16 11:36:46
|
||||||
|
* UpdateUser MingLiPro
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.mingliqiye.utils.springboot.autoconfigure.builder
|
||||||
|
|
||||||
|
import com.mingliqiye.utils.json.converters.base.JsonConverter
|
||||||
|
|
||||||
|
open class JacksonJsonBuilderImpl : JacksonJsonBuilder() {
|
||||||
|
override fun addJsonConverter(jsonConverter: JsonConverter<*, *>): JacksonJsonBuilderImpl {
|
||||||
|
data.add(jsonConverter)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun addJsonConverters(vararg jsonConverters: JsonConverter<*, *>): JacksonJsonBuilder {
|
||||||
|
data.addAll(jsonConverters)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
private val data = mutableListOf<JsonConverter<*, *>>()
|
||||||
|
|
||||||
|
fun getData(): List<JsonConverter<*, *>> {
|
||||||
|
return data.toList()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
* ProjectName mingli-utils
|
* ProjectName mingli-utils
|
||||||
* ModuleName mingli-utils.main
|
* ModuleName mingli-utils.main
|
||||||
* CurrentFile DateTime.kt
|
* CurrentFile DateTime.kt
|
||||||
* LastUpdate 2026-03-14 16:12:08
|
* LastUpdate 2026-11-17 10:16:38
|
||||||
* UpdateUser MingLiPro
|
* UpdateUser MingLiPro
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -543,4 +543,9 @@ class DateTime private constructor(
|
|||||||
(it.epochSecond * 1000L) + (it.nano / 1_000_000L)
|
(it.epochSecond * 1000L) + (it.nano / 1_000_000L)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val epochSecond: Long
|
||||||
|
get() {
|
||||||
|
return toInstant().epochSecond
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
* ProjectName mingli-utils
|
* ProjectName mingli-utils
|
||||||
* ModuleName mingli-utils.main
|
* ModuleName mingli-utils.main
|
||||||
* CurrentFile UUID.kt
|
* CurrentFile UUID.kt
|
||||||
* LastUpdate 2026-06-21 10:40:58
|
* LastUpdate 2026-11-16 14:29:35
|
||||||
* UpdateUser MingLiPro
|
* UpdateUser MingLiPro
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -422,7 +422,7 @@ class UUID : Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun of(str: String, base: BaseType): UUID {
|
fun of(str: String, base: BaseType): UUID {
|
||||||
return UUID(base.baseCodec.decode(str))
|
return UUID(base.codec.decode(str))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -552,7 +552,7 @@ class UUID : Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getString(baseType: BaseType): String {
|
fun getString(baseType: BaseType): String {
|
||||||
return getString(baseType.baseCodec)
|
return getString(baseType.codec)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getString(baseCodec: BaseCodec): String {
|
fun getString(baseCodec: BaseCodec): String {
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright 2026 mingliqiye
|
||||||
|
~
|
||||||
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
~ you may not use this file except in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
~ See the License for the specific language governing permissions and
|
||||||
|
~ limitations under the License.
|
||||||
|
~
|
||||||
|
~ ProjectName mingli-utils
|
||||||
|
~ ModuleName mingli-utils.test
|
||||||
|
~ CurrentFile log4j2.xml
|
||||||
|
~ LastUpdate 2026-11-16 12:59:01
|
||||||
|
~ UpdateUser MingLiPro
|
||||||
|
-->
|
||||||
|
|
||||||
|
<Configuration status="WARN">
|
||||||
|
<Appenders>
|
||||||
|
<Console name="CONSOLE" target="SYSTEM_OUT">
|
||||||
|
<PatternLayout
|
||||||
|
pattern="%style{%d{yyyy-MM-dd HH:mm:ss.SSSSSSS}}{bright,magenta} %highlight{[%p]}{FATAL=white, ERROR=bright_red, WARN=bright_yellow, INFO=bright_green, DEBUG=bright_cyan, TRACE=bright_blue} [%style{%t}{bright,yellow}/%style{%c{1}}{bright,cyan}] -> %style{%m}{#EEDFCC}%n"/>
|
||||||
|
</Console>
|
||||||
|
<RollingFile name="FILE"
|
||||||
|
fileName="log/current.log"
|
||||||
|
filePattern="log/%d{yyyy/MM/dd}.log">
|
||||||
|
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSSSSSS} %p %t/%c/%C.%M(%F:%L) --> %m%n"/>
|
||||||
|
<Policies>
|
||||||
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
|
</Policies>
|
||||||
|
</RollingFile>
|
||||||
|
</Appenders>
|
||||||
|
<Loggers>
|
||||||
|
<Root level="DEBUG">
|
||||||
|
<AppenderRef ref="CONSOLE"/>
|
||||||
|
<AppenderRef ref="FILE"/>
|
||||||
|
</Root>
|
||||||
|
</Loggers>
|
||||||
|
</Configuration>
|
||||||
Reference in New Issue
Block a user