This commit is contained in:
zrh050423 2024-11-21 21:10:56 +08:00
commit d19e678060
68 changed files with 2364 additions and 0 deletions

2
.gitattributes vendored Normal file
View File

@ -0,0 +1,2 @@
/mvnw text eol=lf
*.cmd text eol=crlf

33
.gitignore vendored Normal file
View File

@ -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/

19
.mvn/wrapper/maven-wrapper.properties vendored Normal file
View File

@ -0,0 +1,19 @@
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip

BIN
lib/servlet-api.jar Normal file

Binary file not shown.

259
mvnw vendored Normal file
View File

@ -0,0 +1,259 @@
#!/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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Apache Maven Wrapper startup batch script, version 3.3.2
#
# 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
}
trim() {
# MWRAPPER-139:
# Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds.
# Needed for removing poorly interpreted newline sequences when running in more
# exotic environments such as mingw bash on Windows.
printf "%s" "${1}" | tr -d '[:space:]'
}
# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
while IFS="=" read -r key value; do
case "${key-}" in
distributionUrl) distributionUrl=$(trim "${value-}") ;;
distributionSha256Sum) distributionSha256Sum=$(trim "${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_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}"
MAVEN_HOME="${MAVEN_USER_HOME}/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 "$@"

149
mvnw.cmd vendored Normal file
View File

@ -0,0 +1,149 @@
<# : 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 http://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.2
@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"
if ($env:MAVEN_USER_HOME) {
$MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/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"

99
pom.xml Normal file
View File

@ -0,0 +1,99 @@
<?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.3.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>edu.zrh</groupId>
<artifactId>healthSystem</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>healthSystem</name>
<description>healthSystem</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>23</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- Spring Boot Starter Web: 包含了Spring MVC、Tomcat等 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>3.3.5</version> <!-- 指定版本 -->
</dependency>
<!-- Spring Security依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- Spring Boot Starter Data JPA: 用于简化JPA的开发 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.12</version> <!-- 使用适合你数据库版本的版本号 -->
</dependency>
<!--<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.3</version>
</dependency>-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- <plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/</path>
<port>8080</port>
</configuration>
</plugin>-->
</plugins>
</build>
</project>

View File

@ -0,0 +1,17 @@
package edu.zrh.healthsystem;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author han
*/
@SpringBootApplication
public class HealthSystemApplication {
public static void main(String[] args) {
SpringApplication.run(HealthSystemApplication.class, args);
}
}

View File

@ -0,0 +1,22 @@
package edu.zrh.healthsystem.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.client.RestTemplate;
/**
* @author han
*/
@Configuration
public class WebConfig {
@Bean
public BCryptPasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
}

View File

@ -0,0 +1,18 @@
package edu.zrh.healthsystem.controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author han
*/
@CrossOrigin(origins = "*")
@RestController
public class HelloController {
@GetMapping("/hello")
public String home() {
return "Hello, World!";
}
}

View File

@ -0,0 +1,77 @@
package edu.zrh.healthsystem.controller;
import edu.zrh.healthsystem.model.Elderly;
import edu.zrh.healthsystem.model.elderly.RegularCheckupInfoResponse;
import edu.zrh.healthsystem.repository.RegularCheckupInfoRespository;
import edu.zrh.healthsystem.service.RegularCheckupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@CrossOrigin(origins = "*")
@RestController
@RequestMapping("/regularcheckup")
public class RegularCheckupController {
private final RegularCheckupService regularCheckupService;
@Autowired
public RegularCheckupController(RegularCheckupService regularCheckupService) {
this.regularCheckupService = regularCheckupService;
}
@PostMapping("/add")
public Map<String, Object> add(@RequestBody Elderly elderly) {
RegularCheckupInfoResponse result = regularCheckupService.add(elderly);
if (result != null) {
return Map.of("status", "success", "data", result);
} else {
// 如果登录失败返回失败信息
return Map.of("status", "fail", "message", "连接失败");
}
}
@PostMapping("/delete")
public Map<String, Object> delete(@RequestBody Elderly elderly) {
RegularCheckupInfoResponse result = regularCheckupService.delete(elderly);
if (result != null) {
return Map.of("status", "success", "data", result);
} else {
// 如果登录失败返回失败信息
return Map.of("status", "fail", "message", "连接失败");
}
}
@PostMapping("/update")
public Map<String, Object> update(@RequestBody Elderly elderly) {
RegularCheckupInfoResponse result = regularCheckupService.update(elderly);
if (result != null) {
return Map.of("status", "success", "data", result);
} else {
// 如果登录失败返回失败信息
return Map.of("status", "fail", "message", "连接失败");
}
}
@PostMapping("/get")
public Map<String, Object> get(@RequestBody Elderly elderly) {
RegularCheckupInfoResponse result = regularCheckupService.get(elderly);
if (result != null) {
return Map.of("status", "success", "data", result);
} else {
// 如果登录失败返回失败信息
return Map.of("status", "fail", "message", "连接失败");
}
}
@GetMapping("/getall")
public Map<String, Object> getAll() {
RegularCheckupInfoResponse result = regularCheckupService.getAll();
if (result != null) {
return Map.of("status", "success", "data", result);
} else {
// 如果登录失败返回失败信息
return Map.of("status", "fail", "message", "连接失败");
}
}
}

View File

@ -0,0 +1,39 @@
package edu.zrh.healthsystem.controller;
import edu.zrh.healthsystem.model.Talk;
import edu.zrh.healthsystem.model.TalkResponse;
import edu.zrh.healthsystem.service.TalkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* @author han
*/
@CrossOrigin(origins = "*")
@RestController
public class TalkController {
private final TalkService talkService;
@Autowired
public TalkController(TalkService talkService) {
this.talkService = talkService;
}
@GetMapping("/talk/test")
public String callApi() {
return talkService.callApi("http://10.10.10.44:11434/");
}
@PostMapping("/talk/main")
public Map<String, Object> callApiChat(@RequestBody Talk talk) {
TalkResponse result = talkService.callApiChat(talk);
if (result != null) {
return Map.of("status", "success", "data", result);
} else {
// 如果登录失败返回失败信息
return Map.of("status", "fail", "message", "登录失败");
}
}
}

View File

@ -0,0 +1,35 @@
package edu.zrh.healthsystem.controller.elderly;
import edu.zrh.healthsystem.service.elderly.ElderMainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
* @author han
*/
@CrossOrigin(origins = "*")
@RestController
public class ElderMainController {
private ElderMainService elderMainService;
@Autowired
public ElderMainController(ElderMainService elderMainService) {
this.elderMainService = elderMainService;
}
@GetMapping("/elderly/main")
public Map elderMain() {
List result = elderMainService.elderMain();
if (result != null) {
return Map.of("status", "success", "data", result);
} else {
// 如果登录失败返回失败信息
return Map.of("status", "fail", "message", "登录失败");
}
}
}

View File

@ -0,0 +1,33 @@
package edu.zrh.healthsystem.controller.elderly;
import edu.zrh.healthsystem.model.elderly.ElderlyConnect;
import edu.zrh.healthsystem.model.elderly.ElderlyConnectResponse;
import edu.zrh.healthsystem.service.elderly.ElderlyConnectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@CrossOrigin(origins = "*")
@RestController
public class ElderlyConnectController {
private final ElderlyConnectService elderlyConnectService;
@Autowired
public ElderlyConnectController(ElderlyConnectService elderlyConnectService) {
this.elderlyConnectService = elderlyConnectService;
}
@PostMapping("/elderly/Connect")
public Map<String,Object> elderlyConnect(@RequestBody ElderlyConnect elderlyConnect){
ElderlyConnectResponse result= elderlyConnectService.getElderlyConnectResponse(elderlyConnect);
if (result != null) {
return Map.of("status", "success", "data", result);
} else {
// 如果登录失败返回失败信息
return Map.of("status", "fail", "message", "创建失败");
}
}
}

View File

@ -0,0 +1,33 @@
package edu.zrh.healthsystem.controller.elderly;
import edu.zrh.healthsystem.model.elderly.ElderlyNew;
import edu.zrh.healthsystem.model.elderly.ElderlyNewResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import edu.zrh.healthsystem.service.elderly.ElderlyNewService;
import java.util.Map;
@CrossOrigin(origins = "*")
@RestController
public class ElderlyNewController {
private final ElderlyNewService elderlyNewService;
@Autowired
public ElderlyNewController(ElderlyNewService elderlyNewService) {
this.elderlyNewService = elderlyNewService;
}
@PostMapping("/elderly/new")
public Map<String,Object> elderlyNew(@RequestBody ElderlyNew elderlyNew){
ElderlyNewResponse result= elderlyNewService.elderly(elderlyNew);
if (result != null) {
return Map.of("status", "success", "data", result);
} else {
// 如果登录失败返回失败信息
return Map.of("status", "fail", "message", "创建失败");
}
}
}

View File

@ -0,0 +1,34 @@
package edu.zrh.healthsystem.controller.elderly;
import edu.zrh.healthsystem.model.Elderly;
import edu.zrh.healthsystem.model.elderly.ElderlyShowResponse;
import edu.zrh.healthsystem.service.elderly.ElderlyShowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@CrossOrigin(origins = "*")
@RestController
public class ElderlyShowController {
private final ElderlyShowService elderlyShowService;
@Autowired
public ElderlyShowController(ElderlyShowService elderlyShowService) {
this.elderlyShowService = elderlyShowService;
}
@PostMapping("/elderly/show")
public Map<String,Object> elderlyShow(@RequestBody Elderly elderly){
ElderlyShowResponse result= elderlyShowService.getElderlyShow(elderly);
if (result != null) {
return Map.of("status", "success", "data", result);
} else {
// 如果登录失败返回失败信息
return Map.of("status", "fail", "message", "连接失败");
}
}
}

View File

@ -0,0 +1,38 @@
package edu.zrh.healthsystem.controller.user;
import edu.zrh.healthsystem.model.user.UserLogin;
import edu.zrh.healthsystem.model.user.UserLoginResponse;
import edu.zrh.healthsystem.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* @author han
*/
@CrossOrigin(origins = "*")
@RestController
public class LoginController {
private final LoginService loginService;
@Autowired
public LoginController(LoginService loginService) {
this.loginService = loginService;
}
@PostMapping("/login")
public Map<String, Object> login(@RequestBody UserLogin userLogin) {
// 调用登录服务
UserLoginResponse result = loginService.login(userLogin);
// 如果登录成功返回成功信息和用户信息
if (result != null) {
return Map.of("status", "success", "data", result);
} else {
// 如果登录失败返回失败信息
return Map.of("status", "fail", "message", "登录失败");
}
}
}

View File

@ -0,0 +1,35 @@
package edu.zrh.healthsystem.controller.user;
import edu.zrh.healthsystem.model.user.UserRegister;
import edu.zrh.healthsystem.model.user.UserRegisterResponse;
import edu.zrh.healthsystem.service.RegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* @author han
*/
@RestController
public class RegisterController {
private final RegisterService registerService;
@Autowired
public RegisterController(RegisterService registerService) {
this.registerService = registerService;
}
@PostMapping("/register")
public Map<String,Object> register(@RequestBody UserRegister userRegister) {
UserRegisterResponse result = registerService.register(userRegister);
if (result != null) {
return Map.of("status", "success", "data", result);
} else {
// 如果登录失败返回失败信息
return Map.of("status", "fail", "message", "登录失败");
}
}
}

View File

@ -0,0 +1,75 @@
package edu.zrh.healthsystem.eneity;
import jakarta.persistence.*;
import lombok.Data;
import java.util.Date;
/**
* @author han
*/
@Data
@Entity
@Table(name = "basic_info")
public class BasicInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "elderly_id")
private int elderlyId;
@Column(name = "full_name")
private String fullName;
@Column(name = "gender")
private String gender;
@Column(name = "date_of_birth")
private Date dateOfBirth;
@Column(name = "ethnicity")
private String ethnicity;
@Column(name = "native_place")
private String nativePlace;
@Column(name = "id_number")
private String idNumber;
@Column(name = "permanent_address")
private String permanentAddress;
@Column(name = "occupation")
private String occupation;
@Column(name = "education_level")
private String educationLevel;
@Column(name = "living_alone")
private String livingAlone;
@Column(name = "marital_status")
private String maritalStatus;
@Column(name = "phone_number")
private String phoneNumber;
@Column(name = "contact_name")
private String contactName;
@Column(name = "contact_relation")
private String contactRelation;
@Column(name = "contact_phone")
private String contactPhone;
@Column(name = "eating_habits")
private String eatingHabits;
@Column(name = "exercise_frequency")
private String exerciseFrequency;
}

View File

@ -0,0 +1,31 @@
package edu.zrh.healthsystem.eneity;
import jakarta.persistence.*;
import lombok.Data;
import java.sql.Timestamp;
@Entity
@Table(name = "daily_schedule_info")
@Data
public class DailyScheduleInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int checkInId;
@Column(name = "Elderly_id")
private Integer elderlyId;
@Column(name = "Schedule_id")
private Integer scheduleId;
@Column(name = "Check_in_time")
private Timestamp checkInTime;
@Column(name = "Check_out_time")
private Timestamp checkOutTime;
@Column(name = "notes")
private String notes;
}

View File

@ -0,0 +1,65 @@
package edu.zrh.healthsystem.eneity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Entity
@Table(name = "diseaserecord_info")
public class DiseaseRecordInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "DiseaseID", nullable = false)
private Integer id;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "ProfileID", nullable = false)
private MainProfileInfo profileID;
@Lob
@Column(name = "PastMedicalHistory")
private String pastMedicalHistory;
@Lob
@Column(name = "CurrentMedicalHistory")
private String currentMedicalHistory;
@Lob
@Column(name = "FamilyMedicalHistory")
private String familyMedicalHistory;
@Lob
@Column(name = "Allergies")
private String allergies;
@Lob
@Column(name = "Disability")
private String disability;
@Lob
@Column(name = "VaccinationHistory")
private String vaccinationHistory;
@Lob
@Column(name = "ExposureHistory")
private String exposureHistory;
@Lob
@Column(name = "GeneticDiseaseHistory")
private String geneticDiseaseHistory;
@Lob
@Column(name = "TreatmentHistory")
private String treatmentHistory;
@Lob
@Column(name = "NursingHistory")
private String nursingHistory;
@Lob
@Column(name = "FollowUpManagement")
private String followUpManagement;
}

View File

@ -0,0 +1,27 @@
package edu.zrh.healthsystem.eneity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Entity
@Table(name = "healthbehavior_info")
public class HealthBehaviorInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "BehaviorID", nullable = false)
private Integer id;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "ProfileID", nullable = false)
private MainProfileInfo profileID;
@Column(name = "SmokingStatus", nullable = false)
private String smokingStatus;
@Column(name = "DrinkingStatus", nullable = false)
private String drinkingStatus;
}

View File

@ -0,0 +1,17 @@
package edu.zrh.healthsystem.eneity;
import jakarta.persistence.*;
import lombok.Data;
@Data
@Entity
@Table(name = "mainprofile_info")
public class MainProfileInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int profileId;
@OneToOne
@JoinColumn(name = "elderly_id")
private BasicInfo elderlyId;
}

View File

@ -0,0 +1,29 @@
package edu.zrh.healthsystem.eneity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Entity
@Table(name = "mentalhealth_info")
public class MentalHealthInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "MentalHealthID", nullable = false)
private Integer id;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "Elderly_id", nullable = false)
private MainProfileInfo elderly;
@Lob
@Column(name = "PsychologicalIssues")
private String psychologicalIssues;
@Lob
@Column(name = "FollowUpRecord")
private String followUpRecord;
}

View File

@ -0,0 +1,37 @@
package edu.zrh.healthsystem.eneity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Entity
@Table(name = "pastmedicalhistoryrecord_info")
public class PastMedicalHistoryrecordInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "PastMedicalHistoryID", nullable = false)
private Integer id;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "ProfileID", nullable = false)
private MainProfileInfo profileID;
@Lob
@Column(name = "CurrentMedicalHistory")
private String currentMedicalHistory;
@Lob
@Column(name = "ExposureHistory")
private String exposureHistory;
@Lob
@Column(name = "TreatmentHistory")
private String treatmentHistory;
@Lob
@Column(name = "NursingHistory")
private String nursingHistory;
}

View File

@ -0,0 +1,67 @@
package edu.zrh.healthsystem.eneity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import java.math.BigDecimal;
import java.time.LocalDate;
@Getter
@Setter
@Entity
@Table(name = "regularcheckup_info")
public class RegularCheckupInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "CheckupID", nullable = false)
private Integer id;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "ProfileID", nullable = false)
private MainProfileInfo profileID;
@Column(name = "WeightStatus", nullable = false)
private String weightStatus;
@Column(name = "BloodType", nullable = false)
private String bloodType;
@Lob
@Column(name = "ChronicDiseases")
private String chronicDiseases;
@Column(name = "Height", precision = 5, scale = 2)
private BigDecimal height;
@Column(name = "Weight", precision = 5, scale = 2)
private BigDecimal weight;
@Column(name = "HeartRate")
private Integer heartRate;
@Column(name = "Temperature", precision = 3, scale = 1)
private BigDecimal temperature;
@Column(name = "OxygenSaturation")
private Integer oxygenSaturation;
@Column(name = "BloodPressure", length = 10)
private String bloodPressure;
@Column(name = "GlucoseLevel", precision = 5, scale = 2)
private BigDecimal glucoseLevel;
@Column(name = "Pulse")
private Integer pulse;
@Column(name = "face_image")
private byte[] faceImage;
@Column(name = "tongue_image")
private byte[] tongueImage;
@Column(name = "CheckupDate")
private LocalDate checkupDate;
}

View File

@ -0,0 +1,29 @@
package edu.zrh.healthsystem.eneity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import java.time.Instant;
@Getter
@Setter
@Entity
@Table(name = "schedule_info")
public class ScheduleInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "schedule_id", nullable = false)
private Integer id;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "elderly_id", nullable = false)
private BasicInfo elderly;
@Column(name = "event_description")
private String eventDescription;
@Column(name = "event_time")
private Instant eventTime;
}

View File

@ -0,0 +1,31 @@
package edu.zrh.healthsystem.eneity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import java.time.Instant;
@Getter
@Setter
@Entity
@Table(name = "tcm_diagnosis_info")
public class TcmDiagnosisInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "diagnosis_id", nullable = false)
private Integer id;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "elderly_id", nullable = false)
private BasicInfo elderly;
@Column(name = "diagnosis", nullable = false)
private String diagnosis;
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "diagnosis_time")
private Instant diagnosisTime;
}

View File

@ -0,0 +1,36 @@
package edu.zrh.healthsystem.eneity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import java.time.Instant;
@Getter
@Setter
@Entity
@Table(name = "tcm_qa_info")
public class TcmQaInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "qa_id", nullable = false)
private Integer id;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "elderly_id", nullable = false)
private BasicInfo elderly;
@ColumnDefault("CURRENT_TIMESTAMP")
@Column(name = "asked_time")
private Instant askedTime;
@Lob
@Column(name = "question", nullable = false)
private String question;
@Lob
@Column(name = "answer", nullable = false)
private String answer;
}

View File

@ -0,0 +1,29 @@
package edu.zrh.healthsystem.eneity;
import jakarta.persistence.*;
import lombok.Data;
/**
* @author han
*/
@Data
@Entity
@Table(name = "user_info")
public class UserInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int userId;
@Column(name = "User_name")
private String userName;
@Column(name = "User_password")
private String userPassword;
@Column(name = "User_elderly")
private Integer userElderly;
@Column(name = "User_email")
private String userEmail;
}

View File

@ -0,0 +1,20 @@
package edu.zrh.healthsystem.model;
/**
* @author han
*/
public class Basic {
private int elderlyId;
private String fullName;
private char gender;
private String dateOfBirth;
private String ethnicity;
private String nativePlace;
private String idNumber;
private String permanentAddress;
private String occupation;
private String educationLevel;
private boolean livingAlone;
private String maritalStatus;
private String phoneNumber;
}

View File

@ -0,0 +1,43 @@
package edu.zrh.healthsystem.model;
import edu.zrh.healthsystem.eneity.MainProfileInfo;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDate;
public @Data class Elderly {
private int elderlyId;
private MainProfileInfo profileId;
private String weightStatus;
private String bloodType;
private String chronicDiseases;
private BigDecimal height;
private BigDecimal weight;
private Integer heartRate;
private BigDecimal temperature;
private Integer oxygenSaturation;
private String bloodPressure;
private BigDecimal glucoseLevel;
private Integer pulse;
private byte[] faceImage;
private byte[] tongueImage;
private LocalDate checkupDate;
private String message;
}

View File

@ -0,0 +1,8 @@
package edu.zrh.healthsystem.model;
import lombok.Data;
public @Data class Message {
private String role="user";
private String content;
}

View File

@ -0,0 +1,15 @@
package edu.zrh.healthsystem.model;
import lombok.Data;
import java.util.List;
/**
* @author han
*/
public @Data class Talk {
private String model="qwen2";
private List<Message> messages;
private Boolean stream=false;
}

View File

@ -0,0 +1,21 @@
package edu.zrh.healthsystem.model;
import lombok.Data;
import java.util.List;
/**
* @author han
*/
public @Data class TalkResponse {
private String model;
private String created_at;
private String done;
private String total_duration;
private String load_duration;
private String prompt_eval_count;
private String prompt_eval_duration;
private String eval_count;
private String eval_duration;
private List<Message> messages;
}

View File

@ -0,0 +1,8 @@
package edu.zrh.healthsystem.model.elderly;
import lombok.Data;
public @Data class ElderlyConnect {
private int userId;
private int userElderly;
}

View File

@ -0,0 +1,8 @@
package edu.zrh.healthsystem.model.elderly;
import lombok.Data;
public @Data class ElderlyConnectResponse {
private int userId;
private String message;
}

View File

@ -0,0 +1,32 @@
package edu.zrh.healthsystem.model.elderly;
import lombok.Data;
import java.util.Date;
/**
* @author han
*/
public @Data class ElderlyNew {
private String fullName;
private String gender;
private Date dateOfBirth;
private String ethnicity;
private String nativePlace;
private String idNumber;
private String permanentAddress;
private String occupation;
private String educationLevel;
private String livingAlone;
private String maritalStatus;
private String phoneNumber;
private String contactName;
private String contactRelation;
private String contactPhone;
private String eatingHabits;
private String exerciseFrequency;
}

View File

@ -0,0 +1,8 @@
package edu.zrh.healthsystem.model.elderly;
import lombok.Data;
public @Data class ElderlyNewResponse {
private int elderlyId;
private String message;
}

View File

@ -0,0 +1,27 @@
package edu.zrh.healthsystem.model.elderly;
import lombok.Data;
import java.util.Date;
public @Data class ElderlyShowResponse {
private int ElderlyId;
private String fullName;
private String gender;
private Date dateOfBirth;
private String ethnicity;
private String nativePlace;
private String idNumber;
private String permanentAddress;
private String occupation;
private String educationLevel;
private String livingAlone;
private String maritalStatus;
private String phoneNumber;
private String contactName;
private String contactRelation;
private String contactPhone;
private String eatingHabits;
private String exerciseFrequency;
private String message;
}

View File

@ -0,0 +1,47 @@
package edu.zrh.healthsystem.model.elderly;
import edu.zrh.healthsystem.eneity.MainProfileInfo;
import jakarta.persistence.*;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDate;
/**
* @author han
*/
public @Data class RegularCheckupInfoResponse {
private Integer id;
private MainProfileInfo profileId;
private String weightStatus;
private String bloodType;
private String chronicDiseases;
private BigDecimal height;
private BigDecimal weight;
private Integer heartRate;
private BigDecimal temperature;
private Integer oxygenSaturation;
private String bloodPressure;
private BigDecimal glucoseLevel;
private Integer pulse;
private byte[] faceImage;
private byte[] tongueImage;
private LocalDate checkupDate;
private String message;
}

View File

@ -0,0 +1,10 @@
package edu.zrh.healthsystem.model.user;
import lombok.Data;
/**
* @author han
*/
public @Data class UserLogin {
private String userName;
private String userPassword;
}

View File

@ -0,0 +1,14 @@
package edu.zrh.healthsystem.model.user;
import lombok.Data;
/**
* @author han
*/
public @Data class UserLoginResponse {
private boolean userRe;
private int userId;
private String message;
}

View File

@ -0,0 +1,13 @@
package edu.zrh.healthsystem.model.user;
import lombok.Data;
/**
* @author han
*/
public @Data class UserRegister {
private String userName;
private String userPassword;
private String userEmail;
}

View File

@ -0,0 +1,10 @@
package edu.zrh.healthsystem.model.user;
import lombok.Data;
public @Data class UserRegisterResponse {
private boolean userRe;
private int userId;
private String message;
}

View File

@ -0,0 +1,7 @@
package edu.zrh.healthsystem.repository;
import edu.zrh.healthsystem.eneity.DailyScheduleInfo;
import org.springframework.data.jpa.repository.JpaRepository;
public interface DailyScheduleRepository extends JpaRepository<DailyScheduleInfo, Integer> {
}

View File

@ -0,0 +1,7 @@
package edu.zrh.healthsystem.repository;
import edu.zrh.healthsystem.eneity.DiseaseRecordInfo;
import org.springframework.data.jpa.repository.JpaRepository;
public interface DiseaseRecordRepository extends JpaRepository<DiseaseRecordInfo, Integer> {
}

View File

@ -0,0 +1,7 @@
package edu.zrh.healthsystem.repository;
import edu.zrh.healthsystem.eneity.HealthBehaviorInfo;
import org.springframework.data.jpa.repository.JpaRepository;
public interface HealthBehaviorInfoRespository extends JpaRepository<HealthBehaviorInfo, Integer> {
}

View File

@ -0,0 +1,16 @@
package edu.zrh.healthsystem.repository;
import edu.zrh.healthsystem.eneity.UserInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.Optional;
/**
* @author han
*/
@Repository
public interface LoginRepository extends JpaRepository<UserInfo, Integer> {
Optional<UserInfo> findByUserName(String username);
}

View File

@ -0,0 +1,8 @@
package edu.zrh.healthsystem.repository;
import edu.zrh.healthsystem.eneity.MainProfileInfo;
import edu.zrh.healthsystem.eneity.UserInfo;
import org.springframework.data.jpa.repository.JpaRepository;
public interface MainProfileInfoRepository extends JpaRepository<MainProfileInfo, Integer> {
}

View File

@ -0,0 +1,18 @@
package edu.zrh.healthsystem.repository;
import edu.zrh.healthsystem.eneity.UserInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.Optional;
/**
* @author han
*/
@Repository
public interface RegisterRepository extends JpaRepository<UserInfo, Integer> {
Optional<UserInfo> findByUserName(String username);
Optional<UserInfo> findByUserEmail(String userEmail);
}

View File

@ -0,0 +1,12 @@
package edu.zrh.healthsystem.repository;
import edu.zrh.healthsystem.eneity.RegularCheckupInfo;
import edu.zrh.healthsystem.model.Elderly;
import org.springframework.data.jpa.repository.JpaRepository;
import java.lang.classfile.Opcode;
import java.util.Optional;
public interface RegularCheckupInfoRespository extends JpaRepository<RegularCheckupInfo, Integer> {
Optional<RegularCheckupInfo> findByElderlyId(int elderlyId);
}

View File

@ -0,0 +1,7 @@
package edu.zrh.healthsystem.repository.elderly;
import edu.zrh.healthsystem.eneity.BasicInfo;
import org.springframework.data.jpa.repository.JpaRepository;
public interface ElderMainRepository extends JpaRepository<BasicInfo, Integer> {
}

View File

@ -0,0 +1,13 @@
package edu.zrh.healthsystem.repository.elderly;
import edu.zrh.healthsystem.eneity.UserInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.Optional;
@Repository
public interface ElderlyConnectRepository extends JpaRepository<UserInfo, Integer> {
Optional<UserInfo> findByUserId(int userId);
Optional<UserInfo> findByUserElderly(int userElderly);
}

View File

@ -0,0 +1,11 @@
package edu.zrh.healthsystem.repository.elderly;
import edu.zrh.healthsystem.eneity.BasicInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.Optional;
@Repository
public interface ElderlyNewRepository extends JpaRepository<BasicInfo, Integer> {
Optional<BasicInfo> findByFullName(String fullName);
}

View File

@ -0,0 +1,10 @@
package edu.zrh.healthsystem.repository.elderly;
import edu.zrh.healthsystem.eneity.BasicInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.Optional;
public interface ElderlyShowRepository extends JpaRepository<BasicInfo, Integer> {
Optional<BasicInfo> findByElderlyId(int elderlyId);
}

View File

@ -0,0 +1,57 @@
package edu.zrh.healthsystem.service;
import edu.zrh.healthsystem.eneity.UserInfo;
import edu.zrh.healthsystem.model.user.UserLogin;
import edu.zrh.healthsystem.model.user.UserLoginResponse;
import edu.zrh.healthsystem.repository.LoginRepository;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import java.util.Optional;
/**
* @author han
*/
@Service
public class LoginService {
private final LoginRepository loginRepository;
@Resource
private BCryptPasswordEncoder passwordEncoder;
@Autowired
public LoginService( LoginRepository loginRepository){
this.loginRepository = loginRepository;
}
public UserLoginResponse login(UserLogin userLogin) {
Optional<UserInfo> optionalUserInfo = loginRepository.findByUserName(userLogin.getUserName());
UserLoginResponse userLoginResponse = new UserLoginResponse();
if (optionalUserInfo.isPresent()) {
UserInfo userInfo = optionalUserInfo.get();
// 检查提供的密码是否与数据库中存储的密码匹配
if (passwordEncoder.matches(userLogin.getUserPassword(), userInfo.getUserPassword())) {
// 如果密码正确返回userLogin对象
userLoginResponse.setUserId(userInfo.getUserId());
userLoginResponse.setUserRe(true);
userLoginResponse.setMessage("登录成功");
} else {
// 如果密码不正确抛出异常或返回null
userLoginResponse.setUserId(-1);
userLoginResponse.setUserRe(true);
userLoginResponse.setMessage("密码错误");
}
} else {
// 如果找不到用户抛出异常或返回null
userLoginResponse.setUserId(-2);
userLoginResponse.setUserRe(true);
userLoginResponse.setMessage("未注册用户");
}
return userLoginResponse;
}
}

View File

@ -0,0 +1,55 @@
package edu.zrh.healthsystem.service;
import edu.zrh.healthsystem.eneity.UserInfo;
import edu.zrh.healthsystem.model.user.UserRegister;
import edu.zrh.healthsystem.model.user.UserRegisterResponse;
import edu.zrh.healthsystem.repository.RegisterRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import java.util.Optional;
/**
* @author han
*/
@Service
public class RegisterService {
private final RegisterRepository registerRepository;
// 密码加密
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
@Autowired
public RegisterService(RegisterRepository registerRepository) {
this.registerRepository = registerRepository;
}
public UserRegisterResponse register(UserRegister userRegister) {
// 检查用户名和电子邮件是否已存在
Optional<UserInfo> optionalName = registerRepository.findByUserName(userRegister.getUserName());
Optional<UserInfo> optionalEmail = registerRepository.findByUserEmail(userRegister.getUserEmail());
UserRegisterResponse userRegisterResponse = new UserRegisterResponse();
if (optionalName.isPresent()) {
userRegisterResponse.setMessage("已经存在账户名");
}
else
{
if (optionalEmail.isPresent()) {
userRegisterResponse.setMessage("已经存在电子邮件");
}
else
{
UserInfo user = new UserInfo();
user.setUserName(userRegister.getUserName());
user.setUserEmail(userRegister.getUserEmail());
user.setUserPassword(passwordEncoder.encode(userRegister.getUserPassword()));
registerRepository.save(user);
userRegisterResponse.setUserId(user.getUserId());
userRegisterResponse.setMessage("注册成功");
}
}
return userRegisterResponse;
}
}

View File

@ -0,0 +1,137 @@
package edu.zrh.healthsystem.service;
import edu.zrh.healthsystem.eneity.RegularCheckupInfo;
import edu.zrh.healthsystem.eneity.UserInfo;
import edu.zrh.healthsystem.model.Elderly;
import edu.zrh.healthsystem.model.elderly.RegularCheckupInfoResponse;
import edu.zrh.healthsystem.repository.RegularCheckupInfoRespository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@Service
public class RegularCheckupService {
private final RegularCheckupInfoRespository regularCheckupInfoRespository;
@Autowired
public RegularCheckupService(RegularCheckupInfoRespository regularCheckupInfoRespository) {
this.regularCheckupInfoRespository = regularCheckupInfoRespository;
}
RegularCheckupInfoResponse regularCheckupInfoResponse = new RegularCheckupInfoResponse();
public RegularCheckupInfoResponse add(Elderly elderly) {
Optional<RegularCheckupInfo> optionalElderly = regularCheckupInfoRespository.findByElderlyId(elderly.getElderlyId());
if (optionalElderly.isPresent()) {
regularCheckupInfoResponse.setMessage("已经有表");
} else {
RegularCheckupInfo regularCheckupInfo = new RegularCheckupInfo();
regularCheckupInfo.setBloodType(elderly.getBloodType());
regularCheckupInfo.setId(elderly.getElderlyId());
regularCheckupInfo.setCheckupDate(elderly.getCheckupDate());
regularCheckupInfo.setBloodPressure(elderly.getBloodPressure());
regularCheckupInfo.setFaceImage(elderly.getFaceImage());
regularCheckupInfo.setHeight(elderly.getHeight());
regularCheckupInfo.setGlucoseLevel(elderly.getGlucoseLevel());
regularCheckupInfo.setPulse(elderly.getPulse());
regularCheckupInfo.setHeartRate(elderly.getHeartRate());
regularCheckupInfo.setChronicDiseases(elderly.getChronicDiseases());
regularCheckupInfo.setTemperature(elderly.getTemperature());
regularCheckupInfo.setWeight(elderly.getWeight());
regularCheckupInfo.setTongueImage(elderly.getTongueImage());
regularCheckupInfo.setWeightStatus(elderly.getWeightStatus());
regularCheckupInfo.setOxygenSaturation(elderly.getOxygenSaturation());
regularCheckupInfoRespository.save(regularCheckupInfo);
regularCheckupInfoResponse.setMessage("添加成功");
}
return regularCheckupInfoResponse;
}
public RegularCheckupInfoResponse delete(Elderly elderly) {
Optional<RegularCheckupInfo> optionalElderly = regularCheckupInfoRespository.findByElderlyId(elderly.getElderlyId());
if (optionalElderly.isPresent()) {
RegularCheckupInfo regularCheckupInfo = optionalElderly.get();
regularCheckupInfo.setBloodType(elderly.getBloodType());
regularCheckupInfo.setId(elderly.getElderlyId());
regularCheckupInfo.setCheckupDate(elderly.getCheckupDate());
regularCheckupInfo.setBloodPressure(elderly.getBloodPressure());
regularCheckupInfo.setFaceImage(elderly.getFaceImage());
regularCheckupInfo.setHeight(elderly.getHeight());
regularCheckupInfo.setGlucoseLevel(elderly.getGlucoseLevel());
regularCheckupInfo.setPulse(elderly.getPulse());
regularCheckupInfo.setHeartRate(elderly.getHeartRate());
regularCheckupInfo.setChronicDiseases(elderly.getChronicDiseases());
regularCheckupInfo.setTemperature(elderly.getTemperature());
regularCheckupInfo.setWeight(elderly.getWeight());
regularCheckupInfo.setTongueImage(elderly.getTongueImage());
regularCheckupInfo.setWeightStatus(elderly.getWeightStatus());
regularCheckupInfo.setOxygenSaturation(elderly.getOxygenSaturation());
regularCheckupInfoRespository.save(regularCheckupInfo);
regularCheckupInfoResponse.setMessage("删除成功");
} else {
regularCheckupInfoResponse.setMessage("没有该表");
}
return regularCheckupInfoResponse;
}
public RegularCheckupInfoResponse update(Elderly elderly) {
Optional<RegularCheckupInfo> optionalElderly = regularCheckupInfoRespository.findByElderlyId(elderly.getElderlyId());
if (optionalElderly.isPresent()) {
RegularCheckupInfo regularCheckupInfo = optionalElderly.get();
regularCheckupInfo.setBloodType(elderly.getBloodType());
regularCheckupInfo.setId(elderly.getElderlyId());
regularCheckupInfo.setCheckupDate(elderly.getCheckupDate());
regularCheckupInfo.setBloodPressure(elderly.getBloodPressure());
regularCheckupInfo.setFaceImage(elderly.getFaceImage());
regularCheckupInfo.setHeight(elderly.getHeight());
regularCheckupInfo.setGlucoseLevel(elderly.getGlucoseLevel());
regularCheckupInfo.setPulse(elderly.getPulse());
regularCheckupInfo.setHeartRate(elderly.getHeartRate());
regularCheckupInfo.setChronicDiseases(elderly.getChronicDiseases());
regularCheckupInfo.setTemperature(elderly.getTemperature());
regularCheckupInfo.setWeight(elderly.getWeight());
regularCheckupInfo.setTongueImage(elderly.getTongueImage());
regularCheckupInfo.setWeightStatus(elderly.getWeightStatus());
regularCheckupInfo.setOxygenSaturation(elderly.getOxygenSaturation());
regularCheckupInfoRespository.save(regularCheckupInfo);
regularCheckupInfoResponse.setMessage("更新成功");
} else {
regularCheckupInfoResponse.setMessage("没有该表");
}
return regularCheckupInfoResponse;
}
public RegularCheckupInfoResponse get(Elderly elderly) {
Optional<RegularCheckupInfo> optionalElderly = regularCheckupInfoRespository.findByElderlyId(elderly.getElderlyId());
if (optionalElderly.isPresent()) {
regularCheckupInfoResponse.setBloodType(elderly.getBloodType());
regularCheckupInfoResponse.setId(elderly.getElderlyId());
regularCheckupInfoResponse.setCheckupDate(elderly.getCheckupDate());
regularCheckupInfoResponse.setBloodPressure(elderly.getBloodPressure());
regularCheckupInfoResponse.setFaceImage(elderly.getFaceImage());
regularCheckupInfoResponse.setHeight(elderly.getHeight());
regularCheckupInfoResponse.setGlucoseLevel(elderly.getGlucoseLevel());
regularCheckupInfoResponse.setPulse(elderly.getPulse());
regularCheckupInfoResponse.setHeartRate(elderly.getHeartRate());
regularCheckupInfoResponse.setChronicDiseases(elderly.getChronicDiseases());
regularCheckupInfoResponse.setTemperature(elderly.getTemperature());
regularCheckupInfoResponse.setWeight(elderly.getWeight());
regularCheckupInfoResponse.setProfileId(elderly.getProfileId());
regularCheckupInfoResponse.setTongueImage(elderly.getTongueImage());
regularCheckupInfoResponse.setWeightStatus(elderly.getWeightStatus());
regularCheckupInfoResponse.setOxygenSaturation(elderly.getOxygenSaturation());
regularCheckupInfoResponse.setMessage("查找成功");
} else {
regularCheckupInfoResponse.setMessage("没有该表");
}
return regularCheckupInfoResponse;
}
public RegularCheckupInfoResponse getAll() {
//待实现
regularCheckupInfoResponse.setMessage("查找全部成功");
return regularCheckupInfoResponse;
}
}

View File

@ -0,0 +1,28 @@
package edu.zrh.healthsystem.service;
import edu.zrh.healthsystem.model.Talk;
import edu.zrh.healthsystem.model.TalkResponse;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import java.util.Map;
/**
* @author han
*/
@Service
public class TalkService {
private final RestTemplate restTemplate;
public TalkService(RestTemplate restTemplate) {
this.restTemplate = restTemplate;
}
public String callApi(String url) {
return restTemplate.getForObject(url, String.class);
}
public TalkResponse callApiChat(Talk request) {
return restTemplate.postForObject("http://10.10.10.44:11434/api/chat", request, TalkResponse.class);
}
}

View File

@ -0,0 +1,25 @@
package edu.zrh.healthsystem.service.elderly;
import edu.zrh.healthsystem.eneity.BasicInfo;
import edu.zrh.healthsystem.repository.elderly.ElderMainRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author han
*/
@Service
public class ElderMainService {
private final ElderMainRepository elderMainRepository;
@Autowired
public ElderMainService(ElderMainRepository elderMainRepository) {this.elderMainRepository = elderMainRepository;}
public List elderMain(){
List<BasicInfo> basicInfoList = elderMainRepository.findAll();
return basicInfoList;
}
}

View File

@ -0,0 +1,44 @@
package edu.zrh.healthsystem.service.elderly;
import edu.zrh.healthsystem.eneity.UserInfo;
import edu.zrh.healthsystem.model.elderly.ElderlyConnect;
import edu.zrh.healthsystem.model.elderly.ElderlyConnectResponse;
import edu.zrh.healthsystem.repository.elderly.ElderlyConnectRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Optional;
@Service
public class ElderlyConnectService {
private final ElderlyConnectRepository elderlyConnectRepository;
@Autowired
public ElderlyConnectService(ElderlyConnectRepository elderlyConnectRepository) {
this.elderlyConnectRepository = elderlyConnectRepository;
}
public ElderlyConnectResponse getElderlyConnectResponse(ElderlyConnect elderlyConnect) {
Optional<UserInfo> optionalUserId = elderlyConnectRepository.findByUserId(elderlyConnect.getUserId());
Optional<UserInfo> optionalUserElderly = elderlyConnectRepository.findByUserElderly(elderlyConnect.getUserElderly());
ElderlyConnectResponse elderlyConnectResponse = new ElderlyConnectResponse();
if (optionalUserId.isPresent()) {
if(optionalUserElderly.isPresent())
{
UserInfo userInfo = optionalUserId.get();
userInfo.setUserElderly(elderlyConnect.getUserElderly());
elderlyConnectResponse.setUserId(elderlyConnect.getUserId());
elderlyConnectResponse.setMessage("添加成功");
}
else {
elderlyConnectResponse.setUserId(-2);
elderlyConnectResponse.setMessage("该老人不存在");
}
}
else {
elderlyConnectResponse.setUserId(-1);
elderlyConnectResponse.setMessage("该用户不存在");
}
return elderlyConnectResponse;
}
}

View File

@ -0,0 +1,66 @@
package edu.zrh.healthsystem.service.elderly;
import edu.zrh.healthsystem.eneity.BasicInfo;
import edu.zrh.healthsystem.eneity.MainProfileInfo;
import edu.zrh.healthsystem.model.elderly.ElderlyNew;
import edu.zrh.healthsystem.model.elderly.ElderlyNewResponse;
import edu.zrh.healthsystem.repository.elderly.ElderlyNewRepository;
import edu.zrh.healthsystem.repository.MainProfileInfoRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Optional;
/**
* @author han
*/
@Service
public class ElderlyNewService {
private final ElderlyNewRepository elderlyNewRepository;
private final MainProfileInfoRepository mainProfileInfoRepository;
@Autowired
public ElderlyNewService(ElderlyNewRepository elderlyNewRepository, MainProfileInfoRepository mainProfileInfoRepository) {
this.elderlyNewRepository = elderlyNewRepository;
this.mainProfileInfoRepository = mainProfileInfoRepository;
}
public ElderlyNewResponse elderly(ElderlyNew elderlyNew) {
Optional<BasicInfo> optionalBasicInfo = elderlyNewRepository.findByFullName(elderlyNew.getFullName());
ElderlyNewResponse elderlyNewResponse = new ElderlyNewResponse();
if (optionalBasicInfo.isPresent()) {
elderlyNewResponse.setElderlyId(-1);
elderlyNewResponse.setMessage("该用户已存在");
}
else {
BasicInfo basic = new BasicInfo();
basic.setContactRelation(elderlyNew.getContactRelation());
basic.setContactPhone(elderlyNew.getContactPhone());
basic.setContactName(elderlyNew.getContactName());
basic.setFullName(elderlyNew.getFullName());
basic.setGender(elderlyNew.getGender());
basic.setDateOfBirth(elderlyNew.getDateOfBirth());
basic.setEthnicity(elderlyNew.getEthnicity());
basic.setNativePlace(elderlyNew.getNativePlace());
basic.setIdNumber(elderlyNew.getIdNumber());
basic.setPermanentAddress(elderlyNew.getPermanentAddress());
basic.setOccupation(elderlyNew.getOccupation());
basic.setEducationLevel(elderlyNew.getEducationLevel());
basic.setLivingAlone(elderlyNew.getLivingAlone());
basic.setMaritalStatus(elderlyNew.getMaritalStatus());
basic.setPhoneNumber(elderlyNew.getPhoneNumber());
basic.setEatingHabits(elderlyNew.getEatingHabits());
basic.setExerciseFrequency(elderlyNew.getExerciseFrequency());
elderlyNewRepository.save(basic);
// 创建MainProfile记录
MainProfileInfo mainProfile = new MainProfileInfo();
mainProfile.setElderlyId(basic);
// 保存MainProfile记录
mainProfileInfoRepository.save(mainProfile);
elderlyNewResponse.setElderlyId(basic.getElderlyId());
elderlyNewResponse.setMessage("提交成功");
}
return elderlyNewResponse;
}
}

View File

@ -0,0 +1,51 @@
package edu.zrh.healthsystem.service.elderly;
import edu.zrh.healthsystem.eneity.BasicInfo;
import edu.zrh.healthsystem.model.Elderly;
import edu.zrh.healthsystem.repository.elderly.ElderlyShowRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import edu.zrh.healthsystem.model.elderly.ElderlyShowResponse;
import java.util.Optional;
@Service
public class ElderlyShowService {
private final ElderlyShowRepository elderlyShowRepository;
@Autowired
public ElderlyShowService(ElderlyShowRepository elderlyShowRepository) {
this.elderlyShowRepository = elderlyShowRepository;
}
public ElderlyShowResponse getElderlyShow(Elderly elderly) {
Optional<BasicInfo> optionalelderlyId = elderlyShowRepository.findByElderlyId(elderly.getElderlyId());
ElderlyShowResponse elderlyShowResponse = new ElderlyShowResponse();
if (optionalelderlyId.isPresent()) {
BasicInfo basic=optionalelderlyId.get();
elderlyShowResponse.setElderlyId(basic.getElderlyId());
elderlyShowResponse.setContactName(basic.getContactName());
elderlyShowResponse.setContactPhone(basic.getContactPhone());
elderlyShowResponse.setEatingHabits(basic.getEatingHabits());
elderlyShowResponse.setContactRelation(basic.getContactRelation());
elderlyShowResponse.setEthnicity(basic.getEthnicity());
elderlyShowResponse.setEducationLevel(basic.getEducationLevel());
elderlyShowResponse.setExerciseFrequency(basic.getExerciseFrequency());
elderlyShowResponse.setGender(basic.getGender());
elderlyShowResponse.setMaritalStatus(basic.getMaritalStatus());
elderlyShowResponse.setDateOfBirth(basic.getDateOfBirth());
elderlyShowResponse.setOccupation(basic.getOccupation());
elderlyShowResponse.setLivingAlone(basic.getLivingAlone());
elderlyShowResponse.setNativePlace(basic.getNativePlace());
elderlyShowResponse.setFullName(basic.getFullName());
elderlyShowResponse.setMessage("获取成功");
elderlyShowResponse.setPermanentAddress(basic.getPermanentAddress());
elderlyShowResponse.setIdNumber(basic.getIdNumber());
elderlyShowResponse.setPhoneNumber(basic.getPhoneNumber());
}
else {
elderlyShowResponse.setMessage("该用户不存在");
}
return elderlyShowResponse;
}
}

View File

@ -0,0 +1,34 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!--开启包扫描-->
<context:component-scan base-package="edu.zrh.healthsystem"/>
<context:property-placeholder location="classpath:application.properties" />
<!--开启注解驱动注册一些必要的Bean到SpringMVC容器里面-->
<mvc:annotation-driven>
<!-- 处理乱码 -->
<mvc:message-converters register-defaults="true">
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<constructor-arg value="UTF-8"/>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<!-- 视图解析器
作用1.捕获后端控制器的返回值="index"
2.解析: 在返回值的前后 拼接 ==> "/index.jsp"
-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 前缀 -->
<property name="prefix" value="/WEB-INF/jsp/"></property>
<!-- 后缀 -->
<property name="suffix" value=".jsp"></property>
</bean>
</beans>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 告诉SpringMVC配置文件在哪里-->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/WEB-INF/spring-conf/mvc.xml</param-value>
<!-- <param-value>/WEB-INF/spring-conf/mvc.xml</param-value>-->
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>

View File

@ -0,0 +1,7 @@
spring.application.name=healthSystem
# DataSource settings
spring.datasource.url= jdbc:mysql://localhost:3306/healthsystem?allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=1234
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

View File

@ -0,0 +1,22 @@
package edu.zrh.healthsystem;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import java.sql.DriverManager;
import java.sql.Driver;
import java.util.Enumeration;
@SpringBootTest
class HealthSystemApplicationTests {
@Test
void contextLoads() {
Enumeration<Driver> drivers = DriverManager.getDrivers();
while (drivers.hasMoreElements()) {
Driver driver = drivers.nextElement();
System.out.println("驱动名称: " + driver.getClass().getName());
}
}
}