commit 9f4f77fcc74c6d7f554c6747b7127155cb814e7e Author: lulz1 Date: Thu Feb 1 13:53:03 2024 +0800 初始化代码 diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..549e00a2 --- /dev/null +++ b/.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/ diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 00000000..cb28b0e3 Binary files /dev/null and b/.mvn/wrapper/maven-wrapper.jar differ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 00000000..5f0536eb --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar diff --git a/mvnw b/mvnw new file mode 100644 index 00000000..66df2854 --- /dev/null +++ b/mvnw @@ -0,0 +1,308 @@ +#!/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.2.0 +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /usr/local/etc/mavenrc ] ; then + . /usr/local/etc/mavenrc + fi + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "$(uname)" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME + else + JAVA_HOME="/Library/Java/Home"; export JAVA_HOME + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=$(java-config --jre-home) + fi +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$JAVA_HOME" ] && + JAVA_HOME=$(cygpath --unix "$JAVA_HOME") + [ -n "$CLASSPATH" ] && + CLASSPATH=$(cygpath --path --unix "$CLASSPATH") +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] && + JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="$(which javac)" + if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=$(which readlink) + if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then + if $darwin ; then + javaHome="$(dirname "\"$javaExecutable\"")" + javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac" + else + javaExecutable="$(readlink -f "\"$javaExecutable\"")" + fi + javaHome="$(dirname "\"$javaExecutable\"")" + javaHome=$(expr "$javaHome" : '\(.*\)/bin') + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=$(cd "$wdir/.." || exit 1; pwd) + fi + # end of workaround + done + printf '%s' "$(cd "$basedir" || exit 1; pwd)" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + # Remove \r in case we run on Windows within Git Bash + # and check out the repository with auto CRLF management + # enabled. Otherwise, we may read lines that are delimited with + # \r\n and produce $'-Xarg\r' rather than -Xarg due to word + # splitting rules. + tr -s '\r\n' ' ' < "$1" + fi +} + +log() { + if [ "$MVNW_VERBOSE" = true ]; then + printf '%s\n' "$1" + fi +} + +BASE_DIR=$(find_maven_basedir "$(dirname "$0")") +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR +log "$MAVEN_PROJECTBASEDIR" + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" +if [ -r "$wrapperJarPath" ]; then + log "Found $wrapperJarPath" +else + log "Couldn't find $wrapperJarPath, downloading it ..." + + if [ -n "$MVNW_REPOURL" ]; then + wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + else + wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + fi + while IFS="=" read -r key value; do + # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) + safeValue=$(echo "$value" | tr -d '\r') + case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;; + esac + done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" + log "Downloading from: $wrapperUrl" + + if $cygwin; then + wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") + fi + + if command -v wget > /dev/null; then + log "Found wget ... using wget" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + else + wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + log "Found curl ... using curl" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + else + curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + fi + else + log "Falling back to using Java to download" + javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" + javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaSource=$(cygpath --path --windows "$javaSource") + javaClass=$(cygpath --path --windows "$javaClass") + fi + if [ -e "$javaSource" ]; then + if [ ! -e "$javaClass" ]; then + log " - Compiling MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/javac" "$javaSource") + fi + if [ -e "$javaClass" ]; then + log " - Running MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +# If specified, validate the SHA-256 sum of the Maven wrapper jar file +wrapperSha256Sum="" +while IFS="=" read -r key value; do + case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;; + esac +done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" +if [ -n "$wrapperSha256Sum" ]; then + wrapperSha256Result=false + if command -v sha256sum > /dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then + wrapperSha256Result=true + fi + elif command -v shasum > /dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then + wrapperSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." + echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." + exit 1 + fi + if [ $wrapperSha256Result = false ]; then + echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2 + echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2 + echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2 + exit 1 + fi +fi + +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$JAVA_HOME" ] && + JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") + [ -n "$CLASSPATH" ] && + CLASSPATH=$(cygpath --path --windows "$CLASSPATH") + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +# shellcheck disable=SC2086 # safe args +exec "$JAVACMD" \ + $MAVEN_OPTS \ + $MAVEN_DEBUG_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 00000000..95ba6f54 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,205 @@ +@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.2.0 +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %WRAPPER_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file +SET WRAPPER_SHA_256_SUM="" +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B +) +IF NOT %WRAPPER_SHA_256_SUM%=="" ( + powershell -Command "&{"^ + "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ + "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ + " Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ + " Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ + " Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ + " exit 1;"^ + "}"^ + "}" + if ERRORLEVEL 1 goto error +) + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% ^ + %JVM_CONFIG_MAVEN_PROPS% ^ + %MAVEN_OPTS% ^ + %MAVEN_DEBUG_OPTS% ^ + -classpath %WRAPPER_JAR% ^ + "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%"=="on" pause + +if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% + +cmd /C exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000..acc5545a --- /dev/null +++ b/pom.xml @@ -0,0 +1,96 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.1.8 + + + com.chint + Route + 0.0.1-SNAPSHOT + Route + Route + + 17 + + + + org.springframework.boot + spring-boot-starter-data-jdbc + + + org.springframework.boot + spring-boot-starter-web + + + + com.mysql + mysql-connector-j + runtime + + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + + org.apache.httpcomponents + httpclient + 4.5.14 + + + com.google.code.gson + gson + 2.10.1 + + + com.chint.dc + common-api-sdk + 2.4.0 + + + com.auth0 + java-jwt + 4.4.0 + + + cn.hutool + hutool-all + 5.7.22 + + + com.github.xiaoymin + knife4j-spring-boot-starter + 3.0.3 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + paketobuildpacks/builder-jammy-base:latest + + + + org.projectlombok + lombok + + + + + + + + diff --git a/src/main/java/com/chint/RouteApplication.java b/src/main/java/com/chint/RouteApplication.java new file mode 100644 index 00000000..dc12049d --- /dev/null +++ b/src/main/java/com/chint/RouteApplication.java @@ -0,0 +1,13 @@ +package com.chint; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class RouteApplication { + + public static void main(String[] args) { + SpringApplication.run(RouteApplication.class, args); + } + +} diff --git a/src/main/java/com/chint/domain/aggregates/base/BaseEntity.java b/src/main/java/com/chint/domain/aggregates/base/BaseEntity.java new file mode 100644 index 00000000..73ed081e --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/base/BaseEntity.java @@ -0,0 +1,40 @@ +package com.chint.domain.aggregates.base; + + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.data.annotation.CreatedBy; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedBy; +import org.springframework.data.annotation.LastModifiedDate; + +import java.time.LocalDateTime; + +@Data +public class BaseEntity { + + @ApiModelProperty("启用状态,1启动,0禁用") + public Integer status = 1; + + @ApiModelProperty("排序字段") + public Integer sort = 0; + + @CreatedBy + @ApiModelProperty("创建人标识") + public String createUser; + + @CreatedDate + @ApiModelProperty("创建时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8") + public LocalDateTime createTime; + + @LastModifiedBy + @ApiModelProperty("最后更新人标识") + public String updateUser; + + @LastModifiedDate + @ApiModelProperty("最后更新时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8") + public LocalDateTime updateTime; +} diff --git a/src/main/java/com/chint/domain/aggregates/order/Leg.java b/src/main/java/com/chint/domain/aggregates/order/Leg.java new file mode 100644 index 00000000..c8e71014 --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/order/Leg.java @@ -0,0 +1,109 @@ +package com.chint.domain.aggregates.order; + + +import com.chint.domain.aggregates.base.BaseEntity; +import lombok.Data; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; + +import static com.chint.infrastructure.constant.Constant.*; + + +@Data +public class Leg extends BaseEntity { + + public Long legId; + public Integer legType; + + public LocalDateTime startTime; + public LocalDateTime endTime; + + public Integer sequence = 0; + + public Location origin; + + public Location destination; + + public Long routeId; + + public String amount; + + public String legTypeName; + + public Integer legStatus; + + public String legStatusName; + + private List eventList; + + + + public Leg reloadStatus() { + int eventLength = eventList.size() - 1; + this.legStatus = eventLength < 0 ? LEG_STATUS_PREPARE : eventLength; + if (legStatus > 1) { + Optional legEvent = this.eventList + .stream() + .filter(event -> event.getEventType().equals(LEG_EVENT_ORDERED)) + .findFirst(); + if (legEvent.isPresent()) { + LegEvent event = legEvent.get(); + this.amount = event.getOrderAmount(); + } + } + this.legStatusName = translateLegStatus(this.legStatus); + if (legType != null) { + this.legTypeName = translateLegType(this.legType); + } + return this; + } + + private String translateLegStatus(int status) { + return switch (status) { + case LEG_STATUS_PREPARE -> LEG_STATUS_PREPARE_NAME; + case LEG_STATUS_ORDERED -> LEG_STATUS_ORDERED_NAME; + case LEG_STATUS_PAYED -> LEG_STATUS_PAYED_NAME; + case LEG_STATUS_FINISH -> LEG_STATUS_FINISH_NAME; + default -> "未知状态"; + }; + } + + public String translateLegType(int type) { + return switch (type) { + case LEG_TYPE_TRAIN -> LEG_TYPE_TRAIN_NAME; + case LEG_TYPE_AIRPLANE -> LEG_TYPE_AIRPLANE_NAME; + case LEG_TYPE_HOTEL -> LEG_TYPE_HOTEL_NAME; + case LEG_TYPE_TAXI -> LEG_TYPE_TAXI_NAME; + case LEG_TYPE_OTHER -> LEG_TYPE_OTHER_NAME; + default -> "未知类型"; + }; + } + + private Optional getLatestEventType() { + return eventList.stream() + .map(LegEvent::getEventType) + .max(Integer::compareTo); + } + +// public void handleEvent(EventDTO eventDTO) { +// switch (this.legStatus) { +// case LEG_EVENT_PREPARE: +// handlePrepareEvent(legEventRepository); +// break; +// case LEG_EVENT_ORDERED: +// handleOrderedEvent(legEventRepository, eventDTO.orderDetail, eventDTO.orderAmount); +// break; +// case LEG_EVENT_PAYED: +// handlePayedEvent(legEventRepository, eventDTO.orderAmount); +// break; +// case LEG_EVENT_FINISH: +// handleFinishEvent(legEventRepository); +// break; +// default: +// // 处理未知事件类型或记录错误 +// break; +// } +// } +} \ No newline at end of file diff --git a/src/main/java/com/chint/domain/aggregates/order/LegEvent.java b/src/main/java/com/chint/domain/aggregates/order/LegEvent.java new file mode 100644 index 00000000..ca7d7d8c --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/order/LegEvent.java @@ -0,0 +1,32 @@ +package com.chint.domain.aggregates.order; + +import com.chint.domain.aggregates.base.BaseEntity; +import lombok.Data; + +import static com.chint.infrastructure.constant.Constant.*; + +@Data +public class LegEvent extends BaseEntity { + private Long legEventId; + + private Long legId; + + private Leg leg; + + private Integer eventType; + + private String eventName; + + private String orderAmount; + + + public String translateLegEvent(int event) { + return switch (event) { + case LEG_EVENT_PREPARE -> LEG_EVENT_PREPARE_NAME; + case LEG_EVENT_ORDERED -> LEG_EVENT_ORDERED_NAME; + case LEG_EVENT_PAYED -> LEG_EVENT_PAYED_NAME; + case LEG_EVENT_FINISH -> LEG_EVENT_FINISH_NAME; + default -> "未知事件"; + }; + } +} diff --git a/src/main/java/com/chint/domain/aggregates/order/Location.java b/src/main/java/com/chint/domain/aggregates/order/Location.java new file mode 100644 index 00000000..905fc87c --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/order/Location.java @@ -0,0 +1,21 @@ +package com.chint.domain.aggregates.order; + + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class Location { + + private Long locationId; + private String locationPath; + private String locationPathName; + private String locationName; + private String locationShortName; + private Long parentLocationId; + private Integer level; + +} \ No newline at end of file diff --git a/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java b/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java new file mode 100644 index 00000000..73703229 --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java @@ -0,0 +1,106 @@ +package com.chint.domain.aggregates.order; + + +import com.chint.domain.aggregates.base.BaseEntity; +import com.chint.domain.aggregates.user.User; +import com.chint.infrastructure.util.BigDecimalCalculator; +import lombok.Data; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDateTime; +import java.util.Comparator; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +import static com.chint.infrastructure.constant.Constant.*; + +@Data +@Table("route_order") +public class RouteOrder extends BaseEntity { + @Id + public Long routeId; + + private LocalDateTime bookingTime; + + private String amount; + + private Integer orderStatus; + + private String orderStatusName; + + private User user; + + public List legItems; + + + + public void addItemAtPosition(Leg newItem) { + Integer position = newItem.getSequence(); + if (position == null) { + position = this.legItems.size() + 1; + newItem.setSequence(position); + } + if (position < 0 || position > this.legItems.size() + 1) { + throw new IllegalArgumentException(PARAM_ERROR); + } + Integer streamPosition = position; + this.legItems.stream() + .filter(item -> item.getSequence() >= streamPosition) + .forEach(item -> item.setSequence(item.getSequence() + 1)); + newItem.setRouteId(this.routeId); + newItem.legId = newItem.getLegId(); + newItem.reloadStatus(); + } + + public List legOrdered() { + return this.legItems.stream() + .sorted(Comparator.comparingInt(Leg::getSequence)) + .collect(Collectors.toList()); + } + + public RouteOrder reloadStatus() { + this.amount = this.legItems + .stream() + .filter(leg -> leg.amount != null) + .map(Leg::getAmount) + .reduce(BigDecimalCalculator::add) + .orElse(KEEP_TWO_DECIMAL_ZERO); + this.updateStatus(); + this.orderStatusName = translateOrderStatus(this.orderStatus); + return this; + } + + public void updateStatus() { + if (allItemsInStatus(3)) { + this.orderStatus = 3; + } else if (allItemsInStatus(2)) { + this.orderStatus = 2; + } else if (allItemsInStatus(1)) { + this.orderStatus = 1; + } else { + this.orderStatus = 0; // 或其他适当的默认状态 + } + } + + private boolean allItemsInStatus(int targetStatus) { + for (Leg item : this.legItems) { + if (item.getLegStatus() < targetStatus) { + return false; + } + } + return true; + } + + private String translateOrderStatus(int status) { + return switch (status) { + case ORDER_STATUS_PREPARE -> ORDER_STATUS_PREPARE_NAME; + case ORDER_STATUS_ORDERED -> ORDER_STATUS_ORDERED_NAME; + case ORDER_STATUS_PAYED -> ORDER_STATUS_PAYED_NAME; + case ORDER_STATUS_FINISH -> ORDER_STATUS_FINISH_NAME; + default -> "未知状态"; + }; + } +} \ No newline at end of file diff --git a/src/main/java/com/chint/domain/aggregates/user/User.java b/src/main/java/com/chint/domain/aggregates/user/User.java new file mode 100644 index 00000000..adb467b9 --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/user/User.java @@ -0,0 +1,65 @@ +package com.chint.domain.aggregates.user; + +import com.auth0.jwt.interfaces.Claim; +import com.auth0.jwt.interfaces.DecodedJWT; +import com.chint.domain.aggregates.order.RouteOrder; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +import static com.chint.infrastructure.constant.Constant.*; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class User { + + public Long userId; + public Long employeeNo; + public Integer employeeLevel; + public String name; + public String email; + public String gender; + public String phoneNumber; + public String password; + public String rankCode; + public String companyCode; + public String workStatus; + private List orders; + + public User(Long employeeNo) { + this.employeeNo = employeeNo; + } + + public User(Long userId, Long employeeNo, Integer employeeLevel, String name, String email, String phoneNumber) { + this.userId = userId; + this.employeeNo = employeeNo; + this.employeeLevel = employeeLevel; + this.name = name; + this.email = email; + this.phoneNumber = phoneNumber; + } + + public static User withEmployeeNo(Long employeeNo) { + return new User(employeeNo); + } + + public static User withJwt(DecodedJWT jwt) { + Map claims = jwt.getClaims(); + Claim userId = claims.get(USER_ID); + Claim phoneNumber = claims.get(USER_PHONE); + Claim email = claims.get(USER_EMAIL); + Claim employeeNo = claims.get(USER_EMPLOYEE_NO); + Claim name = claims.get(USER_NAME); + Claim employeeLevel = claims.get(USER_EMPLOYEE_LEVEL); + return new User(userId.asLong(), + employeeNo.asLong(), + employeeLevel.asInt(), + name.asString(), + email.asString(), + phoneNumber.asString()); + } +} \ No newline at end of file diff --git a/src/main/java/com/chint/domain/factoriy/OrderFactory.java b/src/main/java/com/chint/domain/factoriy/OrderFactory.java new file mode 100644 index 00000000..ce62da84 --- /dev/null +++ b/src/main/java/com/chint/domain/factoriy/OrderFactory.java @@ -0,0 +1,8 @@ +package com.chint.domain.factoriy; + +import com.chint.domain.aggregates.order.RouteOrder; +import com.chint.domain.value_object.OrderCreateData; + +public interface OrderFactory { + RouteOrder createOrder(OrderCreateData orderData); +} diff --git a/src/main/java/com/chint/domain/factoriy/RouteOrderFactory.java b/src/main/java/com/chint/domain/factoriy/RouteOrderFactory.java new file mode 100644 index 00000000..cc3ea8e5 --- /dev/null +++ b/src/main/java/com/chint/domain/factoriy/RouteOrderFactory.java @@ -0,0 +1,11 @@ +package com.chint.domain.factoriy; + +import com.chint.domain.aggregates.order.RouteOrder; +import com.chint.domain.value_object.OrderCreateData; + +public class RouteOrderFactory implements OrderFactory{ + @Override + public RouteOrder createOrder(OrderCreateData orderData) { + return null; + } +} diff --git a/src/main/java/com/chint/domain/repositories/LegEventRepository.java b/src/main/java/com/chint/domain/repositories/LegEventRepository.java new file mode 100644 index 00000000..a18f55f2 --- /dev/null +++ b/src/main/java/com/chint/domain/repositories/LegEventRepository.java @@ -0,0 +1,12 @@ +package com.chint.domain.repositories; + +import com.chint.domain.aggregates.order.Leg; +import com.chint.domain.aggregates.order.LegEvent; + +import java.util.List; + +public interface LegEventRepository { + void deleteByLegId(Leg leg); + List findAllByLegId(Long id); + LegEvent save(LegEvent legEvent); +} \ No newline at end of file diff --git a/src/main/java/com/chint/domain/repositories/LegRepository.java b/src/main/java/com/chint/domain/repositories/LegRepository.java new file mode 100644 index 00000000..f93f8739 --- /dev/null +++ b/src/main/java/com/chint/domain/repositories/LegRepository.java @@ -0,0 +1,13 @@ +package com.chint.domain.repositories; + +import com.chint.domain.aggregates.order.Leg; +import com.chint.domain.aggregates.order.RouteOrder; + +import java.util.List; + +public interface LegRepository { + Leg save(Leg bookingItem); + void deleteById(Long id); + List findByOrder(RouteOrder order); + void saveAll(List bookingItems); +} \ No newline at end of file diff --git a/src/main/java/com/chint/domain/repositories/LocationRepository.java b/src/main/java/com/chint/domain/repositories/LocationRepository.java new file mode 100644 index 00000000..286ea099 --- /dev/null +++ b/src/main/java/com/chint/domain/repositories/LocationRepository.java @@ -0,0 +1,8 @@ +package com.chint.domain.repositories; + +import com.chint.domain.aggregates.order.Location; + +public interface LocationRepository { +// List findByHot(List locationHots); + Location findByLocationId(Long locationId); +} \ No newline at end of file diff --git a/src/main/java/com/chint/domain/repositories/RouteRepository.java b/src/main/java/com/chint/domain/repositories/RouteRepository.java new file mode 100644 index 00000000..617b0388 --- /dev/null +++ b/src/main/java/com/chint/domain/repositories/RouteRepository.java @@ -0,0 +1,11 @@ +package com.chint.domain.repositories; + +import com.chint.domain.aggregates.order.RouteOrder; +import com.chint.domain.aggregates.user.User; +import com.chint.infrastructure.util.PageResult; + +public interface RouteRepository { + RouteOrder queryById(Long orderId); + RouteOrder save(RouteOrder routeOrder); + PageResult pageQuery(User user); +} \ No newline at end of file diff --git a/src/main/java/com/chint/domain/repositories/UserRepository.java b/src/main/java/com/chint/domain/repositories/UserRepository.java new file mode 100644 index 00000000..0da5be81 --- /dev/null +++ b/src/main/java/com/chint/domain/repositories/UserRepository.java @@ -0,0 +1,8 @@ +package com.chint.domain.repositories; + +import com.chint.domain.aggregates.user.User; + +public interface UserRepository { + User findById(Long id); + User findByUserEmployeeNo(Long employeeNo); +} \ No newline at end of file diff --git a/src/main/java/com/chint/domain/value_object/OrderCreateData.java b/src/main/java/com/chint/domain/value_object/OrderCreateData.java new file mode 100644 index 00000000..fcc06c74 --- /dev/null +++ b/src/main/java/com/chint/domain/value_object/OrderCreateData.java @@ -0,0 +1,4 @@ +package com.chint.domain.value_object; + +public class OrderCreateData { +} diff --git a/src/main/java/com/chint/infrastructure/constant/Constant.java b/src/main/java/com/chint/infrastructure/constant/Constant.java new file mode 100644 index 00000000..342648fc --- /dev/null +++ b/src/main/java/com/chint/infrastructure/constant/Constant.java @@ -0,0 +1,145 @@ +package com.chint.infrastructure.constant; + +public class Constant { + // 通用消息 + // 通用消息 + public static final String SUCCESS = "操作成功"; + public static final String FAILURE = "操作失败"; + public static final String NOT_FOUND = "未找到相关数据"; + public static final String INVALID_REQUEST = "无效的请求"; + public static final String ACCESS_DENIED = "访问被拒绝"; + public static final String SERVER_ERROR = "服务器错误"; + + // 数据相关消息 + public static final String DATA_ALREADY_EXISTS = "数据已存在"; + public static final String DATA_UPDATE_SUCCESS = "数据更新成功"; + public static final String DATA_CREATION_SUCCESS = "数据创建成功"; + public static final String DATA_DELETION_SUCCESS = "数据删除成功"; + public static final String DATA_NOT_FOUND = "未找到数据"; + public static final String DATA_INVALID = "数据不合法"; + + // JWT 验证消息 + public static final String JWT_INVALID = "无效的 JWT 令牌"; + public static final String JWT_EXPIRED = "JWT 令牌已过期"; + public static final String JWT_REQUIRED = "需要 JWT 令牌"; + public static final String JWT_ACCESS_DENIED = "JWT 令牌不足以访问此资源"; + + // 用户认证消息 + public static final String AUTHENTICATION_FAILED = "认证失败"; + public static final String LOGIN_SUCCESS = "登录成功"; + public static final String LOGIN_FAILURE = "登录失败"; + public static final String LOGOUT_SUCCESS = "成功登出"; + + // 系统消息 + public static final String SYSTEM_MAINTENANCE = "系统维护中"; + public static final String SYSTEM_UPGRADE = "系统升级中"; + + // Param + public static final String PARAM_ERROR = "参数错误"; + + // 订单状态 + public static final int ORDER_STATUS_PREPARE = 0; + public static final String ORDER_STATUS_PREPARE_NAME = "规划中"; + public static final int ORDER_STATUS_ORDERED = 1; + public static final String ORDER_STATUS_ORDERED_NAME = "已下单"; + public static final int ORDER_STATUS_PAYED = 2; + public static final String ORDER_STATUS_PAYED_NAME = "已付款"; + public static final int ORDER_STATUS_FINISH = 3; + public static final String ORDER_STATUS_FINISH_NAME = "已结束"; + + // 规划节点状态 + public static final int LEG_STATUS_PREPARE = 0; + public static final String LEG_STATUS_PREPARE_NAME = "规划中"; + public static final int LEG_STATUS_ORDERED = 1; + public static final String LEG_STATUS_ORDERED_NAME = "已下单"; + public static final int LEG_STATUS_PAYED = 2; + public static final String LEG_STATUS_PAYED_NAME = "已付款"; + public static final int LEG_STATUS_FINISH = 3; + public static final String LEG_STATUS_FINISH_NAME = "已结束"; + + // 规划节点运输方式 + public static final int LEG_TYPE_TRAIN = 0; + public static final String LEG_TYPE_TRAIN_NAME = "火车"; + public static final int LEG_TYPE_AIRPLANE = 1; + public static final String LEG_TYPE_AIRPLANE_NAME = "飞机"; + public static final int LEG_TYPE_HOTEL = 2; + public static final String LEG_TYPE_HOTEL_NAME = "酒店"; + public static final int LEG_TYPE_TAXI = 3; + public static final String LEG_TYPE_TAXI_NAME = "出租车"; + public static final int LEG_TYPE_OTHER = 4; + public static final String LEG_TYPE_OTHER_NAME = "其他"; + + // 规划节点事件 + public static final int LEG_EVENT_PREPARE = 0; + public static final String LEG_EVENT_PREPARE_NAME = "初始事件"; + public static final int LEG_EVENT_ORDERED = 1; + public static final String LEG_EVENT_ORDERED_NAME = "下单事件"; + public static final int LEG_EVENT_PAYED = 2; + public static final String LEG_EVENT_PAYED_NAME = "付款事件"; + public static final int LEG_EVENT_FINISH = 3; + public static final String LEG_EVENT_FINISH_NAME = "结束事件"; + + // 金额 + public static final String KEEP_TWO_DECIMAL_ZERO = "0.00"; + + // 登录信息 + public static final String USER_ID = "userId"; + public static final String USER_PHONE = "phoneNumber"; + public static final String USER_EMAIL = "email"; + public static final String USER_EMPLOYEE_NO = "employeeNo"; + public static final String USER_NAME = "name"; + public static final String USER_EMPLOYEE_LEVEL = "employeeLevel"; + public static final String USER_RANK_CODE = "rankCode"; + public static final String USER_COMPANY_CODE = "companyCode"; + + // JWT + public static final String SECRET = "Superdandan"; // 替换为你自己的密钥 + public static final String SUBJECT = "EmployeeNo"; + public static final long EXPIRATION_TIME_MS = 3600000L; // 1小时过期时间 + public static final String HEADER_TOKEN = "token"; + + // URL + public static final String AK_BASE_URL = "http://10.10.100.184:7052"; + public static final String GET_AK_URL = "/api/DataCenter/GetKey"; + public static final String UPDATE_AK_PATH = "/api/DataCenter/UpdataKey"; + public static final String ADD_AK_URL = "/api/DataCenter/AddKey"; + public static final String SYSTEM_ID = "e72991a531a340b8a017139a6b51db3d"; + public static final String OPENAI_BASE_URL = "https://openapi.chintcloud.net"; + public static final String USER_DATA_PATH = "/open/HR/commonuserlist"; + public static final String TRAVEL_RANK_BASE_URL = "http://10.10.14.178:8080"; + public static final String TRAVEL_RANK_PATH = "/fssc/queryBill/queryTravelLevelByRank"; + + // 携程 + public static final String C_TRIP_BASE_URL = "https://ct.ctrip.com"; + public static final String TICKET_PATH = "/SwitchAPI/Order/Ticket"; + public static final String C_TRIP_APP_KEY = "obk_zhengtai"; // 测试appkey + public static final String C_TRIP_APP_SECURITY = "obk_zhengtai"; // 测试app秘钥 + public static final String USER_SAVE_PATH = "/corpservice/CorpCustService/SaveCorpCustInfoList"; + public static final String HOTEL_CITY_PATH = "/corpopenapi/HotelCity/GetCountryCityExtend"; + public static final String HOTEL_COUNTRY_PATH = "/corpopenapi/HotelCity/GetCountry"; + public static final String AIR_AIRPORT_PATH = "/flightBaseData/queryAirPort"; + public static final String AIR_CITY_PATH = "/flightBaseData/queryCity"; + public static final String AIR_PROVINCE_PATH = "/flightBaseData/queryProvince"; + public static final String AIR_COUNTRY_PATH = "/flightBaseData/queryCountry"; + public static final String TRAIN_CITY_PATH = "/dataapi/train/inter/searchBizLocationList"; + public static final String LANGUAGE_CN = "zh-CN"; + public static final String C_TRIP_USER_SAVE_PATH = "/corpservice/CorpCustService/SaveCorpCustInfoList"; + public static final String C_TRIP_APPROVAL_PATH = "/switchapi/approval.svc/rest/setapproval"; + public static final String C_TRIP_ESTIMATE_PATH = "/bookingrelatedservice/bookingrelatedopenapi"; + public static final String C_TRIP_TOKEN_PATH = "/dataservice/token/getAccessToken"; + public static final String C_TRIP_ORDER_SEARCH_PATH = "/switchapi/Order/SearchOrder"; + + + //同程 + public static final String L_Y_BASE_URL = "https://api.qa.dttrip.cn"; + public static final String L_Y_TOKEN_PATH = "/openapi/api/OAuth/v2/GetAccessToken"; + public static final String L_Y_USER_PATH = "/openapi/api/Employee/SyncEmployeeInfo"; + public static final String L_Y_ACCOUNT = "4f9cb1080b564dd0a94aa95f7a19c8b5"; // 测试appkey + public static final String L_Y_PASSWORD = "1fD3SutgzfS48qznYQiq"; // 测试app秘钥 + public static final String L_Y_SECRET = "WOHzCMvHd823iHgH"; // 测试app秘钥 + + + + // status + public static final int STATUS_DISABLED = 0; +} diff --git a/src/main/java/com/chint/infrastructure/util/BaseContext.java b/src/main/java/com/chint/infrastructure/util/BaseContext.java new file mode 100644 index 00000000..c4dbc4fd --- /dev/null +++ b/src/main/java/com/chint/infrastructure/util/BaseContext.java @@ -0,0 +1,20 @@ +package com.chint.infrastructure.util; + +import com.chint.domain.aggregates.user.User; + +public class BaseContext { + + private static final ThreadLocal threadLocal = new ThreadLocal<>(); + + public static void setCurrentUser(User user) { + threadLocal.set(user); + } + + public static User getCurrentUser() { + return threadLocal.get(); + } + + public static void removeCurrentUser() { + threadLocal.remove(); + } +} \ No newline at end of file diff --git a/src/main/java/com/chint/infrastructure/util/BigDecimalCalculator.java b/src/main/java/com/chint/infrastructure/util/BigDecimalCalculator.java new file mode 100644 index 00000000..3fc08730 --- /dev/null +++ b/src/main/java/com/chint/infrastructure/util/BigDecimalCalculator.java @@ -0,0 +1,62 @@ +package com.chint.infrastructure.util; + +import java.math.BigDecimal; + +import static com.chint.infrastructure.constant.Constant.KEEP_TWO_DECIMAL_ZERO; + +public class BigDecimalCalculator { + + public static String add(String operand1, String operand2) { + try { + BigDecimal decimal1 = new BigDecimal(operand1).setScale(2, BigDecimal.ROUND_HALF_UP); + BigDecimal decimal2 = new BigDecimal(operand2).setScale(2, BigDecimal.ROUND_HALF_UP); + BigDecimal result = decimal1.add(decimal2).setScale(2, BigDecimal.ROUND_HALF_UP); + return result.toString(); + } catch (Exception e) { + return KEEP_TWO_DECIMAL_ZERO; + } + } + + public static String subtract(String operand1, String operand2) { + try { + BigDecimal decimal1 = new BigDecimal(operand1).setScale(2, BigDecimal.ROUND_HALF_UP); + BigDecimal decimal2 = new BigDecimal(operand2).setScale(2, BigDecimal.ROUND_HALF_UP); + BigDecimal result = decimal1.subtract(decimal2).setScale(2, BigDecimal.ROUND_HALF_UP); + return result.toString(); + } catch (Exception e) { + return KEEP_TWO_DECIMAL_ZERO; + } + } + + public static String multiply(String operand1, String operand2) { + try { + BigDecimal decimal1 = new BigDecimal(operand1).setScale(2, BigDecimal.ROUND_HALF_UP); + BigDecimal decimal2 = new BigDecimal(operand2).setScale(2, BigDecimal.ROUND_HALF_UP); + BigDecimal result = decimal1.multiply(decimal2).setScale(2, BigDecimal.ROUND_HALF_UP); + return result.toString(); + } catch (Exception e) { + return KEEP_TWO_DECIMAL_ZERO; + } + } + + public static String divide(String operand1, String operand2) { + try { + BigDecimal decimal1 = new BigDecimal(operand1).setScale(2, BigDecimal.ROUND_HALF_UP); + BigDecimal decimal2 = new BigDecimal(operand2).setScale(2, BigDecimal.ROUND_HALF_UP); + BigDecimal result = decimal1.divide(decimal2, 2, BigDecimal.ROUND_HALF_UP); + return result.toString(); + } catch (Exception e) { + return KEEP_TWO_DECIMAL_ZERO; + } + } + + public static String negateBigDecimal(String value) { + try { + BigDecimal original = new BigDecimal(value).setScale(2, BigDecimal.ROUND_HALF_UP); + BigDecimal negated = original.negate().setScale(2, BigDecimal.ROUND_HALF_UP); + return negated.toString(); + } catch (Exception e) { + return KEEP_TWO_DECIMAL_ZERO; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/chint/infrastructure/util/JWTUtil.java b/src/main/java/com/chint/infrastructure/util/JWTUtil.java new file mode 100644 index 00000000..eb66e9a1 --- /dev/null +++ b/src/main/java/com/chint/infrastructure/util/JWTUtil.java @@ -0,0 +1,44 @@ +package com.chint.infrastructure.util; + +import com.auth0.jwt.JWT; +import com.auth0.jwt.algorithms.Algorithm; +import com.auth0.jwt.interfaces.DecodedJWT; + +import java.util.Date; +import java.util.Map; + +import static com.chint.infrastructure.constant.Constant.EXPIRATION_TIME_MS; +import static com.chint.infrastructure.constant.Constant.SECRET; + +public class JWTUtil { + + public static String createJWT(String SECRET, long EXPIRATION_TIME_MS, String subject, Map claims) { + Date issuedAt = new Date(); + Date expiresAt = new Date(issuedAt.getTime() + EXPIRATION_TIME_MS); + return JWT.create() + .withSubject(subject) + .withIssuedAt(issuedAt) + .withExpiresAt(expiresAt) + .withPayload(claims) + .sign(Algorithm.HMAC256(SECRET)); + } + + public static String createJWT(String subject, Map claims) { + return createJWT(SECRET, EXPIRATION_TIME_MS, subject, claims); + } + + public static DecodedJWT parseJWT(String SECRET, String token) { + return JWT.require(Algorithm.HMAC256(SECRET)) + .build() + .verify(token); + } + + public static boolean verifyJWT(String SECRET, String token) { + try { + parseJWT(SECRET, token); + return true; + } catch (Exception ex) { + return false; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/chint/infrastructure/util/PageResult.java b/src/main/java/com/chint/infrastructure/util/PageResult.java new file mode 100644 index 00000000..69bca8ba --- /dev/null +++ b/src/main/java/com/chint/infrastructure/util/PageResult.java @@ -0,0 +1,25 @@ +package com.chint.infrastructure.util; + +import java.util.List; + +public class PageResult { + private long total; + private List records; + + public PageResult(long total, List records) { + this.total = total; + this.records = records; + } + + public static PageResult page(List res) { + return new PageResult<>(res.size(), res); + } + + public static PageResult totalPageNum(long totalNum, List res) { + return new PageResult<>(totalNum, res); + } + + public static PageResult empty() { + return new PageResult<>(0, List.of()); + } +} \ No newline at end of file diff --git a/src/main/java/com/chint/infrastructure/util/Result.java b/src/main/java/com/chint/infrastructure/util/Result.java new file mode 100644 index 00000000..0453c688 --- /dev/null +++ b/src/main/java/com/chint/infrastructure/util/Result.java @@ -0,0 +1,52 @@ +package com.chint.infrastructure.util; + +import java.io.Serializable; +import java.util.Objects; + +public class Result implements Serializable { + private String msg; + private String code; + private T data; + + public Result() {} + + public Result(String msg, String code, T data) { + this.msg = msg; + this.code = code; + this.data = data; + } + + public Result(String msg, String code) { + this.msg = msg; + this.code = code; + } + + // Getter and Setter methods + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Result result = (Result) o; + return Objects.equals(msg, result.msg) && + Objects.equals(code, result.code) && + Objects.equals(data, result.data); + } + + @Override + public int hashCode() { + return Objects.hash(msg, code, data); + } + + public static Result success(String msg, T data) { + return new Result<>(msg, "1", data); + } + + public static Result success(String msg) { + return new Result<>(msg, "1"); + } + + public static Result error(String msg) { + return new Result<>(msg, "0"); + } +} \ No newline at end of file diff --git a/src/main/java/com/chint/infrastructure/util/Token.java b/src/main/java/com/chint/infrastructure/util/Token.java new file mode 100644 index 00000000..4d0cce40 --- /dev/null +++ b/src/main/java/com/chint/infrastructure/util/Token.java @@ -0,0 +1,13 @@ +package com.chint.infrastructure.util; + +public class Token { + private String token; + + private Token(String token) { + this.token = token; + } + + public static Token of(String token) { + return new Token(token); + } +} \ No newline at end of file diff --git a/src/main/java/com/chint/infrastructure/webconfig/JwtTokenAdminInterceptor.java b/src/main/java/com/chint/infrastructure/webconfig/JwtTokenAdminInterceptor.java new file mode 100644 index 00000000..976af752 --- /dev/null +++ b/src/main/java/com/chint/infrastructure/webconfig/JwtTokenAdminInterceptor.java @@ -0,0 +1,41 @@ +package com.chint.infrastructure.webconfig; + +import com.chint.domain.aggregates.user.User; +import com.chint.infrastructure.util.BaseContext; +import com.chint.infrastructure.util.JWTUtil; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.web.servlet.HandlerInterceptor; + +import static com.chint.infrastructure.constant.Constant.*; + + +public class JwtTokenAdminInterceptor implements HandlerInterceptor { + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + String token = request.getHeader(HEADER_TOKEN); + + if (request.getRequestURI().endsWith("/login")) { + return true; + } + + if (token == null) { + response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); + response.getWriter().write(JWT_REQUIRED); + return false; + } + + try { + JWTUtil.verifyJWT(SECRET, token); + var parseJWT = JWTUtil.parseJWT(SECRET, token); + var withJwt = User.withJwt(parseJWT); + BaseContext.setCurrentUser(withJwt); + return true; // If verification succeeds, continue processing the request + } catch (Exception e) { + response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); + response.getWriter().write(JWT_INVALID); + return false; // Verification failed, deny request + } + } +} \ No newline at end of file diff --git a/src/main/java/com/chint/infrastructure/webconfig/WebConfig.java b/src/main/java/com/chint/infrastructure/webconfig/WebConfig.java new file mode 100644 index 00000000..5bdd1252 --- /dev/null +++ b/src/main/java/com/chint/infrastructure/webconfig/WebConfig.java @@ -0,0 +1,34 @@ +package com.chint.infrastructure.webconfig; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class WebConfig implements WebMvcConfigurer { + + +// @Bean +// public JwtTokenAdminInterceptor JwtTokenAdminInterceptor() { +// return new JwtTokenAdminInterceptor(); +// } + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(new JwtTokenAdminInterceptor()) + .addPathPatterns("/**") + .excludePathPatterns("/public/**", "/login"); + } + + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedOriginPatterns("*") + .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") + .allowedHeaders("*") + .allowCredentials(true) + .maxAge(3600); + } +} diff --git a/src/main/java/com/chint/interfaces/rest/base/PostRequest.java b/src/main/java/com/chint/interfaces/rest/base/PostRequest.java new file mode 100644 index 00000000..e3979607 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/base/PostRequest.java @@ -0,0 +1,38 @@ +package com.chint.interfaces.rest.base; + +import com.google.gson.Gson; +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; +import org.springframework.stereotype.Component; + +import java.io.IOException; + +@Component +public class PostRequest { + private final Gson gson = new Gson(); + private final HttpClient client = HttpClients.createDefault(); + + public T post(String url, Object jsonRequest, Class responseType) { + HttpPost post = new HttpPost(url); + post.setEntity(new StringEntity(gson.toJson(jsonRequest), ContentType.APPLICATION_JSON)); + String responseBody = null; + try { + HttpResponse response = client.execute(post); + HttpEntity responseEntity = response.getEntity(); + responseBody = EntityUtils.toString(responseEntity, "UTF-8"); + } catch (IOException e) { + throw new RuntimeException(e); + } + return gson.fromJson(responseBody, responseType); + } + + public Gson gson() { + return gson; + } +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/CTripApprovalRequest.java b/src/main/java/com/chint/interfaces/rest/ctrip/CTripApprovalRequest.java new file mode 100644 index 00000000..418e73b8 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/CTripApprovalRequest.java @@ -0,0 +1,29 @@ +package com.chint.interfaces.rest.ctrip; + +import com.chint.interfaces.rest.base.PostRequest; +import com.chint.interfaces.rest.ctrip.dto.approval.ApprovalRequest; +import com.chint.interfaces.rest.ctrip.dto.approval.ApprovalResult; +import com.chint.interfaces.rest.ctrip.dto.Authentication; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import static com.chint.infrastructure.constant.Constant.*; + +@Service +public class CTripApprovalRequest { + + private String approvalUrl = C_TRIP_BASE_URL + C_TRIP_APPROVAL_PATH; + + @Autowired + private CTripTicketRequest ticketRequest; + + @Autowired + private PostRequest postRequest; + + public ApprovalResult approval(ApprovalRequest approvalRequest) { + String ticket = ticketRequest.loadTicket(); + approvalRequest.setStatus(0); + approvalRequest.setAuth(Authentication.of(C_TRIP_APP_KEY, ticket)); + return postRequest.post(approvalUrl, approvalRequest, ApprovalResult.class); + } +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/CTripEstimateRequest.java b/src/main/java/com/chint/interfaces/rest/ctrip/CTripEstimateRequest.java new file mode 100644 index 00000000..21b60a99 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/CTripEstimateRequest.java @@ -0,0 +1,61 @@ +package com.chint.interfaces.rest.ctrip; + +import com.chint.domain.aggregates.user.User; +import com.chint.infrastructure.util.BaseContext; +import com.chint.interfaces.rest.base.PostRequest; +import com.chint.interfaces.rest.ctrip.dto.estimate.request.AuthInfo; +import com.chint.interfaces.rest.ctrip.dto.estimate.request.BookingRelatedApiRequest; +import com.chint.interfaces.rest.ctrip.dto.estimate.request.FlightProductInfo; +import com.chint.interfaces.rest.ctrip.dto.estimate.request.TrainProductInfo; +import com.chint.interfaces.rest.ctrip.dto.estimate.response.BookingRelatedApiResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import static com.chint.infrastructure.constant.Constant.*; + +@Component +public class CTripEstimateRequest { + + private String apiName = "bookingRelatedOpenApi.valuateBudget"; + + private String estimateUrl = C_TRIP_BASE_URL + C_TRIP_ESTIMATE_PATH; + + @Autowired + private CTripTokenRequest tokenRequest; + + @Autowired + private PostRequest postRequest; + + public BookingRelatedApiResponse estimate(BookingRelatedApiRequest bookingRelatedApiRequest) { + return postRequest.post(estimateUrl, bookingRelatedApiRequest, BookingRelatedApiResponse.class); + } + + public BookingRelatedApiRequest generateBaseRequest(FlightProductInfo flightProductInfo, TrainProductInfo trainProductInfo) { + BookingRelatedApiRequest bookingRelatedApiRequest = new BookingRelatedApiRequest(); + String token = tokenRequest.getToken(); + bookingRelatedApiRequest.setApiName(apiName); + bookingRelatedApiRequest.setLanguage(LANGUAGE_CN); + bookingRelatedApiRequest.setAuthInfo(AuthInfo.of(C_TRIP_APP_KEY, token)); + User user = BaseContext.getCurrentUser(); + return BookingRelatedApiRequest.builder() + .language(LANGUAGE_CN) + .apiName(apiName) + .authInfo() + .details(C_TRIP_APP_KEY, token) + .done() + .requestContent() + .valuationBaseInfo() + .eID(user.employeeNo.toString()) + .corpID("zhengtai") + .rankName(user.getRankCode()) + .done() + .valuationProductInfo() + .addFlightProductInfo(flightProductInfo) + .addTrainProductInfo(trainProductInfo) + .done() + .done() + .build(); + } + + +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/CTripLocationHttpRequest.java b/src/main/java/com/chint/interfaces/rest/ctrip/CTripLocationHttpRequest.java new file mode 100644 index 00000000..64c8ea93 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/CTripLocationHttpRequest.java @@ -0,0 +1,45 @@ +package com.chint.interfaces.rest.ctrip; + +import com.chint.interfaces.rest.base.PostRequest; +import com.chint.interfaces.rest.ctrip.dto.*; +import com.chint.interfaces.rest.ctrip.dto.location.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +import static com.chint.infrastructure.constant.Constant.*; + +@Service +public class CTripLocationHttpRequest implements LocationHttpRequest { + + + @Autowired + private PostRequest postRequest; + + @Autowired + private CTripTicketRequest ticketRequest; + + private static final String locationCityUrl = C_TRIP_BASE_URL + HOTEL_CITY_PATH; + private static final String locationCountryUrl = C_TRIP_BASE_URL + HOTEL_COUNTRY_PATH; + + + @Override + public void syncLocation() { +// cityRepository.saveAll(syncCity()); +// countryRepository.saveAll(syncCountry()); + } + + public List syncCountry() { + Object jsonRequest = new GetCountry(new Authentification(C_TRIP_APP_KEY, ticketRequest.loadTicket()), LANGUAGE_CN); + CountryResponse response = postRequest.post(locationCountryUrl, jsonRequest, CountryResponse.class); + return response.getData(); + } + + public List syncCity() { + Authentification authentification = new Authentification(C_TRIP_APP_KEY, ticketRequest.loadTicket()); + GetCountryCityExtend getCountryCityExtend = new GetCountryCityExtend(authentification, LANGUAGE_CN, 2); + CityResponse response = postRequest.post(locationCityUrl, getCountryCityExtend, CityResponse.class); + return response.getData(); + } +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/CTripTicketRequest.java b/src/main/java/com/chint/interfaces/rest/ctrip/CTripTicketRequest.java new file mode 100644 index 00000000..c3b31520 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/CTripTicketRequest.java @@ -0,0 +1,55 @@ +package com.chint.interfaces.rest.ctrip; + +import com.chint.interfaces.rest.base.PostRequest; +import com.chint.interfaces.rest.ctrip.dto.ticket.TicketParam; +import com.chint.interfaces.rest.ctrip.dto.ticket.TicketResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; + +import static com.chint.infrastructure.constant.Constant.*; + +@Component +public class CTripTicketRequest { + + @Autowired + private PostRequest postRequest; + + private final String ticketUrl = C_TRIP_BASE_URL + TICKET_PATH; + private final TicketParam ticketParam = new TicketParam(C_TRIP_APP_KEY, C_TRIP_APP_SECURITY); + + // Data class to store ticket and expiry time + public static class CachedTicket { + private final String ticket; + private final LocalDateTime expiryTime; + + public CachedTicket(String ticket, LocalDateTime expiryTime) { + this.ticket = ticket; + this.expiryTime = expiryTime; + } + + public String getTicket() { + return ticket; + } + + public LocalDateTime getExpiryTime() { + return expiryTime; + } + } + + // Cached ticket instance + private CachedTicket cachedTicket = null; + + public String loadTicket() { + // Check if the cached ticket exists and is valid + if (cachedTicket != null && cachedTicket.getExpiryTime().isAfter(LocalDateTime.now())) { + return cachedTicket.getTicket(); + } + System.out.println(ticketParam); + TicketResponse ticket = postRequest.post(ticketUrl, ticketParam, TicketResponse.class); + // Update the cache with an expiry time of 2 hours from the current time + cachedTicket = new CachedTicket(ticket.getTicket(), LocalDateTime.now().plusHours(2)); + return ticket.getTicket(); + } +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/CTripTokenRequest.java b/src/main/java/com/chint/interfaces/rest/ctrip/CTripTokenRequest.java new file mode 100644 index 00000000..5d97243d --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/CTripTokenRequest.java @@ -0,0 +1,27 @@ +package com.chint.interfaces.rest.ctrip; + +import com.chint.interfaces.rest.base.PostRequest; +import com.chint.interfaces.rest.ctrip.dto.token.GetUnionAccessTokenRequest; +import com.chint.interfaces.rest.ctrip.dto.token.GetUnionAccessTokenResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import static com.chint.infrastructure.constant.Constant.*; + +@Service +public class CTripTokenRequest { + + private String tokenUrl = C_TRIP_BASE_URL + C_TRIP_TOKEN_PATH; + + + @Autowired + private PostRequest postRequest; + + public String getToken() { + GetUnionAccessTokenRequest getUnionAccessTokenRequest = + GetUnionAccessTokenRequest.of(C_TRIP_APP_KEY, C_TRIP_APP_SECURITY, 1); + return postRequest + .post(tokenUrl, getUnionAccessTokenRequest, GetUnionAccessTokenResponse.class) + .getAccessToken(); + } +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/CTripUserSaveRequest.java b/src/main/java/com/chint/interfaces/rest/ctrip/CTripUserSaveRequest.java new file mode 100644 index 00000000..ea46ecd2 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/CTripUserSaveRequest.java @@ -0,0 +1,57 @@ +package com.chint.interfaces.rest.ctrip; + +import com.chint.domain.aggregates.user.User; +import com.chint.infrastructure.util.BaseContext; +import com.chint.interfaces.rest.base.PostRequest; +import com.chint.interfaces.rest.ctrip.dto.user.AuthenticationEntity; +import com.chint.interfaces.rest.ctrip.dto.user.AuthenticationInfo; +import com.chint.interfaces.rest.ctrip.dto.user.AuthenticationListRequest; +import com.chint.interfaces.rest.user.UserHttpRequest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.chint.interfaces.rest.ctrip.dto.AuthenticationResponseList; +import java.util.List; + +import static com.chint.infrastructure.constant.Constant.*; + +@Service +public class CTripUserSaveRequest { + @Autowired + private PostRequest postRequest; + + @Autowired + private UserHttpRequest userHttpRequest; + + @Autowired + private CTripTicketRequest ticketRequest; + + private final String userUrl = C_TRIP_BASE_URL + C_TRIP_USER_SAVE_PATH; + + public void saveUserToCTrip() { + User currentUser = BaseContext.getCurrentUser(); + User user = userHttpRequest.loadUserInfo(currentUser); + String ticket = ticketRequest.loadTicket(); + AuthenticationEntity authenticationEntity = buildAuthenticationEntityWithUser(user); + AuthenticationListRequest authenticationListRequest = new AuthenticationListRequest(); + authenticationListRequest.setAppkey(C_TRIP_APP_KEY); + authenticationListRequest.setTicket(ticket); + authenticationListRequest.setCorporationID("zhengtai"); + AuthenticationInfo authenticationInfo = new AuthenticationInfo(); + authenticationInfo.setSequence("0"); + authenticationInfo.setAuthentication(authenticationEntity); + authenticationListRequest.setAuthenticationInfoList(List.of(authenticationInfo)); + AuthenticationResponseList post = postRequest.post(userUrl, authenticationInfo, AuthenticationResponseList.class); + System.out.println(post); + } + + + public AuthenticationEntity buildAuthenticationEntityWithUser(User user) { + AuthenticationEntity authenticationEntity = new AuthenticationEntity(); + authenticationEntity.setName(user.getName()); + authenticationEntity.setEmployeeID(user.getEmployeeNo().toString()); + authenticationEntity.setRankName(user.getRankCode()); + authenticationEntity.setValid(user.getWorkStatus()); + authenticationEntity.setSubAccountName("zhengtai_提前审批测试"); + return authenticationEntity; + } +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/LocationHttpRequest.java b/src/main/java/com/chint/interfaces/rest/ctrip/LocationHttpRequest.java new file mode 100644 index 00000000..2efcdfdf --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/LocationHttpRequest.java @@ -0,0 +1,5 @@ +package com.chint.interfaces.rest.ctrip; + +public interface LocationHttpRequest { + void syncLocation(); +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/Authentication.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/Authentication.java new file mode 100644 index 00000000..e03351ba --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/Authentication.java @@ -0,0 +1,16 @@ +package com.chint.interfaces.rest.ctrip.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class Authentication { + private String appKey; + private String ticket; + // Getters and setters... + + public static Authentication of(String appKey, String ticket) { + return new Authentication(appKey, ticket); + } +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/AuthenticationResponseList.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/AuthenticationResponseList.java new file mode 100644 index 00000000..5af22998 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/AuthenticationResponseList.java @@ -0,0 +1,11 @@ +package com.chint.interfaces.rest.ctrip.dto; + +import lombok.Data; + +import java.util.List; + +@Data +public class AuthenticationResponseList { + private String Result; + private List ErrorMessageList; +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/Authentification.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/Authentification.java new file mode 100644 index 00000000..4d94b60e --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/Authentification.java @@ -0,0 +1,17 @@ +package com.chint.interfaces.rest.ctrip.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +public class Authentification { + private String AppKey; + private String Ticket; + + public Authentification(String appKey, String ticket) { + AppKey = appKey; + Ticket = ticket; + } + + // Constructors, getters, and setters +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/ErrorMessage.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/ErrorMessage.java new file mode 100644 index 00000000..0d1dde5c --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/ErrorMessage.java @@ -0,0 +1,11 @@ +package com.chint.interfaces.rest.ctrip.dto; + +import lombok.Data; + +@Data +public class ErrorMessage { + private int Sequence; + private String ErrorCode; + private String Message; + private String EmployeeID; +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/ResponseStatus.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/ResponseStatus.java new file mode 100644 index 00000000..4f72ab89 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/ResponseStatus.java @@ -0,0 +1,12 @@ +package com.chint.interfaces.rest.ctrip.dto; + +import lombok.Data; + +@Data +public class ResponseStatus { + private Boolean Success; + private int ErrorCode; + private String Message; + + // Constructors, getters, and setters +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/ResponseSuccess.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/ResponseSuccess.java new file mode 100644 index 00000000..4aeb3134 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/ResponseSuccess.java @@ -0,0 +1,13 @@ +package com.chint.interfaces.rest.ctrip.dto; + +public class ResponseSuccess { + + // 是否成功 + private boolean success; + // 消息内容 + private String message; + // 错误代码 + private int errorCode; + + // Getters and setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/ApprovalRequest.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/ApprovalRequest.java new file mode 100644 index 00000000..134b9e03 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/ApprovalRequest.java @@ -0,0 +1,125 @@ +package com.chint.interfaces.rest.ctrip.dto.approval; + +import com.chint.interfaces.rest.ctrip.dto.Authentication; +import com.chint.interfaces.rest.ctrip.dto.approval.air.FlightEndorsementDetail; +import com.chint.interfaces.rest.ctrip.dto.approval.charter.CarCharterEndorsementDetail; +import com.chint.interfaces.rest.ctrip.dto.approval.endor.BusEndorsementDetail; +import com.chint.interfaces.rest.ctrip.dto.approval.hotel.HotelEndorsementDetail; +import com.chint.interfaces.rest.ctrip.dto.approval.pick.CarPickUpEndorsementDetail; +import com.chint.interfaces.rest.ctrip.dto.approval.plan.TravelPlanEndorsementDetail; +import com.chint.interfaces.rest.ctrip.dto.approval.quick.CarQuickEndorsementDetail; +import com.chint.interfaces.rest.ctrip.dto.approval.quick.RankInfo; +import com.chint.interfaces.rest.ctrip.dto.approval.train.TrainEndorsementDetail; +import lombok.Data; + +import java.util.List; + +@Data +public class ApprovalRequest { + // 审批单号 - 必填 + // OA审批通过时生成,同步审批单编号,用于标识审批单 + private String approvalNumber; + + // 状态 - 必填 + // 0为审批中,1为审批通过,2为审批拒绝 + private int status; + + // 携程卡号 - 非必填 + // N表示非必填,多个携程卡号以逗号隔开,长度不能超过500个字符且不重复。 + private String ctripCardNO; + + // 员工编号 - 非必填 + // N表示非必填,多个员工编号以逗号隔开,长度不能超过500个字符且不重复。 + private String employeeID; + + // 机票背书信息详情列表 - 必填 + // Y表示必填项,用于记录一条审批单中的一条或多条航班信息,详细信息格式见3.3.2节的JSON数据交互格式详细说明。 + private List flightEndorsementDetails; + + // 酒店背书信息详情列表 - 必填 + // Y表示必填项。 + private List hotelEndorsementDetails; + + // 火车背书信息详情列表 - 必填 + // Y表示必填项。 + private List trainEndorsementDetails; + + // 租车背书信息详情列表 - 必填 + // Y表示必填项。 + private List carQuickEndorsementDetails; + + // 接送车背书信息详情列表 - 必填 + // Y表示必填项。 + private List carPickUpEndorsementDetails; + + // 包车背书信息详情列表 - 必填 + // Y表示必填项。 + private List carCharterEndorsementDetails; + + // 巴士背书信息详情列表 - 必填 + // Y表示必填项。 + private List busEndorsementDetails; + + // 出差计划背书信息详情列表 - 必填 + // Y表示必填项。 + private List travelPlanEndorsementDetails; + + // 有效期 - 非必填 + // 有效期格式为日期时间,起始时间从2017-01-01开始。 + private String expiredTime; + + // 认证信息 - 非必填 + // 携程分配给客户公司,具体见下表描述。 + private Authentication auth; + + // 成本中心等扩展字段列表,非必填,如无该需求则不需要传 + // Y表示必填项。 + private List extendFieldList; + + // 备注 - 必填 + // Y表示必填项。 + private String remark; + + // 职级信息 - 非必填 + // 职级信息(仅限于职级信息的前20) + private RankInfo rankInfo; + + public ApprovalRequest(String approvalNumber, String employeeID, RankInfo rankInfo) { + this.approvalNumber = approvalNumber; + this.employeeID = employeeID; + this.rankInfo = rankInfo; + } + + public static ApprovalRequest buildApproval(String employeeID, String approvalNumber, RankInfo rankInfo) { + return new ApprovalRequest(employeeID, approvalNumber, rankInfo); + } + + public ApprovalRequest withAir(List flightEndorsementDetails) { + this.flightEndorsementDetails = flightEndorsementDetails; + return this; + } + + public ApprovalRequest withTrain(List hotelEndorsementDetails) { + this.hotelEndorsementDetails = hotelEndorsementDetails; + return this; + } + + public ApprovalRequest withBus(List busEndorsementDetails) { + this.busEndorsementDetails = busEndorsementDetails; + return this; + } + + public ApprovalRequest withPickCar(List carPickUpEndorsementDetails) { + this.carPickUpEndorsementDetails = carPickUpEndorsementDetails; + return this; + } + + public ApprovalRequest withQuickCar(List carQuickEndorsementDetails) { + this.carQuickEndorsementDetails = carQuickEndorsementDetails; + return this; + } + public ApprovalRequest withHotel(List hotelEndorsementDetails) { + this.hotelEndorsementDetails = hotelEndorsementDetails; + return this; + } +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/ApprovalResult.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/ApprovalResult.java new file mode 100644 index 00000000..84d55944 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/ApprovalResult.java @@ -0,0 +1,10 @@ +package com.chint.interfaces.rest.ctrip.dto.approval; + +import lombok.Data; + +@Data +public class ApprovalResult { + + private ResponseStatus Status; + +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/CurrencyType.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/CurrencyType.java new file mode 100644 index 00000000..b6c46cd7 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/CurrencyType.java @@ -0,0 +1,17 @@ +package com.chint.interfaces.rest.ctrip.dto.approval; + +public class CurrencyType { + public final static Integer UnKnow = 0; + public final static Integer RMB = 1; + public final static Integer CNY = 2; + public final static Integer HKD = 3; + public final static Integer USD = 4; + public final static Integer EUR = 5; + public final static Integer SGD = 6; + public final static Integer MOP = 7; + public final static Integer JPY = 8; + public final static Integer THB = 9; + public final static Integer AUD = 10; + public final static Integer GBP = 11; + +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/ExtendField.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/ExtendField.java new file mode 100644 index 00000000..45eece79 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/ExtendField.java @@ -0,0 +1,8 @@ +package com.chint.interfaces.rest.ctrip.dto.approval; + +public class ExtendField { + private String fieldName; + private String fieldValue; + private String fieldType; + // Getters and setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/PassengerDetail.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/PassengerDetail.java new file mode 100644 index 00000000..ac04c051 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/PassengerDetail.java @@ -0,0 +1,65 @@ +package com.chint.interfaces.rest.ctrip.dto.approval; + +import java.util.List; + +public class PassengerDetail { + + // 姓名 - 必填 + // 中文姓名,例如,张三 - 中文姓名最后人员填写必选项,通用汉字集合。 + // (外籍名例如泰国人员NameEn代入) + // 由三部分组成的姓名字段(Name/EID/NameEn 选择其中一) + private String name; + + // 证件类型 - 必填 + // 证件类型列举证件类型编码请详看附件,类型编码数字不下发 + private String credentialsType; + + // 证件号码 - 必填 + // 如果是证件号码,则用于后续证件件号码合理性检查, + // 可包含数字和字母,用于检查合理性;如果是证件证 + // 号,判断所证件证件号码与实际填写情况。 + private String credentialsNumber; + + // 出行人EID - 必填 + // 出行人员信息(Name/EID/NameEn 选择其中一) + // 出行人员信息不会涉及隐私泄露: + // AveragePrice>policyid>rankname>eid + private String EID; + + // 英文姓名 - 必填 + // 英文姓名,例如,中文张三对应英文名字Zhang/San + // (英文名不区分大小写) 中美英姓名填写指导原则如外籍人员人名, + // 可包含英文字母,用于国际航空运输。 + // 通用国际音标对照lastname/firstname + // 可容纳姓名人数最多限制数据 + // 由三部分组成的姓名字段(Name/EID/NameEn 选择其中一) + private String nameEn; + + // 职级名称 - 必填 + // 出行人员信息不会涉及隐私泄露: + // AveragePrice>policyid>rankname>eid + private String rankName; + + // 政策规则EID - 必填 + // 出行人员信息不会涉及隐私泄露: + // AveragePrice>policyid>rankname>eid + private String policyEID; + + // 国家代码 - 必填 + // 如果手机号为空,国外为空,则默认填写为中国大陆区号 + private String countryCode; + + // 手机号码 - 必填 + // 手机中心存储的手机号码,非必填,如无法检索则不下发数据; + // 支持境外、港澳,文件有国际区号为准。一、二、 + // 四、五、六(酒店方在出行人员中心同一字段使用,机票 + // 和火车票方面) + private String mobilePhone; + + // 扩展字段列表 - 可选 + // 不支持新增扩展 + private List extendFieldList; + + // Getters and setters for each field would be included below... + +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/ResponseStatus.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/ResponseStatus.java new file mode 100644 index 00000000..7c1cb0d4 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/ResponseStatus.java @@ -0,0 +1,10 @@ +package com.chint.interfaces.rest.ctrip.dto.approval; + +import lombok.Data; + +@Data +public class ResponseStatus { + private Boolean Success; + private String Message; + private Integer ErrorCode; +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/air/FlightEndorsementDetail.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/air/FlightEndorsementDetail.java new file mode 100644 index 00000000..3c81f3d8 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/air/FlightEndorsementDetail.java @@ -0,0 +1,100 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.air; + +import com.chint.interfaces.rest.ctrip.dto.approval.CurrencyType; +import com.chint.interfaces.rest.ctrip.dto.approval.PassengerDetail; +import lombok.Data; + +import java.util.List; + +@Data +public class FlightEndorsementDetail { + + // 订票类型列表 - 1张, 2张, 3张, 超过3张 + private List bookingTypeList; + + // 订单ID列表 - 最多20个 + private List orderIDList; + + // 航空公司名称 - 不可为空字符串 + private String airline; + + // 货币类型 - 默认CNY + private CurrencyType currency; + + // 航班类型 - 单程(1) or 往返(2) + private FlightWayType flightWay; + + // 起飞日期开始时间 - 格式: yyyy-MM-dd + private String departDateBegin; + + // 起飞日期结束时间 - 格式: yyyy-MM-dd + private String departDateEnd; + + // 返回日期开始时间 - 格式: yyyy-MM-dd + private String returnDateBegin; + + // 返回日期结束时间 - 格式: yyyy-MM-dd + private String returnDateEnd; + + // 起飞时间开始时间 - 格式: HH:mm + private String takeOffBeginTime; + + // 起飞时间结束时间 - 格式: HH:mm + private String takeOffEndTime; + + // 到达时间开始时间 - 格式: HH:mm + private String arrivalBeginTime; + + // 到达时间结束时间 - 格式: HH:mm + private String arrivalEndTime; + + // 折扣率 - 0.1到1.0, 0代表无折扣 + private float discount; + + // 出发国家ID列表 - 最多1000个 + private List departCountryIds; + + // 出发国家代码列表 - 最多1000个 + private List departCountryCodes; + + // 出发城市代码列表 - 最多1000个 + private List departCityCodes; + + // 到达国家ID列表 - 最多1000个 + private List arrivalCountryIds; + + // 到达城市代码列表 - 最多1000个 + private List arrivalCityCodes; + + // 出发城市ID列表 - 最多1000个 + private List departCityIds; + + // 到达城市ID列表 - 最多1000个 + private List arrivalCityIds; + + // 乘客列表 - 无数量限制 + private List passengerList; + + // 价格 - 可为负数, 默认为0 + private float price; + + // 产品类型 - 1代表经济舱, 2代表商务舱 + private ProductTypeEnum productType; + + // 座位等级 - 经济舱(3), 商务舱(2), 头等舱(1) + private SeatClassType seatClass; + + // 跳过的字段位 - 用于标记不包含的字段 + private long skipFields; + + // 旅客数量 - 无限制 + private int travelerCount; + + // 总旅客数量 - 用于统计 + private int totalTravelerCount; + + // 预验证字段位 - 用于标记需要预验证的字段 + private long preVerifyFields; + + // Getters and setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/air/FlightPreVerifyFields.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/air/FlightPreVerifyFields.java new file mode 100644 index 00000000..29b8f70e --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/air/FlightPreVerifyFields.java @@ -0,0 +1,16 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.air; + +// Additional FlightPreVerifyFields constants based on the new image provided +public class FlightPreVerifyFields { + public static final long Airline = 1; // 航空公司字段 + public static final long DepartDateBegin = 2; // 起飞日期开始字段 + public static final long DepartDateEnd = 4; // 起飞日期结束字段 + public static final long DepartCityCodes = 16; // 出发城市代码字段 + public static final long PassengerList = 32; // 乘客列表字段 + public static final long ReturnDateBegin = 128; // 返回日期开始字段 + public static final long ReturnDateEnd = 256; // 返回日期结束字段 + public static final long SeatClass = 512; // 座位等级字段 + public static final long ArrivalCityCodes = 1024; // 到达城市代码字段 + public static final long FlightWay = 65536; // 航班类型字段 + // ... include other fields as necessary +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/air/FlightSkipFields.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/air/FlightSkipFields.java new file mode 100644 index 00000000..b00371ac --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/air/FlightSkipFields.java @@ -0,0 +1,20 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.air; + +import lombok.Data; + +@Data +public class FlightSkipFields { + public static final long Airline = 1; // 航空公司字段 + public static final long DepartDateBegin = 2; // 起飞日期开始字段 + public static final long DepartDateEnd = 4; // 起飞日期结束字段 + public static final long Discount = 8; // 折扣字段 + public static final long DepartCityCodes = 16; // 出发城市代码字段 + public static final long PassengerList = 32; // 乘客列表字段 + public static final long Price = 64; // 价格字段 + public static final long ReturnDateBegin = 128; // 返回日期开始字段 + public static final long ReturnDateEnd = 256; // 返回日期结束字段 + public static final long SeatClass = 512; // 座位等级字段 + public static final long ArrivalCityCodes = 1024; // 到达城市代码字段 + // ... Other fields follow with their corresponding bit values + // Note that this is not an exhaustive list due to the image being cut off. +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/air/FlightWayType.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/air/FlightWayType.java new file mode 100644 index 00000000..3ce1efad --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/air/FlightWayType.java @@ -0,0 +1,14 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.air; + +public enum FlightWayType { + SingleTrip(1), // 单程 + RoundTrip(2); // 往返 + + private final int value; + + FlightWayType(int value) { + this.value = value; + } + + // Getter... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/air/ProductTypeEnum.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/air/ProductTypeEnum.java new file mode 100644 index 00000000..57fee95f --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/air/ProductTypeEnum.java @@ -0,0 +1,11 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.air; + +public enum ProductTypeEnum { + IN(1), // 单程 + OUT(2); // 往返 + private final int value; + + ProductTypeEnum(int value) { + this.value = value; + } +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/air/SeatClassType.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/air/SeatClassType.java new file mode 100644 index 00000000..ab5e584c --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/air/SeatClassType.java @@ -0,0 +1,17 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.air; + +public enum SeatClassType { + UnKnown(0), // 未知 + SaloonCabin(1), // 沙龙舱 + BusinessClass(2), // 商务舱 + SuperTouristClass(4), // 超级旅游舱 + TouristClass(3); // 旅游舱 + + private final int value; + + SeatClassType(int value) { + this.value = value; + } + + // Getter... +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/charter/CarCharterEndorsementDetail.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/charter/CarCharterEndorsementDetail.java new file mode 100644 index 00000000..db0ae027 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/charter/CarCharterEndorsementDetail.java @@ -0,0 +1,48 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.charter; + +import com.chint.interfaces.rest.ctrip.dto.approval.CurrencyType; +import com.chint.interfaces.rest.ctrip.dto.approval.PassengerDetail; + +import java.util.List; + +public class CarCharterEndorsementDetail { + + // 产品类型 + private int productType; + // 乘客列表, 最多100名 + private List passengerList; + // 出发城市代码 + private String departCities; + // 到达城市代码 + private String arriveCities; + // 开始使用日期 + private String beginUseDate; + // 结束使用日期 + private String endUseDate; + // 开始使用时间 + private String beginUseTime; + // 结束使用时间 + private String endUseTime; + // 使用天数 + private int useDays; + // 货币类型, 默认CNY + private CurrencyType currency; + // 价格,默认为0 + private float price; + // 车辆组 + private String vehicleGroup; + // 跳过的字段位 + private long skipFields; + // 预验证字段位 + private long preVerifyFields; + // 座位数 + private int seatsNum; + // 组合ID + private String comboID; + // 版本号 + private int version; + // 总旅客数 + private int totalTravelerCount; + + // Getters and setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/charter/CarCharterPreVerifyFieldType.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/charter/CarCharterPreVerifyFieldType.java new file mode 100644 index 00000000..d679bd89 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/charter/CarCharterPreVerifyFieldType.java @@ -0,0 +1,16 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.charter; + +public class CarCharterPreVerifyFieldType { + public static final long BeginUseDate = 1; // 开始使用日期字段预验证标志 + public static final long EndUseDate = 2; // 结束使用日期字段预验证标志 + public static final long BeginUseTime = 4; // 开始使用时间字段预验证标志 + public static final long EndUseTime = 8; // 结束使用时间字段预验证标志 + public static final long DepartCities = 16; // 出发城市字段预验证标志 + public static final long ArriveCities = 32; // 到达城市字段预验证标志 + public static final long VehicleGroup = 64; // 车辆组字段预验证标志 + public static final long SeatsNum = 128; // 座位数字段预验证标志 + public static final long ComboID = 256; // 组合ID字段预验证标志 + public static final long PassengerList = 512; // 乘客列表字段预验证标志 + public static final long UseDays = 1024; // 使用天数字段预验证标志 + // ... include other fields as necessary +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/charter/CarCharterSkipFieldType.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/charter/CarCharterSkipFieldType.java new file mode 100644 index 00000000..1ae64883 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/charter/CarCharterSkipFieldType.java @@ -0,0 +1,18 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.charter; + +public class CarCharterSkipFieldType { + public static final long BeginUseDate = 1; // 开始使用日期字段跳过标志 + public static final long EndUseDate = 2; // 结束使用日期字段跳过标志 + public static final long BeginUseTime = 4; // 开始使用时间字段跳过标志 + public static final long EndUseTime = 8; // 结束使用时间字段跳过标志 + public static final long DepartCities = 16; // 出发城市字段跳过标志 + public static final long ArriveCities = 32; // 到达城市字段跳过标志 + public static final long VehicleGroup = 64; // 车辆组字段跳过标志 + public static final long SeatsNum = 128; // 座位数字段跳过标志 + public static final long ComboID = 256; // 组合ID字段跳过标志 + public static final long PassengerList = 512; // 乘客列表字段跳过标志 + public static final long UseDays = 1024; // 使用天数字段跳过标志 + public static final long Price = 2048; // 价格字段跳过标志 + public static final long Currency = 4096; // 货币字段跳过标志 + // ... include other fields as necessary +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/endor/BusEndorsementDetail.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/endor/BusEndorsementDetail.java new file mode 100644 index 00000000..f0d437b3 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/endor/BusEndorsementDetail.java @@ -0,0 +1,36 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.endor; + +import com.chint.interfaces.rest.ctrip.dto.approval.CurrencyType; +import com.chint.interfaces.rest.ctrip.dto.approval.PassengerDetail; +import lombok.Data; + +import java.util.List; + +@Data +public class BusEndorsementDetail { + + // 产品类型 + private int productType; + // 乘客列表,最多100名 + private List passengerList; + // 出发城市代码 + private List departCityCodes; + // 到达城市代码 + private List arrivalCityCodes; + // 出发开始日期 + private String departBeginDate; + // 出发结束日期 + private String departEndDate; + // 货币类型,默认CNY + private CurrencyType currency; + // 价格,默认为0 + private float price; + // 跳过的字段位 + private long skipFields; + // 预验证字段位 + private long preVerifyFields; + // 总旅客数 + private int totalTravelerCount; + + // Getters and setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/endor/BusSkipFields.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/endor/BusSkipFields.java new file mode 100644 index 00000000..f9201f5f --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/endor/BusSkipFields.java @@ -0,0 +1,13 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.endor; + +public class BusSkipFields { + public static final long TripWay = 1; + public static final long DepartBeginDate = 2; + public static final long DepartEndDate = 4; + public static final long PassengerList = 8; + public static final long DepartCityCodeList = 16; + public static final long ArrivalCityCodeList = 32; + public static final long Price = 64; + public static final long Currency = 128; + // ... include other fields as necessary +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/hotel/HotelEndorsementDetail.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/hotel/HotelEndorsementDetail.java new file mode 100644 index 00000000..2451991e --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/hotel/HotelEndorsementDetail.java @@ -0,0 +1,71 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.hotel; + +import com.chint.interfaces.rest.ctrip.dto.approval.CurrencyType; +import com.chint.interfaces.rest.ctrip.dto.approval.PassengerDetail; + +import java.util.List; + +public class HotelEndorsementDetail { + + // 产品类型 + private HotelProductTypeEnum productType; + + // 入住开始日期 - 格式: yyyy-MM-dd + private String checkInDateBegin; + + // 入住结束日期 - 格式: yyyy-MM-dd + private String checkInDateEnd; + + // 离店开始日期 - 格式: yyyy-MM-dd + private String checkOutDateBegin; + + // 离店结束日期 - 格式: yyyy-MM-dd + private String checkOutDateEnd; + + // 乘客列表 + private List passengerList; + + // 入住国家ID列表 + private List checkInCountryIds; + + // 入住国家代码列表 + private List checkInCountryCodes; + + // 入住城市代码列表 + private List checkInCityCodes; + + // 最高价格 + private String maxPrice; + + // 最低价格 + private String minPrice; + + // 货币类型 - 默认CNY + private CurrencyType currency; + + // 最大星级 + private String maxStarRating; + + // 最小星级 + private String minStarRating; + + // 平均价格 + private String averagePrice; + + // 房间数量 + private int roomCount; + + // 跳过的字段位 - 用于标记不包含的字段 + private long skipFields; + + // 总房晚数 + private int totalRoomNightCount; + + // 房晚价格 + private String roomNightPrice; + + // 预验证字段位 - 用于标记需要预验证的字段 + private long preVerifyFields; + + // Getters and setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/hotel/HotelPreVerifyFields.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/hotel/HotelPreVerifyFields.java new file mode 100644 index 00000000..89539d57 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/hotel/HotelPreVerifyFields.java @@ -0,0 +1,13 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.hotel; + +// HotelPreVerifyFields constants +public class HotelPreVerifyFields { + public static final long CheckInDateBegin = 1; + public static final long CheckInDateEnd = 2; + public static final long CheckOutDateBegin = 4; + public static final long CheckOutDateEnd = 8; + public static final long PassengerList = 16; + public static final long CheckInCityCodes = 32; + public static final long AveragePrice = 2048; + // ... include other fields as necessary +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/hotel/HotelProductTypeEnum.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/hotel/HotelProductTypeEnum.java new file mode 100644 index 00000000..7713897a --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/hotel/HotelProductTypeEnum.java @@ -0,0 +1,15 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.hotel; + +// HotelProductTypeEnum definition based on the provided image +public enum HotelProductTypeEnum { + Domestic(3), // 国内酒店 + International(4); // 国际酒店 + + private final int value; + + HotelProductTypeEnum(int value) { + this.value = value; + } + + // Getter... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/hotel/HotelSkipFields.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/hotel/HotelSkipFields.java new file mode 100644 index 00000000..71d26e06 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/hotel/HotelSkipFields.java @@ -0,0 +1,20 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.hotel; + +// HotelSkipFields constants based on the provided image +public class HotelSkipFields { + public static final long CheckInDateBegin = 1; + public static final long CheckInDateEnd = 2; + public static final long CheckOutDateBegin = 4; + public static final long CheckOutDateEnd = 8; + public static final long PassengerList = 16; + public static final long CheckInCityCodes = 32; + public static final long MaxPrice = 64; + public static final long MinPrice = 128; + public static final long Currency = 256; + public static final long MaxStarRating = 512; + public static final long MinStarRating = 1024; + public static final long AveragePrice = 2048; + public static final long RoomCount = 4096; + public static final long RoomNightPrice = 8192; + // ... include other fields as necessary +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/pick/CarPickUpEndorsementDetail.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/pick/CarPickUpEndorsementDetail.java new file mode 100644 index 00000000..2bdb9441 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/pick/CarPickUpEndorsementDetail.java @@ -0,0 +1,36 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.pick; + +import com.chint.interfaces.rest.ctrip.dto.approval.CurrencyType; +import com.chint.interfaces.rest.ctrip.dto.approval.PassengerDetail; + +import java.util.List; + +public class CarPickUpEndorsementDetail { + + // 产品类型 + private int productType; + // 乘客列表, 最多100名 + private List passengerList; + // 城市代码 + private String cities; + // 接车开始日期 + private String pickUpBeginDate; + // 接车结束日期 + private String pickUpEndDate; + // 送车开始日期 + private String dropOffBeginDate; + // 送车结束日期 + private String dropOffEndDate; + // 货币类型, 默认CNY + private CurrencyType currency; + // 价格,默认为0 + private float price; + // 车辆组 + private String vehicleGroup; + // 有效性金额 + private int effectivenessAmount; + // 跳过的字段位 + private long skipFields; + + // Getters and setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/pick/CarPickUpSkipFields.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/pick/CarPickUpSkipFields.java new file mode 100644 index 00000000..c31cc6b2 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/pick/CarPickUpSkipFields.java @@ -0,0 +1,19 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.pick; + +// CarPickUpSkipFields bit field constants + +import lombok.Data; + +@Data +public class CarPickUpSkipFields { + public static final long PassengerList = 1; // 乘客列表 + public static final long Cities = 2; // 城市代码 + public static final long PickUpBeginDate = 4; // 接车开始日期 + public static final long PickUpEndDate = 8; // 接车结束日期 + public static final long DropOffBeginDate = 16; // 送车开始日期 + public static final long DropOffEndDate = 32; // 送车结束日期 + public static final long Price = 64; // 价格 + public static final long Currency = 128; // 货币类型 + public static final long VehicleGroup = 256; // 车辆组 + // ... include other fields as necessary +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/plan/TravelPlanEndorsementDetail.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/plan/TravelPlanEndorsementDetail.java new file mode 100644 index 00000000..a402b6c1 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/plan/TravelPlanEndorsementDetail.java @@ -0,0 +1,31 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.plan; + +import com.chint.interfaces.rest.ctrip.dto.approval.PassengerDetail; +import lombok.Data; + +import java.util.List; + +@Data +public class TravelPlanEndorsementDetail { + + // 出差开始日期 + private String travelStartDate; + // 出差结束日期 + private String travelEndDate; + // 出发城市代码 + private String departCities; + // 到达城市代码 + private String arriveCities; + // 允许的产品类型列表 + private List allowProductTypes; + // 租车取车模式类型列表 + private List carPickupPatternTypes; + // 乘客列表 + private List passengerList; + // 酒店是否允许延迟退房 + private boolean hotelCheckOutDelay; + // 预验证字段 + private String preVerifyFields; + + // Getters and setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/quick/CarQuickEndorsementDetail.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/quick/CarQuickEndorsementDetail.java new file mode 100644 index 00000000..c3334897 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/quick/CarQuickEndorsementDetail.java @@ -0,0 +1,42 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.quick; + +import com.chint.interfaces.rest.ctrip.dto.approval.CurrencyType; +import com.chint.interfaces.rest.ctrip.dto.approval.PassengerDetail; +import lombok.Data; + +import java.util.List; + +@Data +public class CarQuickEndorsementDetail { + + // 产品类型 + private int productType; + // 乘客列表, 最多100名 + private List passengerList; + // 城市代码 + private String cities; + // 公司地址列表 + private List companyAddressList; + // 到达地址列表 + private List arrivalAddressList; + // 开始使用日期 + private String beginUseDate; + // 结束使用日期 + private String endUseDate; + // 使用时间列表 + private List useTimeList; + // 货币类型, 默认CNY + private CurrencyType currency; + // 价格,默认为0 + private float price; + // 车辆组 + private String vehicleGroup; + // 有效性金额 + private int effectivenessAmount; + // 跳过的字段位 + private long skipFields; + // 到达城市代码 + private String arrivalCities; + + // Getters and setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/quick/CarQuickSkipFields.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/quick/CarQuickSkipFields.java new file mode 100644 index 00000000..5cbc9ecd --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/quick/CarQuickSkipFields.java @@ -0,0 +1,16 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.quick; + +public class CarQuickSkipFields { + public static final long PassengerList = 1; // 乘客列表 + public static final long Cities = 2; // 城市代码 + public static final long CompanyAddressList = 4; // 公司地址列表 + public static final long BeginUseDate = 8; // 开始使用日期 + public static final long EndUseDate = 16; // 结束使用日期 + public static final long UseTimeList = 32; // 使用时间列表 + public static final long Currency = 64; // 货币类型 + public static final long Price = 128; // 价格 + public static final long VehicleGroup = 256; // 车辆组 + public static final long ArrivalAddressList = 512; // 到达地址列表 + public static final long ArrivalCities = 1024; // 到达城市代码 + // ... include other fields as necessary +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/quick/CompanyAddressDetail.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/quick/CompanyAddressDetail.java new file mode 100644 index 00000000..69377796 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/quick/CompanyAddressDetail.java @@ -0,0 +1,17 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.quick; + +public class CompanyAddressDetail { + + // 坐标类型 + private String coordinateType; + // 地址名称 + private String addressName; + // 经度 + private String longitude; + // 纬度 + private String latitude; + // 允许半径 + private int allowRadius; + + // Getters and setters... +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/quick/RankInfo.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/quick/RankInfo.java new file mode 100644 index 00000000..9500d6ec --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/quick/RankInfo.java @@ -0,0 +1,12 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.quick; + +import lombok.Data; + +// RankInfo class +@Data +public class RankInfo { + // 职级名称 + private String rankName; + + // Getters and setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/quick/RankStatus.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/quick/RankStatus.java new file mode 100644 index 00000000..2adbdf4e --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/quick/RankStatus.java @@ -0,0 +1,20 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.quick; + + +// Enumeration for the provided table related to rank or status +public enum RankStatus { + UNKNOWN(1), // 未知 + LEVEL_2(2), // 二级 + LEVEL_3(3), // 三级 + LEVEL_4(4), // 四级 + // ... other levels + LEVEL_7(7); // 七级 + + private final int id; + + RankStatus(int id) { + this.id = id; + } + + // Getter... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/quick/UseTimeDetail.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/quick/UseTimeDetail.java new file mode 100644 index 00000000..81e66dda --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/quick/UseTimeDetail.java @@ -0,0 +1,15 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.quick; + +// UseTimeDetail class + +import lombok.Data; + +@Data +public class UseTimeDetail { + // 开始使用时间, 格式为HHmm + private String beginUseTime; + // 结束使用时间, 格式为HHmm + private String endUseTime; + + // Getters and setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/rental/CarRentalEndorsementDetail.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/rental/CarRentalEndorsementDetail.java new file mode 100644 index 00000000..3eeb40dd --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/rental/CarRentalEndorsementDetail.java @@ -0,0 +1,44 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.rental; + +import com.chint.interfaces.rest.ctrip.dto.approval.CurrencyType; +import com.chint.interfaces.rest.ctrip.dto.approval.PassengerDetail; + +import java.util.List; + +public class CarRentalEndorsementDetail { + + // 产品类型 + private int productType; + // 乘客列表,最多100名 + private List passengerList; + // 接车城市代码 + private String pickUpCities; + // 送车城市代码 + private String dropOffCities; + // 接车开始日期 + private String pickUpBeginDate; + // 接车结束日期 + private String pickUpEndDate; + // 送车开始日期 + private String dropOffBeginDate; + // 送车结束日期 + private String dropOffEndDate; + // 货币类型,默认CNY + private CurrencyType currency; + // 价格,默认为0 + private float price; + // 车辆组 + private String vehicleGroup; + // 跳过的字段位 + private long skipFields; + // 预验证字段位 + private long preVerifyFields; + // 有效性金额 + private int effectivenessAmount; + // 版本号 + private int version; + // 总旅客数 + private int totalTravelerCount; + + // Getters and setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/rental/CarRentalSkipFieldType.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/rental/CarRentalSkipFieldType.java new file mode 100644 index 00000000..7c491d5d --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/rental/CarRentalSkipFieldType.java @@ -0,0 +1,15 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.rental; + +public class CarRentalSkipFieldType { + public static final long PassengerList = 1; + public static final long PickUpCities = 2; + public static final long DropOffCities = 4; + public static final long PickUpBeginDate = 8; + public static final long PickUpEndDate = 16; + public static final long DropOffBeginDate = 32; + public static final long DropOffEndDate = 64; + public static final long Price = 128; + public static final long Currency = 256; + public static final long VehicleGroup = 512; + // ... include other fields as necessary +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/train/SeatTypeEnum.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/train/SeatTypeEnum.java new file mode 100644 index 00000000..1b285b26 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/train/SeatTypeEnum.java @@ -0,0 +1,17 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.train; + +// SeatTypeEnum definition +public enum SeatTypeEnum { + YZ(201), // 硬座 + RZ(203), // 软座 + // ... other seat types with their corresponding integer values + EDSR(314); // 二等卧 + + private final int value; + + SeatTypeEnum(int value) { + this.value = value; + } + + // Getter... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/train/TrainEndorsementDetail.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/train/TrainEndorsementDetail.java new file mode 100644 index 00000000..e4d9236a --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/train/TrainEndorsementDetail.java @@ -0,0 +1,69 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.train; + +import com.chint.interfaces.rest.ctrip.dto.approval.CurrencyType; +import com.chint.interfaces.rest.ctrip.dto.approval.PassengerDetail; + +import java.util.List; + +// TrainEndorsementDetail class definition +public class TrainEndorsementDetail { + + // 火车产品类型 + private TrainProductTypeEnum productType; + + // 订票类型列表 - 1张, 2张, 3张, 超过3张 + private List bookingTypeList; + + // 订单ID列表 + private List orderIDList; + + // 行程类型 - 单程(1) or 往返(2) + private TripTypeEnum tripType; + + // 出发日期开始 - 格式: yyyy-MM-dd + private String departDateBegin; + + // 出发日期结束 - 格式: yyyy-MM-dd + private String departDateEnd; + + // 返回日期开始 - 格式: yyyy-MM-dd + private String returnDateBegin; + + // 返回日期结束 - 格式: yyyy-MM-dd + private String returnDateEnd; + + // 乘客列表 - 无限制 + private List passengerList; + + // 到达城市代码列表 - 最多1000个 + private List arrivalCityCodes; + + // 出发城市代码列表 - 最多1000个 + private List departCityCodes; + + // 价格 - 可为负数, 默认为0 + private String price; + + // 货币类型 - 默认CNY + private CurrencyType currency; + + // 座位类型 + private List seatType; + + // 跳过的字段位 - 用于标记不包含的字段 + private long skipFields; + + // 旅客数量 - 默认为0 + private int travelerCount; + + // 预验证字段位 - 用于标记需要预验证的字段 + private long preVerifyFields; + + // 列车车次列表 - 如G, D, C, Z, T, K等 + private List trainVehicleTypeList; + + // 总旅客数量 - 用于统计 + private int totalTravelerCount; + + // Getters and setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/train/TrainPreVerifyFields.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/train/TrainPreVerifyFields.java new file mode 100644 index 00000000..84cd2e75 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/train/TrainPreVerifyFields.java @@ -0,0 +1,14 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.train; + +// TrainPreVerifyFields bit field constants +public class TrainPreVerifyFields { + public static final long TripType = 1; + public static final long DepartDateBegin = 2; + public static final long DepartDateEnd = 4; + public static final long ReturnDateBegin = 8; + public static final long ReturnDateEnd = 16; + public static final long PassengerList = 32; + public static final long FromCities = 64; + public static final long ToCities = 128; + // ... include other fields as necessary +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/train/TrainProductTypeEnum.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/train/TrainProductTypeEnum.java new file mode 100644 index 00000000..0e6e9666 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/train/TrainProductTypeEnum.java @@ -0,0 +1,14 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.train; + +// TrainProductTypeEnum definition +public enum TrainProductTypeEnum { + Domestic(5); // 国内火车 + + private final int value; + + TrainProductTypeEnum(int value) { + this.value = value; + } + + // Getter... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/train/TrainSkipFields.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/train/TrainSkipFields.java new file mode 100644 index 00000000..c0ed5109 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/train/TrainSkipFields.java @@ -0,0 +1,17 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.train; + +// TrainSkipFields bit field constants +public class TrainSkipFields { + public static final long TripType = 1; + public static final long DepartDateBegin = 2; + public static final long DepartDateEnd = 4; + public static final long ReturnDateBegin = 8; + public static final long ReturnDateEnd = 16; + public static final long PassengerList = 32; + public static final long FromCities = 64; + public static final long ToCities = 128; + public static final long Price = 256; + public static final long Currency = 512; + public static final long SeatType = 1024; + // ... include other fields as necessary +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/train/TripTypeEnum.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/train/TripTypeEnum.java new file mode 100644 index 00000000..6bc29c9f --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/train/TripTypeEnum.java @@ -0,0 +1,12 @@ +package com.chint.interfaces.rest.ctrip.dto.approval.train; + +public enum TripTypeEnum { + SingleTrip(3), // 国内酒店 + RoundTrip(4); // 国际酒店 + + private final int value; + + TripTypeEnum(int value) { + this.value = value; + } +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/AuthInfo.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/AuthInfo.java new file mode 100644 index 00000000..69619906 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/AuthInfo.java @@ -0,0 +1,20 @@ +package com.chint.interfaces.rest.ctrip.dto.estimate.request; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class AuthInfo { + + // appKey + private String appKey; + // 访问令牌 + private String accessToken; + + // Getters and setters... + + public static AuthInfo of(String appKey, String accessToken) { + return new AuthInfo(appKey, accessToken); + } +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/BookingRelatedApiRequest.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/BookingRelatedApiRequest.java new file mode 100644 index 00000000..dc4999e8 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/BookingRelatedApiRequest.java @@ -0,0 +1,21 @@ +package com.chint.interfaces.rest.ctrip.dto.estimate.request; + +import lombok.Data; + +@Data +public class BookingRelatedApiRequest { + + // 语言 + private String language; + // API名称 + private String apiName; + // 认证信息 + private AuthInfo authInfo; + // 请求内容 + private ValuateBudgetRequestType requestContent; + + // Getters and setters... + public static BookingRelatedApiRequestBuilder builder() { + return new BookingRelatedApiRequestBuilder(); + } +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/BookingRelatedApiRequestBuilder.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/BookingRelatedApiRequestBuilder.java new file mode 100644 index 00000000..86eac4ae --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/BookingRelatedApiRequestBuilder.java @@ -0,0 +1,272 @@ +package com.chint.interfaces.rest.ctrip.dto.estimate.request; + +import java.util.ArrayList; + +public class BookingRelatedApiRequestBuilder { + + private BookingRelatedApiRequest request = new BookingRelatedApiRequest(); + + public BookingRelatedApiRequestBuilder language(String language) { + request.setLanguage(language); + return this; + } + + public BookingRelatedApiRequestBuilder apiName(String apiName) { + request.setApiName(apiName); + return this; + } + + public AuthInfoBuilder authInfo() { + return new AuthInfoBuilder(this, request); + } + + public ValuateBudgetRequestTypeBuilder requestContent() { + return new ValuateBudgetRequestTypeBuilder(this, request); + } + + public BookingRelatedApiRequest build() { + return request; + } + + // Sub-builder for AuthInfo (Example, needs implementation) + public static class AuthInfoBuilder { + private final BookingRelatedApiRequestBuilder parentBuilder; + private final BookingRelatedApiRequest request; + + public AuthInfoBuilder(BookingRelatedApiRequestBuilder parentBuilder, BookingRelatedApiRequest request) { + this.parentBuilder = parentBuilder; + this.request = request; + } + + public AuthInfoBuilder details(String appKey, String accessToken) { + AuthInfo authInfo = new AuthInfo(appKey,accessToken); // Construct AuthInfo with parameters + request.setAuthInfo(authInfo); + return this; + } + + public BookingRelatedApiRequestBuilder done() { + return parentBuilder; + } + } + + // Sub-builder for ValuateBudgetRequestType + public static class ValuateBudgetRequestTypeBuilder { + private final BookingRelatedApiRequestBuilder parentBuilder; + private final BookingRelatedApiRequest request; + private ValuateBudgetRequestType requestContent = new ValuateBudgetRequestType(); + + public ValuateBudgetRequestTypeBuilder(BookingRelatedApiRequestBuilder parentBuilder, BookingRelatedApiRequest request) { + this.parentBuilder = parentBuilder; + this.request = request; + } + + public ValuationBaseInfoBuilder valuationBaseInfo() { + return new ValuationBaseInfoBuilder(this, requestContent); + } + + public ValuationProductInfoBuilder valuationProductInfo() { + return new ValuationProductInfoBuilder(this, requestContent); + } + + public BookingRelatedApiRequestBuilder done() { + request.setRequestContent(requestContent); + return parentBuilder; + } + } + + // Sub-builder for ValuationBaseInfo + public static class ValuationBaseInfoBuilder { + private final ValuateBudgetRequestTypeBuilder parentBuilder; + private final ValuateBudgetRequestType requestContent; + private ValuationBaseInfo baseInfo = new ValuationBaseInfo(); + + public ValuationBaseInfoBuilder(ValuateBudgetRequestTypeBuilder parentBuilder, ValuateBudgetRequestType requestContent) { + this.parentBuilder = parentBuilder; + this.requestContent = requestContent; + } + + public ValuationBaseInfoBuilder corpID(String corpID) { + baseInfo.setCorpID(corpID); + return this; + } + + public ValuationBaseInfoBuilder eID(String eID) { + baseInfo.setEID(eID); + return this; + } + + public ValuationBaseInfoBuilder rankName(String rankName) { + baseInfo.setRankName(rankName); + return this; + } + + public ValuateBudgetRequestTypeBuilder done() { + requestContent.setValuationBaseInfo(baseInfo); + return parentBuilder; + } + } + + // Sub-builder for ValuationProductInfo (Example, needs further implementation for FlightProductInfo, TrainProductInfo, etc.) + public static class ValuationProductInfoBuilder { + private final ValuateBudgetRequestTypeBuilder parentBuilder; + private final ValuateBudgetRequestType requestContent; + private ValuationProductInfo productInfo = new ValuationProductInfo(); + + public ValuationProductInfoBuilder(ValuateBudgetRequestTypeBuilder parentBuilder, ValuateBudgetRequestType requestContent) { + this.parentBuilder = parentBuilder; + this.requestContent = requestContent; + } + + // Method to add FlightProductInfo, TrainProductInfo, etc. + public ValuationProductInfoBuilder addFlightProductInfo(FlightProductInfo flightProductInfo) { + if (productInfo.getFlightProductInfo() == null) { + productInfo.setFlightProductInfo(new ArrayList<>()); + } + productInfo.getFlightProductInfo().add(flightProductInfo); + return this; + } + + // Similar methods for adding TrainProductInfo, etc. + + public ValuationProductInfoBuilder addTrainProductInfo(TrainProductInfo trainProductInfo) { + if (productInfo.getTrainProductInfo() == null) { + productInfo.setTrainProductInfo(new ArrayList<>()); + } + productInfo.getTrainProductInfo().add(trainProductInfo); + return this; + } + + + public ValuateBudgetRequestTypeBuilder done() { + requestContent.setValuationProductInfo(productInfo); + return parentBuilder; + } + } + + // Sub-builder for FlightProductInfo + public static class FlightProductInfoBuilder { + private final ValuationProductInfoBuilder parentBuilder; + private FlightProductInfo flightProductInfo = new FlightProductInfo(); + + public FlightProductInfoBuilder(ValuationProductInfoBuilder parentBuilder) { + this.parentBuilder = parentBuilder; + } + + public FlightProductInfoBuilder flightWay(String flightWay) { + flightProductInfo.setFlightWay(flightWay); + return this; + } + + public FlightProductInfoBuilder classType(String classType) { + flightProductInfo.setClassType(classType); + return this; + } + + public FlightProductInfoBuilder searchRouteNum(Integer searchRouteNum) { + flightProductInfo.setSearchRouteNum(searchRouteNum); + return this; + } + + public FlightProductInfoBuilder airLineCode(String airLineCode) { + flightProductInfo.setAirLineCode(airLineCode); + return this; + } + + public FlightProductInfoBuilder addRouteInfo(RouteInfo routeInfo) { + if (flightProductInfo.getRoutes() == null) { + flightProductInfo.setRoutes(new ArrayList<>()); + } + flightProductInfo.getRoutes().add(routeInfo); + return this; + } + + public ValuationProductInfoBuilder done() { + parentBuilder.addFlightProductInfo(flightProductInfo); + return parentBuilder; + } + } + + // Sub-builder for TrainProductInfo + public static class TrainProductInfoBuilder { + private final ValuationProductInfoBuilder parentBuilder; + private TrainProductInfo trainProductInfo = new TrainProductInfo(); + + public TrainProductInfoBuilder(ValuationProductInfoBuilder parentBuilder) { + this.parentBuilder = parentBuilder; + } + + public TrainProductInfoBuilder departStation(String departStation) { + trainProductInfo.setDepartStation(departStation); + return this; + } + + public TrainProductInfoBuilder arriveStation(String arriveStation) { + trainProductInfo.setArriveStation(arriveStation); + return this; + } + + public TrainProductInfoBuilder departDate(String departDate) { + trainProductInfo.setDepartDate(departDate); + return this; + } + + public TrainProductInfoBuilder trainNo(String trainNo) { + trainProductInfo.setTrainNo(trainNo); + return this; + } + + public TrainProductInfoBuilder departCityID(String departCityID) { + trainProductInfo.setDepartCityID(departCityID); + return this; + } + + public TrainProductInfoBuilder arriveCityID(String arriveCityID) { + trainProductInfo.setArriveCityID(arriveCityID); + return this; + } + + public TrainProductInfoBuilder returnNoTicket(boolean returnNoTicket) { + trainProductInfo.setReturnNoTicket(returnNoTicket); + return this; + } + + public ValuationProductInfoBuilder done() { + parentBuilder.addTrainProductInfo(trainProductInfo); + return parentBuilder; + } + } + + // Sub-builder for RouteInfo + public static class RouteInfoBuilder { + private RouteInfo routeInfo = new RouteInfo(); + + public RouteInfoBuilder arriveCityCode(String arriveCityCode) { + routeInfo.setArriveCityCode(arriveCityCode); + return this; + } + + public RouteInfoBuilder departCityCode(String departCityCode) { + routeInfo.setDepartCityCode(departCityCode); + return this; + } + + public RouteInfoBuilder departDate(String departDate) { + routeInfo.setDepartDate(departDate); + return this; + } + + public RouteInfoBuilder arriveCityID(String arriveCityID) { + routeInfo.setArriveCityID(arriveCityID); + return this; + } + + public RouteInfoBuilder departCityID(String departCityID) { + routeInfo.setDepartCityID(departCityID); + return this; + } + + public RouteInfo build() { + return routeInfo; + } + } +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/FlightProductInfo.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/FlightProductInfo.java new file mode 100644 index 00000000..f10d523a --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/FlightProductInfo.java @@ -0,0 +1,18 @@ +package com.chint.interfaces.rest.ctrip.dto.estimate.request; + +import lombok.Data; + +import java.util.List; + +@Data +public class FlightProductInfo { + // 航班方式 + private String flightWay; + // 舱位类型 + private String classType; + // 航线信息 + private List routes; + + private Integer searchRouteNum; + private String airLineCode; +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/LanguagesEnum.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/LanguagesEnum.java new file mode 100644 index 00000000..2698483d --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/LanguagesEnum.java @@ -0,0 +1,5 @@ +package com.chint.interfaces.rest.ctrip.dto.estimate.request; + +public enum LanguagesEnum { + ZH, EN +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/RouteInfo.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/RouteInfo.java new file mode 100644 index 00000000..a9ecb554 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/RouteInfo.java @@ -0,0 +1,17 @@ +package com.chint.interfaces.rest.ctrip.dto.estimate.request; + +import lombok.Data; + +@Data +public class RouteInfo { + + // 到达城市代码 + private String arriveCityCode; + // 出发城市代码 + private String departCityCode; + // 出发日期 + private String departDate; + private String arriveCityID; + private String departCityID; + // Getters and setters... +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/TrainProductInfo.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/TrainProductInfo.java new file mode 100644 index 00000000..57671a1f --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/TrainProductInfo.java @@ -0,0 +1,14 @@ +package com.chint.interfaces.rest.ctrip.dto.estimate.request; + +import lombok.Data; + +@Data +public class TrainProductInfo { + private String departStation; + private String arriveStation; + private String departDate; //出发日期 格式: yyyy-MM-dd + private String trainNo; //车次 + private String departCityID; //出发城市id,车站和城市id配套二传一,都传优先使用车站 + private String arriveCityID; //到达城市id,车站和城市id配套二传一,都传优先使用车站 + private boolean returnNoTicket; //是否返回无票价格,默认否 +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/ValuateBudgetRequestType.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/ValuateBudgetRequestType.java new file mode 100644 index 00000000..0e2603f8 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/ValuateBudgetRequestType.java @@ -0,0 +1,18 @@ +package com.chint.interfaces.rest.ctrip.dto.estimate.request; + +import lombok.Data; +import org.apache.commons.codec.language.bm.Languages; + +import java.util.List; + +@Data +public class ValuateBudgetRequestType { + + // 估算基础信息 + private ValuationBaseInfo valuationBaseInfo; + // 产品信息 + private ValuationProductInfo valuationProductInfo; + + private LanguagesEnum languages; + // Getters and setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/ValuationBaseInfo.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/ValuationBaseInfo.java new file mode 100644 index 00000000..3d0201f4 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/ValuationBaseInfo.java @@ -0,0 +1,16 @@ +package com.chint.interfaces.rest.ctrip.dto.estimate.request; + +import lombok.Data; + +@Data +public class ValuationBaseInfo { + + // 公司ID + private String corpID; + // 员工ID + private String eID; + // 职级名称 + private String rankName; + + // Getters and setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/ValuationProductInfo.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/ValuationProductInfo.java new file mode 100644 index 00000000..11109574 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/request/ValuationProductInfo.java @@ -0,0 +1,14 @@ +package com.chint.interfaces.rest.ctrip.dto.estimate.request; + +import lombok.Data; + +import java.util.List; + +@Data +public class ValuationProductInfo { + + // Allowable product types like "DOMESTIC_FLIGHT", "INTERNATIONAL_FLIGHT", etc. + private List flightProductInfo; + private List trainProductInfo; + // Getters and setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/AirlineInfo.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/AirlineInfo.java new file mode 100644 index 00000000..2ad3af3b --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/AirlineInfo.java @@ -0,0 +1,21 @@ +package com.chint.interfaces.rest.ctrip.dto.estimate.response; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class AirlineInfo { + // 航班价格类型 + private Integer priceType; + // 航空公司名称 + private String airlineName; + // 起飞时间 + private String departTime; + // 起飞机场 + private String departPort; + // 到达机场 + private String arrivalPort; + // 航班折扣 + private BigDecimal discount; +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/AvailableProductEnum.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/AvailableProductEnum.java new file mode 100644 index 00000000..23ee410c --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/AvailableProductEnum.java @@ -0,0 +1,5 @@ +package com.chint.interfaces.rest.ctrip.dto.estimate.response; + +public enum AvailableProductEnum { + UNKNOWN,FLIGHT,HOTEL,TRAIN +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/BookingRelatedApiResponse.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/BookingRelatedApiResponse.java new file mode 100644 index 00000000..a1c907c8 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/BookingRelatedApiResponse.java @@ -0,0 +1,18 @@ +package com.chint.interfaces.rest.ctrip.dto.estimate.response; + +import com.chint.interfaces.rest.ctrip.dto.ResponseStatus; +import lombok.Data; + +import java.util.List; + +@Data +public class BookingRelatedApiResponse { + + // 请求相关API的响应 + private ResponseStatus status; + // 数据内容 + private ValuateBudgetResponseType data; + + + // Getters and Setters... +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/FlightValuationResult.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/FlightValuationResult.java new file mode 100644 index 00000000..ea95e12e --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/FlightValuationResult.java @@ -0,0 +1,29 @@ +package com.chint.interfaces.rest.ctrip.dto.estimate.response; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +@Data +public class FlightValuationResult { + // 航班总价格 + private BigDecimal totalPrice; + // 航班最高价格 + private BigDecimal maxPrice; + // 航班中等价格 + private BigDecimal mediumPrice; + // 航班最高舱位类别 + private String highestClass; + + private List airlineInfoList; + + // 航班结果描述 + private String resultDescription; + // 航班较低的价格 + private BigDecimal lessPrice; + // 航班更高的价格 + private BigDecimal morePrice; + + // Getters and Setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/HotelValuationResult.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/HotelValuationResult.java new file mode 100644 index 00000000..3773925e --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/HotelValuationResult.java @@ -0,0 +1,18 @@ +package com.chint.interfaces.rest.ctrip.dto.estimate.response; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class HotelValuationResult { + + // 币种 + private String currency; + // 酒店最高价格 + private BigDecimal maxPrice; + // 酒店结果描述 + private String resultDescription; + + // Getters and Setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/SeatMaxPriceInfo.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/SeatMaxPriceInfo.java new file mode 100644 index 00000000..da2d33c9 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/SeatMaxPriceInfo.java @@ -0,0 +1,15 @@ +package com.chint.interfaces.rest.ctrip.dto.estimate.response; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class SeatMaxPriceInfo { + // 座位最高价格信息 + private String seatCode; // 座位代码 + private BigDecimal maxPrice; // 最高价格 + + + // Getters and Setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/TrainTypeDurationMinute.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/TrainTypeDurationMinute.java new file mode 100644 index 00000000..6002c79f --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/TrainTypeDurationMinute.java @@ -0,0 +1,13 @@ +package com.chint.interfaces.rest.ctrip.dto.estimate.response; + +import lombok.Data; + +@Data +public class TrainTypeDurationMinute { + // 火车类型 + private TrainTypeEnum trainType; // 火车类型枚举 + private Float maxDurationMinutes; // 最大持续时间分钟 + private Integer minDurationMinutes; // 最小持续时间分钟 + + // Getters and Setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/TrainTypeEnum.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/TrainTypeEnum.java new file mode 100644 index 00000000..167712f5 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/TrainTypeEnum.java @@ -0,0 +1,9 @@ +package com.chint.interfaces.rest.ctrip.dto.estimate.response; + +public enum TrainTypeEnum { + G, // 高铁 + D, // 动车 + T, // 特快 + K, // 快速 + // ... Add additional train types as necessary +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/TrainValuationResult.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/TrainValuationResult.java new file mode 100644 index 00000000..bdedad51 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/TrainValuationResult.java @@ -0,0 +1,22 @@ +package com.chint.interfaces.rest.ctrip.dto.estimate.response; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +@Data +public class TrainValuationResult { + // 估算的最高价格 + private BigDecimal maxPrice; + // 座位最高价格信息列表 + private List seatMaxPriceInfoList; + // 结果描述 + private String resultDescription; + // 火车类型持续时间分钟列表 + private List trainTypeDurationMinuteList; + // 可用产品列表 + + + // Getters and Setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/ValuateBudgetResponseType.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/ValuateBudgetResponseType.java new file mode 100644 index 00000000..37482d19 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/ValuateBudgetResponseType.java @@ -0,0 +1,19 @@ +package com.chint.interfaces.rest.ctrip.dto.estimate.response; + +import java.math.BigDecimal; +import java.util.List; + +public class ValuateBudgetResponseType { + // 估算结果 + private ValuateBudgetResult valuateBudgetResult; + // 航班估算结果 + private FlightValuationResult flightValuationResult; + // 估算的总价格 + private HotelValuationResult hotelValuationResult; + // 火车估算结果 + private TrainValuationResult trainValuationResult; + + private List availableProductList; + + // Getters and Setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/ValuateBudgetResult.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/ValuateBudgetResult.java new file mode 100644 index 00000000..5716d36d --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/estimate/response/ValuateBudgetResult.java @@ -0,0 +1,14 @@ +package com.chint.interfaces.rest.ctrip.dto.estimate.response; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class ValuateBudgetResult { + // 总价格 + private BigDecimal totalPrice; + // 最高价格 + private BigDecimal maxPrice; + // Getters and Setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/location/City.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/location/City.java new file mode 100644 index 00000000..6462efe1 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/location/City.java @@ -0,0 +1,21 @@ +package com.chint.interfaces.rest.ctrip.dto.location; + +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class City { + + private Long id; + private String City; + private String CityEName; + private String CityName; + private String Country; + private String CountryEName; + private String CountryName; + private String JianPin; + private String Province; + private String ProvinceEName; + private String ProvinceName; +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/location/CityResponse.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/location/CityResponse.java new file mode 100644 index 00000000..b95933f5 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/location/CityResponse.java @@ -0,0 +1,14 @@ +package com.chint.interfaces.rest.ctrip.dto.location; + +import com.chint.interfaces.rest.ctrip.dto.ResponseStatus; +import com.chint.interfaces.rest.ctrip.dto.location.City; +import lombok.Data; + +import java.util.List; +@Data +public class CityResponse { + private ResponseStatus Status; + private List Data; + + // Constructors, getters, and setters +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/location/Country.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/location/Country.java new file mode 100644 index 00000000..0cc1021c --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/location/Country.java @@ -0,0 +1,13 @@ +package com.chint.interfaces.rest.ctrip.dto.location; + +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class Country { + private Long id; + private Integer Country; // 注意:在Kotlin中是Int,在Java中对应的是Integer + private String CountryEName; + private String CountryName; +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/location/CountryResponse.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/location/CountryResponse.java new file mode 100644 index 00000000..c9bf113a --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/location/CountryResponse.java @@ -0,0 +1,13 @@ +package com.chint.interfaces.rest.ctrip.dto.location; + +import com.chint.interfaces.rest.ctrip.dto.ResponseStatus; +import lombok.Data; + +import java.util.List; +@Data +public class CountryResponse { + private ResponseStatus Status; + private List Data; + + // Constructors, getters, and setters +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/location/GetCountry.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/location/GetCountry.java new file mode 100644 index 00000000..a902e141 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/location/GetCountry.java @@ -0,0 +1,16 @@ +package com.chint.interfaces.rest.ctrip.dto.location; + +import com.chint.interfaces.rest.ctrip.dto.Authentification; +import lombok.Data; + +@Data +public class GetCountry { + private Authentification Auth; + private String Language; + + public GetCountry(Authentification auth, String language) { + Auth = auth; + Language = language; + } +// Constructors, getters, and setters +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/location/GetCountryCityExtend.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/location/GetCountryCityExtend.java new file mode 100644 index 00000000..cca54cc3 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/location/GetCountryCityExtend.java @@ -0,0 +1,19 @@ +package com.chint.interfaces.rest.ctrip.dto.location; + +import com.chint.interfaces.rest.ctrip.dto.Authentification; +import lombok.Data; + +@Data +public class GetCountryCityExtend { + private Authentification Auth; + private String Language; + private Integer CountryId; + + public GetCountryCityExtend(Authentification auth, String language, Integer countryId) { + Auth = auth; + Language = language; + CountryId = countryId; + } + + // Constructors, getters, and setters +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/CarOrderInfoEntity.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/CarOrderInfoEntity.java new file mode 100644 index 00000000..cd06a3de --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/CarOrderInfoEntity.java @@ -0,0 +1,4 @@ +package com.chint.interfaces.rest.ctrip.dto.search; + +public class CarOrderInfoEntity { +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/CarQuickOrderInfoEntity.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/CarQuickOrderInfoEntity.java new file mode 100644 index 00000000..9ce0bf36 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/CarQuickOrderInfoEntity.java @@ -0,0 +1,4 @@ +package com.chint.interfaces.rest.ctrip.dto.search; + +public class CarQuickOrderInfoEntity { +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/DomCharterCarOrderInfoEntity.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/DomCharterCarOrderInfoEntity.java new file mode 100644 index 00000000..e59200c0 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/DomCharterCarOrderInfoEntity.java @@ -0,0 +1,4 @@ +package com.chint.interfaces.rest.ctrip.dto.search; + +public class DomCharterCarOrderInfoEntity { +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/DomPickUpCarOrderInfoEntity.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/DomPickUpCarOrderInfoEntity.java new file mode 100644 index 00000000..63eba79f --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/DomPickUpCarOrderInfoEntity.java @@ -0,0 +1,4 @@ +package com.chint.interfaces.rest.ctrip.dto.search; + +public class DomPickUpCarOrderInfoEntity { +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/FlightOrderInfoEntity.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/FlightOrderInfoEntity.java new file mode 100644 index 00000000..94169f44 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/FlightOrderInfoEntity.java @@ -0,0 +1,4 @@ +package com.chint.interfaces.rest.ctrip.dto.search; + +public class FlightOrderInfoEntity { +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/HotelOrderInfoEntity.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/HotelOrderInfoEntity.java new file mode 100644 index 00000000..65c01773 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/HotelOrderInfoEntity.java @@ -0,0 +1,7 @@ +package com.chint.interfaces.rest.ctrip.dto.search; + +import lombok.Data; + +@Data +public class HotelOrderInfoEntity { +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/IntlTrainOrderInfoEntity.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/IntlTrainOrderInfoEntity.java new file mode 100644 index 00000000..f60e1204 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/IntlTrainOrderInfoEntity.java @@ -0,0 +1,4 @@ +package com.chint.interfaces.rest.ctrip.dto.search; + +public class IntlTrainOrderInfoEntity { +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/ItineraryEntity.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/ItineraryEntity.java new file mode 100644 index 00000000..1abb9ec0 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/ItineraryEntity.java @@ -0,0 +1,30 @@ +package com.chint.interfaces.rest.ctrip.dto.search; + +import lombok.Data; + +import java.util.List; + +@Data +public class ItineraryEntity { + + // 行程单号 + private String journeyNO; // 行程单号 + // 酒店订单信息列表 + private List hotelOrderInfoList; // 酒店订单信息列表 + // 航班订单信息列表 + private List flightOrderInfoList; // 航班订单信息列表 + // 火车票订单信息列表 + private List trainOrderInfoList; // 火车票订单信息列表 + // 租车订单信息列表 + private List carOrderInfoList; // 租车订单信息列表 + // 快捷租车订单信息列表 + private List carQuickOrderInfoList; // 快捷租车订单信息列表 + // 接送机租车订单信息列表 + private List domPickUpCarOrderInfoList; // 接送机租车订单信息列表 + // 包车租车订单信息列表 + private List domCharterCarOrderInfoList; // 包车租车订单信息列表 + // 国际火车票订单信息列表 + private List intlTrainOrderInfoList; // 国际火车票订单信息列表 + + // Getters and Setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/SearchOrderRequest.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/SearchOrderRequest.java new file mode 100644 index 00000000..5de078d3 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/SearchOrderRequest.java @@ -0,0 +1,38 @@ +package com.chint.interfaces.rest.ctrip.dto.search; + +import com.chint.interfaces.rest.ctrip.dto.Authentication; +import lombok.Data; + +@Data +public class SearchOrderRequest { + + // 认证信息,ticket用 + private Authentication auth; + // 语言版本 + private String language; // zh-CN 表示中文版; en-US 英文版; + // 行程单号 + private String journeyNo; + // 订单号 + private String orderId; + // 员工编号 + private String eID; + // 用户编号 + private String uID; + // 开始日期 + private String dateFrom; // 查询开始日期,日期格式为:yyyy-MM-dd + // 结束日期 + private String dateTo; // 查询结束日期,日期格式为:yyyy-MM-dd + // 查询类型 + private String searchType; // 查询类型,默认值为1 + // 版本号 + private String version; // 版本号,默认为1.0 + // 国际机票查询类型扩展 + private String fltSearchTypeExtend; // 国际机票查询类型扩展,用于控制DateFrom, DateTo收敛。比如填写“RefundTime” 或 “RebookedTime” 时使用不同的查询逻辑 + // 火车票查询类型扩展 + private String trainSearchTypeExtend; // 火车票查询类型扩展 + // 其他查询类型扩展 + private String htlSearchTypeExtend; // 酒店查询类型扩展 + private String carSearchTypeExtend; // 租车查询类型扩展 + + // Getters and Setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/SearchOrderResponse.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/SearchOrderResponse.java new file mode 100644 index 00000000..65a6c07b --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/SearchOrderResponse.java @@ -0,0 +1,17 @@ +package com.chint.interfaces.rest.ctrip.dto.search; + +import com.chint.interfaces.rest.ctrip.dto.ResponseStatus; +import lombok.Data; + +import java.util.List; + +@Data +public class SearchOrderResponse { + + // 响应状态 + private ResponseStatus status; // 响应状态 + // 行程单列表 + private List itineraryList; // 行程单列表 + + // Getters and Setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/TrainOrderInfoEntity.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/TrainOrderInfoEntity.java new file mode 100644 index 00000000..ff8cdfee --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/TrainOrderInfoEntity.java @@ -0,0 +1,4 @@ +package com.chint.interfaces.rest.ctrip.dto.search; + +public class TrainOrderInfoEntity { +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/ticket/TicketParam.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/ticket/TicketParam.java new file mode 100644 index 00000000..90ecb1d7 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/ticket/TicketParam.java @@ -0,0 +1,16 @@ +package com.chint.interfaces.rest.ctrip.dto.ticket; + +import lombok.Data; + +@Data +public class TicketParam { + private String appKey; + private String appSecurity; + + public TicketParam(String appKey, String appSecurity) { + this.appKey = appKey; + this.appSecurity = appSecurity; + } + + // Getters and setters (or you can make the fields public) +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/ticket/TicketResponse.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/ticket/TicketResponse.java new file mode 100644 index 00000000..ccf6b952 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/ticket/TicketResponse.java @@ -0,0 +1,12 @@ +package com.chint.interfaces.rest.ctrip.dto.ticket; + +import com.chint.interfaces.rest.ctrip.dto.ResponseStatus; +import lombok.Data; + +@Data +public class TicketResponse { + private ResponseStatus Status; + private String Ticket; + + +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/token/GetUnionAccessTokenRequest.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/token/GetUnionAccessTokenRequest.java new file mode 100644 index 00000000..27ca1dc5 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/token/GetUnionAccessTokenRequest.java @@ -0,0 +1,35 @@ +package com.chint.interfaces.rest.ctrip.dto.token; + +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class GetUnionAccessTokenRequest { + + // 应用标识 + private String appKey; + // 应用安全码 + private String appSecurity; + // 访问类型 + private Integer accessType; // token类型:1-获取访问,2-刷新访问;访问类型一般有1、用户级别访问权限获取;2、应用级别访问权限获取 + // 扩展字段 + private String extend; // 扩展字段 + // ip地址 + private String ip; // ip + // 语言 + private String language; // 语言 + // 版本号 + private String version; // 版本号 + + private GetUnionAccessTokenRequest(String appKey, String appSecurity, Integer accessType) { + this.appKey = appKey; + this.appSecurity = appSecurity; + this.accessType = accessType; + } + + // Getters and Setters... + public static GetUnionAccessTokenRequest of(String appKey, String appSecurity, Integer accessType) { + return new GetUnionAccessTokenRequest(appKey, appSecurity, accessType); + } +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/token/GetUnionAccessTokenResponse.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/token/GetUnionAccessTokenResponse.java new file mode 100644 index 00000000..b0411509 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/token/GetUnionAccessTokenResponse.java @@ -0,0 +1,14 @@ +package com.chint.interfaces.rest.ctrip.dto.token; + +import lombok.Data; + +@Data +public class GetUnionAccessTokenResponse { + + // 访问令牌 + private String accessToken; // 令牌 + // 访问时间 + private Integer accessTime; // 令牌有效时间 + + // Getters and Setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/user/AuthenticationEntity.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/user/AuthenticationEntity.java new file mode 100644 index 00000000..d7e9b857 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/user/AuthenticationEntity.java @@ -0,0 +1,12 @@ +package com.chint.interfaces.rest.ctrip.dto.user; + +import lombok.Data; + +@Data +public class AuthenticationEntity { + private String EmployeeID; + private String Name; + private String Valid; //在职情况 A-在职,业务操作为新建卡或者更新卡;I-离职,业务操作为关卡。 + private String RankName; // 职级名称(中文)注:职级的中文名跟英文名,只能传递其中一个。(如果需要使用该字段,需提前联系实施经理在携程后台进行配置) + private String SubAccountName; //子账户,即确定该人员信息落在那个结算主体中,用于确定后续订单费用归属 +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/user/AuthenticationInfo.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/user/AuthenticationInfo.java new file mode 100644 index 00000000..e5ebe136 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/user/AuthenticationInfo.java @@ -0,0 +1,11 @@ +package com.chint.interfaces.rest.ctrip.dto.user; + +import lombok.Data; + +@Data +public class AuthenticationInfo { + private String Sequence; + private AuthenticationEntity Authentication; + + // Constructors, getters, and setters +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/user/AuthenticationListRequest.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/user/AuthenticationListRequest.java new file mode 100644 index 00000000..e8b41380 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/user/AuthenticationListRequest.java @@ -0,0 +1,14 @@ +package com.chint.interfaces.rest.ctrip.dto.user; + +import lombok.Data; + +import java.util.List; +@Data +public class AuthenticationListRequest { + private String Appkey; + private String Ticket; + private String CorporationID; + private List AuthenticationInfoList; + + // Constructors, getters, and setters +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ly/LYPostRequest.java b/src/main/java/com/chint/interfaces/rest/ly/LYPostRequest.java new file mode 100644 index 00000000..19150e05 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ly/LYPostRequest.java @@ -0,0 +1,53 @@ +package com.chint.interfaces.rest.ly; + +import com.chint.interfaces.rest.base.PostRequest; +import com.chint.interfaces.rest.ly.dto.LYBaseRequest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.UUID; + +import static com.chint.infrastructure.constant.Constant.L_Y_SECRET; + +@Service +public class LYPostRequest { + + @Autowired + private PostRequest postRequest; + + @Autowired + private LYTokenRequest lyTokenRequest; + + private String mySecret = L_Y_SECRET; + + public T post(String url, LYBaseRequest jsonRequest, Class responseType) { + String token = lyTokenRequest.loadToken(); + jsonRequest.setRandom(UUID.randomUUID().toString()); + jsonRequest.setTimestamp(String.valueOf(System.currentTimeMillis())); + jsonRequest.setAccessToken(token); + String postDataMd5 = md5(postRequest.gson().toJson(jsonRequest)); + String finallySign = md5(postDataMd5 + mySecret); + jsonRequest.setSign(finallySign); + return postRequest.post(url, jsonRequest, responseType); + } + + public static String md5(String input) { + try { + MessageDigest md = MessageDigest.getInstance("MD5"); + byte[] messageDigest = md.digest(input.getBytes()); + StringBuilder hexString = new StringBuilder(); + for (byte b : messageDigest) { + String hex = Integer.toHexString(0xFF & b); + if (hex.length() == 1) { + hexString.append('0'); + } + hexString.append(hex); + } + return hexString.toString().toLowerCase(); + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/main/java/com/chint/interfaces/rest/ly/LYTokenRequest.java b/src/main/java/com/chint/interfaces/rest/ly/LYTokenRequest.java new file mode 100644 index 00000000..50d8a2c6 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ly/LYTokenRequest.java @@ -0,0 +1,33 @@ +package com.chint.interfaces.rest.ly; + + +import com.chint.interfaces.rest.base.PostRequest; +import com.chint.interfaces.rest.ly.dto.token.TokenParam; +import com.chint.interfaces.rest.ly.dto.token.TokenRequest; +import com.chint.interfaces.rest.ly.dto.token.TokenResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; +import java.util.UUID; + +import static com.chint.infrastructure.constant.Constant.*; + +@Component +public class LYTokenRequest { + + private String tokenUrl = L_Y_BASE_URL + L_Y_TOKEN_PATH; + + @Autowired + private PostRequest postRequest; + + public String loadToken() { + TokenParam tokenParam = new TokenParam(L_Y_ACCOUNT, L_Y_PASSWORD, ""); + TokenRequest tokenRequest = new TokenRequest(); + tokenRequest.setRandom(UUID.randomUUID().toString()); + tokenRequest.setTimestamp(String.valueOf(System.currentTimeMillis())); + tokenRequest.setParam(tokenParam); + TokenResponse post = postRequest.post(tokenUrl, tokenRequest, TokenResponse.class); + return post.getData().getAccessToken(); + } +} diff --git a/src/main/java/com/chint/interfaces/rest/ly/LYUserRequest.java b/src/main/java/com/chint/interfaces/rest/ly/LYUserRequest.java new file mode 100644 index 00000000..741913ea --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ly/LYUserRequest.java @@ -0,0 +1,73 @@ +package com.chint.interfaces.rest.ly; + +import com.chint.domain.aggregates.user.User; +import com.chint.infrastructure.util.BaseContext; +import com.chint.interfaces.rest.base.PostRequest; +import com.chint.interfaces.rest.ly.dto.user.EmployeeRequest; +import com.chint.interfaces.rest.ly.dto.user.EmployeeEntity; +import com.chint.interfaces.rest.user.UserHttpRequest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.chint.interfaces.rest.ly.dto.user.UserResponse; +import java.util.UUID; + +import static com.chint.infrastructure.constant.Constant.L_Y_BASE_URL; +import static com.chint.infrastructure.constant.Constant.L_Y_USER_PATH; + +@Service +public class LYUserRequest { + + @Autowired + private LYPostRequest postRequest; + + @Autowired + private LYTokenRequest tokenRequest; + + @Autowired + private UserHttpRequest userHttpRequest; + + private String userUrl = L_Y_BASE_URL + L_Y_USER_PATH; + + public boolean saveCurrentUser() { + User currentUser = BaseContext.getCurrentUser(); + userHttpRequest.loadUserInfo(currentUser); + EmployeeEntity employeeEntity = user2LYEmployee(currentUser); + EmployeeRequest employeeData = new EmployeeRequest(); + employeeData.setParam(employeeEntity); + UserResponse post = postRequest.post(userUrl, employeeData, UserResponse.class); + return post.isSuccess(); + } + + private Integer translateGender(String gender) { + switch (gender) { + case "M": + return 1; + case "F": + return 0; + default: + throw new RuntimeException("未知性别"); + } + } + + private Integer translateWorkStatus(String workStatus) { + switch (workStatus) { + case "A": + return 1; + case "T": + return 0; + default: + return 0; + } + } + + private EmployeeEntity user2LYEmployee(User user){ + EmployeeEntity employeeEntity = new EmployeeEntity(); + employeeEntity.setOutEmployeeId(String.valueOf(user.employeeNo)); + employeeEntity.setSurName(user.getName()); + employeeEntity.setGender(translateGender(user.getGender())); + employeeEntity.setWorkingState(translateWorkStatus(user.getWorkStatus())); + employeeEntity.setReservationType(0); + employeeEntity.setPositionLevelName(user.getRankCode()); + return employeeEntity; + } +} diff --git a/src/main/java/com/chint/interfaces/rest/ly/dto/LYBaseRequest.java b/src/main/java/com/chint/interfaces/rest/ly/dto/LYBaseRequest.java new file mode 100644 index 00000000..d0b0d3c2 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ly/dto/LYBaseRequest.java @@ -0,0 +1,11 @@ +package com.chint.interfaces.rest.ly.dto; + +import lombok.Data; + +@Data +public class LYBaseRequest { + private String accessToken; + private String random; + private String timestamp; + private String sign; +} diff --git a/src/main/java/com/chint/interfaces/rest/ly/dto/token/TokenParam.java b/src/main/java/com/chint/interfaces/rest/ly/dto/token/TokenParam.java new file mode 100644 index 00000000..56b477f4 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ly/dto/token/TokenParam.java @@ -0,0 +1,42 @@ +package com.chint.interfaces.rest.ly.dto.token; + +import lombok.Data; + +@Data +public class TokenParam { + private String account; + private String password; + private String tokenType; + + // 构造函数 + public TokenParam(String account, String password, String tokenType) { + this.account = account; + this.password = password; + this.tokenType = tokenType; + } + + // Getter 和 Setter 方法 + public String getAccount() { + return account; + } + + public void setAccount(String account) { + this.account = account; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getTokenType() { + return tokenType; + } + + public void setTokenType(String tokenType) { + this.tokenType = tokenType; + } +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ly/dto/token/TokenRequest.java b/src/main/java/com/chint/interfaces/rest/ly/dto/token/TokenRequest.java new file mode 100644 index 00000000..f03a40b5 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ly/dto/token/TokenRequest.java @@ -0,0 +1,13 @@ +package com.chint.interfaces.rest.ly.dto.token; + +import com.chint.interfaces.rest.ly.dto.LYBaseRequest; +import lombok.Data; + +@Data +public class TokenRequest { + private String random; + + private String timestamp; + + private TokenParam param; +} diff --git a/src/main/java/com/chint/interfaces/rest/ly/dto/token/TokenResponse.java b/src/main/java/com/chint/interfaces/rest/ly/dto/token/TokenResponse.java new file mode 100644 index 00000000..e714508a --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ly/dto/token/TokenResponse.java @@ -0,0 +1,84 @@ +package com.chint.interfaces.rest.ly.dto.token; + +import lombok.Data; + +@Data +public class TokenResponse { + private boolean success; + private String errorCode; + private String errorMessage; + private ResponseData data; + private int errorType; + + // 内部类,用于表示响应中的"data"字段 + public static class ResponseData { + private String accessToken; + private long expiryTime; + + // Getter 和 Setter 方法 + public String getAccessToken() { + return accessToken; + } + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + + public long getExpiryTime() { + return expiryTime; + } + + public void setExpiryTime(long expiryTime) { + this.expiryTime = expiryTime; + } + } + + // 构造函数、Getter 和 Setter 方法 + public TokenResponse(boolean success, String errorCode, String errorMessage, ResponseData data, int errorType) { + this.success = success; + this.errorCode = errorCode; + this.errorMessage = errorMessage; + this.data = data; + this.errorType = errorType; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public String getErrorCode() { + return errorCode; + } + + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + public ResponseData getData() { + return data; + } + + public void setData(ResponseData data) { + this.data = data; + } + + public int getErrorType() { + return errorType; + } + + public void setErrorType(int errorType) { + this.errorType = errorType; + } +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ly/dto/user/CostCenter.java b/src/main/java/com/chint/interfaces/rest/ly/dto/user/CostCenter.java new file mode 100644 index 00000000..cdb4ad73 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ly/dto/user/CostCenter.java @@ -0,0 +1,10 @@ +package com.chint.interfaces.rest.ly.dto.user; + +public class CostCenter { + private String costCenterName; + private String costCenterCode; + private String costCenterTypeName; + private String costCenterTypeCode; + private boolean isDefault; + // Getters and setters +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ly/dto/user/EmployeeEntity.java b/src/main/java/com/chint/interfaces/rest/ly/dto/user/EmployeeEntity.java new file mode 100644 index 00000000..7399dce9 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ly/dto/user/EmployeeEntity.java @@ -0,0 +1,36 @@ +package com.chint.interfaces.rest.ly.dto.user; + +import lombok.Data; + +import java.util.List; +import java.util.Map; + +@Data +public class EmployeeEntity { + private String outEmployeeId; + private int employeeType; + private String surName; + private String givenName; + private String enSurName; + private String enGivenName; + private int gender; + private String mobile; + private String email; + private String idCard; + private int reservationType; + private String positionName; + private String positionLevelName; + private String departName; + private int workingState; + private String birthday; + private String credentialExpireDate; + private int credentialType; + private int addTravellerAllowed; + private String employeeCode; + private String costCenter; + private List preTravelPolicyList; + private Map remarks; + private String baseCity; + + // Getters and setters +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ly/dto/user/EmployeeRequest.java b/src/main/java/com/chint/interfaces/rest/ly/dto/user/EmployeeRequest.java new file mode 100644 index 00000000..a793f4c3 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ly/dto/user/EmployeeRequest.java @@ -0,0 +1,15 @@ +package com.chint.interfaces.rest.ly.dto.user; + +import com.chint.interfaces.rest.ly.dto.LYBaseRequest; +import lombok.Data; + +import java.util.List; + +@Data +public class EmployeeRequest extends LYBaseRequest { + private boolean isEncrypt; + private EmployeeEntity param; + private List costCenterList; + + // Getters and setters +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ly/dto/user/PreTravelPolicy.java b/src/main/java/com/chint/interfaces/rest/ly/dto/user/PreTravelPolicy.java new file mode 100644 index 00000000..4700bd91 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ly/dto/user/PreTravelPolicy.java @@ -0,0 +1,8 @@ +package com.chint.interfaces.rest.ly.dto.user; + +public class PreTravelPolicy { + private String policyCode; + private int productTypeId; + + // Getters and setters +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ly/dto/user/UserResponse.java b/src/main/java/com/chint/interfaces/rest/ly/dto/user/UserResponse.java new file mode 100644 index 00000000..5f2816e1 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ly/dto/user/UserResponse.java @@ -0,0 +1,68 @@ +package com.chint.interfaces.rest.ly.dto.user; + +import lombok.Data; + +@Data +public class UserResponse { + private boolean success; + private String errorCode; + private String errorMessage; + private Data data; + private int errorType; + + @lombok.Data + public static class Data { + private String employeeId; + + // Getter and Setter methods for employeeId + public String getEmployeeId() { + return employeeId; + } + + public void setEmployeeId(String employeeId) { + this.employeeId = employeeId; + } + } + + // Getter and Setter methods for all other fields + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public String getErrorCode() { + return errorCode; + } + + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + public Data getData() { + return data; + } + + public void setData(Data data) { + this.data = data; + } + + public int getErrorType() { + return errorType; + } + + public void setErrorType(int errorType) { + this.errorType = errorType; + } +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ly/dto/user/UserSave.java b/src/main/java/com/chint/interfaces/rest/ly/dto/user/UserSave.java new file mode 100644 index 00000000..5d2d9445 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ly/dto/user/UserSave.java @@ -0,0 +1,4 @@ +package com.chint.interfaces.rest.ly.dto.user; + +public class UserSave { +} diff --git a/src/main/java/com/chint/interfaces/rest/user/UserHttpRequest.java b/src/main/java/com/chint/interfaces/rest/user/UserHttpRequest.java new file mode 100644 index 00000000..9566c07f --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/user/UserHttpRequest.java @@ -0,0 +1,7 @@ +package com.chint.interfaces.rest.user; + +import com.chint.domain.aggregates.user.User; + +public interface UserHttpRequest { + User loadUserInfo(User user); +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java b/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java new file mode 100644 index 00000000..b03456fb --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java @@ -0,0 +1,101 @@ +package com.chint.interfaces.rest.user; + +import com.chint.dc.api.DataCenterResult; +import com.chint.dc.api.dto.DataCenterOption; +import com.chint.dc.api.service.DataCenterService; +import com.chint.domain.aggregates.user.User; +import com.chint.interfaces.rest.base.PostRequest; +import com.chint.interfaces.rest.user.dto.*; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.lang.reflect.Type; +import java.util.LinkedHashMap; +import java.util.List; + +import static com.chint.infrastructure.constant.Constant.*; + +@Service +public class UserHttpRequestImpl implements UserHttpRequest { + + + private final String asSkUrl = AK_BASE_URL + GET_AK_URL + "?systemId=" + SYSTEM_ID; + private final String userUrl = OPENAI_BASE_URL + USER_DATA_PATH; + private final String travelRankUrl = TRAVEL_RANK_BASE_URL + TRAVEL_RANK_PATH; + + @Autowired + private PostRequest postRequest; + + @Override + public User loadUserInfo(User user) { + return this.loadSFAndRank(user); + } + + private User loadSFAndRank(User user) { + List loadSFInfo = loadSFInfo(user); + String custManaLevel = loadSFInfo.get(0).getCust_manaLevel(); + String level = custManaLevel != null ? custManaLevel : loadSFInfo.get(0).getCust_profLevel(); + if (level.contains("R")) { + level = level.substring(0, level.length() - 3) + "M0"; + } + TravelRankDTO loadTravelRank = loadTravelRank(new TravelRankParam(level)); + user.rankCode = loadTravelRank.getLEVEL_MAPPING_CODE(); + return user; + } + + private AccessKeyDTO akSkLoad() { + HttpClient client = HttpClients.createDefault(); + HttpGet getMethod = new HttpGet(asSkUrl); + getMethod.setHeader("Content-Type", "application/json"); + try { + var response = client.execute(getMethod); + var responseBody = EntityUtils.toString(response.getEntity(), "UTF-8"); + var gson = new Gson(); + return gson.fromJson(responseBody, AccessKeyDTO.class); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private List loadSFInfo(User user) { + Gson gson = new Gson(); + AccessKeyDTO akSkLoad = akSkLoad(); + DataCenterOption option = new DataCenterOption(); + option.setSk(akSkLoad.sk); + option.setAk(akSkLoad.ak); + option.setUrl(OPENAI_BASE_URL); + DataCenterService dataCenterService = new DataCenterService(option); + LinkedHashMap map = new LinkedHashMap(); + map.put("LoginUsername", user.employeeNo.toString()); + map.put("start", 0); + map.put("pageSize", 1); + DataCenterResult result = dataCenterService.post(USER_DATA_PATH, map); + Type type = new TypeToken>() { + }.getType(); + if (result.getData() != null) { + List fromJson = gson.fromJson(result.getData().toString(), type); + UserDataDTO userDataDTO = fromJson.get(0); + user.setCompanyCode(userDataDTO.getCompany()); + user.setWorkStatus(userDataDTO.getStatus()); + user.setGender(userDataDTO.getGender()); + return fromJson; + } else { + throw new RuntimeException("用户数据不存在"); + } + } + + private TravelRankDTO loadTravelRank(TravelRankParam travelRankParam) { + TravelRankResponseDTO travelRankResponseDTO = postRequest.post(travelRankUrl, travelRankParam, TravelRankResponseDTO.class); + try { + return travelRankResponseDTO.datas.get(0); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/user/dto/AccessKeyDTO.java b/src/main/java/com/chint/interfaces/rest/user/dto/AccessKeyDTO.java new file mode 100644 index 00000000..9443fcde --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/user/dto/AccessKeyDTO.java @@ -0,0 +1,8 @@ +package com.chint.interfaces.rest.user.dto; + +public class AccessKeyDTO { + public String ak; + public String sk; + public String expire; + // Constructor, getters, and setters as needed +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/user/dto/TravelRankDTO.java b/src/main/java/com/chint/interfaces/rest/user/dto/TravelRankDTO.java new file mode 100644 index 00000000..faa15c2f --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/user/dto/TravelRankDTO.java @@ -0,0 +1,12 @@ +package com.chint.interfaces.rest.user.dto; + +import lombok.Data; + +@Data +public class TravelRankDTO { + public String RANK_MAPPING_NAME; + public String LEVEL_MAPPING_CODE; + public String RANK_MAPPING_CODE; + public String LEVEL_MAPPING_NAME; + // Constructor, getters, and setters as needed +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/user/dto/TravelRankParam.java b/src/main/java/com/chint/interfaces/rest/user/dto/TravelRankParam.java new file mode 100644 index 00000000..85995093 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/user/dto/TravelRankParam.java @@ -0,0 +1,14 @@ +package com.chint.interfaces.rest.user.dto; + + +import lombok.Data; + +@Data +public class TravelRankParam { + public String rankCode; + // Constructor, getters, and setters as needed + + public TravelRankParam(String rankCode) { + this.rankCode = rankCode; + } +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/user/dto/TravelRankResponseDTO.java b/src/main/java/com/chint/interfaces/rest/user/dto/TravelRankResponseDTO.java new file mode 100644 index 00000000..b884e001 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/user/dto/TravelRankResponseDTO.java @@ -0,0 +1,10 @@ +package com.chint.interfaces.rest.user.dto; + +import java.util.List; + +public class TravelRankResponseDTO { + public int total; + public boolean success; + public List datas; + // Constructor, getters, and setters as needed +} \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/user/dto/UserDataDTO.java b/src/main/java/com/chint/interfaces/rest/user/dto/UserDataDTO.java new file mode 100644 index 00000000..ca7b100b --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/user/dto/UserDataDTO.java @@ -0,0 +1,148 @@ +package com.chint.interfaces.rest.user.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class UserDataDTO { + private String userId; + private String personIdExternal; + private String LoginUsername; + private String uname; + private String adcode; + private String gender; + private String gender_cn; + private String mobilePhone; + private String email; + private String position; + private String position_cn; + private String cust_manaLevel; + private String cust_manaLevelF; + private String cust_profLevel; + private String cust_techLevel; + private String cust_qualityLevel; + private String nationalId; + private String status; + private String status_cn; + private String managerId; + private String manageSfNum; + private String managerName; + private String company; + private String company_cn; + private String unit1; + private String unit2; + private String unit3; + private String unit4; + private String unit5; + private String unit1_cn; + private String unit2_cn; + private String unit3_cn; + private String unit4_cn; + private String unit5_cn; + private String lastModifiedDateTime; + private String SFModifiedDateTime; + private String okToRehire; + private String leaveReason; + private String joinCompanyDate; + private String joinJtDate; + private String firstDateWorked; + private String dateOfBirth; + private String transDate; + private String lzDate; + private String kqPlace; + private String kqPlaceCN; + private String documentTitle; + private String employeeType; + private String employeeTypeCN; + private String cust_type; + private String custtypeCN; + private String custCategory; + private String custCategoryCN; + private String custSubCategory; + private String custSubCategoryCN; + private String employeeClass; + private String employeeClassCN; + private String customString26; + private String degree_cn; + private String cust_FomatTypeCN; + private String cust_EducationTypeCN; + private String cust_schoolAddressCN; + private String cust_major; + private String cust_school; + private String cust_endDate; + private String cust_degree; + private String cust_degreeCN; + private String customString12; + private String workHour; + private String customString31; + private String customString31_CN; + private String customString32; + private String customString32_CN; + private String customString33; + private String customString33_CN; + private String nation; + private String nativePlace; + private String politicalType; + private String politicalType_CN; + private String maritalStatus; + private String maritalStatus_CN; + private String hKType; + private String hKType_CN; + private String nationality; + private String nationality_CN; + private String customString17; + private String hrbpId; + private String hrbpName; + private String costCenter; + private String employmentType; + private String employmentTypeCN; + private String customString23; + private String customString23CN; + private String customString24; + private String customString24CN; + private String customString25; + private String customString25CN; + private String nationalCardType; + private Integer childCount; + private String customDouble1; + private String customDouble2; + private Integer customLong1; + private String customDate2; + private String jobCode; + private String jobCodeCN; + private String customString34; + private String customString34CN; + private String customString11; + private String customString11CN; + private String projectmanager; + private String documentNumber; + private String contractCustomString6; + private String contractCustomDate2; + private String contractCustomDate3; + private String cust_issueDate; + private String cust_expirationDate; + private String contractCustomString2; + private String contractCustomString1; + private String contractCustomString4; + private String contractCustomString5; + private String contractCustomString3; + private String selfinfoCustomString7; + private String cust_documentType; + private String cust_documentTypeCN; + private String firstName; + private String lastName; + private String cust_position_description; + private String cust_position_descriptionCN; + private String positionStartDate; + private String enuname; + private String urgentRelationName; + private String urgentRelationPhone; + private String urgentRelationShip; + private String urgentRelationShipCN; + private String customString35; + private String customString35CN; + private String pinyin; +} \ No newline at end of file diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml new file mode 100644 index 00000000..379524b8 --- /dev/null +++ b/src/main/resources/application-dev.yml @@ -0,0 +1,11 @@ +server: + port: 8081 + +chint: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + host: localhost + port: 3306 + database: itinerary_booking + username: root + password: 123456 diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml new file mode 100644 index 00000000..7db06668 --- /dev/null +++ b/src/main/resources/application-prod.yml @@ -0,0 +1,12 @@ +server: + port: 8080 + +chint: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + host: localhost + port: 3306 + database: itinerary_booking + username: root + password: 123456 + diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 00000000..25bc92fb --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,9 @@ +spring: + profiles: + active: dev + datasource: + driver-class-name: ${chint.datasource.driver-class-name} + url: jdbc:mysql://${chint.datasource.host}:${chint.datasource.port}/${chint.datasource.database}?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true + username: ${chint.datasource.username} + password: ${chint.datasource.password} + diff --git a/src/test/java/com/chint/CTripTest.java b/src/test/java/com/chint/CTripTest.java new file mode 100644 index 00000000..ac0fb4dc --- /dev/null +++ b/src/test/java/com/chint/CTripTest.java @@ -0,0 +1,38 @@ +package com.chint; + +import com.chint.domain.aggregates.user.User; +import com.chint.infrastructure.util.BaseContext; +import com.chint.interfaces.rest.ctrip.CTripLocationHttpRequest; +import com.chint.interfaces.rest.ctrip.CTripUserSaveRequest; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +public class CTripTest { + + @Autowired + private CTripLocationHttpRequest cTripLocationHttpRequest; + + @Autowired + private CTripUserSaveRequest cTripUserSaveRequest; + + private User user = new User(1L, 230615020L, 1, "卢麟哲", "1033719135@qq.com", "15857193365"); + + @Test + void locationCountry() { + System.out.println(cTripLocationHttpRequest.syncCountry()); + } + + @Test + void locationCity() { + System.out.println(cTripLocationHttpRequest.syncCity()); + } + + @Test + void SaveCorpCustInfoList() { + BaseContext.setCurrentUser(user); + cTripUserSaveRequest.saveUserToCTrip(); + } + +} diff --git a/src/test/java/com/chint/LTTest.java b/src/test/java/com/chint/LTTest.java new file mode 100644 index 00000000..5f426dca --- /dev/null +++ b/src/test/java/com/chint/LTTest.java @@ -0,0 +1,34 @@ +package com.chint; + +import com.chint.domain.aggregates.user.User; +import com.chint.infrastructure.util.BaseContext; +import com.chint.interfaces.rest.ly.LYTokenRequest; +import com.chint.interfaces.rest.ly.LYUserRequest; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +public class LTTest { + + @Autowired + private LYTokenRequest lyTokenRequest; + + + @Autowired + private LYUserRequest lyUserRequest; + + private User user = new User(1L, 230615020L, 1, "卢麟哲", "1033719135@qq.com", "15857193365"); + + @Test + void loadToken(){ + System.out.println(lyTokenRequest.loadToken()); + } + + @Test + void saveCurrentUser2Ly(){ + BaseContext.setCurrentUser(user); + System.out.println(lyUserRequest.saveCurrentUser()); + } + +} diff --git a/src/test/java/com/chint/RouteApplicationTests.java b/src/test/java/com/chint/RouteApplicationTests.java new file mode 100644 index 00000000..c79bbeb5 --- /dev/null +++ b/src/test/java/com/chint/RouteApplicationTests.java @@ -0,0 +1,25 @@ +package com.chint; + +import com.chint.domain.aggregates.user.User; +import com.chint.infrastructure.util.BaseContext; +import com.chint.interfaces.rest.user.UserHttpRequest; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class RouteApplicationTests { + + @Autowired + private UserHttpRequest userHttpRequest; + + private User user = new User(1L, 230615020L, 1, "卢麟哲", "1033719135@qq.com", "15857193365"); + + + @Test + void contextLoads() { + + userHttpRequest.loadUserInfo(user); + } + +}