commit 90a17bd8afd652b20c6b4621fdf201e2669875c1 Author: kric_jspark Date: Wed May 6 13:54:16 2026 +0900 260506_01_fst: First Commit diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8af972c --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +/gradlew text eol=lf +*.bat text eol=crlf +*.jar binary diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2065bc --- /dev/null +++ b/.gitignore @@ -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/ diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..c2b37b0 --- /dev/null +++ b/build.gradle @@ -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() +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..d997cfc Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..c61a118 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..739907d --- /dev/null +++ b/gradlew @@ -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" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..c4bdd3a --- /dev/null +++ b/gradlew.bat @@ -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 diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..24941d7 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'cx-dash-back' diff --git a/src/main/java/com/kri/kfpa/dash/KfpaCxDashBackApplication.java b/src/main/java/com/kri/kfpa/dash/KfpaCxDashBackApplication.java new file mode 100644 index 0000000..061690b --- /dev/null +++ b/src/main/java/com/kri/kfpa/dash/KfpaCxDashBackApplication.java @@ -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); + } + +} diff --git a/src/main/java/com/kri/kfpa/dash/common/consts/KfpaDashConstant.java b/src/main/java/com/kri/kfpa/dash/common/consts/KfpaDashConstant.java new file mode 100644 index 0000000..797adc2 --- /dev/null +++ b/src/main/java/com/kri/kfpa/dash/common/consts/KfpaDashConstant.java @@ -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 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 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() {} +} diff --git a/src/main/java/com/kri/kfpa/dash/config/DataSourceConfig.java b/src/main/java/com/kri/kfpa/dash/config/DataSourceConfig.java new file mode 100644 index 0000000..62c76d1 --- /dev/null +++ b/src/main/java/com/kri/kfpa/dash/config/DataSourceConfig.java @@ -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(); + } +} \ No newline at end of file diff --git a/src/main/java/com/kri/kfpa/dash/controller/AdminController.java b/src/main/java/com/kri/kfpa/dash/controller/AdminController.java new file mode 100644 index 0000000..12b9ed5 --- /dev/null +++ b/src/main/java/com/kri/kfpa/dash/controller/AdminController.java @@ -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); + } +} \ No newline at end of file diff --git a/src/main/java/com/kri/kfpa/dash/controller/AuthController.java b/src/main/java/com/kri/kfpa/dash/controller/AuthController.java new file mode 100644 index 0000000..cb202f8 --- /dev/null +++ b/src/main/java/com/kri/kfpa/dash/controller/AuthController.java @@ -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); + } +} diff --git a/src/main/java/com/kri/kfpa/dash/controller/StatisticsController.java b/src/main/java/com/kri/kfpa/dash/controller/StatisticsController.java new file mode 100644 index 0000000..fda481a --- /dev/null +++ b/src/main/java/com/kri/kfpa/dash/controller/StatisticsController.java @@ -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> getCsiData() { + return statisticsService.getCsiData(); + } + + @Operation(summary = "지역 본부 상세 조회") + @GetMapping("/div-detail/{div}") + public Map getDivDetailData( + @PathVariable String div + ) { + return statisticsService.getDivDetailData(div); + } + +} diff --git a/src/main/java/com/kri/kfpa/dash/dto/CommentValueDto.java b/src/main/java/com/kri/kfpa/dash/dto/CommentValueDto.java new file mode 100644 index 0000000..ab81d73 --- /dev/null +++ b/src/main/java/com/kri/kfpa/dash/dto/CommentValueDto.java @@ -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; + +} diff --git a/src/main/java/com/kri/kfpa/dash/dto/CsiDataDto.java b/src/main/java/com/kri/kfpa/dash/dto/CsiDataDto.java new file mode 100644 index 0000000..9b241b4 --- /dev/null +++ b/src/main/java/com/kri/kfpa/dash/dto/CsiDataDto.java @@ -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(); + } +} diff --git a/src/main/java/com/kri/kfpa/dash/dto/CsiRankDto.java b/src/main/java/com/kri/kfpa/dash/dto/CsiRankDto.java new file mode 100644 index 0000000..828823a --- /dev/null +++ b/src/main/java/com/kri/kfpa/dash/dto/CsiRankDto.java @@ -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(); + } +} diff --git a/src/main/java/com/kri/kfpa/dash/dto/DivDetailDataDto.java b/src/main/java/com/kri/kfpa/dash/dto/DivDetailDataDto.java new file mode 100644 index 0000000..2dadaf8 --- /dev/null +++ b/src/main/java/com/kri/kfpa/dash/dto/DivDetailDataDto.java @@ -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 csiRanks; + + @NotNull + @Schema(description = "항목별 코멘트") + Map commentValues; + + public static DivDetailDataDto of(Map csiRanks, Map commentValues) { + return DivDetailDataDto.builder() + .csiRanks(csiRanks) + .commentValues(commentValues) + .build(); + } +} diff --git a/src/main/java/com/kri/kfpa/dash/dto/LoginRequestDto.java b/src/main/java/com/kri/kfpa/dash/dto/LoginRequestDto.java new file mode 100644 index 0000000..e31ecd4 --- /dev/null +++ b/src/main/java/com/kri/kfpa/dash/dto/LoginRequestDto.java @@ -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; +} diff --git a/src/main/java/com/kri/kfpa/dash/dto/LoginResponseDto.java b/src/main/java/com/kri/kfpa/dash/dto/LoginResponseDto.java new file mode 100644 index 0000000..5b557ee --- /dev/null +++ b/src/main/java/com/kri/kfpa/dash/dto/LoginResponseDto.java @@ -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(); + } +} diff --git a/src/main/java/com/kri/kfpa/dash/dto/RequestWriteDivCommentDto.java b/src/main/java/com/kri/kfpa/dash/dto/RequestWriteDivCommentDto.java new file mode 100644 index 0000000..994ceba --- /dev/null +++ b/src/main/java/com/kri/kfpa/dash/dto/RequestWriteDivCommentDto.java @@ -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 commentValues; + +} diff --git a/src/main/java/com/kri/kfpa/dash/entity/CsiDataEntity.java b/src/main/java/com/kri/kfpa/dash/entity/CsiDataEntity.java new file mode 100644 index 0000000..e54cc04 --- /dev/null +++ b/src/main/java/com/kri/kfpa/dash/entity/CsiDataEntity.java @@ -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; +} diff --git a/src/main/java/com/kri/kfpa/dash/entity/DivCommentEntity.java b/src/main/java/com/kri/kfpa/dash/entity/DivCommentEntity.java new file mode 100644 index 0000000..3ee60ae --- /dev/null +++ b/src/main/java/com/kri/kfpa/dash/entity/DivCommentEntity.java @@ -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 getCommentValues() { + Map 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; + } +} diff --git a/src/main/java/com/kri/kfpa/dash/entity/KonUserEntity.java b/src/main/java/com/kri/kfpa/dash/entity/KonUserEntity.java new file mode 100644 index 0000000..6b93dba --- /dev/null +++ b/src/main/java/com/kri/kfpa/dash/entity/KonUserEntity.java @@ -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; +} diff --git a/src/main/java/com/kri/kfpa/dash/entity/ObjectTypeCsiRankEntity.java b/src/main/java/com/kri/kfpa/dash/entity/ObjectTypeCsiRankEntity.java new file mode 100644 index 0000000..a2c8783 --- /dev/null +++ b/src/main/java/com/kri/kfpa/dash/entity/ObjectTypeCsiRankEntity.java @@ -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; +} diff --git a/src/main/java/com/kri/kfpa/dash/mapper/DataMapper.java b/src/main/java/com/kri/kfpa/dash/mapper/DataMapper.java new file mode 100644 index 0000000..0c5878a --- /dev/null +++ b/src/main/java/com/kri/kfpa/dash/mapper/DataMapper.java @@ -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 selectDivCsiData(@Param("pkey") String pkey); + + List 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 commentValues + ); +} diff --git a/src/main/java/com/kri/kfpa/dash/mapper/KonUserMapper.java b/src/main/java/com/kri/kfpa/dash/mapper/KonUserMapper.java new file mode 100644 index 0000000..683aefd --- /dev/null +++ b/src/main/java/com/kri/kfpa/dash/mapper/KonUserMapper.java @@ -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 + ); +} diff --git a/src/main/java/com/kri/kfpa/dash/service/AdminService.java b/src/main/java/com/kri/kfpa/dash/service/AdminService.java new file mode 100644 index 0000000..c7d8d44 --- /dev/null +++ b/src/main/java/com/kri/kfpa/dash/service/AdminService.java @@ -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 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 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); + } + } + } +} diff --git a/src/main/java/com/kri/kfpa/dash/service/AuthService.java b/src/main/java/com/kri/kfpa/dash/service/AuthService.java new file mode 100644 index 0000000..a0aec67 --- /dev/null +++ b/src/main/java/com/kri/kfpa/dash/service/AuthService.java @@ -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); + } +} diff --git a/src/main/java/com/kri/kfpa/dash/service/StatisticsService.java b/src/main/java/com/kri/kfpa/dash/service/StatisticsService.java new file mode 100644 index 0000000..6d5ba11 --- /dev/null +++ b/src/main/java/com/kri/kfpa/dash/service/StatisticsService.java @@ -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> getCsiData() { + List csiDataList = dataMapper.selectDivCsiData(KFPA_DASH_PKEY); + + Map csiData = csiDataList.stream() + .collect(Collectors.toMap( + CsiDataEntity::getDiv, + entity -> CsiDataDto.from(2026, entity) + )); + + Map> 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 getDivDetailData(String div) { + String idkey = IDKEY_MAP.get(div); + if (idkey == null) { + throw BusinessException.badRequest( + "INVALID_DIVISION", + "유효하지 않은 지역 본부입니다." + ).with("div", div); + } + + List objectTypeCsiRankList = + dataMapper.selectDivObjectTypeCsiRank(KFPA_DASH_PKEY, div); + + Map divDetailData = new LinkedHashMap<>(); + Map 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; + } +} diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml new file mode 100644 index 0000000..ef6156d --- /dev/null +++ b/src/main/resources/application.yaml @@ -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 \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/DataMapper.xml b/src/main/resources/mybatis/mapper/DataMapper.xml new file mode 100644 index 0000000..093024e --- /dev/null +++ b/src/main/resources/mybatis/mapper/DataMapper.xml @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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} + + + + + + + + + + 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} + + diff --git a/src/main/resources/mybatis/mapper/KonUserMapper.xml b/src/main/resources/mybatis/mapper/KonUserMapper.xml new file mode 100644 index 0000000..4dd3725 --- /dev/null +++ b/src/main/resources/mybatis/mapper/KonUserMapper.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + diff --git a/src/test/java/com/kri/kfpa/dash/KfpaCxDashBackApplicationTests.java b/src/test/java/com/kri/kfpa/dash/KfpaCxDashBackApplicationTests.java new file mode 100644 index 0000000..74fbe7b --- /dev/null +++ b/src/test/java/com/kri/kfpa/dash/KfpaCxDashBackApplicationTests.java @@ -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() { + } + +}