260506_01_fst: First Commit
This commit is contained in:
3
.gitattributes
vendored
Normal file
3
.gitattributes
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/gradlew text eol=lf
|
||||
*.bat text eol=crlf
|
||||
*.jar binary
|
||||
37
.gitignore
vendored
Normal file
37
.gitignore
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
HELP.md
|
||||
.gradle
|
||||
build/
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
bin/
|
||||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
out/
|
||||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
62
build.gradle
Normal file
62
build.gradle
Normal file
@@ -0,0 +1,62 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot' version '3.5.7'
|
||||
id 'io.spring.dependency-management' version '1.1.7'
|
||||
}
|
||||
|
||||
group = 'com.kri.kfpa'
|
||||
version = '0.0.1-SNAPSHOT'
|
||||
description = 'kfpa-cx-dash-back'
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(17)
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
compileOnly {
|
||||
extendsFrom annotationProcessor
|
||||
}
|
||||
}
|
||||
|
||||
def giteaUser = findProperty("giteaUser") ?: ""
|
||||
def giteaToken = findProperty("giteaToken") ?: ""
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
maven {
|
||||
name = "gitea"
|
||||
url = uri("https://gitea.kric.com/api/packages/KRi/maven")
|
||||
//allowInsecureProtocol = true
|
||||
credentials {
|
||||
username = giteaUser
|
||||
password = giteaToken
|
||||
}
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
implementation "com.kri.common:starter:beta.1.1.19"
|
||||
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-security'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-validation'
|
||||
implementation "org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.11"
|
||||
|
||||
implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:3.0.5'
|
||||
implementation 'com.microsoft.sqlserver:mssql-jdbc:13.2.1.jre11' // 버전은 환경 맞춰 조정
|
||||
|
||||
compileOnly 'org.projectlombok:lombok'
|
||||
annotationProcessor 'org.projectlombok:lombok'
|
||||
|
||||
developmentOnly 'org.springframework.boot:spring-boot-devtools'
|
||||
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
testImplementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter-test:3.0.5'
|
||||
testImplementation 'org.springframework.security:spring-security-test'
|
||||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
||||
}
|
||||
|
||||
tasks.named('test') {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
248
gradlew
vendored
Normal file
248
gradlew
vendored
Normal file
@@ -0,0 +1,248 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/2d6327017519d23b96af35865dc997fcb544fb40/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
93
gradlew.bat
vendored
Normal file
93
gradlew.bat
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
1
settings.gradle
Normal file
1
settings.gradle
Normal file
@@ -0,0 +1 @@
|
||||
rootProject.name = 'cx-dash-back'
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.kri.kfpa.dash;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class KfpaCxDashBackApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(KfpaCxDashBackApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.kri.kfpa.dash.common.consts;
|
||||
|
||||
import com.kri.kfpa.dash.dto.CsiDataDto;
|
||||
import java.util.Map;
|
||||
|
||||
public final class KfpaDashConstant {
|
||||
|
||||
public static final String KFPA_DASH_PKEY = "2601009_A";
|
||||
public static final String KFPA_COMMENT_PKEY = "2604005_F";
|
||||
public static final String TOTAL = "-1";
|
||||
public static final String SEOUL = "1";
|
||||
public static final String GYEONGGI = "2";
|
||||
public static final String BUSAN = "3";
|
||||
public static final String DAEGU = "4";
|
||||
public static final String DAEJEON = "5";
|
||||
public static final String GWANGJU = "6";
|
||||
|
||||
private static final String IDKEY_PREFIX = "Q1003_";
|
||||
|
||||
public static final Map<String, String> IDKEY_MAP = Map.of(
|
||||
SEOUL, IDKEY_PREFIX + SEOUL,
|
||||
GYEONGGI, IDKEY_PREFIX + GYEONGGI,
|
||||
BUSAN, IDKEY_PREFIX + BUSAN,
|
||||
DAEGU, IDKEY_PREFIX + DAEGU,
|
||||
DAEJEON, IDKEY_PREFIX + DAEJEON,
|
||||
GWANGJU, IDKEY_PREFIX + GWANGJU
|
||||
);
|
||||
|
||||
public static final Map<String, CsiDataDto> DATA_2025 = Map.of(
|
||||
TOTAL, CsiDataDto.of(2025,4.47, 4.46, null, 4.43, 4.63),
|
||||
SEOUL, CsiDataDto.of(2025,4.39, 4.36, null, 4.37, 4.63),
|
||||
GYEONGGI, CsiDataDto.of(2025,4.48, 4.46, null, 4.44, 4.65),
|
||||
BUSAN, CsiDataDto.of(2025,4.43, 4.41, null, 4.39, 4.62),
|
||||
DAEGU, CsiDataDto.of(2025,4.56, 4.55, null, 4.54, 4.66),
|
||||
DAEJEON, CsiDataDto.of(2025,4.47, 4.47, null, 4.40, 4.57),
|
||||
GWANGJU, CsiDataDto.of(2025,4.52, 4.51, null, 4.46, 4.67)
|
||||
);
|
||||
|
||||
private KfpaDashConstant() {}
|
||||
}
|
||||
28
src/main/java/com/kri/kfpa/dash/config/DataSourceConfig.java
Normal file
28
src/main/java/com/kri/kfpa/dash/config/DataSourceConfig.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.kri.kfpa.dash.config;
|
||||
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import javax.sql.DataSource;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
|
||||
@Configuration
|
||||
public class DataSourceConfig {
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
@ConfigurationProperties(prefix = "spring.datasource")
|
||||
public DataSourceProperties mainDataSourceProperties() {
|
||||
return new DataSourceProperties();
|
||||
}
|
||||
|
||||
@Bean(name = "mainDataSource")
|
||||
@Primary
|
||||
public DataSource mainDataSource(DataSourceProperties mainDataSourceProperties) {
|
||||
return mainDataSourceProperties.initializeDataSourceBuilder()
|
||||
.type(HikariDataSource.class)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.kri.kfpa.dash.controller;
|
||||
|
||||
import com.kri.kfpa.dash.dto.RequestWriteDivCommentDto;
|
||||
import com.kri.kfpa.dash.service.AdminService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PatchMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/admin")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "admin", description = "관리자 API")
|
||||
public class AdminController {
|
||||
|
||||
private final AdminService adminService;
|
||||
|
||||
@Operation(summary = "지역 본부 코멘트 작성")
|
||||
@PatchMapping("/div-comment")
|
||||
public boolean updateDivComment(
|
||||
@Valid @RequestBody RequestWriteDivCommentDto request
|
||||
){
|
||||
return adminService.updateDivComment(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.kri.kfpa.dash.controller;
|
||||
|
||||
import com.kri.common.feature.datetime.DateTimeUtil;
|
||||
import com.kri.common.feature.web.RequestUserContext;
|
||||
import com.kri.kfpa.dash.dto.LoginRequestDto;
|
||||
import com.kri.kfpa.dash.dto.LoginResponseDto;
|
||||
import com.kri.kfpa.dash.service.AuthService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/auth")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "Auth", description = "인증 API")
|
||||
public class AuthController {
|
||||
|
||||
private final AuthService authService;
|
||||
|
||||
@Operation(summary = "로그인 요청")
|
||||
@PostMapping("/login")
|
||||
public LoginResponseDto tryLogin(
|
||||
@Valid @RequestBody LoginRequestDto request
|
||||
) {
|
||||
return authService.tryLogin(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.kri.kfpa.dash.controller;
|
||||
|
||||
import com.kri.kfpa.dash.dto.CsiDataDto;
|
||||
import com.kri.kfpa.dash.dto.DivDetailDataDto;
|
||||
import com.kri.kfpa.dash.service.StatisticsService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/statistics")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "Statistics", description = "통계치 조회 API")
|
||||
public class StatisticsController {
|
||||
|
||||
private final StatisticsService statisticsService;
|
||||
|
||||
@Operation(summary = "csi 데이터 조회")
|
||||
@GetMapping("/csi")
|
||||
public Map<String, List<CsiDataDto>> getCsiData() {
|
||||
return statisticsService.getCsiData();
|
||||
}
|
||||
|
||||
@Operation(summary = "지역 본부 상세 조회")
|
||||
@GetMapping("/div-detail/{div}")
|
||||
public Map<String, DivDetailDataDto> getDivDetailData(
|
||||
@PathVariable String div
|
||||
) {
|
||||
return statisticsService.getDivDetailData(div);
|
||||
}
|
||||
|
||||
}
|
||||
29
src/main/java/com/kri/kfpa/dash/dto/CommentValueDto.java
Normal file
29
src/main/java/com/kri/kfpa/dash/dto/CommentValueDto.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package com.kri.kfpa.dash.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "세부 항목 별 코멘트")
|
||||
public class CommentValueDto {
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "고객 직접 체감")
|
||||
private String directExperience;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "고객 간접 체감")
|
||||
private String indirectExperience;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "내부역량 강화 등")
|
||||
private String capability;
|
||||
|
||||
}
|
||||
57
src/main/java/com/kri/kfpa/dash/dto/CsiDataDto.java
Normal file
57
src/main/java/com/kri/kfpa/dash/dto/CsiDataDto.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package com.kri.kfpa.dash.dto;
|
||||
|
||||
import com.kri.kfpa.dash.entity.CsiDataEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.math.BigDecimal;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "CSI 계산결과 Dto")
|
||||
public class CsiDataDto {
|
||||
|
||||
@Schema(description = "연도")
|
||||
private Integer wave;
|
||||
|
||||
@Schema(description = "CSI 점수")
|
||||
private Double csi;
|
||||
|
||||
@Schema(description = "현장 안전점검 도움 정도")
|
||||
private Double safeHelp;
|
||||
|
||||
@Schema(description = "위험개선권고사항 도움 정도")
|
||||
private Double recHelp;
|
||||
|
||||
@Schema(description = "점검직원 전문성")
|
||||
private Double staffProf;
|
||||
|
||||
@Schema(description = "점검직원 태도")
|
||||
private Double staffAtt;
|
||||
|
||||
public static CsiDataDto of(Integer wave, Double csi, Double safeHelp, Double recHelp, Double staffProf, Double staffAtt) {
|
||||
return CsiDataDto.builder()
|
||||
.wave(wave)
|
||||
.csi(csi)
|
||||
.safeHelp(safeHelp)
|
||||
.recHelp(recHelp)
|
||||
.staffProf(staffProf)
|
||||
.staffAtt(staffAtt)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CsiDataDto from(Integer wave,CsiDataEntity entity) {
|
||||
return CsiDataDto.builder()
|
||||
.wave(wave)
|
||||
.csi(entity.getCsi())
|
||||
.safeHelp(entity.getSafeHelp())
|
||||
.recHelp(entity.getRecHelp())
|
||||
.staffProf(entity.getStaffProf())
|
||||
.staffAtt(entity.getStaffAtt())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
27
src/main/java/com/kri/kfpa/dash/dto/CsiRankDto.java
Normal file
27
src/main/java/com/kri/kfpa/dash/dto/CsiRankDto.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.kri.kfpa.dash.dto;
|
||||
|
||||
import com.kri.kfpa.dash.entity.ObjectTypeCsiRankEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "물건 별 순위 Dto")
|
||||
public class CsiRankDto {
|
||||
|
||||
private Double csi;
|
||||
|
||||
private Integer divRank;
|
||||
|
||||
public static CsiRankDto from(ObjectTypeCsiRankEntity entity) {
|
||||
return CsiRankDto.builder()
|
||||
.csi(entity.getCsi())
|
||||
.divRank(entity.getDivRank())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
32
src/main/java/com/kri/kfpa/dash/dto/DivDetailDataDto.java
Normal file
32
src/main/java/com/kri/kfpa/dash/dto/DivDetailDataDto.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.kri.kfpa.dash.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.Map;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "지역 본부 별 상세")
|
||||
public class DivDetailDataDto {
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "물건별 csi 점수 및 순위")
|
||||
private Map<String, CsiRankDto> csiRanks;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "항목별 코멘트")
|
||||
Map<String, CommentValueDto> commentValues;
|
||||
|
||||
public static DivDetailDataDto of(Map<String, CsiRankDto> csiRanks, Map<String, CommentValueDto> commentValues) {
|
||||
return DivDetailDataDto.builder()
|
||||
.csiRanks(csiRanks)
|
||||
.commentValues(commentValues)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
17
src/main/java/com/kri/kfpa/dash/dto/LoginRequestDto.java
Normal file
17
src/main/java/com/kri/kfpa/dash/dto/LoginRequestDto.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.kri.kfpa.dash.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Schema(description = "사용자 로그인 요청")
|
||||
public class LoginRequestDto {
|
||||
|
||||
@Schema(description = "사용자 ID")
|
||||
private String userId;
|
||||
|
||||
@Schema(description = "사용자 PW")
|
||||
private String userPw;
|
||||
}
|
||||
26
src/main/java/com/kri/kfpa/dash/dto/LoginResponseDto.java
Normal file
26
src/main/java/com/kri/kfpa/dash/dto/LoginResponseDto.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.kri.kfpa.dash.dto;
|
||||
|
||||
|
||||
import com.kri.common.feature.auth.dto.JwtUserClaimsDto;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
@Schema(description = "로그인 응답")
|
||||
public class LoginResponseDto {
|
||||
|
||||
@Schema(description = "jwt access 토큰")
|
||||
private String accessToken;
|
||||
|
||||
@Schema(description = "사용자 정보")
|
||||
private JwtUserClaimsDto user;
|
||||
|
||||
public static LoginResponseDto from(String accessToken, JwtUserClaimsDto jwtUserClaims) {
|
||||
return LoginResponseDto.builder()
|
||||
.accessToken(accessToken)
|
||||
.user(jwtUserClaims)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.kri.kfpa.dash.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.Map;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@Schema(description = "관리자 코멘트 입력")
|
||||
public class RequestWriteDivCommentDto {
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "본부 ID")
|
||||
Integer divId;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "항목별 코멘트")
|
||||
Map<String, CommentValueDto> commentValues;
|
||||
|
||||
}
|
||||
21
src/main/java/com/kri/kfpa/dash/entity/CsiDataEntity.java
Normal file
21
src/main/java/com/kri/kfpa/dash/entity/CsiDataEntity.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.kri.kfpa.dash.entity;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class CsiDataEntity {
|
||||
|
||||
private String div;
|
||||
|
||||
private Double csi;
|
||||
|
||||
private Double safeHelp;
|
||||
|
||||
private Double recHelp;
|
||||
|
||||
private Double staffProf;
|
||||
|
||||
private Double staffAtt;
|
||||
}
|
||||
54
src/main/java/com/kri/kfpa/dash/entity/DivCommentEntity.java
Normal file
54
src/main/java/com/kri/kfpa/dash/entity/DivCommentEntity.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package com.kri.kfpa.dash.entity;
|
||||
|
||||
import com.kri.kfpa.dash.dto.CommentValueDto;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class DivCommentEntity {
|
||||
|
||||
private String performance25DirectExperience;
|
||||
|
||||
private String performance25IndirectExperience;
|
||||
|
||||
private String performance25Capability;
|
||||
|
||||
private String plan26DirectExperience;
|
||||
|
||||
private String plan26IndirectExperience;
|
||||
|
||||
private String plan26Capability;
|
||||
|
||||
private String performance26DirectExperience;
|
||||
|
||||
private String performance26IndirectExperience;
|
||||
|
||||
private String performance26Capability;
|
||||
|
||||
public static DivCommentEntity empty() {
|
||||
return new DivCommentEntity();
|
||||
}
|
||||
|
||||
public Map<String, CommentValueDto> getCommentValues() {
|
||||
Map<String, CommentValueDto> commentValues = new LinkedHashMap<>();
|
||||
commentValues.put("performance25", CommentValueDto.builder()
|
||||
.directExperience(performance25DirectExperience)
|
||||
.indirectExperience(performance25IndirectExperience)
|
||||
.capability(performance25Capability)
|
||||
.build());
|
||||
commentValues.put("plan26", CommentValueDto.builder()
|
||||
.directExperience(plan26DirectExperience)
|
||||
.indirectExperience(plan26IndirectExperience)
|
||||
.capability(plan26Capability)
|
||||
.build());
|
||||
commentValues.put("performance26", CommentValueDto.builder()
|
||||
.directExperience(performance26DirectExperience)
|
||||
.indirectExperience(performance26IndirectExperience)
|
||||
.capability(performance26Capability)
|
||||
.build());
|
||||
return commentValues;
|
||||
}
|
||||
}
|
||||
19
src/main/java/com/kri/kfpa/dash/entity/KonUserEntity.java
Normal file
19
src/main/java/com/kri/kfpa/dash/entity/KonUserEntity.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.kri.kfpa.dash.entity;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class KonUserEntity {
|
||||
|
||||
private String pUserMail;
|
||||
|
||||
private String pName;
|
||||
|
||||
private String pCompany;
|
||||
|
||||
private String pTeam;
|
||||
|
||||
private Integer pRole;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.kri.kfpa.dash.entity;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ObjectTypeCsiRankEntity {
|
||||
|
||||
private String div;
|
||||
|
||||
private String objectType;
|
||||
|
||||
private Double csi;
|
||||
|
||||
private Integer divRank;
|
||||
}
|
||||
32
src/main/java/com/kri/kfpa/dash/mapper/DataMapper.java
Normal file
32
src/main/java/com/kri/kfpa/dash/mapper/DataMapper.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.kri.kfpa.dash.mapper;
|
||||
|
||||
import com.kri.kfpa.dash.dto.CommentValueDto;
|
||||
import com.kri.kfpa.dash.entity.CsiDataEntity;
|
||||
import com.kri.kfpa.dash.entity.DivCommentEntity;
|
||||
import com.kri.kfpa.dash.entity.ObjectTypeCsiRankEntity;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface DataMapper {
|
||||
|
||||
List<CsiDataEntity> selectDivCsiData(@Param("pkey") String pkey);
|
||||
|
||||
List<ObjectTypeCsiRankEntity> selectDivObjectTypeCsiRank(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("div") String div
|
||||
);
|
||||
|
||||
DivCommentEntity selectDivComment(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("idkey") String idkey
|
||||
);
|
||||
|
||||
boolean updateDivComment(
|
||||
@Param("pkey") String pkey,
|
||||
@Param("idkey") String idkey,
|
||||
@Param("commentValues") Map<String, CommentValueDto> commentValues
|
||||
);
|
||||
}
|
||||
15
src/main/java/com/kri/kfpa/dash/mapper/KonUserMapper.java
Normal file
15
src/main/java/com/kri/kfpa/dash/mapper/KonUserMapper.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.kri.kfpa.dash.mapper;
|
||||
|
||||
import com.kri.kfpa.dash.entity.KonUserEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@Mapper
|
||||
public interface KonUserMapper {
|
||||
|
||||
KonUserEntity selectKonUser(
|
||||
@Param("pAccessPkey") String pAccessPkey,
|
||||
@Param("pUserMail") String pUserMail,
|
||||
@Param("pPassNew") String pPassNew
|
||||
);
|
||||
}
|
||||
53
src/main/java/com/kri/kfpa/dash/service/AdminService.java
Normal file
53
src/main/java/com/kri/kfpa/dash/service/AdminService.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package com.kri.kfpa.dash.service;
|
||||
|
||||
import static com.kri.kfpa.dash.common.consts.KfpaDashConstant.IDKEY_MAP;
|
||||
import static com.kri.kfpa.dash.common.consts.KfpaDashConstant.KFPA_COMMENT_PKEY;
|
||||
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.kfpa.dash.dto.CommentValueDto;
|
||||
import com.kri.kfpa.dash.dto.RequestWriteDivCommentDto;
|
||||
import com.kri.kfpa.dash.mapper.DataMapper;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AdminService {
|
||||
|
||||
private static final List<String> REQUIRED_COMMENT_KEYS = List.of(
|
||||
"performance25",
|
||||
"plan26",
|
||||
"performance26"
|
||||
);
|
||||
|
||||
private final DataMapper dataMapper;
|
||||
|
||||
public boolean updateDivComment(RequestWriteDivCommentDto request) {
|
||||
String idkey = IDKEY_MAP.get(request.getDivId().toString());
|
||||
if (idkey == null) {
|
||||
throw BusinessException.badRequest("INVALID_DIV_ID", "지역본부 ID가 잘못됐습니다.");
|
||||
}
|
||||
|
||||
validateCommentValues(request.getCommentValues());
|
||||
|
||||
return dataMapper.updateDivComment(KFPA_COMMENT_PKEY, idkey, request.getCommentValues());
|
||||
}
|
||||
|
||||
private void validateCommentValues(Map<String, CommentValueDto> commentValues) {
|
||||
if (commentValues == null) {
|
||||
throw BusinessException.badRequest("INVALID_COMMENT_VALUES", "commentValues는 필수입니다.");
|
||||
}
|
||||
|
||||
for (String requiredKey : REQUIRED_COMMENT_KEYS) {
|
||||
if (commentValues.get(requiredKey) == null) {
|
||||
throw BusinessException.badRequest(
|
||||
"MISSING_COMMENT_VALUE",
|
||||
"필수 코멘트 항목이 누락됐습니다."
|
||||
)
|
||||
.with("requiredKey", requiredKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
41
src/main/java/com/kri/kfpa/dash/service/AuthService.java
Normal file
41
src/main/java/com/kri/kfpa/dash/service/AuthService.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package com.kri.kfpa.dash.service;
|
||||
|
||||
import static com.kri.kfpa.dash.common.consts.KfpaDashConstant.KFPA_DASH_PKEY;
|
||||
|
||||
import com.kri.common.feature.auth.dto.JwtUserClaimsDto;
|
||||
import com.kri.common.feature.auth.jwt.JwtService;
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.kfpa.dash.dto.LoginRequestDto;
|
||||
import com.kri.kfpa.dash.dto.LoginResponseDto;
|
||||
import com.kri.kfpa.dash.entity.KonUserEntity;
|
||||
import com.kri.kfpa.dash.mapper.KonUserMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AuthService {
|
||||
private final JwtService jwtService;
|
||||
private final KonUserMapper konUserMapper;
|
||||
|
||||
public LoginResponseDto tryLogin(LoginRequestDto request) {
|
||||
KonUserEntity konUserEntity = konUserMapper.selectKonUser(KFPA_DASH_PKEY, request.getUserId(), request.getUserPw());
|
||||
|
||||
if(konUserEntity == null){
|
||||
throw BusinessException
|
||||
.notFound("NOT_FOUND_USER","사용자가 없습니다.")
|
||||
.with("userId", request.getUserId());
|
||||
}
|
||||
|
||||
JwtUserClaimsDto claims = JwtUserClaimsDto.builder()
|
||||
.userId(konUserEntity.getPUserMail())
|
||||
.userCmpn(konUserEntity.getPCompany())
|
||||
.userName(konUserEntity.getPName())
|
||||
.userTeam(konUserEntity.getPTeam())
|
||||
.userRole(konUserEntity.getPRole())
|
||||
.build();
|
||||
|
||||
String accessToken = jwtService.generateAccessToken(claims);
|
||||
return LoginResponseDto.from(accessToken, claims);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.kri.kfpa.dash.service;
|
||||
|
||||
import static com.kri.kfpa.dash.common.consts.KfpaDashConstant.DATA_2025;
|
||||
import static com.kri.kfpa.dash.common.consts.KfpaDashConstant.IDKEY_MAP;
|
||||
import static com.kri.kfpa.dash.common.consts.KfpaDashConstant.KFPA_COMMENT_PKEY;
|
||||
import static com.kri.kfpa.dash.common.consts.KfpaDashConstant.KFPA_DASH_PKEY;
|
||||
|
||||
import com.kri.common.feature.web.BusinessException;
|
||||
import com.kri.kfpa.dash.dto.CsiDataDto;
|
||||
import com.kri.kfpa.dash.dto.CsiRankDto;
|
||||
import com.kri.kfpa.dash.dto.DivDetailDataDto;
|
||||
import com.kri.kfpa.dash.entity.CsiDataEntity;
|
||||
import com.kri.kfpa.dash.entity.DivCommentEntity;
|
||||
import com.kri.kfpa.dash.entity.ObjectTypeCsiRankEntity;
|
||||
import com.kri.kfpa.dash.mapper.DataMapper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class StatisticsService {
|
||||
|
||||
private final DataMapper dataMapper;
|
||||
|
||||
public Map<String, List<CsiDataDto>> getCsiData() {
|
||||
List<CsiDataEntity> csiDataList = dataMapper.selectDivCsiData(KFPA_DASH_PKEY);
|
||||
|
||||
Map<String, CsiDataDto> csiData = csiDataList.stream()
|
||||
.collect(Collectors.toMap(
|
||||
CsiDataEntity::getDiv,
|
||||
entity -> CsiDataDto.from(2026, entity)
|
||||
));
|
||||
|
||||
Map<String, List<CsiDataDto>> mergedCsiData = new LinkedHashMap<>();
|
||||
DATA_2025.forEach((div, data) -> mergedCsiData.put(div, new ArrayList<>(List.of(data))));
|
||||
csiData.forEach((div, data) -> mergedCsiData
|
||||
.computeIfAbsent(div, key -> new ArrayList<>())
|
||||
.add(data));
|
||||
|
||||
return mergedCsiData;
|
||||
}
|
||||
|
||||
public Map<String, DivDetailDataDto> getDivDetailData(String div) {
|
||||
String idkey = IDKEY_MAP.get(div);
|
||||
if (idkey == null) {
|
||||
throw BusinessException.badRequest(
|
||||
"INVALID_DIVISION",
|
||||
"유효하지 않은 지역 본부입니다."
|
||||
).with("div", div);
|
||||
}
|
||||
|
||||
List<ObjectTypeCsiRankEntity> objectTypeCsiRankList =
|
||||
dataMapper.selectDivObjectTypeCsiRank(KFPA_DASH_PKEY, div);
|
||||
|
||||
Map<String, DivDetailDataDto> divDetailData = new LinkedHashMap<>();
|
||||
Map<String, DivCommentEntity> divCommentCache = new LinkedHashMap<>();
|
||||
|
||||
for (ObjectTypeCsiRankEntity entity : objectTypeCsiRankList) {
|
||||
DivCommentEntity divCommentEntity = divCommentCache.computeIfAbsent(
|
||||
div,
|
||||
key -> {
|
||||
DivCommentEntity selectedComment = dataMapper.selectDivComment(KFPA_COMMENT_PKEY, idkey);
|
||||
return selectedComment == null ? DivCommentEntity.empty() : selectedComment;
|
||||
}
|
||||
);
|
||||
|
||||
DivDetailDataDto detailData = divDetailData.computeIfAbsent(
|
||||
div,
|
||||
key -> DivDetailDataDto.of(new LinkedHashMap<>(), divCommentEntity.getCommentValues())
|
||||
);
|
||||
detailData.getCsiRanks().put(entity.getObjectType(), CsiRankDto.from(entity));
|
||||
}
|
||||
|
||||
return divDetailData;
|
||||
}
|
||||
}
|
||||
53
src/main/resources/application.yaml
Normal file
53
src/main/resources/application.yaml
Normal file
@@ -0,0 +1,53 @@
|
||||
server:
|
||||
port: 6103
|
||||
forward-headers-strategy: framework
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: kfpa-cx-dash-back
|
||||
datasource:
|
||||
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
|
||||
url: jdbc:sqlserver://1.235.195.8:20022;databaseName=KON;encrypt=false
|
||||
username: kon
|
||||
password: kon#51304
|
||||
|
||||
logging:
|
||||
file:
|
||||
path: ./logs
|
||||
|
||||
mybatis:
|
||||
mapper-locations: classpath:/mybatis/mapper/*.xml
|
||||
type-aliases-package: com.kri.kfpa.dash.entity
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
kri:
|
||||
auth:
|
||||
header-name: "X-API-Key" # API Key 헤더
|
||||
|
||||
security:
|
||||
enabled: true
|
||||
public-paths: # 인증 없이 열어둘 URL
|
||||
- /v3/api-docs/**
|
||||
- /swagger-ui.html
|
||||
- /swagger-ui/**
|
||||
- /ping
|
||||
- /api/v1/statistics/**
|
||||
- /api/v1/auth/login
|
||||
|
||||
swagger:
|
||||
enabled: true
|
||||
title: "KFPA CSI Dashboard API"
|
||||
description: "화재보험협회 고객 관점 성과 측정·평가 체계 API"
|
||||
version: "v1.0.0"
|
||||
base-package: "com.kri.kfpa.dash"
|
||||
allowed-ips:
|
||||
- 211.254.145.130
|
||||
|
||||
web:
|
||||
enabled: true # 공통 Web 구성 사용 여부 (기본 true)
|
||||
redis:
|
||||
enabled: false # RedisQueueHelper 사용 시 true
|
||||
scheduling:
|
||||
enabled: false # @Scheduled 사용 시 true
|
||||
155
src/main/resources/mybatis/mapper/DataMapper.xml
Normal file
155
src/main/resources/mybatis/mapper/DataMapper.xml
Normal file
@@ -0,0 +1,155 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.kri.kfpa.dash.mapper.DataMapper">
|
||||
<resultMap id="DivCsiDataResultMap" type="com.kri.kfpa.dash.entity.CsiDataEntity">
|
||||
<result property="div" column="div"/>
|
||||
<result property="csi" column="csi"/>
|
||||
<result property="safeHelp" column="safe_help"/>
|
||||
<result property="recHelp" column="rec_help"/>
|
||||
<result property="staffProf" column="staff_prof"/>
|
||||
<result property="staffAtt" column="staff_att"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="DivObjectTypeCsiRankResultMap" type="com.kri.kfpa.dash.entity.ObjectTypeCsiRankEntity">
|
||||
<result property="div" column="div"/>
|
||||
<result property="objectType" column="object_type"/>
|
||||
<result property="csi" column="csi"/>
|
||||
<result property="divRank" column="div_rank"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="DivCommentResultMap" type="com.kri.kfpa.dash.entity.DivCommentEntity">
|
||||
<result property="performance25DirectExperience" column="performance25_direct_experience"/>
|
||||
<result property="performance25IndirectExperience" column="performance25_indirect_experience"/>
|
||||
<result property="performance25Capability" column="performance25_capability"/>
|
||||
<result property="plan26DirectExperience" column="plan26_direct_experience"/>
|
||||
<result property="plan26IndirectExperience" column="plan26_indirect_experience"/>
|
||||
<result property="plan26Capability" column="plan26_capability"/>
|
||||
<result property="performance26DirectExperience" column="performance26_direct_experience"/>
|
||||
<result property="performance26IndirectExperience" column="performance26_indirect_experience"/>
|
||||
<result property="performance26Capability" column="performance26_capability"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="BaseDataSelect">
|
||||
SELECT
|
||||
IDKEY
|
||||
, TRY_CAST(JSON_VALUE(DATJSON, '$.Q1.Q1') AS DECIMAL(18, 4)) AS q1
|
||||
, TRY_CAST(JSON_VALUE(DATJSON, '$.Q2.Q2') AS DECIMAL(18, 4)) AS q2
|
||||
, TRY_CAST(JSON_VALUE(DATJSON, '$.Q7.Q7') AS DECIMAL(18, 4)) AS q4
|
||||
, TRY_CAST(JSON_VALUE(DATJSON, '$.Q10.Q10') AS DECIMAL(18, 4)) AS q5
|
||||
, CASE
|
||||
WHEN JSON_VALUE(DATJSON, '$.Q16.Q14') IS NOT NULL
|
||||
THEN JSON_VALUE(DATJSON, '$.Q16.Q14')
|
||||
ELSE JSON_VALUE(DATJSON, '$.Q14.Q14')
|
||||
END AS object_type_raw
|
||||
, CASE
|
||||
WHEN JSON_VALUE(DATJSON, '$.Q16.Q15') IS NOT NULL
|
||||
THEN JSON_VALUE(DATJSON, '$.Q16.Q15')
|
||||
ELSE JSON_VALUE(DATJSON, '$.Q15.Q15')
|
||||
END AS div
|
||||
FROM Kon.dbo.DATA
|
||||
WHERE SURVEY_TYPE != 'TEST'
|
||||
AND Status = 10
|
||||
AND PKEY = #{pkey}
|
||||
</sql>
|
||||
|
||||
<select id="selectDivCsiData" resultMap="DivCsiDataResultMap">
|
||||
WITH Base AS (
|
||||
<include refid="BaseDataSelect"/>
|
||||
)
|
||||
SELECT
|
||||
div
|
||||
, AVG(q1 * 0.4 + q2 * 0.4 + q4 * 0.1 + q5 * 0.1) AS csi
|
||||
, AVG(q1) AS safe_help
|
||||
, AVG(q2) AS rec_help
|
||||
, AVG(q4) AS staff_prof
|
||||
, AVG(q5) AS staff_att
|
||||
FROM Base
|
||||
WHERE object_type_raw IS NOT NULL
|
||||
AND div IS NOT NULL
|
||||
AND object_type_raw != '99'
|
||||
AND div != '99'
|
||||
GROUP BY div
|
||||
ORDER BY div
|
||||
</select>
|
||||
|
||||
<select id="selectDivObjectTypeCsiRank" resultMap="DivObjectTypeCsiRankResultMap">
|
||||
WITH Base AS (
|
||||
<include refid="BaseDataSelect"/>
|
||||
),
|
||||
Recode AS (
|
||||
SELECT
|
||||
IDKEY
|
||||
, q1
|
||||
, q2
|
||||
, q4
|
||||
, q5
|
||||
, div
|
||||
, CASE
|
||||
WHEN object_type_raw IN ('4', '12') THEN object_type_raw
|
||||
ELSE '90'
|
||||
END AS object_type
|
||||
FROM Base
|
||||
),
|
||||
CsiAgg AS (
|
||||
SELECT
|
||||
div
|
||||
, object_type
|
||||
, AVG(q1 * 0.4 + q2 * 0.4 + q4 * 0.1 + q5 * 0.1) AS csi
|
||||
FROM Recode
|
||||
WHERE div IS NOT NULL
|
||||
AND div = #{div}
|
||||
GROUP BY div, object_type
|
||||
)
|
||||
SELECT
|
||||
div
|
||||
, object_type
|
||||
, CSI
|
||||
, DENSE_RANK() OVER (
|
||||
PARTITION BY object_type
|
||||
ORDER BY CSI DESC
|
||||
) AS div_rank
|
||||
FROM CsiAgg
|
||||
ORDER BY div, object_type, div_rank
|
||||
</select>
|
||||
|
||||
<select id="selectDivComment" resultMap="DivCommentResultMap">
|
||||
SELECT
|
||||
ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_1_1'), '') AS performance25_direct_experience
|
||||
, ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_2_1'), '') AS performance25_indirect_experience
|
||||
, ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_3_1'), '') AS performance25_capability
|
||||
, ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_1_2'), '') AS plan26_direct_experience
|
||||
, ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_2_2'), '') AS plan26_indirect_experience
|
||||
, ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_3_2'), '') AS plan26_capability
|
||||
, ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_1_3'), '') AS performance26_direct_experience
|
||||
, ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_2_3'), '') AS performance26_indirect_experience
|
||||
, ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_3_3'), '') AS performance26_capability
|
||||
FROM Kon.dbo.DATA
|
||||
WHERE PKEY = #{pkey}
|
||||
AND IDKEY = #{idkey}
|
||||
</select>
|
||||
|
||||
<update id="updateDivComment">
|
||||
UPDATE A
|
||||
SET DATJSON = JSON_MODIFY(
|
||||
DATJSON,
|
||||
'$.Q1',
|
||||
JSON_QUERY((
|
||||
SELECT
|
||||
#{commentValues.performance25.directExperience} AS [Q1_1_1]
|
||||
, #{commentValues.performance25.indirectExperience} AS [Q1_2_1]
|
||||
, #{commentValues.performance25.capability} AS [Q1_3_1]
|
||||
, #{commentValues.plan26.directExperience} AS [Q1_1_2]
|
||||
, #{commentValues.plan26.indirectExperience} AS [Q1_2_2]
|
||||
, #{commentValues.plan26.capability} AS [Q1_3_2]
|
||||
, #{commentValues.performance26.directExperience} AS [Q1_1_3]
|
||||
, #{commentValues.performance26.indirectExperience} AS [Q1_2_3]
|
||||
, #{commentValues.performance26.capability} AS [Q1_3_3]
|
||||
FOR JSON PATH, WITHOUT_ARRAY_WRAPPER
|
||||
))
|
||||
)
|
||||
FROM Kon.dbo.DATA A
|
||||
WHERE PKEY = #{pkey}
|
||||
AND IDKEY = #{idkey}
|
||||
</update>
|
||||
</mapper>
|
||||
26
src/main/resources/mybatis/mapper/KonUserMapper.xml
Normal file
26
src/main/resources/mybatis/mapper/KonUserMapper.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.kri.kfpa.dash.mapper.KonUserMapper">
|
||||
<resultMap id="KonUserResultMap" type="com.kri.kfpa.dash.entity.KonUserEntity">
|
||||
<result property="pUserMail" column="p_user_mail"/>
|
||||
<result property="pName" column="p_name"/>
|
||||
<result property="pCompany" column="p_company"/>
|
||||
<result property="pTeam" column="p_team"/>
|
||||
<result property="pRole" column="p_role"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectKonUser" resultMap="KonUserResultMap">
|
||||
SELECT
|
||||
p_user_mail,
|
||||
p_name,
|
||||
p_company,
|
||||
p_team,
|
||||
p_role
|
||||
FROM Kon.dbo.KON_USER
|
||||
WHERE is_delete = '0'
|
||||
AND p_access_pkey LIKE CONCAT('%', #{pAccessPkey}, '%')
|
||||
AND p_user_mail = #{pUserMail}
|
||||
AND p_pass_new = #{pPassNew}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.kri.kfpa.dash;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class KfpaCxDashBackApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user