Browse Source

0525 springboot + mybatis plus

Qing 11 months ago
parent
commit
4809e1a0e0
44 changed files with 1821 additions and 6 deletions
  1. 33 0
      novel-demo/.gitignore
  2. 18 0
      novel-demo/.mvn/wrapper/maven-wrapper.properties
  3. 250 0
      novel-demo/mvnw
  4. 146 0
      novel-demo/mvnw.cmd
  5. 86 0
      novel-demo/pom.xml
  6. 15 0
      novel-demo/src/main/java/com/sf/NovelDemoApplication.java
  7. 18 0
      novel-demo/src/main/java/com/sf/controller/BookChapterController.java
  8. 18 0
      novel-demo/src/main/java/com/sf/controller/BookContentController.java
  9. 35 0
      novel-demo/src/main/java/com/sf/controller/BookInfoController.java
  10. 18 0
      novel-demo/src/main/java/com/sf/controller/HomeBookController.java
  11. 131 0
      novel-demo/src/main/java/com/sf/entity/BookChapter.java
  12. 92 0
      novel-demo/src/main/java/com/sf/entity/BookContent.java
  13. 322 0
      novel-demo/src/main/java/com/sf/entity/BookInfo.java
  14. 109 0
      novel-demo/src/main/java/com/sf/entity/HomeBook.java
  15. 16 0
      novel-demo/src/main/java/com/sf/mapper/BookChapterMapper.java
  16. 16 0
      novel-demo/src/main/java/com/sf/mapper/BookContentMapper.java
  17. 19 0
      novel-demo/src/main/java/com/sf/mapper/BookInfoMapper.java
  18. 16 0
      novel-demo/src/main/java/com/sf/mapper/HomeBookMapper.java
  19. 16 0
      novel-demo/src/main/java/com/sf/service/IBookChapterService.java
  20. 16 0
      novel-demo/src/main/java/com/sf/service/IBookContentService.java
  21. 17 0
      novel-demo/src/main/java/com/sf/service/IBookInfoService.java
  22. 16 0
      novel-demo/src/main/java/com/sf/service/IHomeBookService.java
  23. 20 0
      novel-demo/src/main/java/com/sf/service/impl/BookChapterServiceImpl.java
  24. 20 0
      novel-demo/src/main/java/com/sf/service/impl/BookContentServiceImpl.java
  25. 22 0
      novel-demo/src/main/java/com/sf/service/impl/BookInfoServiceImpl.java
  26. 20 0
      novel-demo/src/main/java/com/sf/service/impl/HomeBookServiceImpl.java
  27. 61 0
      novel-demo/src/main/java/com/sf/util/GeneUtils.java
  28. 5 0
      novel-demo/src/main/resources/application.properties
  29. 5 0
      novel-demo/src/main/resources/mapper/BookChapterMapper.xml
  30. 5 0
      novel-demo/src/main/resources/mapper/BookContentMapper.xml
  31. 5 0
      novel-demo/src/main/resources/mapper/BookInfoMapper.xml
  32. 5 0
      novel-demo/src/main/resources/mapper/HomeBookMapper.xml
  33. 63 0
      novel-demo/src/test/java/com/sf/NovelDemoApplicationTests.java
  34. 25 0
      springboot-demo/pom.xml
  35. 3 3
      springboot-demo/src/main/java/com/sf/SpringbootDemoApplication.java
  36. 22 0
      springboot-demo/src/main/java/com/sf/controller/BookController.java
  37. 17 0
      springboot-demo/src/main/java/com/sf/controller/ThymeController.java
  38. 34 0
      springboot-demo/src/main/java/com/sf/entity/Book.java
  39. 24 0
      springboot-demo/src/main/java/com/sf/mapper/BookMapper.java
  40. 0 3
      springboot-demo/src/main/resources/application.properties
  41. 12 0
      springboot-demo/src/main/resources/application.yml
  42. 8 0
      springboot-demo/src/main/resources/mapper/BookMapper.xml
  43. 12 0
      springboot-demo/src/main/resources/mybatis-config.xml
  44. 10 0
      springboot-demo/src/main/resources/templates/hello.html

+ 33 - 0
novel-demo/.gitignore

@@ -0,0 +1,33 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/

+ 18 - 0
novel-demo/.mvn/wrapper/maven-wrapper.properties

@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+wrapperVersion=3.3.1
+distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip

+ 250 - 0
novel-demo/mvnw

@@ -0,0 +1,250 @@
+#!/bin/sh
+# ----------------------------------------------------------------------------
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Apache Maven Wrapper startup batch script, version 3.3.1
+#
+# Optional ENV vars
+# -----------------
+#   JAVA_HOME - location of a JDK home dir, required when download maven via java source
+#   MVNW_REPOURL - repo url base for downloading maven distribution
+#   MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
+#   MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output
+# ----------------------------------------------------------------------------
+
+set -euf
+[ "${MVNW_VERBOSE-}" != debug ] || set -x
+
+# OS specific support.
+native_path() { printf %s\\n "$1"; }
+case "$(uname)" in
+CYGWIN* | MINGW*)
+  [ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")"
+  native_path() { cygpath --path --windows "$1"; }
+  ;;
+esac
+
+# set JAVACMD and JAVACCMD
+set_java_home() {
+  # For Cygwin and MinGW, ensure paths are in Unix format before anything is touched
+  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"
+      JAVACCMD="$JAVA_HOME/jre/sh/javac"
+    else
+      JAVACMD="$JAVA_HOME/bin/java"
+      JAVACCMD="$JAVA_HOME/bin/javac"
+
+      if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then
+        echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2
+        echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2
+        return 1
+      fi
+    fi
+  else
+    JAVACMD="$(
+      'set' +e
+      'unset' -f command 2>/dev/null
+      'command' -v java
+    )" || :
+    JAVACCMD="$(
+      'set' +e
+      'unset' -f command 2>/dev/null
+      'command' -v javac
+    )" || :
+
+    if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then
+      echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2
+      return 1
+    fi
+  fi
+}
+
+# hash string like Java String::hashCode
+hash_string() {
+  str="${1:-}" h=0
+  while [ -n "$str" ]; do
+    char="${str%"${str#?}"}"
+    h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296))
+    str="${str#?}"
+  done
+  printf %x\\n $h
+}
+
+verbose() { :; }
+[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; }
+
+die() {
+  printf %s\\n "$1" >&2
+  exit 1
+}
+
+# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
+while IFS="=" read -r key value; do
+  case "${key-}" in
+  distributionUrl) distributionUrl="${value-}" ;;
+  distributionSha256Sum) distributionSha256Sum="${value-}" ;;
+  esac
+done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties"
+[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties"
+
+case "${distributionUrl##*/}" in
+maven-mvnd-*bin.*)
+  MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/
+  case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in
+  *AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;;
+  :Darwin*x86_64) distributionPlatform=darwin-amd64 ;;
+  :Darwin*arm64) distributionPlatform=darwin-aarch64 ;;
+  :Linux*x86_64*) distributionPlatform=linux-amd64 ;;
+  *)
+    echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2
+    distributionPlatform=linux-amd64
+    ;;
+  esac
+  distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip"
+  ;;
+maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;
+*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
+esac
+
+# apply MVNW_REPOURL and calculate MAVEN_HOME
+# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
+[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}"
+distributionUrlName="${distributionUrl##*/}"
+distributionUrlNameMain="${distributionUrlName%.*}"
+distributionUrlNameMain="${distributionUrlNameMain%-bin}"
+MAVEN_HOME="$HOME/.m2/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")"
+
+exec_maven() {
+  unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || :
+  exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD"
+}
+
+if [ -d "$MAVEN_HOME" ]; then
+  verbose "found existing MAVEN_HOME at $MAVEN_HOME"
+  exec_maven "$@"
+fi
+
+case "${distributionUrl-}" in
+*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;;
+*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;;
+esac
+
+# prepare tmp dir
+if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then
+  clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; }
+  trap clean HUP INT TERM EXIT
+else
+  die "cannot create temp dir"
+fi
+
+mkdir -p -- "${MAVEN_HOME%/*}"
+
+# Download and Install Apache Maven
+verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
+verbose "Downloading from: $distributionUrl"
+verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
+
+# select .zip or .tar.gz
+if ! command -v unzip >/dev/null; then
+  distributionUrl="${distributionUrl%.zip}.tar.gz"
+  distributionUrlName="${distributionUrl##*/}"
+fi
+
+# verbose opt
+__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR=''
+[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v
+
+# normalize http auth
+case "${MVNW_PASSWORD:+has-password}" in
+'') MVNW_USERNAME='' MVNW_PASSWORD='' ;;
+has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;;
+esac
+
+if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then
+  verbose "Found wget ... using wget"
+  wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl"
+elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then
+  verbose "Found curl ... using curl"
+  curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl"
+elif set_java_home; then
+  verbose "Falling back to use Java to download"
+  javaSource="$TMP_DOWNLOAD_DIR/Downloader.java"
+  targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName"
+  cat >"$javaSource" <<-END
+	public class Downloader extends java.net.Authenticator
+	{
+	  protected java.net.PasswordAuthentication getPasswordAuthentication()
+	  {
+	    return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() );
+	  }
+	  public static void main( String[] args ) throws Exception
+	  {
+	    setDefault( new Downloader() );
+	    java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() );
+	  }
+	}
+	END
+  # For Cygwin/MinGW, switch paths to Windows format before running javac and java
+  verbose " - Compiling Downloader.java ..."
+  "$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java"
+  verbose " - Running Downloader.java ..."
+  "$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")"
+fi
+
+# If specified, validate the SHA-256 sum of the Maven distribution zip file
+if [ -n "${distributionSha256Sum-}" ]; then
+  distributionSha256Result=false
+  if [ "$MVN_CMD" = mvnd.sh ]; then
+    echo "Checksum validation is not supported for maven-mvnd." >&2
+    echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
+    exit 1
+  elif command -v sha256sum >/dev/null; then
+    if echo "$distributionSha256Sum  $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then
+      distributionSha256Result=true
+    fi
+  elif command -v shasum >/dev/null; then
+    if echo "$distributionSha256Sum  $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then
+      distributionSha256Result=true
+    fi
+  else
+    echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2
+    echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
+    exit 1
+  fi
+  if [ $distributionSha256Result = false ]; then
+    echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2
+    echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2
+    exit 1
+  fi
+fi
+
+# unzip and move
+if command -v unzip >/dev/null; then
+  unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip"
+else
+  tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar"
+fi
+printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url"
+mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
+
+clean || :
+exec_maven "$@"

+ 146 - 0
novel-demo/mvnw.cmd

@@ -0,0 +1,146 @@
+<# : batch portion
+@REM ----------------------------------------------------------------------------
+@REM Licensed to the Apache Software Foundation (ASF) under one
+@REM or more contributor license agreements.  See the NOTICE file
+@REM distributed with this work for additional information
+@REM regarding copyright ownership.  The ASF licenses this file
+@REM to you under the Apache License, Version 2.0 (the
+@REM "License"); you may not use this file except in compliance
+@REM with the License.  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,
+@REM software distributed under the License is distributed on an
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+@REM KIND, either express or implied.  See the License for the
+@REM specific language governing permissions and limitations
+@REM under the License.
+@REM ----------------------------------------------------------------------------
+
+@REM ----------------------------------------------------------------------------
+@REM Apache Maven Wrapper startup batch script, version 3.3.1
+@REM
+@REM Optional ENV vars
+@REM   MVNW_REPOURL - repo url base for downloading maven distribution
+@REM   MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
+@REM   MVNW_VERBOSE - true: enable verbose log; others: silence the output
+@REM ----------------------------------------------------------------------------
+
+@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0)
+@SET __MVNW_CMD__=
+@SET __MVNW_ERROR__=
+@SET __MVNW_PSMODULEP_SAVE=%PSModulePath%
+@SET PSModulePath=
+@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @(
+  IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B)
+)
+@SET PSModulePath=%__MVNW_PSMODULEP_SAVE%
+@SET __MVNW_PSMODULEP_SAVE=
+@SET __MVNW_ARG0_NAME__=
+@SET MVNW_USERNAME=
+@SET MVNW_PASSWORD=
+@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*)
+@echo Cannot start maven from wrapper >&2 && exit /b 1
+@GOTO :EOF
+: end batch / begin powershell #>
+
+$ErrorActionPreference = "Stop"
+if ($env:MVNW_VERBOSE -eq "true") {
+  $VerbosePreference = "Continue"
+}
+
+# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties
+$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl
+if (!$distributionUrl) {
+  Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
+}
+
+switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) {
+  "maven-mvnd-*" {
+    $USE_MVND = $true
+    $distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip"
+    $MVN_CMD = "mvnd.cmd"
+    break
+  }
+  default {
+    $USE_MVND = $false
+    $MVN_CMD = $script -replace '^mvnw','mvn'
+    break
+  }
+}
+
+# apply MVNW_REPOURL and calculate MAVEN_HOME
+# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
+if ($env:MVNW_REPOURL) {
+  $MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" }
+  $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')"
+}
+$distributionUrlName = $distributionUrl -replace '^.*/',''
+$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$',''
+$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain"
+$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join ''
+$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME"
+
+if (Test-Path -Path "$MAVEN_HOME" -PathType Container) {
+  Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME"
+  Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
+  exit $?
+}
+
+if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) {
+  Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl"
+}
+
+# prepare tmp dir
+$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile
+$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir"
+$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null
+trap {
+  if ($TMP_DOWNLOAD_DIR.Exists) {
+    try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
+    catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
+  }
+}
+
+New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null
+
+# Download and Install Apache Maven
+Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
+Write-Verbose "Downloading from: $distributionUrl"
+Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
+
+$webclient = New-Object System.Net.WebClient
+if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) {
+  $webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD)
+}
+[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
+$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null
+
+# If specified, validate the SHA-256 sum of the Maven distribution zip file
+$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum
+if ($distributionSha256Sum) {
+  if ($USE_MVND) {
+    Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties."
+  }
+  Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash
+  if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) {
+    Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property."
+  }
+}
+
+# unzip and move
+Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null
+Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null
+try {
+  Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null
+} catch {
+  if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) {
+    Write-Error "fail to move MAVEN_HOME"
+  }
+} finally {
+  try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
+  catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
+}
+
+Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"

+ 86 - 0
novel-demo/pom.xml

@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <!-- 可能需要降版本 -->
+        <version>3.2.0</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>com.sf</groupId>
+    <artifactId>novel-demo</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>novel-demo</name>
+    <description>novel-demo</description>
+    <properties>
+        <java.version>17</java.version>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
+        <!-- mybatis整合springboot启动器 -->
+        <dependency>
+            <groupId>org.mybatis.spring.boot</groupId>
+            <artifactId>mybatis-spring-boot-starter</artifactId>
+            <version>3.0.3</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.mysql</groupId>
+            <artifactId>mysql-connector-j</artifactId>
+            <version>8.4.0</version>
+        </dependency>
+
+<!--        <dependency>-->
+<!--            <groupId>mysql</groupId>-->
+<!--            <artifactId>mysql-connector-java</artifactId>-->
+<!--            <version>8.0.33</version>-->
+<!--        </dependency>-->
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.18.32</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-boot-starter</artifactId>
+            <version>3.5.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-generator</artifactId>
+            <version>3.5.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.freemarker</groupId>
+            <artifactId>freemarker</artifactId>
+            <version>2.3.32</version>
+        </dependency>
+
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 15 - 0
novel-demo/src/main/java/com/sf/NovelDemoApplication.java

@@ -0,0 +1,15 @@
+package com.sf;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+@MapperScan("com.sf.mapper")
+public class NovelDemoApplication {
+
+    public static void main(String[] args) {
+        SpringApplication.run(NovelDemoApplication.class, args);
+    }
+
+}

+ 18 - 0
novel-demo/src/main/java/com/sf/controller/BookChapterController.java

@@ -0,0 +1,18 @@
+package com.sf.controller;
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.stereotype.Controller;
+
+/**
+ * <p>
+ * 小说章节 前端控制器
+ * </p>
+ *
+ * @author baomidou
+ * @since 2024-05-25
+ */
+@Controller
+@RequestMapping("/bookChapter")
+public class BookChapterController {
+
+}

+ 18 - 0
novel-demo/src/main/java/com/sf/controller/BookContentController.java

@@ -0,0 +1,18 @@
+package com.sf.controller;
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.stereotype.Controller;
+
+/**
+ * <p>
+ * 小说内容 前端控制器
+ * </p>
+ *
+ * @author baomidou
+ * @since 2024-05-25
+ */
+@Controller
+@RequestMapping("/bookContent")
+public class BookContentController {
+
+}

+ 35 - 0
novel-demo/src/main/java/com/sf/controller/BookInfoController.java

@@ -0,0 +1,35 @@
+package com.sf.controller;
+
+import com.sf.entity.BookInfo;
+import com.sf.service.IBookInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 小说信息 前端控制器
+ * </p>
+ *
+ * @author baomidou
+ * @since 2024-05-25
+ */
+@RestController
+@RequestMapping("/bookInfo")
+public class BookInfoController {
+
+    @Autowired
+    private IBookInfoService bookInfoService;
+
+    // http://localhost:8080/bookInfo/list
+    @GetMapping("/list")
+    public List<BookInfo> list(){
+        // 不需要编写sql语句  直接进行增删改查操作
+        return bookInfoService.list();
+    }
+
+}

+ 18 - 0
novel-demo/src/main/java/com/sf/controller/HomeBookController.java

@@ -0,0 +1,18 @@
+package com.sf.controller;
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.stereotype.Controller;
+
+/**
+ * <p>
+ * 小说推荐 前端控制器
+ * </p>
+ *
+ * @author baomidou
+ * @since 2024-05-25
+ */
+@Controller
+@RequestMapping("/homeBook")
+public class HomeBookController {
+
+}

+ 131 - 0
novel-demo/src/main/java/com/sf/entity/BookChapter.java

@@ -0,0 +1,131 @@
+package com.sf.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ * 小说章节
+ * </p>
+ *
+ * @author baomidou
+ * @since 2024-05-25
+ */
+@TableName("book_chapter")
+public class BookChapter implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 小说ID
+     */
+    private Long bookId;
+
+    /**
+     * 章节号
+     */
+    private Integer chapterNum;
+
+    /**
+     * 章节名
+     */
+    private String chapterName;
+
+    /**
+     * 章节字数
+     */
+    private Integer wordCount;
+
+    /**
+     * 是否收费;1-收费 0-免费
+     */
+    private Byte isVip;
+
+    private LocalDateTime createTime;
+
+    private LocalDateTime updateTime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getBookId() {
+        return bookId;
+    }
+
+    public void setBookId(Long bookId) {
+        this.bookId = bookId;
+    }
+
+    public Integer getChapterNum() {
+        return chapterNum;
+    }
+
+    public void setChapterNum(Integer chapterNum) {
+        this.chapterNum = chapterNum;
+    }
+
+    public String getChapterName() {
+        return chapterName;
+    }
+
+    public void setChapterName(String chapterName) {
+        this.chapterName = chapterName;
+    }
+
+    public Integer getWordCount() {
+        return wordCount;
+    }
+
+    public void setWordCount(Integer wordCount) {
+        this.wordCount = wordCount;
+    }
+
+    public Byte getIsVip() {
+        return isVip;
+    }
+
+    public void setIsVip(Byte isVip) {
+        this.isVip = isVip;
+    }
+
+    public LocalDateTime getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(LocalDateTime createTime) {
+        this.createTime = createTime;
+    }
+
+    public LocalDateTime getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(LocalDateTime updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    @Override
+    public String toString() {
+        return "BookChapter{" +
+            "id = " + id +
+            ", bookId = " + bookId +
+            ", chapterNum = " + chapterNum +
+            ", chapterName = " + chapterName +
+            ", wordCount = " + wordCount +
+            ", isVip = " + isVip +
+            ", createTime = " + createTime +
+            ", updateTime = " + updateTime +
+        "}";
+    }
+}

+ 92 - 0
novel-demo/src/main/java/com/sf/entity/BookContent.java

@@ -0,0 +1,92 @@
+package com.sf.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ * 小说内容
+ * </p>
+ *
+ * @author baomidou
+ * @since 2024-05-25
+ */
+@TableName("book_content")
+public class BookContent implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 章节ID
+     */
+    private Long chapterId;
+
+    /**
+     * 小说章节内容
+     */
+    private String content;
+
+    private LocalDateTime createTime;
+
+    private LocalDateTime updateTime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getChapterId() {
+        return chapterId;
+    }
+
+    public void setChapterId(Long chapterId) {
+        this.chapterId = chapterId;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public LocalDateTime getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(LocalDateTime createTime) {
+        this.createTime = createTime;
+    }
+
+    public LocalDateTime getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(LocalDateTime updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    @Override
+    public String toString() {
+        return "BookContent{" +
+            "id = " + id +
+            ", chapterId = " + chapterId +
+            ", content = " + content +
+            ", createTime = " + createTime +
+            ", updateTime = " + updateTime +
+        "}";
+    }
+}

+ 322 - 0
novel-demo/src/main/java/com/sf/entity/BookInfo.java

@@ -0,0 +1,322 @@
+package com.sf.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ * 小说信息
+ * </p>
+ *
+ * @author baomidou
+ * @since 2024-05-25
+ */
+@TableName("book_info")
+public class BookInfo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 作品方向;0-男频 1-女频
+     */
+    private Byte workDirection;
+
+    /**
+     * 类别ID
+     */
+    private Long categoryId;
+
+    /**
+     * 类别名
+     */
+    private String categoryName;
+
+    /**
+     * 小说封面地址
+     */
+    private String picUrl;
+
+    /**
+     * 小说名
+     */
+    private String bookName;
+
+    /**
+     * 作家id
+     */
+    private Long authorId;
+
+    /**
+     * 作家名
+     */
+    private String authorName;
+
+    /**
+     * 书籍描述
+     */
+    private String bookDesc;
+
+    /**
+     * 评分;总分:10 ,真实评分 = score/10
+     */
+    private Byte score;
+
+    /**
+     * 书籍状态;0-连载中 1-已完结
+     */
+    private Byte bookStatus;
+
+    /**
+     * 点击量
+     */
+    private Long visitCount;
+
+    /**
+     * 总字数
+     */
+    private Integer wordCount;
+
+    /**
+     * 评论数
+     */
+    private Integer commentCount;
+
+    /**
+     * 最新章节ID
+     */
+    private Long lastChapterId;
+
+    /**
+     * 最新章节名
+     */
+    private String lastChapterName;
+
+    /**
+     * 最新章节更新时间
+     */
+    private LocalDateTime lastChapterUpdateTime;
+
+    /**
+     * 是否收费;1-收费 0-免费
+     */
+    private Byte isVip;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updateTime;
+
+    /**
+     * 类别名
+     */
+    private String categoryNamecopy;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Byte getWorkDirection() {
+        return workDirection;
+    }
+
+    public void setWorkDirection(Byte workDirection) {
+        this.workDirection = workDirection;
+    }
+
+    public Long getCategoryId() {
+        return categoryId;
+    }
+
+    public void setCategoryId(Long categoryId) {
+        this.categoryId = categoryId;
+    }
+
+    public String getCategoryName() {
+        return categoryName;
+    }
+
+    public void setCategoryName(String categoryName) {
+        this.categoryName = categoryName;
+    }
+
+    public String getPicUrl() {
+        return picUrl;
+    }
+
+    public void setPicUrl(String picUrl) {
+        this.picUrl = picUrl;
+    }
+
+    public String getBookName() {
+        return bookName;
+    }
+
+    public void setBookName(String bookName) {
+        this.bookName = bookName;
+    }
+
+    public Long getAuthorId() {
+        return authorId;
+    }
+
+    public void setAuthorId(Long authorId) {
+        this.authorId = authorId;
+    }
+
+    public String getAuthorName() {
+        return authorName;
+    }
+
+    public void setAuthorName(String authorName) {
+        this.authorName = authorName;
+    }
+
+    public String getBookDesc() {
+        return bookDesc;
+    }
+
+    public void setBookDesc(String bookDesc) {
+        this.bookDesc = bookDesc;
+    }
+
+    public Byte getScore() {
+        return score;
+    }
+
+    public void setScore(Byte score) {
+        this.score = score;
+    }
+
+    public Byte getBookStatus() {
+        return bookStatus;
+    }
+
+    public void setBookStatus(Byte bookStatus) {
+        this.bookStatus = bookStatus;
+    }
+
+    public Long getVisitCount() {
+        return visitCount;
+    }
+
+    public void setVisitCount(Long visitCount) {
+        this.visitCount = visitCount;
+    }
+
+    public Integer getWordCount() {
+        return wordCount;
+    }
+
+    public void setWordCount(Integer wordCount) {
+        this.wordCount = wordCount;
+    }
+
+    public Integer getCommentCount() {
+        return commentCount;
+    }
+
+    public void setCommentCount(Integer commentCount) {
+        this.commentCount = commentCount;
+    }
+
+    public Long getLastChapterId() {
+        return lastChapterId;
+    }
+
+    public void setLastChapterId(Long lastChapterId) {
+        this.lastChapterId = lastChapterId;
+    }
+
+    public String getLastChapterName() {
+        return lastChapterName;
+    }
+
+    public void setLastChapterName(String lastChapterName) {
+        this.lastChapterName = lastChapterName;
+    }
+
+    public LocalDateTime getLastChapterUpdateTime() {
+        return lastChapterUpdateTime;
+    }
+
+    public void setLastChapterUpdateTime(LocalDateTime lastChapterUpdateTime) {
+        this.lastChapterUpdateTime = lastChapterUpdateTime;
+    }
+
+    public Byte getIsVip() {
+        return isVip;
+    }
+
+    public void setIsVip(Byte isVip) {
+        this.isVip = isVip;
+    }
+
+    public LocalDateTime getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(LocalDateTime createTime) {
+        this.createTime = createTime;
+    }
+
+    public LocalDateTime getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(LocalDateTime updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public String getCategoryNamecopy() {
+        return categoryNamecopy;
+    }
+
+    public void setCategoryNamecopy(String categoryNamecopy) {
+        this.categoryNamecopy = categoryNamecopy;
+    }
+
+    @Override
+    public String toString() {
+        return "BookInfo{" +
+            "id = " + id +
+            ", workDirection = " + workDirection +
+            ", categoryId = " + categoryId +
+            ", categoryName = " + categoryName +
+            ", picUrl = " + picUrl +
+            ", bookName = " + bookName +
+            ", authorId = " + authorId +
+            ", authorName = " + authorName +
+            ", bookDesc = " + bookDesc +
+            ", score = " + score +
+            ", bookStatus = " + bookStatus +
+            ", visitCount = " + visitCount +
+            ", wordCount = " + wordCount +
+            ", commentCount = " + commentCount +
+            ", lastChapterId = " + lastChapterId +
+            ", lastChapterName = " + lastChapterName +
+            ", lastChapterUpdateTime = " + lastChapterUpdateTime +
+            ", isVip = " + isVip +
+            ", createTime = " + createTime +
+            ", updateTime = " + updateTime +
+            ", categoryNamecopy = " + categoryNamecopy +
+        "}";
+    }
+}

+ 109 - 0
novel-demo/src/main/java/com/sf/entity/HomeBook.java

@@ -0,0 +1,109 @@
+package com.sf.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * <p>
+ * 小说推荐
+ * </p>
+ *
+ * @author baomidou
+ * @since 2024-05-25
+ */
+@TableName("home_book")
+public class HomeBook implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 推荐类型;0-轮播图 1-顶部栏 2-本周强推 3-热门推荐 4-精品推荐
+     */
+    private Byte type;
+
+    /**
+     * 推荐排序
+     */
+    private Byte sort;
+
+    /**
+     * 推荐小说ID
+     */
+    private Long bookId;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updateTime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Byte getType() {
+        return type;
+    }
+
+    public void setType(Byte type) {
+        this.type = type;
+    }
+
+    public Byte getSort() {
+        return sort;
+    }
+
+    public void setSort(Byte sort) {
+        this.sort = sort;
+    }
+
+    public Long getBookId() {
+        return bookId;
+    }
+
+    public void setBookId(Long bookId) {
+        this.bookId = bookId;
+    }
+
+    public LocalDateTime getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(LocalDateTime createTime) {
+        this.createTime = createTime;
+    }
+
+    public LocalDateTime getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(LocalDateTime updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    @Override
+    public String toString() {
+        return "HomeBook{" +
+            "id = " + id +
+            ", type = " + type +
+            ", sort = " + sort +
+            ", bookId = " + bookId +
+            ", createTime = " + createTime +
+            ", updateTime = " + updateTime +
+        "}";
+    }
+}

+ 16 - 0
novel-demo/src/main/java/com/sf/mapper/BookChapterMapper.java

@@ -0,0 +1,16 @@
+package com.sf.mapper;
+
+import com.sf.entity.BookChapter;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 小说章节 Mapper 接口
+ * </p>
+ *
+ * @author baomidou
+ * @since 2024-05-25
+ */
+public interface BookChapterMapper extends BaseMapper<BookChapter> {
+
+}

+ 16 - 0
novel-demo/src/main/java/com/sf/mapper/BookContentMapper.java

@@ -0,0 +1,16 @@
+package com.sf.mapper;
+
+import com.sf.entity.BookContent;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 小说内容 Mapper 接口
+ * </p>
+ *
+ * @author baomidou
+ * @since 2024-05-25
+ */
+public interface BookContentMapper extends BaseMapper<BookContent> {
+
+}

+ 19 - 0
novel-demo/src/main/java/com/sf/mapper/BookInfoMapper.java

@@ -0,0 +1,19 @@
+package com.sf.mapper;
+
+import com.sf.entity.BookInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ * 小说信息 Mapper 接口
+ * </p>
+ *
+ * @author baomidou
+ * @since 2024-05-25
+ */
+// BaseMapper是mybatisplus 提供的基础类
+//@Mapper
+public interface BookInfoMapper extends BaseMapper<BookInfo> {
+
+}

+ 16 - 0
novel-demo/src/main/java/com/sf/mapper/HomeBookMapper.java

@@ -0,0 +1,16 @@
+package com.sf.mapper;
+
+import com.sf.entity.HomeBook;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 小说推荐 Mapper 接口
+ * </p>
+ *
+ * @author baomidou
+ * @since 2024-05-25
+ */
+public interface HomeBookMapper extends BaseMapper<HomeBook> {
+
+}

+ 16 - 0
novel-demo/src/main/java/com/sf/service/IBookChapterService.java

@@ -0,0 +1,16 @@
+package com.sf.service;
+
+import com.sf.entity.BookChapter;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * 小说章节 服务类
+ * </p>
+ *
+ * @author baomidou
+ * @since 2024-05-25
+ */
+public interface IBookChapterService extends IService<BookChapter> {
+
+}

+ 16 - 0
novel-demo/src/main/java/com/sf/service/IBookContentService.java

@@ -0,0 +1,16 @@
+package com.sf.service;
+
+import com.sf.entity.BookContent;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * 小说内容 服务类
+ * </p>
+ *
+ * @author baomidou
+ * @since 2024-05-25
+ */
+public interface IBookContentService extends IService<BookContent> {
+
+}

+ 17 - 0
novel-demo/src/main/java/com/sf/service/IBookInfoService.java

@@ -0,0 +1,17 @@
+package com.sf.service;
+
+import com.sf.entity.BookInfo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * 小说信息 服务类
+ * </p>
+ *
+ * @author baomidou
+ * @since 2024-05-25
+ */
+// IService是mybatisplus提供的 基础服务接口
+public interface IBookInfoService extends IService<BookInfo> {
+
+}

+ 16 - 0
novel-demo/src/main/java/com/sf/service/IHomeBookService.java

@@ -0,0 +1,16 @@
+package com.sf.service;
+
+import com.sf.entity.HomeBook;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * 小说推荐 服务类
+ * </p>
+ *
+ * @author baomidou
+ * @since 2024-05-25
+ */
+public interface IHomeBookService extends IService<HomeBook> {
+
+}

+ 20 - 0
novel-demo/src/main/java/com/sf/service/impl/BookChapterServiceImpl.java

@@ -0,0 +1,20 @@
+package com.sf.service.impl;
+
+import com.sf.entity.BookChapter;
+import com.sf.mapper.BookChapterMapper;
+import com.sf.service.IBookChapterService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 小说章节 服务实现类
+ * </p>
+ *
+ * @author baomidou
+ * @since 2024-05-25
+ */
+@Service
+public class BookChapterServiceImpl extends ServiceImpl<BookChapterMapper, BookChapter> implements IBookChapterService {
+
+}

+ 20 - 0
novel-demo/src/main/java/com/sf/service/impl/BookContentServiceImpl.java

@@ -0,0 +1,20 @@
+package com.sf.service.impl;
+
+import com.sf.entity.BookContent;
+import com.sf.mapper.BookContentMapper;
+import com.sf.service.IBookContentService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 小说内容 服务实现类
+ * </p>
+ *
+ * @author baomidou
+ * @since 2024-05-25
+ */
+@Service
+public class BookContentServiceImpl extends ServiceImpl<BookContentMapper, BookContent> implements IBookContentService {
+
+}

+ 22 - 0
novel-demo/src/main/java/com/sf/service/impl/BookInfoServiceImpl.java

@@ -0,0 +1,22 @@
+package com.sf.service.impl;
+
+import com.sf.entity.BookInfo;
+import com.sf.mapper.BookInfoMapper;
+import com.sf.service.IBookInfoService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 小说信息 服务实现类
+ * </p>
+ *
+ * @author baomidou
+ * @since 2024-05-25
+ */
+// ServiceImpl 是mybatisplus提供的服务基础实现类
+@Service
+public class BookInfoServiceImpl extends ServiceImpl<BookInfoMapper, BookInfo>
+        implements IBookInfoService {
+
+}

+ 20 - 0
novel-demo/src/main/java/com/sf/service/impl/HomeBookServiceImpl.java

@@ -0,0 +1,20 @@
+package com.sf.service.impl;
+
+import com.sf.entity.HomeBook;
+import com.sf.mapper.HomeBookMapper;
+import com.sf.service.IHomeBookService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 小说推荐 服务实现类
+ * </p>
+ *
+ * @author baomidou
+ * @since 2024-05-25
+ */
+@Service
+public class HomeBookServiceImpl extends ServiceImpl<HomeBookMapper, HomeBook> implements IHomeBookService {
+
+}

+ 61 - 0
novel-demo/src/main/java/com/sf/util/GeneUtils.java

@@ -0,0 +1,61 @@
+package com.sf.util;
+
+import com.baomidou.mybatisplus.generator.FastAutoGenerator;
+import com.baomidou.mybatisplus.generator.config.OutputFile;
+import com.baomidou.mybatisplus.generator.config.rules.DbColumnType;
+import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
+
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class GeneUtils {
+
+    public static void main(String[] args) {
+
+        List<String> list = new ArrayList<>();
+//        list.add("home_book");
+//        list.add("book_info");  // 书籍表
+//        list.add("book_chapter"); // 书籍章节表
+        list.add("book_content"); // 章节内容表
+
+        // 快速生成器
+        FastAutoGenerator.create("jdbc:mysql://localhost:3306/novel-cloud?useUnicode=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=Asia/Shanghai",
+                        "root", "root123456")
+                // 全局配置
+                .globalConfig(builder -> {
+                    builder.author("baomidou") // 设置作者
+//                            .enableSwagger() // 开启 swagger 模式
+                            .outputDir("src/main/java/"); // 指定输出目录
+//                            .outputDir("src\\main\\java\\"); // 指定输出目录
+                })
+                // 数据源配置
+                .dataSourceConfig(builder ->
+                        builder.typeConvertHandler((globalConfig, typeRegistry, metaInfo) -> {
+                            int typeCode = metaInfo.getJdbcType().TYPE_CODE;
+                            if (typeCode == Types.SMALLINT) {
+                                // 自定义类型转换
+                                return DbColumnType.INTEGER;
+                            }
+                            return typeRegistry.getColumnType(metaInfo);
+                        })
+                )
+                // 包配置
+                .packageConfig(builder ->
+                        builder.parent("com.sf") // 设置父包名
+                                .moduleName("") // 设置父包模块名
+                                .pathInfo(Collections.singletonMap(OutputFile.xml, "src/main/resources/mapper"))// 设置mapperXml生成路径
+                                .entity("entity") //设置实体类包名
+                                .mapper("mapper")
+                )
+                // 策略配置
+                .strategyConfig(builder ->
+//                                builder.addInclude("book_info") // 设置需要生成的表名
+                                builder.addInclude(list) // 设置需要生成的表名
+//                                .addTablePrefix("t_", "c_") // 设置过滤表前缀
+                )
+                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板,默认的是Velocity引擎模板
+                .execute();
+    }
+}

+ 5 - 0
novel-demo/src/main/resources/application.properties

@@ -0,0 +1,5 @@
+spring.application.name=novel-demo
+
+spring.datasource.url=jdbc:mysql://localhost:3306/novel-cloud?useUnicode=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=Asia/Shanghai
+spring.datasource.username=root
+spring.datasource.password=root123456

+ 5 - 0
novel-demo/src/main/resources/mapper/BookChapterMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.sf.mapper.BookChapterMapper">
+
+</mapper>

+ 5 - 0
novel-demo/src/main/resources/mapper/BookContentMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.sf.mapper.BookContentMapper">
+
+</mapper>

+ 5 - 0
novel-demo/src/main/resources/mapper/BookInfoMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.sf.mapper.BookInfoMapper">
+
+</mapper>

+ 5 - 0
novel-demo/src/main/resources/mapper/HomeBookMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.sf.mapper.HomeBookMapper">
+
+</mapper>

+ 63 - 0
novel-demo/src/test/java/com/sf/NovelDemoApplicationTests.java

@@ -0,0 +1,63 @@
+package com.sf;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.sf.entity.BookInfo;
+import com.sf.mapper.BookInfoMapper;
+import com.sf.service.IBookInfoService;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.util.List;
+
+@SpringBootTest
+class NovelDemoApplicationTests {
+
+    @Autowired
+    private IBookInfoService bookInfoService;
+
+    @Autowired
+    private BookInfoMapper bookInfoMapper;
+
+    @Test
+    void contextLoads() {
+
+//        List<BookInfo> list = bookInfoService.list();
+//        System.out.println(list);
+
+//        List<BookInfo> bookInfos = bookInfoMapper.selectList(null);
+        // 使用条件构造器
+        QueryWrapper queryWrapper = new QueryWrapper();
+        queryWrapper.eq("category_name","历史军事");
+        queryWrapper.eq("author_name","当年明月");
+        // where id = '1337762752513486849'
+        List<BookInfo> bookInfos1 = bookInfoMapper.selectList(queryWrapper);
+        System.out.println(bookInfos1);
+
+        // 使用lambda表达式的条件构造器
+        // :: 类的方法
+        LambdaQueryWrapper<BookInfo> queryWrapper1 = new LambdaQueryWrapper<>();
+        queryWrapper1.eq(BookInfo::getCategoryName,"历史军事");
+        queryWrapper1.eq(BookInfo::getAuthorName,"当年明月");
+        List<BookInfo> bookInfos2 = bookInfoMapper.selectList(queryWrapper1);
+        System.out.println(bookInfos2);
+
+        // service层的方法也可以使用条件构造器  但是不建议写在controller中
+//        List<BookInfo> list = bookInfoService.list(queryWrapper1);
+    }
+
+    // https://baomidou.com/guides/wrapper/#_top
+    // 练习  筛选访问次数visit_count > 200 且  书籍字数 word_count < 400000 的书籍
+
+    @Test
+    public void test(){
+        QueryWrapper queryWrapper = new QueryWrapper();
+        queryWrapper.gt("visit_count","200");
+        queryWrapper.lt("word_count","400000");
+        List<BookInfo> bookInfos1 = bookInfoMapper.selectList(queryWrapper);
+        System.out.println(bookInfos1.size());
+        System.out.println(bookInfos1);
+    }
+
+}

+ 25 - 0
springboot-demo/pom.xml

@@ -24,6 +24,31 @@
             <artifactId>spring-boot-starter-web</artifactId>
         </dependency>
 
+        <!-- 整合thymeleaf -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-thymeleaf</artifactId>
+        </dependency>
+
+        <!-- mybatis整合springboot启动器 -->
+        <dependency>
+            <groupId>org.mybatis.spring.boot</groupId>
+            <artifactId>mybatis-spring-boot-starter</artifactId>
+            <version>3.0.3</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.mysql</groupId>
+            <artifactId>mysql-connector-j</artifactId>
+            <version>8.4.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.18.32</version>
+        </dependency>
+
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-test</artifactId>

+ 3 - 3
springboot-demo/src/main/java/com/sf/SpringbootDemoApplication.java

@@ -1,13 +1,15 @@
 package com.sf;
 
+import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.context.annotation.Bean;
 
 //  @SpringBootApplication 注解的作用 告诉springboot这是 应用的启动类
 //  springboot 原则:约定优于配置
-//
+//  resources中的文件夹  static存储静态文件  templates存储模版文件
 @SpringBootApplication
+@MapperScan("com.sf.mapper")
 public class SpringbootDemoApplication {
 
     // 有启动入口  main
@@ -16,6 +18,4 @@ public class SpringbootDemoApplication {
         SpringApplication.run(SpringbootDemoApplication.class, args);
     }
 
-//    @Bean
-
 }

+ 22 - 0
springboot-demo/src/main/java/com/sf/controller/BookController.java

@@ -0,0 +1,22 @@
+package com.sf.controller;
+
+import com.sf.entity.Book;
+import com.sf.mapper.BookMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@RestController
+public class BookController {
+
+    @Autowired
+    private BookMapper bookMapper;
+
+    // http://localhost:18080/list
+    @GetMapping("/list")
+    public List<Book> getBookList(){
+        return bookMapper.findAll();
+    }
+}

+ 17 - 0
springboot-demo/src/main/java/com/sf/controller/ThymeController.java

@@ -0,0 +1,17 @@
+package com.sf.controller;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.GetMapping;
+
+// 页面是@Controller  数据是@RestController
+@Controller
+public class ThymeController {
+
+    // http://localhost:18080/thyme
+    @GetMapping("/thyme")
+    public String thyme(Model model) {
+        model.addAttribute("name", "Thymeleaf");
+        return "hello";
+    }
+}

+ 34 - 0
springboot-demo/src/main/java/com/sf/entity/Book.java

@@ -0,0 +1,34 @@
+package com.sf.entity;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class Book implements Serializable {
+
+    private static final long serialVersionUID = 5047814726963775513L;
+
+    private Long id;
+
+    private String bookId;
+
+    private String bookName;
+
+    private String typeId;
+
+    private String authorId;
+
+    private String authorName;
+
+    private String bookImg;
+
+    private String bookDesc;
+
+}

+ 24 - 0
springboot-demo/src/main/java/com/sf/mapper/BookMapper.java

@@ -0,0 +1,24 @@
+package com.sf.mapper;
+
+import com.sf.entity.Book;
+import org.apache.ibatis.annotations.Result;
+import org.apache.ibatis.annotations.Results;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+public interface BookMapper {
+
+//    @Select("select * from book")
+//    @Results(id = "bookMap", value = {
+//            @Result(id = true, column = "id", property = "id"),
+//            @Result(column = "book_id", property = "bookId"),
+//            @Result(column = "book_name", property = "bookName"),
+//            @Result(column = "type_id", property = "typeId"),
+//            @Result(column = "author_id", property = "authorId"),
+//            @Result(column = "author_name", property = "authorName"),
+//            @Result(column = "book_img", property = "bookImg"),
+//            @Result(column = "book_desc", property = "bookDesc")
+//    })
+    List<Book> findAll();
+}

+ 0 - 3
springboot-demo/src/main/resources/application.properties

@@ -1,3 +0,0 @@
-spring.application.name=springboot-demo
-
-server.port=18080

+ 12 - 0
springboot-demo/src/main/resources/application.yml

@@ -0,0 +1,12 @@
+mybatis:
+    config-location: classpath:mybatis-config.xml
+    mapper-locations: classpath*:/mapper/*.xml
+server:
+    port: 18080
+spring:
+    application:
+        name: springboot-demo
+    datasource:
+        password: root123456
+        url: jdbc:mysql://localhost:3306/novels?useUnicode=true&characterEncoding=utf-8&allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=Asia/Shanghai
+        username: root

+ 8 - 0
springboot-demo/src/main/resources/mapper/BookMapper.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.sf.mapper.BookMapper">
+
+    <select id="findAll" resultType="com.sf.entity.Book">
+        select * from book;
+    </select>
+</mapper>

+ 12 - 0
springboot-demo/src/main/resources/mybatis-config.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-config.dtd">
+<configuration>
+    <settings>
+        <!-- 使用mybatis的自动驼峰转换-->
+        <setting name="mapUnderscoreToCamelCase" value="true"/>
+    </settings>
+    <mappers>
+<!--        <mapper resource="mapper/BookMapper.xml"></mapper>-->
+    </mappers>
+</configuration>

+ 10 - 0
springboot-demo/src/main/resources/templates/hello.html

@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html lang="en" xmlns:th="http://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8">
+    <title>Title</title>
+</head>
+<body>
+<p th:text="${name}"></p>
+</body>
+</html>