init repo
This commit is contained in:
31
.github/workflows/gradle.yml
vendored
Normal file
31
.github/workflows/gradle.yml
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
name: Java CI with Gradle (Kotlin)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: 21
|
||||
distribution: temurin
|
||||
- name: Validate Gradle wrapper
|
||||
uses: gradle/wrapper-validation-action@v1.0.4
|
||||
- name: Build with Gradle
|
||||
uses: gradle/gradle-build-action@v2.2.0
|
||||
with:
|
||||
arguments: build
|
||||
- uses: actions/upload-artifact@v3.1.0
|
||||
with:
|
||||
name: Build Artifacts
|
||||
path: |
|
||||
**/build/reports
|
15
.gitignore
vendored
Normal file
15
.gitignore
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
Thumbs.db
|
||||
.DS_Store
|
||||
.gradle
|
||||
build/
|
||||
target/
|
||||
out/
|
||||
.micronaut/
|
||||
.idea
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.project
|
||||
.settings
|
||||
.classpath
|
||||
.factorypath
|
83
README.md
Normal file
83
README.md
Normal file
@ -0,0 +1,83 @@
|
||||
## Micronaut 4.7.5 Documentation
|
||||
|
||||
- [User Guide](https://docs.micronaut.io/4.7.5/guide/index.html)
|
||||
- [API Reference](https://docs.micronaut.io/4.7.5/api/index.html)
|
||||
- [Configuration Reference](https://docs.micronaut.io/4.7.5/guide/configurationreference.html)
|
||||
- [Micronaut Guides](https://guides.micronaut.io/index.html)
|
||||
|
||||
---
|
||||
|
||||
- [Jib Gradle Plugin](https://plugins.gradle.org/plugin/com.google.cloud.tools.jib)
|
||||
- [Micronaut Gradle Plugin documentation](https://micronaut-projects.github.io/micronaut-gradle-plugin/latest/)
|
||||
- [GraalVM Gradle Plugin documentation](https://graalvm.github.io/native-build-tools/latest/gradle-plugin.html)
|
||||
- [Shadow Gradle Plugin](https://plugins.gradle.org/plugin/com.github.johnrengelman.shadow)
|
||||
|
||||
## Feature micronaut-aot documentation
|
||||
|
||||
- [Micronaut AOT documentation](https://micronaut-projects.github.io/micronaut-aot/latest/guide/)
|
||||
|
||||
## Feature openapi documentation
|
||||
|
||||
- [Micronaut OpenAPI Support documentation](https://micronaut-projects.github.io/micronaut-openapi/latest/guide/index.html)
|
||||
|
||||
- [https://www.openapis.org](https://www.openapis.org)
|
||||
|
||||
## Feature ksp documentation
|
||||
|
||||
- [Micronaut Kotlin Symbol Processing (KSP) documentation](https://docs.micronaut.io/latest/guide/#kotlin)
|
||||
|
||||
- [https://kotlinlang.org/docs/ksp-overview.html](https://kotlinlang.org/docs/ksp-overview.html)
|
||||
|
||||
## Feature views-thymeleaf documentation
|
||||
|
||||
- [Micronaut Thymeleaf Views documentation](https://micronaut-projects.github.io/micronaut-views/latest/guide/index.html#thymeleaf)
|
||||
|
||||
- [https://www.thymeleaf.org/](https://www.thymeleaf.org/)
|
||||
|
||||
## Feature data-jdbc documentation
|
||||
|
||||
- [Micronaut Data JDBC documentation](https://micronaut-projects.github.io/micronaut-data/latest/guide/index.html#jdbc)
|
||||
|
||||
## Feature flyway documentation
|
||||
|
||||
- [Micronaut Flyway Database Migration documentation](https://micronaut-projects.github.io/micronaut-flyway/latest/guide/index.html)
|
||||
|
||||
- [https://flywaydb.org/](https://flywaydb.org/)
|
||||
|
||||
## Feature serialization-jackson documentation
|
||||
|
||||
- [Micronaut Serialization Jackson Core documentation](https://micronaut-projects.github.io/micronaut-serialization/latest/guide/)
|
||||
|
||||
## Feature crac documentation
|
||||
|
||||
- [Micronaut Support for CRaC (Coordinated Restore at Checkpoint) documentation](https://micronaut-projects.github.io/micronaut-crac/latest/guide)
|
||||
|
||||
- [https://wiki.openjdk.org/display/CRaC](https://wiki.openjdk.org/display/CRaC)
|
||||
|
||||
## Feature spring documentation
|
||||
|
||||
- [Micronaut Spring Framework Annotations documentation](https://micronaut-projects.github.io/micronaut-spring/latest/guide/index.html)
|
||||
|
||||
## Feature github-workflow-ci documentation
|
||||
|
||||
- [https://docs.github.com/en/actions](https://docs.github.com/en/actions)
|
||||
|
||||
## Feature rss documentation
|
||||
|
||||
- [Micronaut RSS Feed documentation](https://micronaut-projects.github.io/micronaut-rss/latest/guide/index.html#whatsNew)
|
||||
|
||||
## Feature swagger-ui documentation
|
||||
|
||||
- [Micronaut Swagger UI documentation](https://micronaut-projects.github.io/micronaut-openapi/latest/guide/index.html)
|
||||
|
||||
- [https://swagger.io/tools/swagger-ui/](https://swagger.io/tools/swagger-ui/)
|
||||
|
||||
## Feature data-spring-jdbc documentation
|
||||
|
||||
- [Micronaut Data Spring JDBC documentation](https://micronaut-projects.github.io/micronaut-data/latest/guide/#spring)
|
||||
|
||||
## Feature jdbc-hikari documentation
|
||||
|
||||
- [Micronaut Hikari JDBC Connection Pool documentation](https://micronaut-projects.github.io/micronaut-sql/latest/guide/index.html#jdbc)
|
||||
|
||||
|
117
build.gradle.kts
Normal file
117
build.gradle.kts
Normal file
@ -0,0 +1,117 @@
|
||||
plugins {
|
||||
id("org.jetbrains.kotlin.jvm") version "1.9.25"
|
||||
id("org.jetbrains.kotlin.plugin.allopen") version "1.9.25"
|
||||
id("com.google.devtools.ksp") version "1.9.25-1.0.20"
|
||||
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||
id("io.micronaut.crac") version "4.4.4"
|
||||
id("io.micronaut.application") version "4.4.4"
|
||||
id("com.google.cloud.tools.jib") version "2.8.0"
|
||||
id("io.micronaut.aot") version "4.4.4"
|
||||
}
|
||||
|
||||
version = "0.1"
|
||||
group = "com.mazhangjing"
|
||||
|
||||
val kotlinVersion = project.properties.get("kotlinVersion")
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
ksp("io.micronaut.data:micronaut-data-processor")
|
||||
ksp("io.micronaut:micronaut-http-validation")
|
||||
ksp("io.micronaut.openapi:micronaut-openapi")
|
||||
ksp("io.micronaut.serde:micronaut-serde-processor")
|
||||
ksp("io.micronaut.spring:micronaut-spring-annotation")
|
||||
ksp("io.micronaut.spring:micronaut-spring-boot-annotation")
|
||||
ksp("io.micronaut.spring:micronaut-spring-web-annotation")
|
||||
implementation("io.micronaut:micronaut-http-server")
|
||||
implementation("io.micronaut.crac:micronaut-crac")
|
||||
implementation("io.micronaut.data:micronaut-data-jdbc")
|
||||
implementation("io.micronaut.data:micronaut-data-spring")
|
||||
implementation("io.micronaut.data:micronaut-data-spring-jdbc")
|
||||
implementation("io.micronaut.flyway:micronaut-flyway") {
|
||||
exclude(group = "org.flywaydb", module = "flyway-core")
|
||||
}
|
||||
implementation("org.flywaydb:flyway-core:10.20.1")
|
||||
implementation("io.micronaut.kotlin:micronaut-kotlin-extension-functions")
|
||||
implementation("io.micronaut.kotlin:micronaut-kotlin-runtime")
|
||||
implementation("io.micronaut.rss:micronaut-rss")
|
||||
implementation("io.micronaut.serde:micronaut-serde-jackson")
|
||||
implementation("io.micronaut.sql:micronaut-jdbc-hikari")
|
||||
implementation("io.micronaut.views:micronaut-views-fieldset")
|
||||
implementation("io.micronaut.views:micronaut-views-thymeleaf")
|
||||
implementation("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}")
|
||||
implementation("org.springframework:spring-jdbc")
|
||||
implementation("org.springframework.boot:spring-boot-starter")
|
||||
implementation("org.springframework.boot:spring-boot-starter-web")
|
||||
compileOnly("io.micronaut:micronaut-http-client")
|
||||
compileOnly("io.micronaut.openapi:micronaut-openapi-annotations")
|
||||
runtimeOnly("ch.qos.logback:logback-classic")
|
||||
runtimeOnly("com.fasterxml.jackson.module:jackson-module-kotlin")
|
||||
runtimeOnly("com.h2database:h2")
|
||||
runtimeOnly("io.micronaut.spring:micronaut-spring-boot")
|
||||
runtimeOnly("io.micronaut.spring:micronaut-spring-web")
|
||||
runtimeOnly("org.yaml:snakeyaml")
|
||||
kspTest("io.micronaut.spring:micronaut-spring-boot-annotation")
|
||||
kspTest("io.micronaut.spring:micronaut-spring-web-annotation")
|
||||
testImplementation("io.micronaut:micronaut-http-client")
|
||||
}
|
||||
|
||||
application {
|
||||
mainClass = "com.mazhangjing.ApplicationKt"
|
||||
}
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.toVersion("21")
|
||||
}
|
||||
|
||||
|
||||
tasks {
|
||||
jib {
|
||||
to {
|
||||
image = "gcr.io/myapp/jib-image"
|
||||
}
|
||||
}
|
||||
}
|
||||
graalvmNative.toolchainDetection = false
|
||||
|
||||
graalvmNative {
|
||||
binaries {
|
||||
named("main") {
|
||||
imageName.set("story")
|
||||
buildArgs.add("-Ob")
|
||||
}
|
||||
}
|
||||
// metadataRepository {
|
||||
// moduleToConfigVersion.put("org.flywaydb:flyway-core", "10.20.1")
|
||||
// }
|
||||
}
|
||||
|
||||
micronaut {
|
||||
runtime("netty")
|
||||
testRuntime("junit5")
|
||||
processing {
|
||||
incremental(true)
|
||||
annotations("com.mazhangjing.*")
|
||||
}
|
||||
aot {
|
||||
// Please review carefully the optimizations enabled below
|
||||
// Check https://micronaut-projects.github.io/micronaut-aot/latest/guide/ for more details
|
||||
optimizeServiceLoading = false
|
||||
convertYamlToJava = false
|
||||
precomputeOperations = true
|
||||
cacheEnvironment = true
|
||||
optimizeClassLoading = true
|
||||
deduceEnvironment = true
|
||||
optimizeNetty = true
|
||||
replaceLogbackXml = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
tasks.named<io.micronaut.gradle.docker.NativeImageDockerfile>("dockerfileNative") {
|
||||
jdkVersion = "21"
|
||||
}
|
||||
|
||||
|
3
gradle.properties
Normal file
3
gradle.properties
Normal file
@ -0,0 +1,3 @@
|
||||
micronautVersion=4.7.5
|
||||
kotlinVersion=1.9.25
|
||||
org.gradle.jvmargs=-Xmx4096M
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
252
gradlew
vendored
Normal file
252
gradlew
vendored
Normal file
@ -0,0 +1,252 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# https://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.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||
' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
94
gradlew.bat
vendored
Normal file
94
gradlew.bat
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
6
micronaut-cli.yml
Normal file
6
micronaut-cli.yml
Normal file
@ -0,0 +1,6 @@
|
||||
applicationType: default
|
||||
defaultPackage: com.mazhangjing
|
||||
testFramework: junit
|
||||
sourceLanguage: kotlin
|
||||
buildTool: gradle_kotlin
|
||||
features: [ app-name, crac, data, data-jdbc, data-spring-jdbc, flyway, github-workflow-ci, graalvm, gradle, h2, http-client-test, jdbc-hikari, jib, junit, kotlin, kotlin-application, kotlin-extension-functions, ksp, logback, micronaut-aot, micronaut-build, micronaut-http-validation, netty-server, openapi, readme, rss, serialization-jackson, shade, spring, spring-boot, spring-data-jdbc, spring-web, static-resources, swagger-ui, views-fieldset, views-thymeleaf, yaml, yaml-build ]
|
7
openapi.properties
Normal file
7
openapi.properties
Normal file
@ -0,0 +1,7 @@
|
||||
swagger-ui.enabled=true
|
||||
redoc.enabled=false
|
||||
openapi-explorer.enabled=false
|
||||
rapidoc.enabled=false
|
||||
rapidoc.bg-color=#14191f
|
||||
rapidoc.text-color=#aec2e0
|
||||
rapidoc.sort-endpoints-by=method
|
2
settings.gradle.kts
Normal file
2
settings.gradle.kts
Normal file
@ -0,0 +1,2 @@
|
||||
rootProject.name = "story"
|
||||
|
21
src/main/kotlin/com/mazhangjing/Application.kt
Normal file
21
src/main/kotlin/com/mazhangjing/Application.kt
Normal file
@ -0,0 +1,21 @@
|
||||
package com.mazhangjing
|
||||
|
||||
import io.micronaut.context.ApplicationContextBuilder
|
||||
import io.micronaut.context.ApplicationContextConfigurer
|
||||
import io.micronaut.context.annotation.ContextConfigurer
|
||||
import io.micronaut.runtime.Micronaut.run
|
||||
import io.swagger.v3.oas.annotations.*
|
||||
import io.swagger.v3.oas.annotations.info.*
|
||||
|
||||
@OpenAPIDefinition(
|
||||
info = Info(
|
||||
title = "story",
|
||||
version = "0.0"
|
||||
)
|
||||
)
|
||||
object Api
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
run(*args)
|
||||
}
|
||||
|
47
src/main/kotlin/com/mazhangjing/StoryController.kt
Normal file
47
src/main/kotlin/com/mazhangjing/StoryController.kt
Normal file
@ -0,0 +1,47 @@
|
||||
package com.mazhangjing
|
||||
|
||||
import io.micronaut.http.HttpResponse
|
||||
import io.micronaut.http.annotation.Controller
|
||||
import io.micronaut.http.annotation.Get
|
||||
import io.micronaut.http.HttpStatus
|
||||
import io.micronaut.http.annotation.PathVariable
|
||||
import io.micronaut.http.annotation.QueryValue
|
||||
|
||||
@Controller("/")
|
||||
class StoryController(
|
||||
private val repository: StoryRepository
|
||||
) {
|
||||
|
||||
@Get(uri = "/", produces = ["text/plain"])
|
||||
fun index(): String {
|
||||
return "Example Response"
|
||||
}
|
||||
|
||||
@Get(uri = "/all", produces = ["application/json"])
|
||||
fun all(): List<Story> {
|
||||
return repository.findAll()
|
||||
}
|
||||
|
||||
@Get(uri = "/delete/{id}", produces = ["application/json"])
|
||||
fun deleteById(@PathVariable id: Long): Map<String, String> {
|
||||
repository.deleteById(id)
|
||||
return mapOf("result" to "OK")
|
||||
}
|
||||
|
||||
@Get("/{id}", produces = ["application/json"])
|
||||
fun findById(@PathVariable id: Long): Any? {
|
||||
return repository.findById(id).orElse(null) ?: HttpResponse.notFound("story not found");
|
||||
}
|
||||
|
||||
@Get("/add", produces = ["application/json"])
|
||||
fun add(@QueryValue name: String, @QueryValue content: String): Map<String, Any> {
|
||||
val res = repository.save(
|
||||
Story(
|
||||
id = null,
|
||||
title = name,
|
||||
content = content
|
||||
)
|
||||
)
|
||||
return mapOf("result" to "OK", "story" to res)
|
||||
}
|
||||
}
|
22
src/main/kotlin/com/mazhangjing/StoryService.kt
Normal file
22
src/main/kotlin/com/mazhangjing/StoryService.kt
Normal file
@ -0,0 +1,22 @@
|
||||
package com.mazhangjing
|
||||
|
||||
import io.micronaut.data.annotation.GeneratedValue
|
||||
import io.micronaut.data.annotation.Id
|
||||
import io.micronaut.data.annotation.MappedEntity
|
||||
import io.micronaut.data.jdbc.annotation.JdbcRepository
|
||||
import io.micronaut.data.model.query.builder.sql.Dialect
|
||||
import io.micronaut.data.repository.CrudRepository
|
||||
import io.micronaut.serde.annotation.Serdeable
|
||||
|
||||
@MappedEntity
|
||||
@Serdeable
|
||||
data class Story(
|
||||
@field:Id
|
||||
@field:GeneratedValue
|
||||
val id: Long? = null,
|
||||
val title: String,
|
||||
val content: String,
|
||||
)
|
||||
|
||||
@JdbcRepository(dialect = Dialect.H2)
|
||||
interface StoryRepository: CrudRepository<Story, Long>
|
24
src/main/resources/application.yml
Normal file
24
src/main/resources/application.yml
Normal file
@ -0,0 +1,24 @@
|
||||
micronaut:
|
||||
application:
|
||||
name: story
|
||||
router:
|
||||
static-resources:
|
||||
swagger:
|
||||
paths: classpath:META-INF/swagger
|
||||
mapping: /swagger/**
|
||||
swagger-ui:
|
||||
paths: classpath:META-INF/swagger/views/swagger-ui
|
||||
mapping: /swagger-ui/**
|
||||
datasources:
|
||||
default:
|
||||
url: jdbc:h2:mem:devDb;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
|
||||
username: sa
|
||||
password: ''
|
||||
driver-class-name: org.h2.Driver
|
||||
dialect: H2
|
||||
allow-pool-suspension: true
|
||||
transaction-manager: springJdbc
|
||||
flyway:
|
||||
datasources:
|
||||
default:
|
||||
enabled: true
|
12
src/main/resources/db/migration/V1__create_story_db.sql
Normal file
12
src/main/resources/db/migration/V1__create_story_db.sql
Normal file
@ -0,0 +1,12 @@
|
||||
CREATE TABLE story
|
||||
(
|
||||
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
content TEXT NOT NULL
|
||||
);
|
||||
|
||||
---
|
||||
INSERT INTO story(id, title, content)
|
||||
values (1, 'Hello', 'World');
|
||||
INSERT INTO story(id, title, content)
|
||||
values (2, 'Again', 'World');
|
15
src/main/resources/logback.xml
Normal file
15
src/main/resources/logback.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<configuration>
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<!-- encoders are assigned the type
|
||||
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
|
||||
<encoder>
|
||||
<pattern>%cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
</configuration>
|
4
src/main/resources/views/fieldset/errors.html
Normal file
4
src/main/resources/views/fieldset/errors.html
Normal file
@ -0,0 +1,4 @@
|
||||
<th:block th:fragment="errors(name,errors)" xmlns:th="http://www.thymeleaf.org" th:each="error : ${errors}">
|
||||
<div th:id="|${name}ValidationServerFeedback|" class="invalid-feedback"
|
||||
th:text="${#strings.defaultString(#messages.msgOrNull(error.code()),error.defaultMessage())}"></div>
|
||||
</th:block>
|
52
src/main/resources/views/fieldset/fieldset.html
Normal file
52
src/main/resources/views/fieldset/fieldset.html
Normal file
@ -0,0 +1,52 @@
|
||||
<th:block th:each="field : ${el.fields()}" th:fragment="fieldset(el)" xmlns:th="http://www.thymeleaf.org">
|
||||
<th:block th:if="${field.tag.toString() == 'input' && field.type.toString() == 'file'}"><input
|
||||
th:replace="~{fieldset/inputfile :: inputfile(${field})}"/></th:block>
|
||||
<th:block th:if="${field.tag.toString() == 'input' && field.type.toString() == 'hidden'}"><input
|
||||
th:replace="~{fieldset/inputhidden :: inputhidden(${field})}"/></th:block>
|
||||
<th:block th:if="${field.tag.toString() == 'input' && field.type.toString() == 'password'}">
|
||||
<div class="mb-3" th:insert="~{fieldset/inputstring :: inputstring('password',${field})}"/>
|
||||
</th:block>
|
||||
<th:block th:if="${field.tag.toString() == 'textarea'}">
|
||||
<div class="mb-3" th:insert="~{fieldset/textarea :: textarea(${field})}"/>
|
||||
</th:block>
|
||||
<th:block th:if="${field.tag.toString() == 'input' && field.type.toString() == 'number'}">
|
||||
<div class="mb-3" th:insert="~{fieldset/inputnumber :: inputnumber(${field})}"/>
|
||||
</th:block>
|
||||
<th:block th:if="${field.tag.toString() == 'input' && field.type.toString() == 'submit'}">
|
||||
<div th:replace="~{fieldset/inputsubmit :: inputsubmit(${field})}"/>
|
||||
</th:block>
|
||||
<th:block th:if="${field.tag.toString() == 'input' && field.type.toString() == 'datetime-local'}">
|
||||
<div class="mb-3" th:insert="~{fieldset/inputdatetimelocal :: inputdatetimelocal(${field})}"></div>
|
||||
</th:block>
|
||||
<th:block th:if="${field.tag.toString() == 'input' && field.type.toString() == 'date'}">
|
||||
<div class="mb-3" th:insert="~{fieldset/inputdate :: inputdate(${field})}"></div>
|
||||
</th:block>
|
||||
<th:block th:if="${field.tag.toString() == 'input' && field.type.toString() == 'time'}">
|
||||
<div class="mb-3" th:insert="~{fieldset/inputtime :: inputtime(${field})}"></div>
|
||||
</th:block>
|
||||
<th:block th:if="${field.tag.toString() == 'input' && field.type.toString() == 'text'}">
|
||||
<div class="mb-3" th:insert="~{fieldset/inputstring :: inputstring('text', ${field})}"></div>
|
||||
</th:block>
|
||||
<th:block th:if="${field.tag.toString() == 'input' && field.type.toString() == 'email'}">
|
||||
<div class="mb-3" th:insert="~{fieldset/inputstring :: inputstring('email', ${field})}"></div>
|
||||
</th:block>
|
||||
<th:block th:if="${field.tag.toString() == 'input' && field.type.toString() == 'tel'}">
|
||||
<div class="mb-3" th:insert="~{fieldset/inputstring :: inputstring('tel', ${field})}"></div>
|
||||
</th:block>
|
||||
<th:block th:if="${field.tag.toString() == 'input' && field.type.toString() == 'url'}">
|
||||
<div class="mb-3" th:insert="~{fieldset/inputstring :: inputstring('url', ${field})}"></div>
|
||||
</th:block>
|
||||
<th:block th:if="${field.tag.toString() == 'input' && field.type.toString() == 'radio'}">
|
||||
<div class="mb-3" th:insert="~{fieldset/inputradios :: inputradios(${field})}"></div>
|
||||
</th:block>
|
||||
<th:block th:if="${field.tag.toString() == 'input' && field.type.toString() == 'checkbox'}">
|
||||
<div class="mb-3" th:insert="~{fieldset/inputcheckbox :: inputcheckbox(${field})}"></div>
|
||||
</th:block>
|
||||
<th:block th:if="${field.tag.toString() == 'select'}">
|
||||
<div class="mb-3" th:insert="~{fieldset/select :: select(${field})}"></div>
|
||||
</th:block>
|
||||
<th:block th:if="${field.tag.toString() == 'trix-editor'}">
|
||||
<div class="mb-3" th:if="${el.hasErrors()}" th:insert="~{fieldset/errors :: errors(${el.errors()})}"></div>
|
||||
<div class="mb-3" th:insert="~{fieldset/trixeditor :: trixeditor(${field})}"></div>
|
||||
</th:block>
|
||||
</th:block>
|
6
src/main/resources/views/fieldset/form.html
Normal file
6
src/main/resources/views/fieldset/form.html
Normal file
@ -0,0 +1,6 @@
|
||||
<th:block th:fragment="form(form)" xmlns:th="http://www.thymeleaf.org">
|
||||
<form th:action="${form.action()}" th:method="${form.method()}" th:enctype="${form.enctype()}"
|
||||
th:data-turbo="${form.dataturbo()}">
|
||||
<fieldset th:replace="~{fieldset/fieldset :: fieldset(${form.fieldset()})}"></fieldset>
|
||||
</form>
|
||||
</th:block>
|
13
src/main/resources/views/fieldset/inputcheckbox.html
Normal file
13
src/main/resources/views/fieldset/inputcheckbox.html
Normal file
@ -0,0 +1,13 @@
|
||||
<th:block th:fragment="inputcheckbox(el)" xmlns:th="http://www.thymeleaf.org">
|
||||
<th:block th:if="${el.label() && el.checkboxes().size() > 1}"><label
|
||||
th:replace="~{fieldset/label :: label(null, ${el.label()})}"></label></th:block>
|
||||
<div class="form-check" th:each="checkbox : ${el.checkboxes()}"><input type="checkbox" th:name="${checkbox.name()}"
|
||||
th:value="${checkbox.value()}"
|
||||
th:id="${checkbox.id()}"
|
||||
class="form-check-input"
|
||||
th:required="${checkbox.required()}"
|
||||
th:disabled="${checkbox.disabled()}"
|
||||
th:checked="${checkbox.checked()}"
|
||||
th:classappend="${el.hasErrors() ? 'is-invalid' : ''}"/><label
|
||||
th:replace="~{fieldset/label :: label(${checkbox.id()}, ${checkbox.label()})}"></label></div>
|
||||
</th:block>
|
14
src/main/resources/views/fieldset/inputdate.html
Normal file
14
src/main/resources/views/fieldset/inputdate.html
Normal file
@ -0,0 +1,14 @@
|
||||
<th:block th:fragment="inputdate(el)" xmlns:th="http://www.thymeleaf.org"><label
|
||||
th:replace="~{fieldset/label :: label(${el.id()}, ${el.label()})}"></label><input th:type="date"
|
||||
th:name="${el.name()}"
|
||||
th:value="${el.value()}"
|
||||
th:id="${el.id()}"
|
||||
th:min="${el.min()}"
|
||||
th:max="${el.max()}"
|
||||
th:step="${el.step()}"
|
||||
th:required="${el.required()}"
|
||||
class="form-control"
|
||||
th:classappend="${el.hasErrors()} ? is-invalid"
|
||||
th:attr="aria-describedby=${el.hasErrors}?|${el.name}ValidationServerFeedback|"/>
|
||||
<div th:if="${el.hasErrors()}" th:replace="~{fieldset/errors :: errors(${el.name()}, ${el.errors()})}"></div>
|
||||
</th:block>
|
14
src/main/resources/views/fieldset/inputdatetimelocal.html
Normal file
14
src/main/resources/views/fieldset/inputdatetimelocal.html
Normal file
@ -0,0 +1,14 @@
|
||||
<th:block th:fragment="inputdatetimelocal(el)" xmlns:th="http://www.thymeleaf.org"><label
|
||||
th:replace="~{fieldset/label :: label(${el.id()}, ${el.label()})}"></label><input th:type="datetime-local"
|
||||
th:name="${el.name()}"
|
||||
th:value="${el.value()}"
|
||||
th:id="${el.id()}"
|
||||
th:min="${el.min()}"
|
||||
th:max="${el.max()}"
|
||||
th:step="${el.step()}"
|
||||
th:required="${el.required()}"
|
||||
class="form-control"
|
||||
th:classappend="${el.hasErrors()} ? is-invalid"
|
||||
th:attr="aria-describedby=${el.hasErrors}?|${el.name}ValidationServerFeedback|"/>
|
||||
<div th:if="${el.hasErrors()}" th:replace="~{fieldset/errors :: errors(${el.name()}, ${el.errors()})}"></div>
|
||||
</th:block>
|
2
src/main/resources/views/fieldset/inputemail.html
Normal file
2
src/main/resources/views/fieldset/inputemail.html
Normal file
@ -0,0 +1,2 @@
|
||||
<th:block th:fragment="inputemail(el)" xmlns:th="http://www.thymeleaf.org"><input
|
||||
th:replace="~{fieldset/inputstring :: inputstring('email', ${el})}"/></th:block>
|
11
src/main/resources/views/fieldset/inputfile.html
Normal file
11
src/main/resources/views/fieldset/inputfile.html
Normal file
@ -0,0 +1,11 @@
|
||||
<th:block th:fragment="inputfile(el)" xmlns:th="http://www.thymeleaf.org"><label
|
||||
th:replace="~{fieldset/label :: label(${el.id()}, ${el.label()})}"></label><input th:type="file"
|
||||
th:name="${el.name()}"
|
||||
th:id="${el.id()}"
|
||||
th:accept="${el.accept()}"
|
||||
th:required="${el.required()}"
|
||||
class="form-control"
|
||||
th:classappend="${el.hasErrors()} ? is-invalid"
|
||||
th:attr="aria-describedby=${el.hasErrors}?|${el.name}ValidationServerFeedback|"/>
|
||||
<div th:if="${el.hasErrors()}" th:replace="~{fieldset/errors :: errors(${el.name()}, ${el.errors()})}"></div>
|
||||
</th:block>
|
2
src/main/resources/views/fieldset/inputhidden.html
Normal file
2
src/main/resources/views/fieldset/inputhidden.html
Normal file
@ -0,0 +1,2 @@
|
||||
<input th:fragment="inputhidden(el)" xmlns:th="http://www.thymeleaf.org" type="hidden" th:name="${el.name()}"
|
||||
th:value="${el.value()}"/>
|
16
src/main/resources/views/fieldset/inputnumber.html
Normal file
16
src/main/resources/views/fieldset/inputnumber.html
Normal file
@ -0,0 +1,16 @@
|
||||
<th:block th:fragment="inputnumber(el)" xmlns:th="http://www.thymeleaf.org"><label
|
||||
th:replace="~{fieldset/label :: label(${el.id()}, ${el.label()})}"></label><input th:type="number"
|
||||
th:name="${el.name()}"
|
||||
th:value="${el.value()}"
|
||||
th:id="${el.id()}"
|
||||
th:min="${el.min()}"
|
||||
th:max="${el.max()}"
|
||||
th:step="${el.step()}"
|
||||
th:placeholder="${el.placeholder()}"
|
||||
th:readOnly="${el.readOnly()}"
|
||||
th:required="${el.required()}"
|
||||
class="form-control"
|
||||
th:classappend="${el.hasErrors()} ? is-invalid"
|
||||
th:attr="aria-describedby=${el.hasErrors}?|${el.name}ValidationServerFeedback|"/>
|
||||
<div th:if="${el.hasErrors()}" th:replace="~{fieldset/errors :: errors(${el.name()}, ${el.errors()})}"></div>
|
||||
</th:block>
|
2
src/main/resources/views/fieldset/inputpassword.html
Normal file
2
src/main/resources/views/fieldset/inputpassword.html
Normal file
@ -0,0 +1,2 @@
|
||||
<th:block th:fragment="inputpassword(el)" xmlns:th="http://www.thymeleaf.org"><input
|
||||
th:replace="~{fieldset/inputstring :: inputstring('password', ${el})}"/></th:block>
|
3
src/main/resources/views/fieldset/inputradio.html
Normal file
3
src/main/resources/views/fieldset/inputradio.html
Normal file
@ -0,0 +1,3 @@
|
||||
<input th:fragment="inputradio(el,radio)" xmlns:th="http://www.thymeleaf.org" type="radio" th:name="${el.name()}"
|
||||
th:value="${radio.value()}" th:id="${radio.id()}" class="form-check-input" th:required="${el.required()}"
|
||||
th:disabled="${radio.disabled()}" th:checked="${radio.checked()}"/>
|
3
src/main/resources/views/fieldset/inputradios.html
Normal file
3
src/main/resources/views/fieldset/inputradios.html
Normal file
@ -0,0 +1,3 @@
|
||||
<div th:fragment="inputradios(el)" xmlns:th="http://www.thymeleaf.org" class="form-check"
|
||||
th:each="radio : ${el.buttons()}"><input th:replace="~{fieldset/inputradio :: inputradio(${el}, ${radio})}"/><label
|
||||
th:replace="~{fieldset/label :: label(${radio.id()}, ${radio.label()})}"></label></div>
|
17
src/main/resources/views/fieldset/inputstring.html
Normal file
17
src/main/resources/views/fieldset/inputstring.html
Normal file
@ -0,0 +1,17 @@
|
||||
<th:block th:fragment="inputstring(type, el)" xmlns:th="http://www.thymeleaf.org"><label
|
||||
th:replace="~{fieldset/label :: label(${el.id()}, ${el.label()})}"></label><input th:type="${type}"
|
||||
th:name="${el.name()}"
|
||||
th:value="${el.value()}"
|
||||
th:id="${el.id()}"
|
||||
th:placeholder="${el.placeholder()}"
|
||||
th:pattern="${el.pattern()}"
|
||||
th:minlength="${el.minLength()}"
|
||||
th:maxlength="${el.maxLength()}"
|
||||
th:size="${el.size()}"
|
||||
th:readOnly="${el.readOnly()}"
|
||||
th:required="${el.required()}"
|
||||
class="form-control"
|
||||
th:classappend="${el.hasErrors()} ? is-invalid"
|
||||
th:attr="aria-describedby=${el.hasErrors}?|${el.name}ValidationServerFeedback|"/>
|
||||
<div th:if="${el.hasErrors()}" th:replace="~{fieldset/errors :: errors(${el.name()}, ${el.errors()})}"></div>
|
||||
</th:block>
|
6
src/main/resources/views/fieldset/inputsubmit.html
Normal file
6
src/main/resources/views/fieldset/inputsubmit.html
Normal file
@ -0,0 +1,6 @@
|
||||
<th:block th:fragment="inputsubmit(el)" xmlns:th="http://www.thymeleaf.org"><input th:if="${el.value().code() != null}"
|
||||
type="submit"
|
||||
th:value="${#strings.defaultString(#messages.msgOrNull(el.value().code()),el.value().defaultMessage())}"
|
||||
class="btn btn-primary"/><input
|
||||
th:unless="${el.value().code() != null}" type="submit" th:value="${el.value().defaultMessage()}"
|
||||
class="btn btn-primary"/></th:block>
|
2
src/main/resources/views/fieldset/inputtel.html
Normal file
2
src/main/resources/views/fieldset/inputtel.html
Normal file
@ -0,0 +1,2 @@
|
||||
<th:block th:fragment="inputtel(el)" xmlns:th="http://www.thymeleaf.org"><input
|
||||
th:replace="~{fieldset/inputstring :: inputstring('tel', ${el})}"/></th:block>
|
2
src/main/resources/views/fieldset/inputtext.html
Normal file
2
src/main/resources/views/fieldset/inputtext.html
Normal file
@ -0,0 +1,2 @@
|
||||
<th:block th:fragment="inputtext(el)" xmlns:th="http://www.thymeleaf.org"><input
|
||||
th:replace="~{fieldset/inputstring :: inputstring('text', ${el})}"/></th:block>
|
13
src/main/resources/views/fieldset/inputtime.html
Normal file
13
src/main/resources/views/fieldset/inputtime.html
Normal file
@ -0,0 +1,13 @@
|
||||
<th:block th:fragment="inputtime(el)" xmlns:th="http://www.thymeleaf.org"><label
|
||||
th:replace="~{fieldset/label :: label(${el.id()}, ${el.label()})}"></label><input th:type="time"
|
||||
th:name="${el.name()}"
|
||||
th:value="${el.value()}"
|
||||
th:id="${el.id()}"
|
||||
th:min="${el.min()}"
|
||||
th:max="${el.max()}"
|
||||
th:required="${el.required()}"
|
||||
class="form-control"
|
||||
th:classappend="${el.hasErrors()} ? is-invalid"
|
||||
th:attr="aria-describedby=${el.hasErrors}?|${el.name}ValidationServerFeedback|"/>
|
||||
<div th:if="${el.hasErrors()}" th:replace="~{fieldset/errors :: errors(${el.name()}, ${el.errors()})}"></div>
|
||||
</th:block>
|
2
src/main/resources/views/fieldset/inputurl.html
Normal file
2
src/main/resources/views/fieldset/inputurl.html
Normal file
@ -0,0 +1,2 @@
|
||||
<th:block th:fragment="inputurl(el)" xmlns:th="http://www.thymeleaf.org"><input
|
||||
th:replace="~{fieldset/inputstring :: inputstring('url', ${el})}"/></th:block>
|
6
src/main/resources/views/fieldset/label.html
Normal file
6
src/main/resources/views/fieldset/label.html
Normal file
@ -0,0 +1,6 @@
|
||||
<th:block th:fragment="label(id, el)" xmlns:th="http://www.thymeleaf.org"><label th:if="${el.code()}"
|
||||
th:for="${id != null ? id : null}"
|
||||
th:text="${#strings.defaultString(#messages.msgOrNull(el.code()),el.defaultMessage())}"
|
||||
class="form-label"></label><label
|
||||
th:unless="${el.code()}" th:for="${id != null ? id : null}" th:text="${el.defaultMessage()}"
|
||||
class="form-label"></label></th:block>
|
7
src/main/resources/views/fieldset/option.html
Normal file
7
src/main/resources/views/fieldset/option.html
Normal file
@ -0,0 +1,7 @@
|
||||
<th:block th:fragment="option(el)" xmlns:th="http://www.thymeleaf.org">
|
||||
<option th:if="${el.label().code() != null}" th:value="${el.value()}"
|
||||
th:text="${#strings.defaultString(#messages.msgOrNull(el.label().code()),el.label().defaultMessage())}"
|
||||
th:selected="${el.selected()}" th:disabled="${el.disabled()}"></option>
|
||||
<option th:unless="${el.label().code() != null}" th:value="${el.value()}" th:text="${el.label().defaultMessage()}"
|
||||
th:selected="${el.selected()}" th:disabled="${el.disabled()}"></option>
|
||||
</th:block>
|
13
src/main/resources/views/fieldset/select.html
Normal file
13
src/main/resources/views/fieldset/select.html
Normal file
@ -0,0 +1,13 @@
|
||||
<th:block th:fragment="select(el)" xmlns:th="http://www.thymeleaf.org"><label
|
||||
th:replace="~{fieldset/label :: label(${el.id()}, ${el.label()})}"></label><select th:name="${el.name()}"
|
||||
th:id="${el.id()}"
|
||||
class="form-select"
|
||||
th:classappend="${el.hasErrors()} ? is-invalid"
|
||||
th:attr="aria-describedby=${el.hasErrors}?|${el.name}ValidationServerFeedback|"
|
||||
th:required="${el.required()}">
|
||||
<th:block th:each="option : ${el.options()}">
|
||||
<option th:replace="~{fieldset/option :: option(${option})}"></option>
|
||||
</th:block>
|
||||
</select>
|
||||
<div th:if="${el.hasErrors()}" th:replace="~{fieldset/errors :: errors(${el.name()}, ${el.errors()})}"></div>
|
||||
</th:block>
|
11
src/main/resources/views/fieldset/textarea.html
Normal file
11
src/main/resources/views/fieldset/textarea.html
Normal file
@ -0,0 +1,11 @@
|
||||
<th:block th:fragment="textarea(el)" xmlns:th="http://www.thymeleaf.org"><label
|
||||
th:replace="~{fieldset/label :: label(${el.id()},${el.label()})}"/><textarea th:name="${el.name()}"
|
||||
th:text="${el.value()}"
|
||||
th:id="${el.id()}"
|
||||
th:cols="${el.cols()}"
|
||||
th:rows="${el.rows()}"
|
||||
class="form-control"
|
||||
th:classappend="${el.hasErrors()} ? is-invalid"
|
||||
th:attr="aria-describedby=${el.hasErrors}?|${el.name}ValidationServerFeedback|"/>
|
||||
<div th:if="${el.hasErrors()}" th:replace="~{fieldset/errors :: errors(${el.name()}, ${el.errors()})}"></div>
|
||||
</th:block>
|
6
src/main/resources/views/fieldset/trixeditor.html
Normal file
6
src/main/resources/views/fieldset/trixeditor.html
Normal file
@ -0,0 +1,6 @@
|
||||
<th:block th:fragment="trixeditor(el)" xmlns:th="http://www.thymeleaf.org"><label
|
||||
th:replace="~{fieldset/label :: label(${el.id()},${el.label()})}"/><input type="hidden" th:name="${el.name()}"
|
||||
th:value="${el.value()}"
|
||||
th:id="${el.id()}"/>
|
||||
<trix-editor th:input="${el.id()}"></trix-editor>
|
||||
</th:block>
|
14
src/main/resources/views/layout.html
Normal file
14
src/main/resources/views/layout.html
Normal file
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" th:fragment="layout(title, script, content)" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title th:replace="${title}"></title>
|
||||
<script th:replace="${script}"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div th:replace="${content}"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
20
src/test/kotlin/com/mazhangjing/StoryTest.kt
Normal file
20
src/test/kotlin/com/mazhangjing/StoryTest.kt
Normal file
@ -0,0 +1,20 @@
|
||||
package com.mazhangjing
|
||||
|
||||
import io.micronaut.runtime.EmbeddedApplication
|
||||
import io.micronaut.test.extensions.junit5.annotation.MicronautTest
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
import jakarta.inject.Inject
|
||||
|
||||
@MicronautTest
|
||||
class StoryTest {
|
||||
|
||||
@Inject
|
||||
lateinit var application: EmbeddedApplication<*>
|
||||
|
||||
@Test
|
||||
fun testItWorks() {
|
||||
Assertions.assertTrue(application.isRunning)
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user